Modify dosfstools to support the dummy 8.3 short filename values used by Linux systems with the VFAT_FS_NO_DUALNAMES option enabled. Signed-off-by: Andrew Tridgell diff -urp dosfstools-3.0.1.saved/src/check.c dosfstools-3.0.1/src/check.c --- dosfstools-3.0.1.saved/src/check.c 2008-09-28 20:06:37.000000000 +1000 +++ dosfstools-3.0.1/src/check.c 2009-07-21 12:26:18.000000000 +1000 @@ -235,16 +235,21 @@ static char *file_stat(DOS_FILE *file) } -static int bad_name(unsigned char *name) +static int bad_name(DOS_FILE *file) { int i, spc, suspicious = 0; char *bad_chars = atari_format ? "*?\\/:" : "*?<>|\"\\/:"; + char *name = file->dir_ent.name; /* Do not complain about (and auto-correct) the extended attribute files * of OS/2. */ if (strncmp(name,"EA DATA SF",11) == 0 || strncmp(name,"WP ROOT SF",11) == 0) return 0; + /* don't complain about the dummy 11 bytes used by patched Linux + kernels */ + if (file->dir_ent.lcase & FAT_NO_83NAME) return 0; + for (i = 0; i < 8; i++) { if (name[i] < ' ' || name[i] == 0x7f) return 1; if (name[i] > 0x7f) ++suspicious; @@ -572,7 +577,7 @@ static int check_dir(DOS_FS *fs,DOS_FILE parent = (*root)->parent; good = bad = 0; for (walk = root; *walk; walk = &(*walk)->next) - if (bad_name((*walk)->dir_ent.name)) bad++; + if (bad_name(*walk)) bad++; else good++; if (*root && parent && good+bad > 4 && bad > good/2) { printf("%s\n Has a large number of bad entries. (%d/%d)\n", @@ -599,7 +604,7 @@ static int check_dir(DOS_FS *fs,DOS_FILE else dotdot++; } if (!((*walk)->dir_ent.attr & ATTR_VOLUME) && - bad_name((*walk)->dir_ent.name)) { + bad_name(*walk)) { printf("%s\n Bad file name.\n",path_name(*walk)); if (interactive) printf("1) Drop file\n2) Rename file\n3) Auto-rename\n" @@ -629,7 +634,7 @@ static int check_dir(DOS_FS *fs,DOS_FILE skip = 0; while (*scan && !skip) { if (!((*scan)->dir_ent.attr & ATTR_VOLUME) && - !strncmp((*walk)->dir_ent.name,(*scan)->dir_ent.name,MSDOS_NAME)) { + !memcmp((*walk)->dir_ent.name,(*scan)->dir_ent.name,MSDOS_NAME)) { printf("%s\n Duplicate directory entry.\n First %s\n", path_name(*walk),file_stat(*walk)); printf(" Second %s\n",file_stat(*scan)); diff -urp dosfstools-3.0.1.saved/src/dosfsck.h dosfstools-3.0.1/src/dosfsck.h --- dosfstools-3.0.1.saved/src/dosfsck.h 2008-09-28 20:06:37.000000000 +1000 +++ dosfstools-3.0.1/src/dosfsck.h 2009-07-21 12:25:43.000000000 +1000 @@ -208,6 +208,9 @@ extern void *mem_queue; /* return -16 as a number with fs->fat_bits bits */ #define FAT_EXTD(fs) (((1 << fs->eff_fat_bits)-1) & ~0xf) +/* marker for files with no 8.3 name */ +#define FAT_NO_83NAME 32 + #endif /* Local Variables: */