"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "init.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.

init.c  (mtools-4.0.35.tar.bz2):init.c  (mtools-4.0.36.tar.bz2)
skipping to change at line 54 skipping to change at line 54
static int read_boot(Stream_t *Stream, union bootsector * boot, size_t size) static int read_boot(Stream_t *Stream, union bootsector * boot, size_t size)
{ {
size_t boot_sector_size; /* sector size, as stored in boot sector */ size_t boot_sector_size; /* sector size, as stored in boot sector */
/* read the first sector, or part of it */ /* read the first sector, or part of it */
if(!size) if(!size)
size = BOOTSIZE; size = BOOTSIZE;
if(size > MAX_BOOT) if(size > MAX_BOOT)
size = MAX_BOOT; size = MAX_BOOT;
if (force_read(Stream, boot->characters, 0, size) != (ssize_t) size) if (force_pread(Stream, boot->characters, 0, size) != (ssize_t) size)
return -1; return -1;
boot_sector_size = WORD(secsiz); boot_sector_size = WORD(secsiz);
if(boot_sector_size < sizeof(boot->bytes)) { if(boot_sector_size < sizeof(boot->bytes)) {
/* zero rest of in-memory boot sector */ /* zero rest of in-memory boot sector */
memset(boot->bytes+boot_sector_size, 0, memset(boot->bytes+boot_sector_size, 0,
sizeof(boot->bytes) - boot_sector_size); sizeof(boot->bytes) - boot_sector_size);
} }
return 0; return 0;
skipping to change at line 82 skipping to change at line 82
return 0; return 0;
} }
static doscp_t *get_dosConvert(Stream_t *Stream) static doscp_t *get_dosConvert(Stream_t *Stream)
{ {
DeclareThis(Fs_t); DeclareThis(Fs_t);
return This->cp; return This->cp;
} }
Class_t FsClass = { Class_t FsClass = {
read_pass_through, /* read */ 0,
write_pass_through, /* write */ 0,
pread_pass_through, /* read */
pwrite_pass_through, /* write */
fs_flush, fs_flush,
fs_free, /* free */ fs_free, /* free */
0, /* set geometry */ 0, /* set geometry */
get_data_pass_through, get_data_pass_through,
0, /* pre allocate */ 0, /* pre allocate */
get_dosConvert, /* dosconvert */ get_dosConvert, /* dosconvert */
0 /* discard */ 0 /* discard */
}; };
/** /**
skipping to change at line 107 skipping to change at line 109
*/ */
static int get_media_type(Stream_t *St, union bootsector *boot) static int get_media_type(Stream_t *St, union bootsector *boot)
{ {
int media; int media;
media = boot->boot.descr; media = boot->boot.descr;
if(media < 0xf0){ if(media < 0xf0){
char temp[512]; char temp[512];
/* old DOS disk. Media descriptor in the first FAT byte */ /* old DOS disk. Media descriptor in the first FAT byte */
/* we assume 512-byte sectors here */ /* we assume 512-byte sectors here */
if (force_read(St,temp,512,512) == 512) if (force_pread(St,temp,512,512) == 512)
media = (unsigned char) temp[0]; media = (unsigned char) temp[0];
else else
media = 0; media = 0;
} else } else
media += 0x100; media += 0x100;
return media; return media;
} }
Stream_t *GetFs(Stream_t *Fs) Stream_t *GetFs(Stream_t *Fs)
{ {
skipping to change at line 501 skipping to change at line 503
char errmsg[81]; char errmsg[81];
union bootsector boot; union bootsector boot;
Fs_t *This; Fs_t *This;
This = New(Fs_t); This = New(Fs_t);
if (!This) if (!This)
return NULL; return NULL;
This->Direct = NULL; init_head(&This->head, &FsClass, NULL);
This->Next = NULL;
This->refs = 1;
This->Buffer = 0;
This->Class = &FsClass;
This->preallocatedClusters = 0; This->preallocatedClusters = 0;
This->lastFatSectorNr = 0; This->lastFatSectorNr = 0;
This->lastFatAccessMode = 0; This->lastFatAccessMode = 0;
This->lastFatSectorData = 0; This->lastFatSectorData = 0;
This->drive = drive; This->drive = drive;
This->last = 0; This->last = 0;
This->Direct = find_device(drive, mode, &dev, &boot, name, &media, This->head.Next = find_device(drive, mode, &dev, &boot, name, &media,
&maxSize, isRop); &maxSize, isRop);
if(!This->Direct) if(!This->head.Next)
return NULL; return NULL;
cylinder_size = dev.heads * dev.sectors; cylinder_size = dev.heads * dev.sectors;
This->serialized = 0; This->serialized = 0;
tot_sectors = parseFsParams(This, &boot, media, cylinder_size); tot_sectors = parseFsParams(This, &boot, media, cylinder_size);
if(tot_sectors == 0) { if(tot_sectors == 0) {
/* Error raised by parseFsParams */ /* Error raised by parseFsParams */
return NULL; return NULL;
} }
skipping to change at line 565 skipping to change at line 563
disk_size <<= 1; disk_size <<= 1;
} }
#endif #endif
if (disk_size % 2) if (disk_size % 2)
disk_size *= 2; disk_size *= 2;
if(!dev.blocksize || dev.blocksize < This->sector_size) if(!dev.blocksize || dev.blocksize < This->sector_size)
blocksize = This->sector_size; blocksize = This->sector_size;
else else
blocksize = dev.blocksize; blocksize = dev.blocksize;
if (disk_size) if (disk_size) {
This->Next = buf_init(This->Direct, Stream_t *Buffer = buf_init(This->head.Next,
8 * disk_size * blocksize, 8 * disk_size * blocksize,
disk_size * blocksize, disk_size * blocksize,
This->sector_size); This->sector_size);
else
This->Next = This->Direct;
if (This->Next == NULL) { if (Buffer != NULL)
perror("init: allocate buffer"); This->head.Next = Buffer;
This->Next = This->Direct; else
perror("init: allocate buffer");
} }
/* read the FAT sectors */ /* read the FAT sectors */
if(fat_read(This, &boot, dev.use_2m&0x7f)){ if(fat_read(This, &boot, dev.use_2m&0x7f)){
fprintf(stderr, "Error reading FAT\n"); fprintf(stderr, "Error reading FAT\n");
This->num_fat = 1; This->num_fat = 1;
FREE(&This->Next); FREE(&This->head.Next);
Free(This->Next); Free(This->head.Next);
return NULL; return NULL;
} }
/* Set the codepage */ /* Set the codepage */
This->cp = cp_open(dev.codepage); This->cp = cp_open(dev.codepage);
if(This->cp == NULL) { if(This->cp == NULL) {
fprintf(stderr, "Error setting code page\n"); fprintf(stderr, "Error setting code page\n");
fs_free((Stream_t *)This); fs_free((Stream_t *)This);
FREE(&This->Next); FREE(&This->head.Next);
Free(This->Next); Free(This->head.Next);
return NULL; return NULL;
} }
return (Stream_t *) This; return (Stream_t *) This;
} }
char getDrive(Stream_t *Stream) char getDrive(Stream_t *Stream)
{ {
DeclareThis(Fs_t); DeclareThis(Fs_t);
if(This->Class != &FsClass) if(This->head.Class != &FsClass)
return getDrive(GetFs(Stream)); return getDrive(GetFs(Stream));
else else
return This->drive; return This->drive;
} }
/* /*
* Upper layer asks to pre-allocated more additional clusters * Upper layer asks to pre-allocated more additional clusters
* Parameters: * Parameters:
* size: new additional clusters to pre-allocate * size: new additional clusters to pre-allocate
* Return: * Return:
 End of changes. 10 change blocks. 
27 lines changed or deleted 24 lines changed or added

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