}
/*}}}*/
/* 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? */
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);
}
/*}}}*/
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);
}
/*}}}*/