Changeset 1961

Show
Ignore:
Timestamp:
02/28/09 17:34:21 (3 years ago)
Author:
mwhitworth
Message:

Add checks for when a user specifies a FAT size that cannot be satisfied.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Whitix/tags/0.2b/user/makefs/fat/main.c

    r1955 r1961  
    319319                        numClusts32 = 0; 
    320320                } 
     321                 
     322                if (numClusts32 < 65526) 
     323                { 
     324                        if (verbose) 
     325                                printf("FAT32: too few clusters\n"); 
     326                                 
     327                        numClusts32 = 0; 
     328                } 
    321329 
    322330                if (numClusts12 || numClusts16 || numClusts32) 
     
    326334        }while (secsPerClus && secsPerClus <= 128); 
    327335 
    328         if (!fatSize) 
    329         { 
    330                 fatSize=(numClusts16 > numClusts12) ? 16 : 12; 
    331                  
    332                 if (numClusts32 > numClusts16) 
    333                         fatSize = 32; 
    334  
    335                 if (verbose) 
    336                         printf("Chose FAT%d\n",fatSize); 
     336        switch (fatSize) 
     337        { 
     338                case 12: 
     339                        break; 
     340                 
     341                case 16: 
     342                        break; 
     343                 
     344                case 32: 
     345                        if (numClusts32 == 0) 
     346                        { 
     347                                printf("mkfatfs: error: FAT32 filesystem would be misdetected as FAT12 or FAT16\n"); 
     348                                return 1; 
     349                        } 
     350                        break; 
     351                         
     352                case 0: 
     353                        fatSize=(numClusts16 > numClusts12) ? 16 : 12; 
     354                 
     355                        if (numClusts32 > numClusts16) 
     356                                fatSize = 32; 
     357 
     358                        if (verbose) 
     359                                printf("Chose FAT%d\n",fatSize); 
    337360        } 
    338361