Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KzLfh-0004iu-Lv for qemu-devel@nongnu.org; Sun, 09 Nov 2008 20:34:29 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KzLfg-0004if-OL for qemu-devel@nongnu.org; Sun, 09 Nov 2008 20:34:28 -0500 Received: from [199.232.76.173] (port=55378 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KzLfg-0004ic-IO for qemu-devel@nongnu.org; Sun, 09 Nov 2008 20:34:28 -0500 Received: from savannah.gnu.org ([199.232.41.3]:35371 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KzLfg-0003tz-E4 for qemu-devel@nongnu.org; Sun, 09 Nov 2008 20:34:28 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KzLff-0005Y4-Pj for qemu-devel@nongnu.org; Mon, 10 Nov 2008 01:34:27 +0000 Received: from balrog by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KzLff-0005Y0-IT for qemu-devel@nongnu.org; Mon, 10 Nov 2008 01:34:27 +0000 MIME-Version: 1.0 Errors-To: balrog Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Andrzej Zaborowski Message-Id: Date: Mon, 10 Nov 2008 01:34:27 +0000 Subject: [Qemu-devel] [5665] Currently trying to turn an oversized directory into a VVFAT image will Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5665 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5665 Author: balrog Date: 2008-11-10 01:34:27 +0000 (Mon, 10 Nov 2008) Log Message: ----------- 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/ Modified Paths: -------------- trunk/block-vvfat.c Modified: trunk/block-vvfat.c =================================================================== --- trunk/block-vvfat.c 2008-11-10 01:05:01 UTC (rev 5664) +++ trunk/block-vvfat.c 2008-11-10 01:34:27 UTC (rev 5665) @@ -890,7 +890,6 @@ 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 @@ 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);