"Fossies" - the Fresh Open Source Software Archive  

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

directory.c  (mtools-4.0.35.tar.bz2):directory.c  (mtools-4.0.36.tar.bz2)
skipping to change at line 35 skipping to change at line 35
/* #define DEBUG */ /* #define DEBUG */
/* /*
* Read a directory entry into caller supplied buffer * Read a directory entry into caller supplied buffer
*/ */
struct directory *dir_read(direntry_t *entry, int *error) struct directory *dir_read(direntry_t *entry, int *error)
{ {
ssize_t n; ssize_t n;
*error = 0; *error = 0;
if((n=force_read(entry->Dir, (char *) (&entry->dir), if((n=force_pread(entry->Dir, (char *) (&entry->dir),
(mt_off_t) entry->entry * MDIR_SIZE, (mt_off_t) entry->entry * MDIR_SIZE,
MDIR_SIZE)) != MDIR_SIZE) { MDIR_SIZE)) != MDIR_SIZE) {
if (n < 0) { if (n < 0) {
*error = -1; *error = -1;
} }
return NULL; return NULL;
} }
return &entry->dir; return &entry->dir;
} }
/* /*
* Make a subdirectory grow in length. Only subdirectories (not root) * Make a subdirectory grow in length. Only subdirectories (not root)
* may grow. Returns a 0 on success, 1 on failure (disk full), or -1 * may grow. Returns a 0 on success, 1 on failure (disk full), or -1
* on error. * on error.
*/ */
int dir_grow(Stream_t *Dir, int size) int dir_grow(Stream_t *Dir, int size)
{ {
Stream_t *Stream = GetFs(Dir); Stream_t *Stream = GetFs(Dir);
DeclareThis(FsPublic_t); DeclareThis(Fs_t);
ssize_t ret; ssize_t ret;
unsigned int buflen; unsigned int buflen;
char *buffer; char *buffer;
if (!getfreeMinClusters(Dir, 1)) if (!getfreeMinClusters(Dir, 1))
return -1; return -1;
buflen = This->cluster_size * This->sector_size; buflen = getClusterBytes(This);
if(! (buffer=malloc(buflen)) ){ if(! (buffer=malloc(buflen)) ){
perror("dir_grow: malloc"); perror("dir_grow: malloc");
return -1; return -1;
} }
memset((char *) buffer, '\0', buflen); memset((char *) buffer, '\0', buflen);
ret = force_write(Dir, buffer, (mt_off_t) size * MDIR_SIZE, buflen); ret = force_pwrite(Dir, buffer, (mt_off_t) size * MDIR_SIZE, buflen);
free(buffer); free(buffer);
if(ret < (int) buflen) if(ret < (int) buflen)
return -1; return -1;
return 0; return 0;
} }
void low_level_dir_write(direntry_t *entry) void low_level_dir_write(direntry_t *entry)
{ {
force_write(entry->Dir, force_pwrite(entry->Dir,
(char *) (&entry->dir), (char *) (&entry->dir),
(mt_off_t) entry->entry * MDIR_SIZE, MDIR_SIZE); (mt_off_t) entry->entry * MDIR_SIZE, MDIR_SIZE);
} }
void low_level_dir_write_end(Stream_t *Dir, int entry) void low_level_dir_write_end(Stream_t *Dir, int entry)
{ {
char zero = ENDMARK; char zero = ENDMARK;
force_write(Dir, &zero, (mt_off_t) entry * MDIR_SIZE, 1); force_pwrite(Dir, &zero, (mt_off_t) entry * MDIR_SIZE, 1);
} }
/* /*
* Make a directory entry. Builds a directory entry based on the * Make a directory entry. Builds a directory entry based on the
* name, attribute, starting cluster number, and size. Returns a pointer * name, attribute, starting cluster number, and size. Returns a pointer
* to a static directory structure. * to a static directory structure.
*/ */
struct directory *mk_entry(const dos_name_t *dn, unsigned char attr, struct directory *mk_entry(const dos_name_t *dn, unsigned char attr,
unsigned int fat, uint32_t size, time_t date, unsigned int fat, uint32_t size, time_t date,
 End of changes. 6 change blocks. 
10 lines changed or deleted 10 lines changed or added

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