From patchwork Sun Oct 17 18:26:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hugo-lkml@carfax.org.uk X-Patchwork-Id: 260381 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9HIRKnd024312 for ; Sun, 17 Oct 2010 18:27:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932493Ab0JQS1R (ORCPT ); Sun, 17 Oct 2010 14:27:17 -0400 Received: from frost.carfax.org.uk ([212.13.194.111]:2220 "EHLO frost.carfax.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932392Ab0JQS1P (ORCPT ); Sun, 17 Oct 2010 14:27:15 -0400 Received: from intmx.carfax.org.uk ([10.0.0.5] helo=vlad.carfax.org.uk ident=Debian-exim) by frost.carfax.org.uk with esmtp (Exim 4.69) (envelope-from ) id 1P7Xww-0001oD-DZ for linux-btrfs@vger.kernel.org; Sun, 17 Oct 2010 18:27:14 +0000 Received: from hrm by vlad.carfax.org.uk with local (Exim 4.69) (envelope-from ) id 1P7Xww-0003DZ-36; Sun, 17 Oct 2010 19:27:14 +0100 Message-Id: <20101017182706.891779663@carfax.org.uk> User-Agent: quilt/0.48-1 Date: Sun, 17 Oct 2010 19:26:47 +0100 From: hugo-lkml@carfax.org.uk To: linux-btrfs@vger.kernel.org Cc: Hugo Mills Subject: [patch 4/4] Add an option to show ISO, binary or raw bytes counts using btrfs-show. References: <20101017182643.297900488@carfax.org.uk> Content-Disposition: inline; filename=btrfs-show-numbers X-frost.carfax.org.uk-Spam-Score: -0.0 (/) X-frost.carfax.org.uk-Spam-Report: Spam detection software, running on the system "spamd0.lon.bitfolk.com", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Change btrfs-show to allow the user to control the scales used for sizes in the output. Signed-off-by: Hugo Mills --- btrfs-show.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) [...] Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sun, 17 Oct 2010 18:27:21 +0000 (UTC) Index: btrfs-progs-unstable/btrfs-show.c =================================================================== --- btrfs-progs-unstable.orig/btrfs-show.c 2010-10-17 19:00:34.000000000 +0100 +++ btrfs-progs-unstable/btrfs-show.c 2010-10-17 19:12:50.000000000 +0100 @@ -52,7 +52,7 @@ return 0; } -static void print_one_uuid(struct btrfs_fs_devices *fs_devices) +static void print_one_uuid(struct btrfs_fs_devices *fs_devices, int format) { char uuidbuf[37]; struct list_head *cur; @@ -69,8 +69,7 @@ else printf("Label: none "); - super_bytes_used = pretty_sizes(device->super_bytes_used, - PRETTY_SIZE_BINARY); + super_bytes_used = pretty_sizes(device->super_bytes_used, format); total = device->total_devs; printf(" uuid: %s\n\tTotal devices %llu FS bytes used %s\n", uuidbuf, @@ -82,8 +81,8 @@ char *total_bytes; char *bytes_used; device = list_entry(cur, struct btrfs_device, dev_list); - total_bytes = pretty_sizes(device->total_bytes, PRETTY_SIZE_BINARY); - bytes_used = pretty_sizes(device->bytes_used, PRETTY_SIZE_BINARY); + total_bytes = pretty_sizes(device->total_bytes, format); + bytes_used = pretty_sizes(device->bytes_used, format); printf("\tdevid %4llu size %s used %s path %s\n", (unsigned long long)device->devid, total_bytes, bytes_used, device->name); @@ -99,7 +98,8 @@ static void print_usage(void) { - fprintf(stderr, "usage: btrfs-show [search label or device]\n"); + fprintf(stderr, "usage: btrfs-show [-i|-b|-r] [search label or device]\n"); + fprintf(stderr, "Options:\n -i, -b, -r: Show sizes in ISO, binary or raw form respectively.\n"); fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION); exit(1); } @@ -117,6 +117,7 @@ char *search = NULL; int ret; int option_index = 0; + int format = PRETTY_SIZE_BINARY; while(1) { int c; @@ -125,6 +126,15 @@ if (c < 0) break; switch(c) { + case 'i': + format = PRETTY_SIZE_ISO; + break; + case 'b': + format = PRETTY_SIZE_BINARY; + break; + case 'r': + format = PRETTY_SIZE_RAW; + break; default: print_usage(); } @@ -144,7 +154,7 @@ list); if (search && uuid_search(fs_devices, search) == 0) continue; - print_one_uuid(fs_devices); + print_one_uuid(fs_devices, format); } printf("%s\n", BTRFS_BUILD_VERSION); return 0;