"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xdf_io.c" between
mtools-4.0.35.tar.bz2 and mtools-4.0.36.tar.bz2

About: Mtools is a collection of utilities to access MS-DOS disks from Unix without mounting them.

xdf_io.c  (mtools-4.0.35.tar.bz2):xdf_io.c  (mtools-4.0.36.tar.bz2)
skipping to change at line 84 skipping to change at line 84
unsigned char sector; unsigned char sector;
unsigned char sizecode; unsigned char sizecode;
unsigned int dirty:1; unsigned int dirty:1;
unsigned int phantom:2; unsigned int phantom:2;
unsigned int valid:1; unsigned int valid:1;
unsigned int head:1; unsigned int head:1;
} TrackMap_t; } TrackMap_t;
typedef struct Xdf_t { typedef struct Xdf_t {
Class_t *Class; struct Stream_t head;
int refs;
Stream_t *Next;
Stream_t *Buffer;
int fd; int fd;
char *buffer; char *buffer;
bool track_valid; bool track_valid;
uint8_t current_track; uint8_t current_track;
sector_map_t *map; sector_map_t *map;
uint32_t track_size; uint32_t track_size;
skipping to change at line 493 skipping to change at line 490
/* beginning of the file system */ /* beginning of the file system */
ptr = fill_t0(This, ptr, ptr = fill_t0(This, ptr,
(This->track_size - This->FatSize) * 2 - (This->track_size - This->FatSize) * 2 -
This->RootDirSize - 6, This->RootDirSize - 6,
&sector, &head); &sector, &head);
} }
This->last_sector = ptr; This->last_sector = ptr;
return 0; return 0;
} }
static ssize_t xdf_read(Stream_t *Stream, char *buf, static ssize_t xdf_pread(Stream_t *Stream, char *buf,
mt_off_t where, size_t len) mt_off_t where, size_t len)
{ {
uint32_t begin, end; uint32_t begin, end;
ssize_t ret; ssize_t ret;
DeclareThis(Xdf_t); DeclareThis(Xdf_t);
if(decompose(This, truncBytes32(where), len, &begin, &end, 0) < 0) if(decompose(This, truncBytes32(where), len, &begin, &end, 0) < 0)
/* Read beyond end of device */ /* Read beyond end of device */
return 0; return 0;
ret = load_data(This, begin, end, 4); ret = load_data(This, begin, end, 4);
if(ret < 0 || (size_t) ret < begin) if(ret < 0 || (size_t) ret < begin)
return -1; return -1;
maximize(len, (size_t) ret - begin); maximize(len, (size_t) ret - begin);
memcpy(buf, This->buffer + begin, len); memcpy(buf, This->buffer + begin, len);
return (ssize_t) (end - begin); return (ssize_t) (end - begin);
} }
static ssize_t xdf_write(Stream_t *Stream, char *buf, mt_off_t where, size_t len static ssize_t xdf_pwrite(Stream_t *Stream, char *buf,
) mt_off_t where, size_t len)
{ {
uint32_t begin, end; uint32_t begin, end;
ssize_t len2; ssize_t len2;
DeclareThis(Xdf_t); DeclareThis(Xdf_t);
if(decompose(This, truncBytes32(where), len, &begin, &end, 0) < 0) { if(decompose(This, truncBytes32(where), len, &begin, &end, 0) < 0) {
/* Write beyond end of device */ /* Write beyond end of device */
errno = EFBIG; errno = EFBIG;
return -1; return -1;
} }
skipping to change at line 597 skipping to change at line 595
struct device *orig_dev UNUSEDP) struct device *orig_dev UNUSEDP)
{ {
DeclareThis(Xdf_t); DeclareThis(Xdf_t);
if(check_geom(This, dev)) if(check_geom(This, dev))
return 1; return 1;
set_geom(This, dev); set_geom(This, dev);
return 0; return 0;
} }
static Class_t XdfClass = { static Class_t XdfClass = {
xdf_read, 0,
xdf_write, 0,
xdf_pread,
xdf_pwrite,
xdf_flush, xdf_flush,
xdf_free, xdf_free,
config_geom, config_geom,
0, /* get_data */ 0, /* get_data */
0, /* pre-allocate */ 0, /* pre-allocate */
0, /* get_dosConvert */ 0, /* get_dosConvert */
0 /* discard */ 0 /* discard */
}; };
Stream_t *XdfOpen(struct device *dev, const char *name, Stream_t *XdfOpen(struct device *dev, const char *name,
skipping to change at line 624 skipping to change at line 624
unsigned int type; unsigned int type;
uint16_t fatSize; uint16_t fatSize;
if(dev && ((!SHOULD_USE_XDF(dev) && !getenv("MTOOLS_USE_XDF")) || if(dev && ((!SHOULD_USE_XDF(dev) && !getenv("MTOOLS_USE_XDF")) ||
check_geom(NULL, dev))) check_geom(NULL, dev)))
return NULL; return NULL;
This = New(Xdf_t); This = New(Xdf_t);
if (!This) if (!This)
return NULL; return NULL;
init_head(&This->head, &XdfClass, NULL);
This->Class = &XdfClass;
This->sector_size = 512; This->sector_size = 512;
This->stretch = 0; This->stretch = 0;
precmd(dev); precmd(dev);
This->fd = open(name, This->fd = open(name,
((mode | dev->mode) & ~O_ACCMODE) | ((mode | dev->mode) & ~O_ACCMODE) |
O_EXCL | O_NDELAY | O_RDWR); O_EXCL | O_NDELAY | O_RDWR);
if(This->fd < 0) { if(This->fd < 0) {
#ifdef HAVE_SNPRINTF #ifdef HAVE_SNPRINTF
snprintf(errmsg,199,"xdf floppy: open: \"%s\"", strerror(errno)); snprintf(errmsg,199,"xdf floppy: open: \"%s\"", strerror(errno));
skipping to change at line 709 skipping to change at line 709
if(type == NUMBER(xdf_table)) if(type == NUMBER(xdf_table))
goto exit_3; goto exit_3;
if(info) { if(info) {
info->RootDirSize = This->RootDirSize; info->RootDirSize = This->RootDirSize;
info->FatSize = This->FatSize; info->FatSize = This->FatSize;
info->BadSectors = 5; info->BadSectors = 5;
} }
decompose(This, 0, 512, &begin, &end, 1); decompose(This, 0, 512, &begin, &end, 1);
This->refs = 1;
This->Next = 0;
This->Buffer = 0;
if(dev) if(dev)
set_geom(This, dev); set_geom(This, dev);
return (Stream_t *) This; return &This->head;
exit_3: exit_3:
Free(This->track_map); Free(This->track_map);
exit_2: exit_2:
Free(This->buffer); Free(This->buffer);
exit_1: exit_1:
close(This->fd); close(This->fd);
exit_0: exit_0:
Free(This); Free(This);
return NULL; return NULL;
 End of changes. 8 change blocks. 
15 lines changed or deleted 11 lines changed or added

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