X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device_posix.c;h=0393eed716f39ae3c0edc9634c10d465166a7570;hb=edf600144998d1a1e09898548938cc11b95c10bc;hp=6362a9aa53f9aa5d61469309f99dde239487b0e6;hpb=749b004e4bb5830a6246a30ebe0a158e448327c5;p=debian%2Fcpmtools diff --git a/device_posix.c b/device_posix.c index 6362a9a..0393eed 100644 --- a/device_posix.c +++ b/device_posix.c @@ -22,11 +22,12 @@ 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; + this->offset=offset; } /*}}}*/ /* Device_close -- Close an image file */ /*{{{*/ @@ -45,7 +46,7 @@ const char *Device_readSector(const struct Device *this, int track, int sector, assert(sectorsectrk); assert(track>=0); assert(tracktracks); - if (lseek(this->fd,(off_t)(sector+track*this->sectrk)*this->secLength,SEEK_SET)==-1) + if (lseek(this->fd,(off_t)(((sector+track*this->sectrk)*this->secLength)+this->offset),SEEK_SET)==-1) { return strerror(errno); } @@ -67,7 +68,7 @@ const char *Device_writeSector(const struct Device *this, int track, int sector, assert(sectorsectrk); assert(track>=0); assert(tracktracks); - if (lseek(this->fd,(off_t)(sector+track*this->sectrk)*this->secLength, SEEK_SET)==-1) + if (lseek(this->fd,(off_t)(((sector+track*this->sectrk)*this->secLength)+this->offset),SEEK_SET)==-1) { return strerror(errno); }