diff -Naru ori/dosfstools-2.10/Makefile dosfstools-2.10/Makefile --- ori/dosfstools-2.10/Makefile 2003-05-15 22:00:27.000000000 +0300 +++ dosfstools-2.10/Makefile 2005-04-27 09:39:21.000000000 +0300 @@ -2,7 +2,7 @@ # Makefile for dosfstools (mkdosfs and dosfsck) # -CC = gcc +CC = powerpc-linux-uclibc-gcc CPP = $(CC) -E OPTFLAGS = -O2 -fomit-frame-pointer WARNFLAGS = -Wall @@ -10,7 +10,7 @@ CFLAGS = $(OPTFLAGS) $(WARNFLAGS) $(DEBUGFLAGS) LDFLAGS = -PREFIX = +PREFIX = .. SBINDIR = $(PREFIX)/sbin MANDIR = $(PREFIX)/usr/man/man8 diff -Naru ori/dosfstools-2.10/dosfsck/boot.c dosfstools-2.10/dosfsck/boot.c --- ori/dosfstools-2.10/dosfsck/boot.c 2003-06-14 23:03:20.000000000 +0300 +++ dosfstools-2.10/dosfsck/boot.c 2005-09-24 09:39:52.000000000 +0300 @@ -58,6 +58,7 @@ return( "undefined" ); } +#ifdef DOSFSCK_DBG static void dump_boot(DOS_FS *fs,struct boot_sector *b,unsigned lss) { unsigned short sectors; @@ -67,7 +68,7 @@ char id[9]; strncpy(id,b->system_id,8); id[8] = 0; - printf("System ID \"%s\"\n",id); + //printf("System ID \"%s\"\n",id); //jack20050328+ } else { /* On Atari, a 24 bit serial number is stored at offset 8 of the boot @@ -109,21 +110,25 @@ sectors = GET_UNALIGNED_W( b->sectors ); printf("%10u sectors total\n", sectors ? sectors : CF_LE_L(b->total_sect)); } +#endif static void check_backup_boot(DOS_FS *fs, struct boot_sector *b, int lss) { struct boot_sector b2; - + if (!fs->backupboot_start) { printf( "There is no backup boot sector.\n" ); if (CF_LE_W(b->reserved) < 3) { printf( "And there is no space for creating one!\n" ); return; } - if (interactive) - printf( "1) Create one\n2) Do without a backup\n" ); - else printf( " Auto-creating backup boot block.\n" ); - if (!interactive || get_key("12","?") == '1') { +// if (interactive) +// printf( "1) Create one\n2) Do without a backup\n" ); +// else printf( " Auto-creating backup boot block.\n" ); + if (!interactive) + printf( " Auto-creating backup boot block.\n" ); +// if (!interactive || get_key("12","?") == '1') { + if (!interactive ) { int bbs; /* The usual place for the backup boot sector is sector 6. Choose * that or the last reserved sector. */ @@ -151,7 +156,7 @@ __u8 *p, *q; int i, pos, first = 1; char buf[20]; - + printf( "There are differences between boot sector and its backup.\n" ); printf( "Differences: (offset:original/backup)\n " ); pos = 2; @@ -167,22 +172,23 @@ } } printf( "\n" ); - - if (interactive) - printf( "1) Copy original to backup\n" - "2) Copy backup to original\n" - "3) No action\n" ); - else printf( " Not automatically fixing this.\n" ); - switch (interactive ? get_key("123","?") : '3') { - case '1': - fs_write(fs->backupboot_start,sizeof(*b),b); - break; - case '2': - fs_write(0,sizeof(b2),&b2); - break; - default: - break; - } +//jack20050328+ +// if (interactive) +// printf( "1) Copy original to backup\n" +// "2) Copy backup to original\n" +// "3) No action\n" ); +// else printf( " Not automatically fixing this.\n" ); +// switch (interactive ? get_key("123","?") : '3') { +// case '1': +// fs_write(fs->backupboot_start,sizeof(*b),b); +// break; +// case '2': +// fs_write(0,sizeof(b2),&b2); +// break; +// default: +// break; +// } +//jack20050328 end } } @@ -201,10 +207,15 @@ if (!b->info_sector) { printf( "No FSINFO sector\n" ); - if (interactive) - printf( "1) Create one\n2) Do without FSINFO\n" ); - else printf( " Not automatically creating it.\n" ); - if (interactive && get_key("12","?") == '1') { +//jack20050328+ +// if (interactive) +// printf( "1) Create one\n2) Do without FSINFO\n" ); +// else printf( " Not automatically creating it.\n" ); + if (!interactive) + printf( " Not automatically creating it.\n" ); +// if (interactive && get_key("12","?") == '1') { + if (interactive) { +//jack20050328 end /* search for a free reserved sector (not boot sector and not * backup boot sector) */ __u32 s; @@ -231,6 +242,7 @@ } fs->fsinfo_start = CF_LE_W(b->info_sector)*lss; + fs_read(fs->fsinfo_start,sizeof(i),&i); if (i.magic != CT_LE_L(0x41615252) || @@ -249,10 +261,13 @@ printf( " Offset %d: 0x%04x != expected 0x%04x\n", offsetof(struct info_sector,boot_sign), CF_LE_W(i.boot_sign),0xaa55); - if (interactive) - printf( "1) Correct\n2) Don't correct (FSINFO invalid then)\n" ); - else printf( " Auto-correcting it.\n" ); - if (!interactive || get_key("12","?") == '1') { +// if (interactive) +// printf( "1) Correct\n2) Don't correct (FSINFO invalid then)\n" ); +// else printf( " Auto-correcting it.\n" ); +// if (!interactive || get_key("12","?") == '1') { + if (!interactive) + printf( " Auto-correcting it.\n" ); + if (!interactive) { init_fsinfo(&i); fs_write(fs->fsinfo_start,sizeof(i),&i); } @@ -266,27 +281,36 @@ void read_boot(DOS_FS *fs) { struct boot_sector b; - unsigned total_sectors; + unsigned long total_sectors; unsigned short logical_sector_size, sectors; unsigned fat_length; loff_t data_size; - + fs_read(0,sizeof(b),&b); logical_sector_size = GET_UNALIGNED_W(b.sector_size); + //printf("logical sector size = %d\n",logical_sector_size); if (!logical_sector_size) die("Logical sector size is zero."); fs->cluster_size = b.cluster_size*logical_sector_size; + if (!fs->cluster_size) die("Cluster size is zero."); if (b.fats != 2 && b.fats != 1) die("Currently, only 1 or 2 FATs are supported, not %d.\n",b.fats); fs->nfats = b.fats; sectors = GET_UNALIGNED_W(b.sectors); total_sectors = sectors ? sectors : CF_LE_L(b.total_sect); + //printf("total sectors = %ld\n",total_sectors); +#ifdef DOSFSCK_DBG if (verbose) printf("Checking we can access the last sector of the filesystem\n"); +#endif /* Can't access last odd sector anyway, so round down */ - fs_test((loff_t)((total_sectors & ~1)-1)*(loff_t)logical_sector_size, - logical_sector_size); + //jack20050325+ +// fs_test((loff_t)((total_sectors & ~1)-1)*(loff_t)logical_sector_size, +// logical_sector_size); + //fs_test(0,logical_sector_size); + fat_length = CF_LE_W(b.fat_length) ? CF_LE_W(b.fat_length) : CF_LE_L(b.fat32_length); + fs->fat_start = (loff_t)CF_LE_W(b.reserved)*logical_sector_size; fs->root_start = ((loff_t)CF_LE_W(b.reserved)+b.fats*fat_length)* logical_sector_size; @@ -359,7 +383,9 @@ /* ++roman: On Atari, these two fields are often left uninitialized */ if (!atari_format && (!b.secs_track || !b.heads)) die("Invalid disk format in boot sector."); +#ifdef DOSFSCK_DBG if (verbose) dump_boot(fs,&b,logical_sector_size); +#endif } /* Local Variables: */ diff -Naru ori/dosfstools-2.10/dosfsck/check.c dosfstools-2.10/dosfsck/check.c --- ori/dosfstools-2.10/dosfsck/check.c 2003-01-21 23:33:40.000000000 +0200 +++ dosfstools-2.10/dosfsck/check.c 2005-09-24 09:39:52.000000000 +0300 @@ -20,7 +20,7 @@ #include "lfn.h" #include "check.h" - +#define PATH_MAX 15 //+Bing add 03112005 static DOS_FILE *root; /* get start field of a dir entry */ @@ -359,26 +359,33 @@ name = strncmp(file->dir_ent.name,MSDOS_DOT,MSDOS_NAME) ? ".." : "."; if (!(file->dir_ent.attr & ATTR_DIR)) { printf("%s\n Is a non-directory.\n",path_name(file)); - if (interactive) - printf("1) Drop it\n2) Auto-rename\n3) Rename\n" - "4) Convert to directory\n"); - else printf(" Auto-renaming it.\n"); - switch (interactive ? get_key("1234","?") : '2') { - case '1': - drop_file(fs,file); - return 1; - case '2': - auto_rename(file); - printf(" Renamed to %s\n",file_name(file->dir_ent.name)); - return 0; - case '3': - rename_file(file); - return 0; - case '4': - MODIFY(file,size,CT_LE_L(0)); - MODIFY(file,attr,file->dir_ent.attr | ATTR_DIR); - break; - } +//jack20050328+ +// if (interactive) +// printf("1) Drop it\n2) Auto-rename\n3) Rename\n" +// "4) Convert to directory\n"); +// else printf(" Auto-renaming it.\n"); +// switch (interactive ? get_key("1234","?") : '2') { +//jack20050328 end + if (!interactive) + { + switch ('2') + { + case '1': + drop_file(fs,file); + return 1; + case '2': + auto_rename(file); + printf(" Renamed to %s\n",file_name(file->dir_ent.name)); + return 0; + case '3': + rename_file(file); + return 0; + case '4': + MODIFY(file,size,CT_LE_L(0)); + MODIFY(file,attr,file->dir_ent.attr | ATTR_DIR); + break; + } + } } if (!dots) { printf("Root contains directory \"%s\". Dropping it.\n",name); @@ -394,7 +401,7 @@ DOS_FILE *owner; int restart; unsigned long expect,curr,this,clusters,prev,walk,clusters2; - + if (file->dir_ent.attr & ATTR_DIR) { if (CF_LE_L(file->dir_ent.size)) { printf("%s\n Directory has non-zero size. Fixing it.\n", @@ -471,15 +478,17 @@ "is FAT32 root dir.\n", clusters*fs->cluster_size ); do_trunc = 1; } - else if (interactive) - printf("1) Truncate first to %lu bytes%s\n" - "2) Truncate second to %lu bytes\n",clusters*fs->cluster_size, - restart ? " and restart" : "",clusters2*fs->cluster_size); +//jack20050328+ +// else if (interactive) +// printf("1) Truncate first to %lu bytes%s\n" +// "2) Truncate second to %lu bytes\n",clusters*fs->cluster_size, +// restart ? " and restart" : "",clusters2*fs->cluster_size); else printf(" Truncating second to %lu bytes.\n",clusters2* fs->cluster_size); if (do_trunc != 2 && (do_trunc == 1 || - (interactive && get_key("12","?") == '1'))) { +// (interactive && get_key("12","?") == '1'))) { + (interactive))) { prev = 0; clusters = 0; for (this = FSTART(owner,fs); this > 0 && this != -1; this = @@ -507,6 +516,7 @@ else MODIFY_START(file,0,fs); break; } +//jack20050328 end } set_owner(fs,curr,file); clusters++; @@ -538,7 +548,7 @@ DOS_FILE *parent,**walk,**scan; int dot,dotdot,skip,redo; int good,bad; - + if (!*root) return 0; parent = (*root)->parent; good = bad = 0; @@ -549,14 +559,20 @@ printf("%s\n Has a large number of bad entries. (%d/%d)\n", path_name(parent),bad,good+bad); if (!dots) printf( " Not dropping root directory.\n" ); - else if (!interactive) printf(" Not dropping it in auto-mode.\n"); - else if (get_key("yn","Drop directory ? (y/n)") == 'y') { +//jack20050328+ +// else if (!interactive) printf(" Not dropping it in auto-mode.\n"); +// else if (get_key("yn","Drop directory ? (y/n)") == 'y') { + else if (!interactive) { + printf("Fix , dropping it in auto-mode.\n"); truncate_file(fs,parent,0); MODIFY(parent,name[0],DELETED_FLAG); + /* buglet: deleted directory stays in the list. */ return 1; } +//jack20050328 end } + dot = dotdot = redo = 0; walk = root; while (*walk) { @@ -569,30 +585,40 @@ if (!strncmp((*walk)->dir_ent.name,MSDOS_DOT,MSDOS_NAME)) dot++; else dotdot++; } + + //jack20050328+ for debug show file name + //printf("name = %s\n",(*walk)->dir_ent.name); + if (!((*walk)->dir_ent.attr & ATTR_VOLUME) && bad_name((*walk)->dir_ent.name)) { printf("%s\n Bad file name.\n",path_name(*walk)); - if (interactive) - printf("1) Drop file\n2) Rename file\n3) Auto-rename\n" - "4) Keep it\n"); - else printf(" Auto-renaming it.\n"); - switch (interactive ? get_key("1234","?") : '3') { - case '1': - drop_file(fs,*walk); - walk = &(*walk)->next; - continue; - case '2': - rename_file(*walk); - redo = 1; - break; - case '3': - auto_rename(*walk); - printf(" Renamed to %s\n",file_name((*walk)->dir_ent. - name)); - break; - case '4': - break; - } + if (!interactive) + { +//jack20050328+ +// if (interactive) +// printf("1) Drop file\n2) Rename file\n3) Auto-rename\n" +// "4) Keep it\n"); +// else printf(" Auto-renaming it.\n"); +// switch (interactive ? get_key("1234","?") : '3') { +//jack20050328 end + switch ('3') { + case '1': + drop_file(fs,*walk); + walk = &(*walk)->next; + continue; + case '2': + rename_file(*walk); + redo = 1; + break; + case '3': + auto_rename(*walk); + printf(" Renamed to %s\n",file_name((*walk)->dir_ent. + name)); + break; + case '4': + break; + } + } } /* don't check for duplicates of the volume label */ if (!((*walk)->dir_ent.attr & ATTR_VOLUME)) { @@ -604,42 +630,49 @@ printf("%s\n Duplicate directory entry.\n First %s\n", path_name(*walk),file_stat(*walk)); printf(" Second %s\n",file_stat(*scan)); - if (interactive) - printf("1) Drop first\n2) Drop second\n3) Rename first\n" - "4) Rename second\n5) Auto-rename first\n" - "6) Auto-rename second\n"); - else printf(" Auto-renaming second.\n"); - switch (interactive ? get_key("123456","?") : '6') { - case '1': - drop_file(fs,*walk); - *walk = (*walk)->next; - skip = 1; - break; - case '2': - drop_file(fs,*scan); - *scan = (*scan)->next; - continue; - case '3': - rename_file(*walk); - printf(" Renamed to %s\n",path_name(*walk)); - redo = 1; - break; - case '4': - rename_file(*scan); - printf(" Renamed to %s\n",path_name(*walk)); - redo = 1; - break; - case '5': - auto_rename(*walk); - printf(" Renamed to %s\n",file_name((*walk)->dir_ent. - name)); - break; - case '6': - auto_rename(*scan); - printf(" Renamed to %s\n",file_name((*scan)->dir_ent. - name)); - break; - } +//jack20050328+ +// if (interactive) +// printf("1) Drop first\n2) Drop second\n3) Rename first\n" +// "4) Rename second\n5) Auto-rename first\n" +// "6) Auto-rename second\n"); +// else printf(" Auto-renaming second.\n"); +// switch (interactive ? get_key("123456","?") : '6') { + if (!interactive) + { + switch ('6') + { +//jack20050328end + case '1': + drop_file(fs,*walk); + *walk = (*walk)->next; + skip = 1; + break; + case '2': + drop_file(fs,*scan); + *scan = (*scan)->next; + continue; + case '3': + rename_file(*walk); + printf(" Renamed to %s\n",path_name(*walk)); + redo = 1; + break; + case '4': + rename_file(*scan); + printf(" Renamed to %s\n",path_name(*walk)); + redo = 1; + break; + case '5': + auto_rename(*walk); + printf(" Renamed to %s\n",file_name((*walk)->dir_ent. + name)); + break; + case '6': + auto_rename(*scan); + printf(" Renamed to %s\n",file_name((*scan)->dir_ent. + name)); + break; + } + } } scan = &(*scan)->next; } @@ -742,7 +775,9 @@ FD_TYPE type; if (offset) - fs_read(offset,sizeof(DIR_ENT),&de); + { + fs_read(offset,sizeof(DIR_ENT),&de); + } else { memcpy(de.name," ",MSDOS_NAME); de.attr = ATTR_DIR; @@ -792,7 +827,7 @@ DOS_FILE **chain; int i; unsigned long clu_num; - + chain = &this->first; i = 0; clu_num = FSTART(this,fs); diff -Naru ori/dosfstools-2.10/dosfsck/common.c dosfstools-2.10/dosfsck/common.c --- ori/dosfstools-2.10/dosfsck/common.c 2003-05-15 21:39:16.000000000 +0300 +++ dosfstools-2.10/dosfsck/common.c 2005-04-27 09:39:21.000000000 +0300 @@ -41,6 +41,7 @@ vfprintf(stderr,msg,args); va_end(args); fprintf(stderr,":%s\n",strerror(errno)); + printf("ERROR \n"); exit(1); } diff -Naru ori/dosfstools-2.10/dosfsck/common.h dosfstools-2.10/dosfsck/common.h --- ori/dosfstools-2.10/dosfsck/common.h 1998-04-28 14:14:25.000000000 +0300 +++ dosfstools-2.10/dosfsck/common.h 2005-09-24 09:39:52.000000000 +0300 @@ -2,6 +2,7 @@ /* Written 1993 by Werner Almesberger */ +//#define DOSFSCK_DBG 1 #ifndef _COMMON_H #define _COMMON_H diff -Naru ori/dosfstools-2.10/dosfsck/dosfsck.c dosfstools-2.10/dosfsck/dosfsck.c --- ori/dosfstools-2.10/dosfsck/dosfsck.c 2003-06-14 23:03:20.000000000 +0300 +++ dosfstools-2.10/dosfsck/dosfsck.c 2005-09-24 09:39:52.000000000 +0300 @@ -31,6 +31,7 @@ static void usage(char *name) { +#ifdef DOSFSCK_DBG fprintf(stderr,"usage: %s [-aAflrtvVwy] [-d path -d ...] " "[-u path -u ...]\n%15sdevice\n",name,""); fprintf(stderr," -a automatically repair the file system\n"); @@ -45,6 +46,7 @@ fprintf(stderr," -V perform a verification pass\n"); fprintf(stderr," -w write changes to disk immediately\n"); fprintf(stderr," -y same as -a, for compat with other *fsck\n"); +#endif exit(2); } @@ -77,6 +79,10 @@ #endif } +void touch_file() +{ + system("touch /tmp/fsck_result"); +} int main(int argc,char **argv) { @@ -88,6 +94,7 @@ interactive = 1; check_atari(); + atexit(touch_file); //+Bing modified 04212005 while ((c = getopt(argc,argv,"Aad:flrtu:vVwy")) != EOF) switch (c) { case 'A': /* toggle Atari format */ @@ -100,7 +107,9 @@ salvage_files = 1; break; case 'd': +#ifdef DOSFSCK_DBG file_add(optarg,fdt_drop); +#endif break; case 'f': salvage_files = 1; @@ -116,11 +125,13 @@ test = 1; break; case 'u': +#ifdef DOSFSCK_DBG file_add(optarg,fdt_undelete); +#endif break; case 'v': verbose = 1; - printf("dosfsck " VERSION " (" VERSION_DATE ")\n"); + //printf("dosfsck " VERSION " (" VERSION_DATE ")\n"); break; case 'V': verify = 1; @@ -132,12 +143,14 @@ usage(argv[0]); } if ((test || write_immed) && !rw) { +#ifdef DOSFSCK_DBG fprintf(stderr,"-t and -w require -a or -r\n"); +#endif exit(2); } if (optind != argc-1) usage(argv[0]); - printf( "dosfsck " VERSION ", " VERSION_DATE ", FAT32, LFN\n" ); + //printf( "dosfsck " VERSION ", " VERSION_DATE ", FAT32, LFN\n" ); fs_open(argv[optind],rw); read_boot(&fs); if (verify) printf("Starting check/repair pass.\n"); @@ -158,9 +171,15 @@ if (fs_changed()) { if (rw) { +#if 1 //+Bing modified 0419205 if (interactive) - rw = get_key("yn","Perform changes ? (y/n)") == 'y'; - else printf("Performing changes.\n"); + { + //rw = get_key("yn","Perform changes ? (y/n)") == 'y'; + rw = 0; + } + else + printf("Performing changes.\n"); +#endif } else printf("Leaving file system unchanged.\n"); @@ -168,7 +187,7 @@ printf( "%s: %u files, %lu/%lu clusters\n", argv[optind], n_files, fs.clusters - free_clusters, fs.clusters ); - + return fs_close(rw) ? 1 : 0; } diff -Naru ori/dosfstools-2.10/dosfsck/fat.c dosfstools-2.10/dosfsck/fat.c --- ori/dosfstools-2.10/dosfsck/fat.c 2003-06-14 23:03:20.000000000 +0300 +++ dosfstools-2.10/dosfsck/fat.c 2005-09-24 09:39:52.000000000 +0300 @@ -80,11 +80,14 @@ } if (first_ok && second_ok) { if (interactive) { - printf("FATs differ but appear to be intact. Use which FAT ?\n" - "1) Use first FAT\n2) Use second FAT\n"); - if (get_key("12","?") == '1') - fs_write(fs->fat_start+fs->fat_size,eff_size,use = first); - else fs_write(fs->fat_start,eff_size,use = second); +//jack20050328+ + printf("FATs differ but appear to be intact."); +// printf("FATs differ but appear to be intact. Use which FAT ?\n" +// "1) Use first FAT\n2) Use second FAT\n"); +// if (get_key("12","?") == '1') +// fs_write(fs->fat_start+fs->fat_size,eff_size,use = first); +// else fs_write(fs->fat_start,eff_size,use = second); +//jack20050328 end } else { printf("FATs differ but appear to be intact. Using first " @@ -199,8 +202,10 @@ { unsigned long i; +#ifdef DOSFSCK_DBG if (verbose) printf("Checking for bad clusters.\n"); +#endif for (i = 2; i < fs->clusters+2; i++) if (!get_owner(fs,i) && !FAT_IS_BAD(fs,fs->fat[i].value)) if (!fs_test(cluster_start(fs,i),fs->cluster_size)) { @@ -215,8 +220,10 @@ int reclaimed; unsigned long i; +#ifdef DOSFSCK_DBG if (verbose) printf("Checking for unused clusters.\n"); +#endif reclaimed = 0; for (i = 2; i < fs->clusters+2; i++) if (!get_owner(fs,i) && fs->fat[i].value && @@ -261,8 +268,10 @@ int reclaimed,files,changed; unsigned long i,next,walk; +#ifdef DOSFSCK_DBG if (verbose) printf("Reclaiming unconnected clusters.\n"); +#endif for (i = 2; i < fs->clusters+2; i++) fs->fat[i].prev = 0; for (i = 2; i < fs->clusters+2; i++) { next = fs->fat[i].value; @@ -324,26 +333,42 @@ if (!fs->fsinfo_start) return free; +#ifdef DOSFSCK_DBG if (verbose) printf("Checking free cluster summary.\n"); +#endif if (fs->free_clusters >= 0) { if (free != fs->free_clusters) { printf( "Free cluster summary wrong (%ld vs. really %ld)\n", fs->free_clusters,free); - if (interactive) - printf( "1) Correct\n2) Don't correct\n" ); - else printf( " Auto-correcting.\n" ); - if (!interactive || get_key("12","?") == '1') - do_set = 1; +//jack20050328+ +// if (interactive) +// printf( "1) Correct\n2) Don't correct\n" ); +// else printf( " Auto-correcting.\n" ); + if (!interactive) + { + printf( " Auto-correcting.\n" ); + do_set = 1; + } +// if (!interactive || get_key("12","?") == '1') +// do_set = 1; +//jack20050328 end } } else { printf( "Free cluster summary uninitialized (should be %ld)\n", free ); - if (interactive) - printf( "1) Set it\n2) Leave it uninitialized\n" ); - else printf( " Auto-setting.\n" ); - if (!interactive || get_key("12","?") == '1') - do_set = 1; +//jack20050328+ +// if (interactive) +// printf( "1) Set it\n2) Leave it uninitialized\n" ); +// else printf( " Auto-setting.\n" ); +// if (!interactive || get_key("12","?") == '1') +// do_set = 1; + if (!interactive) + { + printf( " Auto-setting.\n" ); + do_set = 1; + } +//jack20050328 end } if (do_set) { diff -Naru ori/dosfstools-2.10/dosfsck/file.c dosfstools-2.10/dosfsck/file.c --- ori/dosfstools-2.10/dosfsck/file.c 2003-06-14 23:03:20.000000000 +0300 +++ dosfstools-2.10/dosfsck/file.c 2005-09-24 09:39:52.000000000 +0300 @@ -117,7 +117,7 @@ return 1; } - +#ifdef DOSFSCK_DBG void file_add(char *path,FD_TYPE type) { FDSC **current,*walk; @@ -149,7 +149,7 @@ path = here+1; } } - +#endif FDSC **file_cd(FDSC **curr,char *fixed) { diff -Naru ori/dosfstools-2.10/dosfsck/io.c dosfstools-2.10/dosfsck/io.c --- ori/dosfstools-2.10/dosfsck/io.c 2003-06-14 23:03:20.000000000 +0300 +++ dosfstools-2.10/dosfsck/io.c 2005-06-02 11:31:54.000000000 +0300 @@ -42,11 +42,17 @@ /* Use the _llseek system call directly, because there (once?) was a bug in * the glibc implementation of it. */ #include -#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__ +//#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__ +#if 1 //+Bing modified for compiling 03102005 /* On alpha, the syscall is simply lseek, because it's a 64 bit system. */ static loff_t llseek( int fd, loff_t offset, int whence ) { + //loff_t status ; return lseek(fd, offset, whence); + //return lseek(fd, 0, SEEK_END ); + //status = lseek(fd, offset, whence); + //printf("status = %d\n",status); + //return status; } #else # ifndef __NR__llseek @@ -85,8 +91,7 @@ { CHANGE *walk; int got; - - if (llseek(fd,pos,0) != pos) pdie("Seek to %lld",pos); + if (llseek(fd,pos,0) != pos) pdie("fs_read Seek to. %lld",pos); if ((got = read(fd,data,size)) < 0) pdie("Read %d bytes at %lld",size,pos); if (got != size) die("Got %d bytes instead of %d at %lld",got,size,pos); for (walk = changes; walk; walk = walk->next) { @@ -105,8 +110,13 @@ { void *scratch; int okay; + + //printf("fs_test\n"); + + //if (llseek(fd,pos,0) != pos) pdie("Seek to %lld",pos); + if (lseek(fd,pos,0) != pos) + pdie("Seek to %lld",pos); - if (llseek(fd,pos,0) != pos) pdie("Seek to %lld",pos); scratch = alloc(size); okay = read(fd,scratch,size) == size; free(scratch); @@ -121,7 +131,7 @@ if (write_immed) { did_change = 1; - if (llseek(fd,pos,0) != pos) pdie("Seek to %lld",pos); + if (llseek(fd,pos,0) != pos) pdie("fs_write Seek to %lld",pos); if ((did = write(fd,data,size)) == size) return; if (did < 0) pdie("Write %d bytes at %lld",size,pos); die("Wrote %d bytes instead of %d at %lld",did,size,pos); @@ -165,6 +175,7 @@ int changed; changed = !!changes; + if (write) fs_flush(); else while (changes) { next = changes->next; @@ -173,12 +184,19 @@ changes = next; } if (close(fd) < 0) pdie("closing file system"); + + if( changed == 1) + printf("ERROR"); + else + printf("SUCCESS"); + return changed || did_change; } int fs_changed(void) { + printf("fs_changed %d \n", (!!changes || did_change)); return !!changes || did_change; } diff -Naru ori/dosfstools-2.10/dosfsck/lfn.c dosfstools-2.10/dosfsck/lfn.c --- ori/dosfstools-2.10/dosfsck/lfn.c 2003-01-21 23:51:47.000000000 +0200 +++ dosfstools-2.10/dosfsck/lfn.c 2005-04-27 09:39:21.000000000 +0300 @@ -149,10 +149,10 @@ { LFN_ENT *lfn = (LFN_ENT *)de; unsigned offset; - + if (de->attr != VFAT_LN_ATTR) die("lfn_add_slot called with non-LFN directory entry"); - + if (lfn->id & LFN_ID_START) { if (lfn_slot != -1) { int can_clear = 0; @@ -175,14 +175,19 @@ free( part2 ); can_clear = 1; } - if (interactive) { - printf( "1: Delete previous LFN\n2: Leave it as it is.\n" ); - if (can_clear) - printf( "3: Clear start bit and concatenate LFNs\n" ); - } - else printf( " Not auto-correcting this.\n" ); - if (interactive) { - switch( get_key( can_clear ? "123" : "12", "?" )) { +//jack20050328+ +// if (interactive) { +// printf( "1: Delete previous LFN\n2: Leave it as it is.\n" ); +// if (can_clear) +// printf( "3: Clear start bit and concatenate LFNs\n" ); +// } +// else printf( " Not auto-correcting this.\n" ); +// if (interactive) { +// switch( get_key( can_clear ? "123" : "12", "?" )) { + if (!interactive) { + printf("Clear start bit and concatenate LFNs\n"); + switch( can_clear ? '3' : '1') { +//jack20050328 end case '1': clear_lfn_slots( 0, lfn_parts-1 ); lfn_reset(); @@ -212,13 +217,18 @@ printf( "Long filename fragment \"%s\" found outside a LFN " "sequence.\n (Maybe the start bit is missing on the " "last fragment)\n", part ); - if (interactive) { - printf( "1: Delete fragment\n2: Leave it as it is.\n" - "3: Set start bit\n" ); - } - else printf( " Not auto-correcting this.\n" ); - if (interactive) { - switch( get_key( "123", "?" )) { +//jack20050328+ +// if (interactive) { +// printf( "1: Delete fragment\n2: Leave it as it is.\n" +// "3: Set start bit\n" ); +// } +// else printf( " Not auto-correcting this.\n" ); +// if (interactive) { +// switch( get_key( "123", "?" )) { + if (!interactive) { + printf("Fix to set start bit\n"); + switch('3') { +//jack20050328 end case '1': if (!lfn_offsets) lfn_offsets = alloc( sizeof(loff_t) ); @@ -261,14 +271,19 @@ free( part2 ); can_fix = 1; } - if (interactive) { - printf( "1: Delete LFN\n2: Leave it as it is (and ignore LFN so far)\n" ); - if (can_fix) - printf( "3: Correct sequence number\n" ); - } - else printf( " Not auto-correcting this.\n" ); - if (interactive) { - switch( get_key( can_fix ? "123" : "12", "?" )) { +//jack20050328+ +// if (interactive) { +// printf( "1: Delete LFN\n2: Leave it as it is (and ignore LFN so far)\n" ); +// if (can_fix) +// printf( "3: Correct sequence number\n" ); +// } +// else printf( " Not auto-correcting this.\n" ); +// if (interactive) { +// switch( get_key( can_fix ? "123" : "12", "?" )) { + if (!interactive) { + printf( "Fix correct sequence number\n" ); +//jack20050328 end + switch( can_fix ? '3' : '1') { case '1': lfn_offsets[lfn_parts++] = dir_offset; clear_lfn_slots( 0, lfn_parts-1 ); @@ -293,13 +308,17 @@ printf( "Checksum in long filename part wrong " "(%02x vs. expected %02x).\n", lfn->alias_checksum, lfn_checksum ); - if (interactive) { - printf( "1: Delete LFN\n2: Leave it as it is.\n" - "3: Correct checksum\n" ); - } - else printf( " Not auto-correcting this.\n" ); - if (interactive) { - switch( get_key( "123", "?" )) { +//jack20050328+ +// if (interactive) { +// printf( "1: Delete LFN\n2: Leave it as it is.\n" +// "3: Correct checksum\n" ); +// } +// else printf( " Not auto-correcting this.\n" ); +// if (interactive) { +// switch( get_key( "123", "?" )) { +//jack20050328 end + if (!interactive) { + switch('3'){ case '1': lfn_offsets[lfn_parts++] = dir_offset; clear_lfn_slots( 0, lfn_parts-1 ); @@ -326,22 +345,31 @@ if (lfn->reserved != 0) { printf( "Reserved field in VFAT long filename slot is not 0 " "(but 0x%02x).\n", lfn->reserved ); - if (interactive) - printf( "1: Fix.\n2: Leave it.\n" ); - else printf( "Auto-setting to 0.\n" ); - if (!interactive || get_key("12","?") == '1') { - lfn->reserved = 0; - fs_write( dir_offset+offsetof(LFN_ENT,reserved), - sizeof(lfn->reserved), &lfn->reserved ); - } +//jack20050328+ +// if (interactive) +// printf( "1: Fix.\n2: Leave it.\n" ); +// else printf( "Auto-setting to 0.\n" ); +// if (!interactive || get_key("12","?") == '1') { + if (!interactive) + { + printf( "Fix ,Auto-setting to 0.\n" ); + lfn->reserved = 0; + fs_write( dir_offset+offsetof(LFN_ENT,reserved), + sizeof(lfn->reserved), &lfn->reserved ); +//jack20050328 end + } } if (lfn->start != CT_LE_W(0)) { printf( "Start cluster field in VFAT long filename slot is not 0 " "(but 0x%04x).\n", lfn->start ); - if (interactive) - printf( "1: Fix.\n2: Leave it.\n" ); - else printf( "Auto-setting to 0.\n" ); - if (!interactive || get_key("12","?") == '1') { +//jack20050328+ +// if (interactive) +// printf( "1: Fix.\n2: Leave it.\n" ); +// else printf( "Auto-setting to 0.\n" ); +// if (!interactive || get_key("12","?") == '1') { + if (interactive){ + printf( "Fix Auto-setting to 0.\n" ); +//jack20050328 end lfn->start = CT_LE_W(0); fs_write( dir_offset+offsetof(LFN_ENT,start), sizeof(lfn->start),&lfn->start ); @@ -382,14 +410,19 @@ " (Start may have been overwritten by %s)\n", long_name, short_name ); free( long_name ); - if (interactive) { - printf( "1: Delete LFN\n2: Leave it as it is.\n" - "3: Fix numbering (truncates long name and attaches " - "it to short name %s)\n", short_name ); - } - else printf( " Not auto-correcting this.\n" ); - if (interactive) { - switch( get_key( "123", "?" )) { +//jack20050328+ +// if (interactive) { +// printf( "1: Delete LFN\n2: Leave it as it is.\n" +// "3: Fix numbering (truncates long name and attaches " +// "it to short name %s)\n", short_name ); +// } +// else printf( " Not auto-correcting this.\n" ); +// if (interactive) { +// switch( get_key( "123", "?" )) { + if (!interactive) { + printf( "3: Fix numbering (truncates long name and attaches it to short name %s)\n", short_name ); + switch('3') { +//jack20050328 end case '1': clear_lfn_slots( 0, lfn_parts-1 ); lfn_reset(); @@ -422,29 +455,31 @@ " (Short name %s may have changed without updating the long name)\n", long_name, short_name ); free( long_name ); - if (interactive) { - printf( "1: Delete LFN\n2: Leave it as it is.\n" - "3: Fix checksum (attaches to short name %s)\n", - short_name ); - } - else printf( " Not auto-correcting this.\n" ); - if (interactive) { - switch( get_key( "123", "?" )) { - case '1': - clear_lfn_slots( 0, lfn_parts-1 ); - lfn_reset(); - return NULL; - case '2': - lfn_reset(); - return NULL; - case '3': - for( i = 0; i < lfn_parts; ++i ) { - fs_write( lfn_offsets[i]+offsetof(LFN_ENT,alias_checksum), - sizeof(sum), &sum ); - } - break; - } - } +//jack2000328+ +// if (interactive) { +// printf( "1: Delete LFN\n2: Leave it as it is.\n" +// "3: Fix checksum (attaches to short name %s)\n", +// short_name ); +// } +// else printf( " Not auto-correcting this.\n" ); +// if (interactive) { +// switch( get_key( "123", "?" )) { +// case '1': +// clear_lfn_slots( 0, lfn_parts-1 ); +// lfn_reset(); +// return NULL; +// case '2': +// lfn_reset(); +// return NULL; +// case '3': +// for( i = 0; i < lfn_parts; ++i ) { +// fs_write( lfn_offsets[i]+offsetof(LFN_ENT,alias_checksum), +// sizeof(sum), &sum ); +// } +// break; +// } +// } +//jack20050328 end } lfn = cnv_unicode( lfn_unicode, UNTIL_0, 1 ); diff -Naru ori/dosfstools-2.10/mkdosfs/mkdosfs.c dosfstools-2.10/mkdosfs/mkdosfs.c --- ori/dosfstools-2.10/mkdosfs/mkdosfs.c 2003-06-14 23:07:08.000000000 +0300 +++ dosfstools-2.10/mkdosfs/mkdosfs.c 2005-09-24 09:39:52.000000000 +0300 @@ -66,7 +66,9 @@ #include #include -#if __BYTE_ORDER == __BIG_ENDIAN +//#define MKDOS_DBG 1 + +#if __BYTE_ORDER == __BIG_ENDIAN #include #ifdef __le16_to_cpu @@ -96,7 +98,8 @@ /* Use the _llseek system call directly, because there (once?) was a bug in * the glibc implementation of it. */ #include -#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__ +//#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__ +#if 1 //+Bing modified for compiling 03102005 /* On alpha, the syscall is simply lseek, because it's a 64 bit system. */ static loff_t llseek( int fd, loff_t offset, int whence ) { @@ -431,8 +434,10 @@ if (got < 0) got = 0; +#ifdef MKDOS_DBG if (got & (BLOCK_SIZE - 1)) printf ("Unexpected values in do_check: probably bugs\n"); +#endif got /= BLOCK_SIZE; return got; @@ -464,12 +469,13 @@ int try, got; int i; static char blkbuf[BLOCK_SIZE * TEST_BUFFER_BLOCKS]; - +#ifdef MKDOS_DBG if (verbose) { printf ("Searching for bad blocks "); fflush (stdout); } +#endif currently_testing = 0; if (verbose) { @@ -498,13 +504,14 @@ badblocks++; currently_testing++; } - +#ifdef MKDOS_DBG if (verbose) printf ("\n"); if (badblocks) printf ("%d bad block%s\n", badblocks, (badblocks > 1) ? "s" : ""); +#endif } @@ -528,9 +535,11 @@ } fclose (listfile); +#ifdef MKDOS_DBG if (badblocks) printf ("%d bad block%s\n", badblocks, (badblocks > 1) ? "s" : ""); +#endif } @@ -580,6 +589,7 @@ } close (fd); + //fprintf(stderr, "BLOCK_SIZE %d low %d \n", BLOCK_SIZE, low); return low / BLOCK_SIZE; } @@ -871,10 +881,11 @@ else { memcpy(bs.boot_jump, dummy_boot_jump_m68k, 2); } +#ifdef MKDOS_DBG if (verbose >= 2) printf( "Boot jump code is %02x %02x\n", bs.boot_jump[0], bs.boot_jump[1] ); - +#endif if (!reserved_sectors) reserved_sectors = (size_fat == 32) ? 32 : 1; else { @@ -882,8 +893,10 @@ die("On FAT32 at least 2 reserved sectors are needed."); } bs.reserved = CT_LE_W(reserved_sectors); +#ifdef MKDOS_DBG if (verbose >= 2) printf( "Using %d reserved sectors\n", reserved_sectors ); +#endif bs.fats = (char) nr_fats; if (!atari_format || size_fat == 32) bs.hidden = CT_LE_L(0); @@ -906,14 +919,16 @@ else /* An initial guess for bs.cluster_size should already be set */ maxclustsize = 128; - +#ifdef MKDOS_DBG if (verbose >= 2) printf( "%d sectors for FAT+data, starting with %d sectors/cluster\n", fatdata, bs.cluster_size ); +#endif do { +#ifdef MKDOS_DBG if (verbose >= 2) printf( "Trying with %d sectors/cluster:\n", bs.cluster_size ); - +#endif /* The factor 2 below avoids cut-off errors for nr_fats == 1. * The "nr_fats*3" is for the reserved first two FAT entries */ clust12 = 2*((long long) fatdata *sector_size + nr_fats*3) / @@ -926,13 +941,17 @@ maxclust12 = (fatlength12 * 2 * sector_size) / 3; if (maxclust12 > MAX_CLUST_12) maxclust12 = MAX_CLUST_12; +#ifdef MKDOS_DBG if (verbose >= 2) printf( "FAT12: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n", clust12, fatlength12, maxclust12, MAX_CLUST_12 ); +#endif if (clust12 > maxclust12-2) { clust12 = 0; +#ifdef MKDOS_DBG if (verbose >= 2) printf( "FAT12: too much clusters\n" ); +#endif } clust16 = ((long long) fatdata *sector_size + nr_fats*4) / @@ -945,21 +964,27 @@ maxclust16 = (fatlength16 * sector_size) / 2; if (maxclust16 > MAX_CLUST_16) maxclust16 = MAX_CLUST_16; +#ifdef MKDOS_DBG if (verbose >= 2) printf( "FAT16: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n", clust16, fatlength16, maxclust16, MAX_CLUST_16 ); +#endif if (clust16 > maxclust16-2) { +#ifdef MKDOS_DBG if (verbose >= 2) printf( "FAT16: too much clusters\n" ); +#endif clust16 = 0; } /* The < 4078 avoids that the filesystem will be misdetected as having a * 12 bit FAT. */ if (clust16 < FAT12_THRESHOLD && !(size_fat_by_user && size_fat == 16)) { +#ifdef MKDOS_DBG if (verbose >= 2) printf( clust16 < FAT12_THRESHOLD ? "FAT16: would be misdetected as FAT12\n" : "FAT16: too much clusters\n" ); +#endif clust16 = 0; } @@ -973,13 +998,17 @@ maxclust32 = (fatlength32 * sector_size) / 4; if (maxclust32 > MAX_CLUST_32) maxclust32 = MAX_CLUST_32; +#ifdef MKDOS_DBG if (verbose >= 2) printf( "FAT32: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n", clust32, fatlength32, maxclust32, MAX_CLUST_32 ); +#endif if (clust32 > maxclust32) { clust32 = 0; +#ifdef MKDOS_DBG if (verbose >= 2) printf( "FAT32: too much clusters\n" ); +#endif } if ((clust12 && (size_fat == 0 || size_fat == 12)) || @@ -994,8 +1023,10 @@ * FAT32 is (not yet) choosen automatically */ if (!size_fat) { size_fat = (clust16 > clust12) ? 16 : 12; +#ifdef MKDOS_DBG if (verbose >= 2) printf( "Choosing %d bits for FAT\n", size_fat ); +#endif } switch (size_fat) { @@ -1054,9 +1085,10 @@ if (!size_fat) size_fat = (num_sectors == 1440 || num_sectors == 2400 || num_sectors == 2880 || num_sectors == 5760) ? 12 : 16; +#ifdef MKDOS_DBG if (verbose >= 2) printf( "Choosing %d bits for FAT\n", size_fat ); - +#endif /* Atari format: cluster size should be 2, except explicitly requested by * the user, since GEMDOS doesn't like other cluster sizes very much. * Instead, tune the sector size for the FS to fit. @@ -1068,10 +1100,11 @@ sector_size <<= 1; } } +#ifdef MKDOS_DBG if (verbose >= 2) printf( "Sector size must be %d to have less than %d log. sectors\n", sector_size, GEMDOS_MAX_SECTORS ); - +#endif /* Check if there are enough FAT indices for how much clusters we have */ do { fatdata = num_sectors - cdiv (root_dir_entries * 32, sector_size) - @@ -1088,19 +1121,21 @@ * not really present cluster. */ clusters = (fatdata - nr_fats*fat_length)/bs.cluster_size; maxclust = (fat_length*sector_size*8)/size_fat; +#ifdef MKDOS_DBG if (verbose >= 2) printf( "ss=%d: #clu=%d, fat_len=%d, maxclu=%d\n", sector_size, clusters, fat_length, maxclust ); - +#endif /* last 10 cluster numbers are special (except FAT32: 4 high bits rsvd); * first two numbers are reserved */ if (maxclust <= (size_fat == 32 ? MAX_CLUST_32 : (1<= 2) printf( clusters > maxclust-2 ? "Too many clusters\n" : "FAT too big\n" ); - +#endif /* need to increment sector_size once more to */ if (sector_size_set) die( "With this sector size, the maximum number of FAT entries " @@ -1142,9 +1177,11 @@ else if (backup_boot >= reserved_sectors) die("Backup boot sector must be a reserved sector"); } +#ifdef MKDOS_DBG if (verbose >= 2) printf( "Using sector %d as backup boot sector (0 = none)\n", backup_boot ); +#endif bs.fat32.backup_boot = CT_LE_W(backup_boot); memset( &bs.fat32.reserved2, 0, sizeof(bs.fat32.reserved2) ); } @@ -1153,9 +1190,11 @@ /* Just some consistency checks */ if (num_sectors >= GEMDOS_MAX_SECTORS) die( "GEMDOS can't handle more than 65531 sectors" ); +#ifdef MKDOS_DBG else if (num_sectors >= OLDGEMDOS_MAX_SECTORS) printf( "Warning: More than 32765 sector need TOS 1.04 " "or higher.\n" ); +#endif } if (num_sectors >= 65536) { @@ -1191,7 +1230,7 @@ if (blocks < start_data_block + 32) /* Arbitrary undersize file system! */ die ("Too few blocks for viable file system"); - +#ifdef MKDOS_DBG if (verbose) { printf("%s has %d head%s and %d sector%s per track,\n", @@ -1218,9 +1257,10 @@ } /* Make the file allocation tables! */ - + printf("fat %ld , fat_length =%d sector_size = %d \n", (fat_length * sector_size), fat_length, sector_size); +#endif if ((fat = (unsigned char *) malloc (fat_length * sector_size)) == NULL) - die ("unable to allocate space for FAT image in memory"); + die ("1. unable to allocate space for FAT image in memory"); memset( fat, 0, fat_length * sector_size ); @@ -1241,7 +1281,7 @@ if ((root_dir = (struct msdos_dir_entry *) malloc (size_root_dir)) == NULL) { free (fat); /* Tidy up before we die! */ - die ("unable to allocate space for root directory in memory"); + die ("2. unable to allocate space for root directory in memory"); } memset(root_dir, 0, size_root_dir); @@ -1369,12 +1409,16 @@ void usage (void) { +#ifdef MKDOS_DBG fatal_error("\ Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] [-b backup-boot-sector]\n\ [-m boot-msg-file] [-n volume-name] [-i volume-id]\n\ [-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs]\n\ [-F fat-size] [-r root-dir-entries] [-R reserved-sectors]\n\ /dev/name [blocks]\n"); +#else + fatal_error("\n"); +#endif } /* @@ -1405,6 +1449,18 @@ #endif } +void touch_file(int status, void *arg) +{ + printf("exit status %d \n", status); + if(status != 0) + system("touch /tmp/format_error"); + else + { + printf("success \n"); + system("touch /tmp/format_result"); +} +} + /* The "main" entry point into the utility - we pick up the options and attempt to process them in some sort of sensible way. In the event that some/all of the options are invalid we need to tell the user so that something can be done! */ @@ -1419,6 +1475,7 @@ int i = 0, pos, ch; int create = 0; + on_exit(touch_file, (void *) NULL); //+Bing modified 06092005 if (argc && *argv) { /* What's the program name? */ char *p; program_name = *argv; @@ -1442,12 +1499,14 @@ break; case 'b': /* b : location of backup boot sector */ +#ifdef MKDOS_DBG backup_boot = (int) strtol (optarg, &tmp, 0); if (*tmp || backup_boot < 2 || backup_boot > 0xffff) { printf ("Bad location for backup boot sector : %s\n", optarg); usage (); } +#endif break; case 'c': /* c : Check FS as we build it */ @@ -1482,19 +1541,24 @@ break; case 'i': /* i : specify volume ID */ +#ifdef MKDOS_DBG volume_id = strtol(optarg, &tmp, 16); if ( *tmp ) { printf("Volume ID must be a hexadecimal number\n"); usage(); } +#endif break; case 'l': /* l : Bad block filename */ +#ifdef MKDOS_DBG listfile = optarg; +#endif break; case 'm': /* m : Set boot message */ +#ifdef MKDOS_DBG if ( strcmp(optarg, "-") ) { msgfile = fopen(optarg, "r"); @@ -1559,31 +1623,39 @@ if ( msgfile != stdin ) fclose(msgfile); } +#endif break; case 'n': /* n : Volume name */ +#ifdef MKDOS_DBG sprintf(volume_name, "%-11.11s", optarg); +#endif break; case 'r': /* r : Root directory entries */ +#ifdef MKDOS_DBG root_dir_entries = (int) strtol (optarg, &tmp, 0); if (*tmp || root_dir_entries < 16 || root_dir_entries > 32768) - { - printf ("Bad number of root directory entries : %s\n", optarg); + { + printf ("Bad number of root directory entries : %s\n", optarg); usage (); } +#endif break; case 'R': /* R : number of reserved sectors */ +#ifdef MKDOS_DBG reserved_sectors = (int) strtol (optarg, &tmp, 0); if (*tmp || reserved_sectors < 1 || reserved_sectors > 0xffff) { - printf ("Bad number of reserved sectors : %s\n", optarg); + printf ("Bad number of reserved sectors : %s\n", optarg); usage (); } +#endif break; case 's': /* s : Sectors per cluster */ +#ifdef MKDOS_DBG sectors_per_cluster = (int) strtol (optarg, &tmp, 0); if (*tmp || (sectors_per_cluster != 1 && sectors_per_cluster != 2 && sectors_per_cluster != 4 && sectors_per_cluster != 8 @@ -1593,9 +1665,11 @@ printf ("Bad number of sectors per cluster : %s\n", optarg); usage (); } +#endif break; case 'S': /* S : Sector size */ +#ifdef MKDOS_DBG sector_size = (int) strtol (optarg, &tmp, 0); if (*tmp || (sector_size != 512 && sector_size != 1024 && sector_size != 2048 && sector_size != 4096 && @@ -1606,14 +1680,19 @@ usage (); } sector_size_set = 1; +#endif break; case 'v': /* v : Verbose execution */ +#ifdef MKDOS_DBG ++verbose; +#endif break; default: +#ifdef MKDOS_DBG printf( "Unknown option: %c\n", c ); +#endif usage (); } if (optind < argc) @@ -1625,11 +1704,13 @@ if (optind == argc - 2) /* Either check the user specified number */ { blocks = (int) strtol (argv[optind + 1], &tmp, 0); +#if 0 //+Bing modified 05042005 if (!create && blocks != i) { fprintf (stderr, "Warning: block count mismatch: "); fprintf (stderr, "found %d but assuming %d.\n",i,blocks); } +#endif } else if (optind == argc - 1) /* Or use value found */ { @@ -1645,7 +1726,9 @@ } if (*tmp) { +#ifdef MKDOS_DBG printf ("Bad block count : %s\n", argv[optind + 1]); +#endif usage (); }