Commit 8ce0f8699347bb4beab1cbdb4245907d21cc26ea
1 parent
59795a1f
Currently trying to turn an oversized directory into a VVFAT image will
result in a cryptic error (and an abort): qemu: block-vvfat.c:97: array_get: Assertion `index < array->next' failed. Aborted Turn this into an actually useful error message: Directory does not fit in FAT16 (capacity 504MB) qemu: could not open disk image fat:$DIR/ git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5665 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
13 additions
and
9 deletions
block-vvfat.c
| ... | ... | @@ -890,7 +890,6 @@ static int init_directories(BDRVVVFATState* s, |
| 890 | 890 | s->path = mapping->path; |
| 891 | 891 | |
| 892 | 892 | for (i = 0, cluster = 0; i < s->mapping.next; i++) { |
| 893 | - int j; | |
| 894 | 893 | /* MS-DOS expects the FAT to be 0 for the root directory |
| 895 | 894 | * (except for the media byte). */ |
| 896 | 895 | /* LATER TODO: still true for FAT32? */ |
| ... | ... | @@ -923,20 +922,25 @@ static int init_directories(BDRVVVFATState* s, |
| 923 | 922 | |
| 924 | 923 | assert(mapping->begin < mapping->end); |
| 925 | 924 | |
| 925 | + /* next free cluster */ | |
| 926 | + cluster = mapping->end; | |
| 927 | + | |
| 928 | + if(cluster > s->cluster_count) { | |
| 929 | + fprintf(stderr,"Directory does not fit in FAT%d (capacity %s)\n", | |
| 930 | + s->fat_type, | |
| 931 | + s->fat_type == 12 ? s->sector_count == 2880 ? "1.44 MB" | |
| 932 | + : "2.88 MB" | |
| 933 | + : "504MB"); | |
| 934 | + return -EINVAL; | |
| 935 | + } | |
| 936 | + | |
| 926 | 937 | /* fix fat for entry */ |
| 927 | 938 | if (fix_fat) { |
| 939 | + int j; | |
| 928 | 940 | for(j = mapping->begin; j < mapping->end - 1; j++) |
| 929 | 941 | fat_set(s, j, j+1); |
| 930 | 942 | fat_set(s, mapping->end - 1, s->max_fat_value); |
| 931 | 943 | } |
| 932 | - | |
| 933 | - /* next free cluster */ | |
| 934 | - cluster = mapping->end; | |
| 935 | - | |
| 936 | - if(cluster > s->cluster_count) { | |
| 937 | - fprintf(stderr,"Directory does not fit in FAT%d\n",s->fat_type); | |
| 938 | - return -1; | |
| 939 | - } | |
| 940 | 944 | } |
| 941 | 945 | |
| 942 | 946 | mapping = array_get(&(s->mapping), 0); | ... | ... |