diff options
author | balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-11-10 01:34:27 +0000 |
---|---|---|
committer | balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-11-10 01:34:27 +0000 |
commit | 8ce0f8699347bb4beab1cbdb4245907d21cc26ea (patch) | |
tree | 5fb7b39e2e98095445efe65d6c72693799abedcc /block-vvfat.c | |
parent | 59795a1f92ed81b63612edd41323792e81d2af7a (diff) | |
download | qemu-8ce0f8699347bb4beab1cbdb4245907d21cc26ea.zip qemu-8ce0f8699347bb4beab1cbdb4245907d21cc26ea.tar.gz qemu-8ce0f8699347bb4beab1cbdb4245907d21cc26ea.tar.bz2 |
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
Diffstat (limited to 'block-vvfat.c')
-rw-r--r-- | block-vvfat.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/block-vvfat.c b/block-vvfat.c index 9e2841a..5fcf746 100644 --- a/block-vvfat.c +++ b/block-vvfat.c @@ -890,7 +890,6 @@ static int init_directories(BDRVVVFATState* s, s->path = mapping->path; for (i = 0, cluster = 0; i < s->mapping.next; i++) { - int j; /* MS-DOS expects the FAT to be 0 for the root directory * (except for the media byte). */ /* LATER TODO: still true for FAT32? */ @@ -923,20 +922,25 @@ static int init_directories(BDRVVVFATState* s, assert(mapping->begin < mapping->end); + /* next free cluster */ + cluster = mapping->end; + + if(cluster > s->cluster_count) { + fprintf(stderr,"Directory does not fit in FAT%d (capacity %s)\n", + s->fat_type, + s->fat_type == 12 ? s->sector_count == 2880 ? "1.44 MB" + : "2.88 MB" + : "504MB"); + return -EINVAL; + } + /* fix fat for entry */ if (fix_fat) { + int j; for(j = mapping->begin; j < mapping->end - 1; j++) fat_set(s, j, j+1); fat_set(s, mapping->end - 1, s->max_fat_value); } - - /* next free cluster */ - cluster = mapping->end; - - if(cluster > s->cluster_count) { - fprintf(stderr,"Directory does not fit in FAT%d\n",s->fat_type); - return -1; - } } mapping = array_get(&(s->mapping), 0); |