- Replace stupid concept of using a set of global variables for various boolean flags (1 variable per 1 flag) by a concept of one global var having a specified set of flags (FSCHECK_VERBOSE, etc).

svn path=/trunk/; revision=35146
This commit is contained in:
Aleksey Bragin 2008-08-06 13:07:28 +00:00
parent 516e0bb394
commit a75b654567
6 changed files with 60 additions and 61 deletions

View file

@ -119,10 +119,10 @@ static void check_backup_boot(DOS_FS *fs, struct boot_sector *b, int lss)
VfatPrint( "And there is no space for creating one!\n" ); VfatPrint( "And there is no space for creating one!\n" );
return; return;
} }
if (interactive) if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1) Create one\n2) Do without a backup\n" ); VfatPrint( "1) Create one\n2) Do without a backup\n" );
else VfatPrint( " Auto-creating backup boot block.\n" ); else VfatPrint( " Auto-creating backup boot block.\n" );
if (!interactive || get_key("12","?") == '1') { if (!(FsCheckFlags & FSCHECK_INTERACTIVE) || get_key("12","?") == '1') {
int bbs; int bbs;
/* The usual place for the backup boot sector is sector 6. Choose /* The usual place for the backup boot sector is sector 6. Choose
* that or the last reserved sector. */ * that or the last reserved sector. */
@ -167,12 +167,12 @@ static void check_backup_boot(DOS_FS *fs, struct boot_sector *b, int lss)
} }
VfatPrint( "\n" ); VfatPrint( "\n" );
if (interactive) if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1) Copy original to backup\n" VfatPrint( "1) Copy original to backup\n"
"2) Copy backup to original\n" "2) Copy backup to original\n"
"3) No action\n" ); "3) No action\n" );
else VfatPrint( " Not automatically fixing this.\n" ); else VfatPrint( " Not automatically fixing this.\n" );
switch (interactive ? get_key("123","?") : '3') { switch ((FsCheckFlags & FSCHECK_INTERACTIVE) ? get_key("123","?") : '3') {
case '1': case '1':
fs_write(fs->backupboot_start,sizeof(*b),b); fs_write(fs->backupboot_start,sizeof(*b),b);
break; break;
@ -200,10 +200,10 @@ static void read_fsinfo(DOS_FS *fs, struct boot_sector *b,int lss)
if (!b->info_sector) { if (!b->info_sector) {
VfatPrint( "No FSINFO sector\n" ); VfatPrint( "No FSINFO sector\n" );
if (interactive) if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1) Create one\n2) Do without FSINFO\n" ); VfatPrint( "1) Create one\n2) Do without FSINFO\n" );
else VfatPrint( " Not automatically creating it.\n" ); else VfatPrint( " Not automatically creating it.\n" );
if (interactive && get_key("12","?") == '1') { if ((FsCheckFlags & FSCHECK_INTERACTIVE) && get_key("12","?") == '1') {
/* search for a free reserved sector (not boot sector and not /* search for a free reserved sector (not boot sector and not
* backup boot sector) */ * backup boot sector) */
__u32 s; __u32 s;
@ -248,10 +248,10 @@ static void read_fsinfo(DOS_FS *fs, struct boot_sector *b,int lss)
VfatPrint( " Offset %llu: 0x%04x != expected 0x%04x\n", VfatPrint( " Offset %llu: 0x%04x != expected 0x%04x\n",
(__u64)offsetof(struct info_sector,boot_sign), (__u64)offsetof(struct info_sector,boot_sign),
CF_LE_W(i.boot_sign),0xaa55); CF_LE_W(i.boot_sign),0xaa55);
if (interactive) if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1) Correct\n2) Don't correct (FSINFO invalid then)\n" ); VfatPrint( "1) Correct\n2) Don't correct (FSINFO invalid then)\n" );
else VfatPrint( " Auto-correcting it.\n" ); else VfatPrint( " Auto-correcting it.\n" );
if (!interactive || get_key("12","?") == '1') { if (!(FsCheckFlags & FSCHECK_INTERACTIVE) || get_key("12","?") == '1') {
init_fsinfo(&i); init_fsinfo(&i);
fs_write(fs->fsinfo_start,sizeof(i),&i); fs_write(fs->fsinfo_start,sizeof(i),&i);
} }
@ -280,7 +280,7 @@ void read_boot(DOS_FS *fs)
fs->nfats = b.fats; fs->nfats = b.fats;
sectors = GET_UNALIGNED_W(b.sectors); sectors = GET_UNALIGNED_W(b.sectors);
total_sectors = sectors ? sectors : CF_LE_L(b.total_sect); total_sectors = sectors ? sectors : CF_LE_L(b.total_sect);
if (verbose) VfatPrint("Checking we can access the last sector of the filesystem\n"); if (FsCheckFlags & FSCHECK_VERBOSE) VfatPrint("Checking we can access the last sector of the filesystem\n");
/* Can't access last odd sector anyway, so round down */ /* Can't access last odd sector anyway, so round down */
fs_test((loff_t)((total_sectors & ~1)-1)*(loff_t)logical_sector_size, fs_test((loff_t)((total_sectors & ~1)-1)*(loff_t)logical_sector_size,
logical_sector_size); logical_sector_size);
@ -358,7 +358,7 @@ void read_boot(DOS_FS *fs)
/* ++roman: On Atari, these two fields are often left uninitialized */ /* ++roman: On Atari, these two fields are often left uninitialized */
if (!atari_format && (!b.secs_track || !b.heads)) if (!atari_format && (!b.secs_track || !b.heads))
die("Invalid disk format in boot sector."); die("Invalid disk format in boot sector.");
if (verbose) dump_boot(fs,&b,logical_sector_size); if (FsCheckFlags & FSCHECK_VERBOSE) dump_boot(fs,&b,logical_sector_size);
} }
/* Local Variables: */ /* Local Variables: */

