From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LvCac-0003yh-BK for qemu-devel@nongnu.org; Sat, 18 Apr 2009 11:36:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LvCab-0003y2-Gy for qemu-devel@nongnu.org; Sat, 18 Apr 2009 11:36:21 -0400 Received: from [199.232.76.173] (port=45682 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LvCab-0003xn-6S for qemu-devel@nongnu.org; Sat, 18 Apr 2009 11:36:21 -0400 Received: from savannah.gnu.org ([199.232.41.3]:40169 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 1LvCaa-0005Fg-Le for qemu-devel@nongnu.org; Sat, 18 Apr 2009 11:36:20 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LvCaa-0006k9-3r for qemu-devel@nongnu.org; Sat, 18 Apr 2009 15:36:20 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LvCaZ-0006k5-Tc for qemu-devel@nongnu.org; Sat, 18 Apr 2009 15:36:20 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Sat, 18 Apr 2009 15:36:19 +0000 Subject: [Qemu-devel] [7181] qemu-io: Fix handling of bdrv_is_allocated() return value ( Kevin Wolf) 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: 7181 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7181 Author: aliguori Date: 2009-04-18 15:36:19 +0000 (Sat, 18 Apr 2009) Log Message: ----------- qemu-io: Fix handling of bdrv_is_allocated() return value (Kevin Wolf) bdrv_is_allocated() returns a boolean which indicates if the offset is allocated, not 0 on success and everything else is an error. Signed-off-by: Kevin Wolf Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/qemu-io.c Modified: trunk/qemu-io.c =================================================================== --- trunk/qemu-io.c 2009-04-18 15:36:15 UTC (rev 7180) +++ trunk/qemu-io.c 2009-04-18 15:36:19 UTC (rev 7181) @@ -794,6 +794,7 @@ char s1[64]; int num; int ret; + const char *retstr; offset = cvtnum(argv[1]); if (offset & 0x1ff) { @@ -808,18 +809,15 @@ nb_sectors = 1; ret = bdrv_is_allocated(bs, offset >> 9, nb_sectors, &num); - if (ret) { - printf("is_allocated: %s", strerror(ret)); - return 0; - } cvtstr(offset, s1, sizeof(s1)); + retstr = ret ? "allocated" : "not allocated"; if (nb_sectors == 1) - printf("sector allocated at offset %s\n", s1); + printf("sector %s at offset %s\n", retstr, s1); else - printf("%d/%d sectors allocated at offset %s\n", - num, nb_sectors, s1); + printf("%d/%d sectors %s at offset %s\n", + num, nb_sectors, retstr, s1); return 0; }