X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device_libdsk.c;h=739a3acb14b3c07315795a6af0459695eb264921;hb=edf600144998d1a1e09898548938cc11b95c10bc;hp=b0d58b5651f4c8c2dcb921c2cb730d854b919931;hpb=224b4e6d27a3af235500d9d8028ddbd3a60af7ed;p=debian%2Fcpmtools diff --git a/device_libdsk.c b/device_libdsk.c index b0d58b5..739a3ac 100644 --- a/device_libdsk.c +++ b/device_libdsk.c @@ -25,12 +25,15 @@ const char *Device_open(struct Device *this, const char *filename, int mode, con } /*}}}*/ /* Device_setGeometry -- Set disk geometry */ /*{{{*/ -void Device_setGeometry(struct Device *this, int secLength, int sectrk, int tracks) +void Device_setGeometry(struct Device *this, int secLength, int sectrk, int tracks, off_t offset) { this->secLength=secLength; this->sectrk=sectrk; this->tracks=tracks; - + /* Must be an even multiple of sector size */ + assert(offset%secLength==0); + this->offset=offset; + this->geom.dg_secsize = secLength; this->geom.dg_sectors = sectrk; /* Did the autoprobe guess right about the number of sectors & cylinders? */ @@ -62,7 +65,7 @@ const char *Device_close(struct Device *this) const char *Device_readSector(const struct Device *this, int track, int sector, char *buf) { dsk_err_t e; - e = dsk_lread(this->dev, &this->geom, buf, (track * this->sectrk) + sector); + e = dsk_lread(this->dev, &this->geom, buf, (track * this->sectrk) + sector + this->offset/this->secLength); return (e?dsk_strerror(e):(const char*)0); } /*}}}*/ @@ -70,7 +73,7 @@ const char *Device_readSector(const struct Device *this, int track, int sector, const char *Device_writeSector(const struct Device *this, int track, int sector, const char *buf) { dsk_err_t e; - e = dsk_lwrite(this->dev, &this->geom, buf, (track * this->sectrk) + sector); + e = dsk_lwrite(this->dev, &this->geom, buf, (track * this->sectrk) + sector + this->offset/this->secLength); return (e?dsk_strerror(e):(const char*)0); } /*}}}*/