diff options
Diffstat (limited to 'directory.c')
-rw-r--r-- | directory.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/directory.c b/directory.c index 6a17aa0..79a4624 100644 --- a/directory.c +++ b/directory.c @@ -30,11 +30,11 @@ */ struct directory *dir_read(direntry_t *entry, int *error) { - int n; + ssize_t n; *error = 0; - if((n=force_read(entry->Dir, (char *) (&entry->dir), - (mt_off_t) entry->entry * MDIR_SIZE, - MDIR_SIZE)) != MDIR_SIZE) { + if((n=force_pread(entry->Dir, (char *) (&entry->dir), + (mt_off_t) entry->entry * MDIR_SIZE, + MDIR_SIZE)) != MDIR_SIZE) { if (n < 0) { *error = -1; } @@ -52,23 +52,23 @@ struct directory *dir_read(direntry_t *entry, int *error) int dir_grow(Stream_t *Dir, int size) { Stream_t *Stream = GetFs(Dir); - DeclareThis(FsPublic_t); - int ret; + DeclareThis(Fs_t); + ssize_t ret; unsigned int buflen; char *buffer; - + if (!getfreeMinClusters(Dir, 1)) return -1; - buflen = This->cluster_size * This->sector_size; + buflen = getClusterBytes(This); if(! (buffer=malloc(buflen)) ){ perror("dir_grow: malloc"); return -1; } - + 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); if(ret < (int) buflen) return -1; @@ -78,15 +78,15 @@ int dir_grow(Stream_t *Dir, int size) void low_level_dir_write(direntry_t *entry) { - force_write(entry->Dir, - (char *) (&entry->dir), - (mt_off_t) entry->entry * MDIR_SIZE, MDIR_SIZE); + force_pwrite(entry->Dir, + (char *) (&entry->dir), + (mt_off_t) entry->entry * MDIR_SIZE, MDIR_SIZE); } void low_level_dir_write_end(Stream_t *Dir, int entry) { 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); } /* @@ -96,28 +96,28 @@ void low_level_dir_write_end(Stream_t *Dir, int entry) */ struct directory *mk_entry(const dos_name_t *dn, unsigned char attr, - unsigned int fat, size_t size, time_t date, + unsigned int fat, uint32_t size, time_t date, struct directory *ndir) { struct tm *now; time_t date2 = date; - unsigned char hour, min_hi, min_low, sec; - unsigned char year, month_hi, month_low, day; + uint8_t hour, min_hi, min_low, sec; + uint8_t year, month_hi, month_low, day; now = localtime(&date2); dosnameToDirentry(dn, ndir); ndir->attr = attr; ndir->ctime_ms = 0; - hour = now->tm_hour << 3; - min_hi = now->tm_min >> 3; - min_low = now->tm_min << 5; - sec = now->tm_sec / 2; + hour = (uint8_t) (now->tm_hour << 3); + min_hi = (uint8_t) (now->tm_min >> 3); + min_low = (uint8_t) (now->tm_min << 5); + sec = (uint8_t) (now->tm_sec / 2); ndir->ctime[1] = ndir->time[1] = hour + min_hi; ndir->ctime[0] = ndir->time[0] = min_low + sec; - year = (now->tm_year - 80) << 1; - month_hi = (now->tm_mon + 1) >> 3; - month_low = (now->tm_mon + 1) << 5; - day = now->tm_mday; + year = (uint8_t) ((now->tm_year - 80) << 1); + month_hi = (uint8_t) ((now->tm_mon + 1) >> 3); + month_low = (uint8_t) ((now->tm_mon + 1) << 5); + day = (uint8_t) (now->tm_mday); ndir -> adate[1] = ndir->cdate[1] = ndir->date[1] = year + month_hi; ndir -> adate[0] = ndir->cdate[0] = ndir->date[0] = month_low + day; @@ -133,7 +133,7 @@ struct directory *mk_entry(const dos_name_t *dn, unsigned char attr, * Thus it doesn't bother with character set conversions */ struct directory *mk_entry_from_base(const char *base, unsigned char attr, - unsigned int fat, size_t size, time_t date, + unsigned int fat, uint32_t size, time_t date, struct directory *ndir) { struct dos_name_t dn; |