X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device_posix.c;h=fd425cafed1fdb649d087c523d46b83101a0ed57;hb=4656a08e5f5e9a51b1c9f93d098ec9fc2bd2e308;hp=82071a4e080071e037104ab353536ee31a930f55;hpb=32087c67d53a8f8058b359388f23e2dbc9436d54;p=debian%2Fcpmtools diff --git a/device_posix.c b/device_posix.c index 82071a4..fd425ca 100644 --- a/device_posix.c +++ b/device_posix.c @@ -1,16 +1,9 @@ /* #includes */ /*{{{C}}}*//*{{{*/ -#undef _POSIX_SOURCE -#define _POSIX_SOURCE 1 -#undef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 2 - -#ifdef DMALLOC -#include "dmalloc.h" -#endif +#include "config.h" #include #include -#include "config.h" +#include #include #include @@ -20,17 +13,23 @@ /* Device_open -- Open an image file */ /*{{{*/ const char *Device_open(struct Device *this, const char *filename, int mode, const char *deviceOpts) { + if (deviceOpts != NULL) + { + return "POSIX driver accepts no options (build compiled without libdsk)"; + } this->fd=open(filename,mode); this->opened=(this->fd==-1?0:1); return ((this->fd==-1)?strerror(errno):(const char*)0); } /*}}}*/ /* Device_setGeometry -- Set disk geometry */ /*{{{*/ -void Device_setGeometry(struct Device *this, int secLength, int sectrk, int tracks) +const char *Device_setGeometry(struct Device *this, int secLength, int sectrk, int tracks, off_t offset, const char *libdskGeometry) { this->secLength=secLength; this->sectrk=sectrk; this->tracks=tracks; + this->offset=offset; + return NULL; } /*}}}*/ /* Device_close -- Close an image file */ /*{{{*/ @@ -45,11 +44,13 @@ const char *Device_readSector(const struct Device *this, int track, int sector, { int res; + assert(this); assert(sector>=0); assert(sectorsectrk); assert(track>=0); assert(tracktracks); - if (lseek(this->fd,(off_t)(sector+track*this->sectrk)*this->secLength,SEEK_SET)==-1) + assert(buf); + if (lseek(this->fd,(off_t)(((sector+track*this->sectrk)*this->secLength)+this->offset),SEEK_SET)==-1) { return strerror(errno); } @@ -59,7 +60,11 @@ const char *Device_readSector(const struct Device *this, int track, int sector, { return strerror(errno); } - else memset(buf+res,0,this->secLength-res); /* hit end of disk image */ + else +{ +printf("len %d\n",this->secLength-res); + memset(buf+res,0,this->secLength-res); /* hit end of disk image */ +} } return (const char*)0; } @@ -71,7 +76,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); }