"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/dskgeom.c" between
libdsk-1.5.15.tar.gz and libdsk-1.5.17.tar.gz

About: LIBDSK is a library for accessing discs and disc image files. Development version.

dskgeom.c  (libdsk-1.5.15):dskgeom.c  (libdsk-1.5.17)
skipping to change at line 237 skipping to change at line 237
} }
/* Probe the geometry of a disc. This will always use the boot sector. */ /* Probe the geometry of a disc. This will always use the boot sector. */
dsk_err_t dsk_defgetgeom(DSK_DRIVER *self, DSK_GEOMETRY *geom) dsk_err_t dsk_defgetgeom(DSK_DRIVER *self, DSK_GEOMETRY *geom)
{ {
DSK_FORMAT secid; DSK_FORMAT secid;
dsk_err_t e; dsk_err_t e;
unsigned char *secbuf; unsigned char *secbuf;
unsigned long dsksize; unsigned long dsksize;
dsk_rate_t oldrate; dsk_rate_t oldrate;
unsigned bootsecsize = 0;
if (!self || !geom || !self->dr_class) return DSK_ERR_BADPTR; if (!self || !geom || !self->dr_class) return DSK_ERR_BADPTR;
memset(geom, 0, sizeof(*geom)); memset(geom, 0, sizeof(*geom));
/* Switch to a minimal format */ /* Switch to a minimal format */
e = dg_stdformat(geom, FMT_180K, NULL, NULL); e = dg_stdformat(geom, FMT_180K, NULL, NULL);
if (e) return e; if (e) return e;
/* Allocate buffer for boot sector (512 bytes) */ /* Allocate buffer for boot sector (512 bytes) */
secbuf = dsk_malloc(geom->dg_secsize); secbuf = dsk_malloc(geom->dg_secsize);
if (!secbuf) return DSK_ERR_NOMEM; if (!secbuf) return DSK_ERR_NOMEM;
bootsecsize = geom->dg_secsize;
/* Check for CPC6128 type discs. Also probe the data rate; if we get a /* Check for CPC6128 type discs. Also probe the data rate; if we get a
* missing address mark, then the data rate is wrong. * missing address mark, then the data rate is wrong.
*/ */
e = dg_stdformat(geom, FMT_180K, NULL, NULL); e = dg_stdformat(geom, FMT_180K, NULL, NULL);
if (e) return e; if (e) return e;
e = dsk_lsecid(self, geom, 0, &secid); e = dsk_lsecid(self, geom, 0, &secid);
/* Check for HD discs */ /* Check for HD discs */
if (e == DSK_ERR_NOADDR) if (e == DSK_ERR_NOADDR)
{ {
skipping to change at line 363 skipping to change at line 365
/* Switch to a format with 1k sectors */ /* Switch to a format with 1k sectors */
if (geom->dg_datarate == RATE_HD) if (geom->dg_datarate == RATE_HD)
e = dg_stdformat(geom, FMT_ACORN1600, NULL, NULL) ; e = dg_stdformat(geom, FMT_ACORN1600, NULL, NULL) ;
else e = dg_stdformat(geom, FMT_ACORN800, NULL, NULL); else e = dg_stdformat(geom, FMT_ACORN800, NULL, NULL);
if (e) return e; if (e) return e;
/* And restore it. */ /* And restore it. */
geom->dg_datarate = rate; geom->dg_datarate = rate;
/* Allocate buffer for boot sector (1k bytes) */ /* Allocate buffer for boot sector (1k bytes) */
secbuf = dsk_malloc(geom->dg_secsize); secbuf = dsk_malloc(geom->dg_secsize);
if (!secbuf) return DSK_ERR_NOMEM; if (!secbuf) return DSK_ERR_NOMEM;
bootsecsize = geom->dg_secsize;
e = dsk_lread(self, geom, secbuf, 0); e = dsk_lread(self, geom, secbuf, 0);
if (!e) if (!e)
{ {
dsksize = secbuf[0xFC] + 256 * secbuf[0xFD] + dsksize = secbuf[0xFC] + 256 * secbuf[0xFD] +
65536L * secbuf[0xFE]; 65536L * secbuf[0xFE];
/* Check for 1600k-format */ /* Check for 1600k-format */
if (geom->dg_datarate == RATE_HD) if (geom->dg_datarate == RATE_HD)
{ {
/* XXX Need a better check for Acorn 1600k */ /* XXX Need a better check for Acorn 1600k */
dsk_free(secbuf); dsk_free(secbuf);
skipping to change at line 493 skipping to change at line 496
/* [1.5.6] If we are reading a floppy, LDBS file, DSK file or /* [1.5.6] If we are reading a floppy, LDBS file, DSK file or
* anything with metadata, then the data rate used to read the * anything with metadata, then the data rate used to read the
* boot sector will be the correct one. If, however, we are reading * boot sector will be the correct one. If, however, we are reading
* something like a POSIX file with no metadata, then the read will * something like a POSIX file with no metadata, then the read will
* have succeeded with the default RATE_SD and the rate specified by * have succeeded with the default RATE_SD and the rate specified by
* the boot sector is a better indication of the proper value. * the boot sector is a better indication of the proper value.
* *
* So, try rereading the boot sector using the rate determined from * So, try rereading the boot sector using the rate determined from
* the boot sector. If that succeeds, all well and good. If not, * the boot sector. If that succeeds, all well and good. If not,
* revert to the rate when the boot sector was initially read */ * revert to the rate when the boot sector was initially read */
if (oldrate != geom->dg_datarate) if (oldrate != geom->dg_datarate && geom->dg_secsize <= bootsecsize)
{ {
dsk_err_t err2; dsk_err_t err2;
/* Try to reread the sector. */ /* Try to reread the sector. */
err2 = dsk_lread(self, geom, secbuf, 0); err2 = dsk_lread(self, geom, secbuf, 0);
/* If that failed, revert. */ /* If that failed, revert. */
if (err2 == DSK_ERR_NOADDR) if (err2 == DSK_ERR_NOADDR)
{ {
geom->dg_datarate = oldrate; geom->dg_datarate = oldrate;
} }
 End of changes. 4 change blocks. 
1 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)