summaryrefslogtreecommitdiffstats
path: root/src/fat_adv.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2012-11-06 09:46:08 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2012-11-06 09:46:08 +0100
commit34da5767b6235158fe1d1e2a784a40dbb590f9db (patch)
tree6cb89049881d951c3adeb4e87edabdf75a5f6d56 /src/fat_adv.c
parent7d15a16cb83c2719f136785898ed3c6dd415f824 (diff)
Don't depend on "struct stat" for storing information about files, this
fix inode truncation when compiled with cygwin
Diffstat (limited to 'src/fat_adv.c')
-rw-r--r--src/fat_adv.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/src/fat_adv.c b/src/fat_adv.c
index f9be08a..23d2a67 100644
--- a/src/fat_adv.c
+++ b/src/fat_adv.c
@@ -214,9 +214,9 @@ static int ask_root_directory(disk_t *disk_car, const partition_t *partition, co
}
else
waddstr(window, " ");
- if(current_file->stat.st_mtime!=0)
+ if(current_file->td_mtime!=0)
{
- const struct tm *tm_p=localtime(&current_file->stat.st_mtime);
+ const struct tm *tm_p=localtime(&current_file->td_mtime);
snprintf(datestr, sizeof(datestr),"%2d-%s-%4d %02d:%02d",
tm_p->tm_mday, monstr[tm_p->tm_mon],
1900 + tm_p->tm_year, tm_p->tm_hour,
@@ -224,14 +224,10 @@ static int ask_root_directory(disk_t *disk_car, const partition_t *partition, co
} else {
strncpy(datestr, " ",sizeof(datestr));
}
- mode_string(current_file->stat.st_mode,str);
+ mode_string(current_file->st_mode, str);
wprintw(window, "%s %3u %3u ",
- str, (unsigned int)current_file->stat.st_uid, (unsigned int)current_file->stat.st_gid);
-#ifdef DJGPP
- wprintw(window, "%9llu", (long long unsigned int)current_file->file_size);
-#else
- wprintw(window, "%9llu", (long long unsigned int)current_file->stat.st_size);
-#endif
+ str, (unsigned int)current_file->st_uid, (unsigned int)current_file->st_gid);
+ wprintw(window, "%9llu", (long long unsigned int)current_file->st_size);
/* FIXME: screen overlaps due to long filename */
wprintw(window, " %s %s\n", datestr, current_file->name);
if(current_file==pos)
@@ -504,7 +500,7 @@ static unsigned int fat32_find_root_cluster(disk_t *disk_car,const partition_t *
{
file_data_t *dir_list;
dir_list=dir_fat_aux(buffer, cluster_size, cluster_size, 0);
- if(dir_list!=NULL && (dir_list->next==NULL || dir_list->stat.st_ino!=dir_list->next->stat.st_ino))
+ if(dir_list!=NULL && (dir_list->next==NULL || dir_list->st_ino!=dir_list->next->st_ino))
{
int test_date=1;
if(verbose>0)
@@ -624,15 +620,11 @@ static int file2entry(struct msdos_dir_entry *de, const file_data_t *current_fil
{
de->ext[j]=' ';
}
- de->attr=(LINUX_S_ISDIR(current_file->stat.st_mode)!=0?ATTR_DIR:ATTR_NONE);
- fat_date_unix2dos(current_file->stat.st_mtime,&de->time,&de->date);
- de->start=le16(current_file->stat.st_ino);
- de->starthi=le16(current_file->stat.st_ino>>16);
-#ifdef DJGPP
- de->size=le32(current_file->file_size);
-#else
- de->size=le32(current_file->stat.st_size);
-#endif
+ de->attr=(LINUX_S_ISDIR(current_file->st_mode)!=0?ATTR_DIR:ATTR_NONE);
+ fat_date_unix2dos(current_file->td_mtime,&de->time,&de->date);
+ de->start=le16(current_file->st_ino);
+ de->starthi=le16(current_file->st_ino>>16);
+ de->size=le32(current_file->st_size);
return 0;
}
@@ -842,10 +834,10 @@ static int analyse_dir_entries2(disk_t *disk_car,const partition_t *partition, c
{
dir_aff_log(NULL, dir_list);
}
- for(current_file=dir_list;(current_file!=NULL)&&(LINUX_S_ISDIR(current_file->stat.st_mode)==0);current_file=current_file->next);
+ for(current_file=dir_list;(current_file!=NULL)&&(LINUX_S_ISDIR(current_file->st_mode)==0);current_file=current_file->next);
if(current_file!=NULL)
{
- unsigned long int new_inode=current_file->stat.st_ino;
+ unsigned long int new_inode=current_file->st_ino;
unsigned int dir_entries;
if(verbose>1)
{