View file

@ -267,7 +267,7 @@ static int bad_name(unsigned char *name)
/* Only complain about too much suspicious chars in interactive mode, /* Only complain about too much suspicious chars in interactive mode,
* never correct them automatically. The chars are all basically ok, so we * never correct them automatically. The chars are all basically ok, so we
* shouldn't auto-correct such names. */ * shouldn't auto-correct such names. */
if (interactive && suspicious > 6) if ((FsCheckFlags & FSCHECK_INTERACTIVE) && suspicious > 6)
return 1; return 1;
return 0; return 0;
} }
@ -365,11 +365,11 @@ static int handle_dot(DOS_FS *fs,DOS_FILE *file,int dots)
name = strncmp((char*)file->dir_ent.name,MSDOS_DOT,MSDOS_NAME) ? ".." : "."; name = strncmp((char*)file->dir_ent.name,MSDOS_DOT,MSDOS_NAME) ? ".." : ".";
if (!(file->dir_ent.attr & ATTR_DIR)) { if (!(file->dir_ent.attr & ATTR_DIR)) {
VfatPrint("%s\n Is a non-directory.\n",path_name(file)); VfatPrint("%s\n Is a non-directory.\n",path_name(file));
if (interactive) if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint("1) Drop it\n2) Auto-rename\n3) Rename\n" VfatPrint("1) Drop it\n2) Auto-rename\n3) Rename\n"
"4) Convert to directory\n"); "4) Convert to directory\n");
else VfatPrint(" Auto-renaming it.\n"); else VfatPrint(" Auto-renaming it.\n");
switch (interactive ? get_key("1234","?") : '2') { switch ((FsCheckFlags & FSCHECK_INTERACTIVE) ? get_key("1234","?") : '2') {
case '1': case '1':
drop_file(fs,file); drop_file(fs,file);
return 1; return 1;
@ -483,7 +483,7 @@ static int check_file(DOS_FS *fs,DOS_FILE *file)
"is FAT32 root dir.\n", clusters*fs->cluster_size ); "is FAT32 root dir.\n", clusters*fs->cluster_size );
do_trunc = 1; do_trunc = 1;
} }
else if (interactive) else if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint("1) Truncate first to %lu bytes%s\n" VfatPrint("1) Truncate first to %lu bytes%s\n"
"2) Truncate second to %lu bytes\n",clusters*fs->cluster_size, "2) Truncate second to %lu bytes\n",clusters*fs->cluster_size,
restart ? " and restart" : "",clusters2*fs->cluster_size); restart ? " and restart" : "",clusters2*fs->cluster_size);
@ -491,7 +491,7 @@ static int check_file(DOS_FS *fs,DOS_FILE *file)
fs->cluster_size); fs->cluster_size);
if (do_trunc != 2 && if (do_trunc != 2 &&
(do_trunc == 1 || (do_trunc == 1 ||
(interactive && get_key("12","?") == '1'))) { ((FsCheckFlags & FSCHECK_INTERACTIVE) && get_key("12","?") == '1'))) {
prev = 0; prev = 0;
clusters = 0; clusters = 0;
for (this = FSTART(owner,fs); this > 0 && this != -1; this = for (this = FSTART(owner,fs); this > 0 && this != -1; this =
@ -561,7 +561,7 @@ static int check_dir(DOS_FS *fs,DOS_FILE **root,int dots)
VfatPrint("%s\n Has a large number of bad entries. (%d/%d)\n", VfatPrint("%s\n Has a large number of bad entries. (%d/%d)\n",
path_name(parent),bad,good+bad); path_name(parent),bad,good+bad);
if (!dots) VfatPrint( " Not dropping root directory.\n" ); if (!dots) VfatPrint( " Not dropping root directory.\n" );
else if (!interactive) VfatPrint(" Not dropping it in auto-mode.\n"); else if (!(FsCheckFlags & FSCHECK_INTERACTIVE)) VfatPrint(" Not dropping it in auto-mode.\n");
else if (get_key("yn","Drop directory ? (y/n)") == 'y') { else if (get_key("yn","Drop directory ? (y/n)") == 'y') {
truncate_file(fs,parent,0); truncate_file(fs,parent,0);
MODIFY(parent,name[0],DELETED_FLAG); MODIFY(parent,name[0],DELETED_FLAG);
@ -584,11 +584,11 @@ static int check_dir(DOS_FS *fs,DOS_FILE **root,int dots)
if (!((*walk)->dir_ent.attr & ATTR_VOLUME) && if (!((*walk)->dir_ent.attr & ATTR_VOLUME) &&
bad_name((*walk)->dir_ent.name)) { bad_name((*walk)->dir_ent.name)) {
VfatPrint("%s\n Bad file name.\n",path_name(*walk)); VfatPrint("%s\n Bad file name.\n",path_name(*walk));
if (interactive) if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint("1) Drop file\n2) Rename file\n3) Auto-rename\n" VfatPrint("1) Drop file\n2) Rename file\n3) Auto-rename\n"
"4) Keep it\n"); "4) Keep it\n");
else VfatPrint(" Auto-renaming it.\n"); else VfatPrint(" Auto-renaming it.\n");
switch (interactive ? get_key("1234","?") : '3') { switch ((FsCheckFlags & FSCHECK_INTERACTIVE) ? get_key("1234","?") : '3') {
case '1': case '1':
drop_file(fs,*walk); drop_file(fs,*walk);
walk = &(*walk)->next; walk = &(*walk)->next;
@ -616,12 +616,12 @@ static int check_dir(DOS_FS *fs,DOS_FILE **root,int dots)
VfatPrint("%s\n Duplicate directory entry.\n First %s\n", VfatPrint("%s\n Duplicate directory entry.\n First %s\n",
path_name(*walk),file_stat(*walk)); path_name(*walk),file_stat(*walk));
VfatPrint(" Second %s\n",file_stat(*scan)); VfatPrint(" Second %s\n",file_stat(*scan));
if (interactive) if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint("1) Drop first\n2) Drop second\n3) Rename first\n" VfatPrint("1) Drop first\n2) Drop second\n3) Rename first\n"
"4) Rename second\n5) Auto-rename first\n" "4) Rename second\n5) Auto-rename first\n"
"6) Auto-rename second\n"); "6) Auto-rename second\n");
else VfatPrint(" Auto-renaming second.\n"); else VfatPrint(" Auto-renaming second.\n");
switch (interactive ? get_key("123456","?") : '6') { switch ((FsCheckFlags & FSCHECK_INTERACTIVE) ? get_key("123456","?") : '6') {
case '1': case '1':
drop_file(fs,*walk); drop_file(fs,*walk);
*walk = (*walk)->next; *walk = (*walk)->next;
@ -789,7 +789,7 @@ static void add_file(DOS_FS *fs,DOS_FILE ***chain,DOS_FILE *parent,
if (type == fdt_undelete) undelete(fs,new); if (type == fdt_undelete) undelete(fs,new);
**chain = new; **chain = new;
*chain = &new->next; *chain = &new->next;
if (list) { if (FsCheckFlags & FSCHECK_LIST_FILES) {
VfatPrint("Checking file %s",path_name(new)); VfatPrint("Checking file %s",path_name(new));
if (new->lfn) if (new->lfn)
VfatPrint(" (%s)", file_name(new->dir_ent.name) ); VfatPrint(" (%s)", file_name(new->dir_ent.name) );
@ -799,7 +799,7 @@ static void add_file(DOS_FS *fs,DOS_FILE ***chain,DOS_FILE *parent,
strncmp((char*)de.name,MSDOS_DOT,MSDOS_NAME) != 0 && strncmp((char*)de.name,MSDOS_DOT,MSDOS_NAME) != 0 &&
strncmp((char*)de.name,MSDOS_DOTDOT,MSDOS_NAME) != 0) strncmp((char*)de.name,MSDOS_DOTDOT,MSDOS_NAME) != 0)
++n_files; ++n_files;
test_file(fs,new,test); test_file(fs,new,FsCheckFlags & FSCHECK_TEST_READ);
} }

View file

@ -29,13 +29,6 @@ typedef __int64 ll_t;
#endif #endif
#define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
#define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h>*/
#define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
//#include <linux/version.h>
//# include "types.h"
#ifdef _M_IX86 #ifdef _M_IX86
#include "byteorder.h" #include "byteorder.h"
#endif #endif
@ -165,7 +158,13 @@ typedef struct {
#define offsetof(t,e) ((int)&(((t *)0)->e)) #define offsetof(t,e) ((int)&(((t *)0)->e))
#endif #endif
extern int interactive,list,verbose,test,write_immed; #define FSCHECK_INTERACTIVE 0x01
#define FSCHECK_LIST_FILES 0x02
#define FSCHECK_TEST_READ 0x04
#define FSCHECK_VERBOSE 0x08
#define FSCHECK_IMMEDIATE_WRITE 0x10
extern ULONG FsCheckFlags;
extern int atari_format; extern int atari_format;
extern unsigned n_files; extern unsigned n_files;
extern void *mem_queue; extern void *mem_queue;

View file

@ -79,7 +79,7 @@ void read_fat(DOS_FS *fs)
fs_write(fs->fat_start,eff_size,use = second); fs_write(fs->fat_start,eff_size,use = second);
} }
if (first_ok && second_ok) { if (first_ok && second_ok) {
if (interactive) { if (FsCheckFlags & FSCHECK_INTERACTIVE) {
VfatPrint("FATs differ but appear to be intact. Use which FAT ?\n" VfatPrint("FATs differ but appear to be intact. Use which FAT ?\n"
"1) Use first FAT\n2) Use second FAT\n"); "1) Use first FAT\n2) Use second FAT\n");
if (get_key("12","?") == '1') if (get_key("12","?") == '1')
@ -199,7 +199,7 @@ void fix_bad(DOS_FS *fs)
{ {
unsigned long i; unsigned long i;
if (verbose) if (FsCheckFlags & FSCHECK_VERBOSE)
VfatPrint("Checking for bad clusters.\n"); VfatPrint("Checking for bad clusters.\n");
for (i = 2; i < fs->clusters+2; i++) for (i = 2; i < fs->clusters+2; i++)
if (!get_owner(fs,i) && !FAT_IS_BAD(fs,fs->fat[i].value)) if (!get_owner(fs,i) && !FAT_IS_BAD(fs,fs->fat[i].value))
@ -215,7 +215,7 @@ void reclaim_free(DOS_FS *fs)
int reclaimed; int reclaimed;
unsigned long i; unsigned long i;
if (verbose) if (FsCheckFlags & FSCHECK_VERBOSE)
VfatPrint("Checking for unused clusters.\n"); VfatPrint("Checking for unused clusters.\n");
reclaimed = 0; reclaimed = 0;
for (i = 2; i < fs->clusters+2; i++) for (i = 2; i < fs->clusters+2; i++)
@ -261,7 +261,7 @@ void reclaim_file(DOS_FS *fs)
int reclaimed,files,changed; int reclaimed,files,changed;
unsigned long i,next,walk; unsigned long i,next,walk;
if (verbose) if (FsCheckFlags & FSCHECK_VERBOSE)
VfatPrint("Reclaiming unconnected clusters.\n"); VfatPrint("Reclaiming unconnected clusters.\n");
for (i = 2; i < fs->clusters+2; i++) fs->fat[i].prev = 0; for (i = 2; i < fs->clusters+2; i++) fs->fat[i].prev = 0;
for (i = 2; i < fs->clusters+2; i++) { for (i = 2; i < fs->clusters+2; i++) {
@ -324,25 +324,25 @@ unsigned long update_free(DOS_FS *fs)
if (!fs->fsinfo_start) if (!fs->fsinfo_start)
return free; return free;
if (verbose) if (FsCheckFlags & FSCHECK_VERBOSE)
VfatPrint("Checking free cluster summary.\n"); VfatPrint("Checking free cluster summary.\n");
if (fs->free_clusters >= 0) { if (fs->free_clusters >= 0) {
if (free != fs->free_clusters) { if (free != fs->free_clusters) {
VfatPrint( "Free cluster summary wrong (%ld vs. really %ld)\n", VfatPrint( "Free cluster summary wrong (%ld vs. really %ld)\n",
fs->free_clusters,free); fs->free_clusters,free);
if (interactive) if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1) Correct\n2) Don't correct\n" ); VfatPrint( "1) Correct\n2) Don't correct\n" );
else VfatPrint( " Auto-correcting.\n" ); else VfatPrint( " Auto-correcting.\n" );
if (!interactive || get_key("12","?") == '1') if (!(FsCheckFlags & FSCHECK_INTERACTIVE) || get_key("12","?") == '1')
do_set = 1; do_set = 1;
} }
} }
else { else {
VfatPrint( "Free cluster summary uninitialized (should be %ld)\n", free ); VfatPrint( "Free cluster summary uninitialized (should be %ld)\n", free );
if (interactive) if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1) Set it\n2) Leave it uninitialized\n" ); VfatPrint( "1) Set it\n2) Leave it uninitialized\n" );
else VfatPrint( " Auto-setting.\n" ); else VfatPrint( " Auto-setting.\n" );
if (!interactive || get_key("12","?") == '1') if (!(FsCheckFlags & FSCHECK_INTERACTIVE) || get_key("12","?") == '1')
do_set = 1; do_set = 1;
} }

View file

@ -139,7 +139,7 @@ void fs_write(loff_t pos,int size,void *data)
int did; int did;
#if 1 //SAE #if 1 //SAE
if (write_immed) { if (FsCheckFlags & FSCHECK_IMMEDIATE_WRITE) {
void *scratch; void *scratch;
const size_t readsize_aligned = (size % 512) ? (size + (512 - (size % 512))) : size; const size_t readsize_aligned = (size % 512) ? (size + (512 - (size % 512))) : size;
const loff_t seekpos_aligned = pos - (pos % 512); const loff_t seekpos_aligned = pos - (pos % 512);
@ -204,10 +204,10 @@ void fs_write(loff_t pos,int size,void *data)
static void fs_flush(void) static void fs_flush(void)
{ {
CHANGE *this; CHANGE *this;
int old_write_immed = write_immed; int old_write_immed = (FsCheckFlags & FSCHECK_IMMEDIATE_WRITE);
/* Disable writes to the list now */ /* Disable writes to the list now */
write_immed = 1; FsCheckFlags |= FSCHECK_IMMEDIATE_WRITE;
while (changes) { while (changes) {
this = changes; this = changes;
@ -220,7 +220,7 @@ static void fs_flush(void)
} }
/* Restore values */ /* Restore values */
write_immed = old_write_immed; if (!old_write_immed) FsCheckFlags ^= FSCHECK_IMMEDIATE_WRITE;
} }

View file

@ -173,13 +173,13 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
vffree( part2 ); vffree( part2 );
can_clear = 1; can_clear = 1;
} }
if (interactive) { if (FsCheckFlags & FSCHECK_INTERACTIVE) {
VfatPrint( "1: Delete previous LFN\n2: Leave it as it is.\n" ); VfatPrint( "1: Delete previous LFN\n2: Leave it as it is.\n" );
if (can_clear) if (can_clear)
VfatPrint( "3: Clear start bit and concatenate LFNs\n" ); VfatPrint( "3: Clear start bit and concatenate LFNs\n" );
} }
else VfatPrint( " Not auto-correcting this.\n" ); else VfatPrint( " Not auto-correcting this.\n" );
if (interactive) { if (FsCheckFlags & FSCHECK_INTERACTIVE) {
switch( get_key( can_clear ? "123" : "12", "?" )) { switch( get_key( can_clear ? "123" : "12", "?" )) {
case '1': case '1':
clear_lfn_slots( 0, lfn_parts-1 ); clear_lfn_slots( 0, lfn_parts-1 );
@ -210,12 +210,12 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
VfatPrint( "Long filename fragment \"%s\" found outside a LFN " VfatPrint( "Long filename fragment \"%s\" found outside a LFN "
"sequence.\n (Maybe the start bit is missing on the " "sequence.\n (Maybe the start bit is missing on the "
"last fragment)\n", part ); "last fragment)\n", part );
if (interactive) { if (FsCheckFlags & FSCHECK_INTERACTIVE) {
VfatPrint( "1: Delete fragment\n2: Leave it as it is.\n" VfatPrint( "1: Delete fragment\n2: Leave it as it is.\n"
"3: Set start bit\n" ); "3: Set start bit\n" );
} }
else VfatPrint( " Not auto-correcting this.\n" ); else VfatPrint( " Not auto-correcting this.\n" );
if (interactive) { if (FsCheckFlags & FSCHECK_INTERACTIVE) {
switch( get_key( "123", "?" )) { switch( get_key( "123", "?" )) {
case '1': case '1':
if (!lfn_offsets) if (!lfn_offsets)
@ -259,13 +259,13 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
vffree( part2 ); vffree( part2 );
can_fix = 1; can_fix = 1;
} }
if (interactive) { if (FsCheckFlags & FSCHECK_INTERACTIVE) {
VfatPrint( "1: Delete LFN\n2: Leave it as it is (and ignore LFN so far)\n" ); VfatPrint( "1: Delete LFN\n2: Leave it as it is (and ignore LFN so far)\n" );
if (can_fix) if (can_fix)
VfatPrint( "3: Correct sequence number\n" ); VfatPrint( "3: Correct sequence number\n" );
} }
else VfatPrint( " Not auto-correcting this.\n" ); else VfatPrint( " Not auto-correcting this.\n" );
if (interactive) { if (FsCheckFlags & FSCHECK_INTERACTIVE) {
switch( get_key( can_fix ? "123" : "12", "?" )) { switch( get_key( can_fix ? "123" : "12", "?" )) {
case '1': case '1':
lfn_offsets[lfn_parts++] = dir_offset; lfn_offsets[lfn_parts++] = dir_offset;
@ -291,12 +291,12 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
VfatPrint( "Checksum in long filename part wrong " VfatPrint( "Checksum in long filename part wrong "
"(%02x vs. expected %02x).\n", "(%02x vs. expected %02x).\n",
lfn->alias_checksum, lfn_checksum ); lfn->alias_checksum, lfn_checksum );
if (interactive) { if (FsCheckFlags & FSCHECK_INTERACTIVE) {
VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n" VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n"
"3: Correct checksum\n" ); "3: Correct checksum\n" );
} }
else VfatPrint( " Not auto-correcting this.\n" ); else VfatPrint( " Not auto-correcting this.\n" );
if (interactive) { if (FsCheckFlags & FSCHECK_INTERACTIVE) {
switch( get_key( "123", "?" )) { switch( get_key( "123", "?" )) {
case '1': case '1':
lfn_offsets[lfn_parts++] = dir_offset; lfn_offsets[lfn_parts++] = dir_offset;
@ -326,10 +326,10 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
if (lfn->reserved != 0) { if (lfn->reserved != 0) {
VfatPrint( "Reserved field in VFAT long filename slot is not 0 " VfatPrint( "Reserved field in VFAT long filename slot is not 0 "
"(but 0x%02x).\n", lfn->reserved ); "(but 0x%02x).\n", lfn->reserved );
if (interactive) if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1: Fix.\n2: Leave it.\n" ); VfatPrint( "1: Fix.\n2: Leave it.\n" );
else VfatPrint( "Auto-setting to 0.\n" ); else VfatPrint( "Auto-setting to 0.\n" );
if (!interactive || get_key("12","?") == '1') { if (!(FsCheckFlags & FSCHECK_INTERACTIVE) || get_key("12","?") == '1') {
lfn->reserved = 0; lfn->reserved = 0;
fs_write( dir_offset+offsetof(LFN_ENT,reserved), fs_write( dir_offset+offsetof(LFN_ENT,reserved),
sizeof(lfn->reserved), &lfn->reserved ); sizeof(lfn->reserved), &lfn->reserved );
@ -338,10 +338,10 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
if (lfn->start != CT_LE_W(0)) { if (lfn->start != CT_LE_W(0)) {
VfatPrint( "Start cluster field in VFAT long filename slot is not 0 " VfatPrint( "Start cluster field in VFAT long filename slot is not 0 "
"(but 0x%04x).\n", lfn->start ); "(but 0x%04x).\n", lfn->start );
if (interactive) if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1: Fix.\n2: Leave it.\n" ); VfatPrint( "1: Fix.\n2: Leave it.\n" );
else VfatPrint( "Auto-setting to 0.\n" ); else VfatPrint( "Auto-setting to 0.\n" );
if (!interactive || get_key("12","?") == '1') { if (!(FsCheckFlags & FSCHECK_INTERACTIVE) || get_key("12","?") == '1') {
lfn->start = CT_LE_W(0); lfn->start = CT_LE_W(0);
fs_write( dir_offset+offsetof(LFN_ENT,start), fs_write( dir_offset+offsetof(LFN_ENT,start),
sizeof(lfn->start),&lfn->start ); sizeof(lfn->start),&lfn->start );
@ -382,13 +382,13 @@ char *lfn_get( DIR_ENT *de )
" (Start may have been overwritten by %s)\n", " (Start may have been overwritten by %s)\n",
long_name, short_name ); long_name, short_name );
vffree( long_name ); vffree( long_name );
if (interactive) { if (FsCheckFlags & FSCHECK_INTERACTIVE) {
VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n" VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n"
"3: Fix numbering (truncates long name and attaches " "3: Fix numbering (truncates long name and attaches "
"it to short name %s)\n", short_name ); "it to short name %s)\n", short_name );
} }
else VfatPrint( " Not auto-correcting this.\n" ); else VfatPrint( " Not auto-correcting this.\n" );
if (interactive) { if (FsCheckFlags & FSCHECK_INTERACTIVE) {
switch( get_key( "123", "?" )) { switch( get_key( "123", "?" )) {
case '1': case '1':
clear_lfn_slots( 0, lfn_parts-1 ); clear_lfn_slots( 0, lfn_parts-1 );
@ -422,13 +422,13 @@ char *lfn_get( DIR_ENT *de )
" (Short name %s may have changed without updating the long name)\n", " (Short name %s may have changed without updating the long name)\n",
long_name, short_name ); long_name, short_name );
vffree( long_name ); vffree( long_name );
if (interactive) { if (FsCheckFlags & FSCHECK_INTERACTIVE) {
VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n" VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n"
"3: Fix checksum (attaches to short name %s)\n", "3: Fix checksum (attaches to short name %s)\n",
short_name ); short_name );
} }
else VfatPrint( " Not auto-correcting this.\n" ); else VfatPrint( " Not auto-correcting this.\n" );
if (interactive) { if (FsCheckFlags & FSCHECK_INTERACTIVE) {
switch( get_key( "123", "?" )) { switch( get_key( "123", "?" )) {
case '1': case '1':
clear_lfn_slots( 0, lfn_parts-1 ); clear_lfn_slots( 0, lfn_parts-1 );
@ -461,10 +461,10 @@ void lfn_check_orphaned(void)
long_name = CNV_PARTS_SO_FAR(); long_name = CNV_PARTS_SO_FAR();
VfatPrint("Orphaned long file name part \"%s\"\n", long_name); VfatPrint("Orphaned long file name part \"%s\"\n", long_name);
if (interactive) if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1: Delete.\n2: Leave it.\n" ); VfatPrint( "1: Delete.\n2: Leave it.\n" );
else VfatPrint( " Auto-deleting.\n" ); else VfatPrint( " Auto-deleting.\n" );
if (!interactive || get_key("12","?") == '1') { if (!(FsCheckFlags & FSCHECK_INTERACTIVE) || get_key("12","?") == '1') {
clear_lfn_slots(0, lfn_parts - 1); clear_lfn_slots(0, lfn_parts - 1);
} }
lfn_reset(); lfn_reset();