From: Hugo Mills <hugo@carfax.org.uk>
To: linux-btrfs@vger.kernel.org
Cc: Hugo Mills <hugo@carfax.org.uk>
Subject: [patch v2 4/4] Add an option to show ISO, binary or raw bytes counts using btrfs-show.
Date: Thu, 21 Oct 2010 20:01:39 +0100 [thread overview]
Message-ID: <20101021190203.471102162@carfax.org.uk> (raw)
In-Reply-To: 20101021190135.757086134@carfax.org.uk
Change btrfs-show to allow the user to control the scales used for
sizes in the output.
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
---
btrfs-show.c | 27 +++++++++++++++++++--------
man/btrfs-show.8.in | 10 ++++++++--
2 files changed, 27 insertions(+), 10 deletions(-)
Index: btrfs-progs-unstable/btrfs-show.c
===================================================================
--- btrfs-progs-unstable.orig/btrfs-show.c 2010-10-20 19:48:33.000000000 +0100
+++ btrfs-progs-unstable/btrfs-show.c 2010-10-20 20:18:11.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_RAW);
+ 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_RAW);
- bytes_used = pretty_sizes(device->bytes_used, PRETTY_SIZE_RAW);
+ 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,13 +98,18 @@
static void print_usage(void)
{
- fprintf(stderr, "usage: btrfs-show [search label or device]\n");
+ fprintf(stderr, "usage: btrfs-show [options] [search label or device]\n");
+ fprintf(stderr, "Options:\n");
+ fprintf(stderr, "\t-h, --human-readable\tShow sizes in powers of 2^10.\n");
+ fprintf(stderr, "\t-s, --si\t\tShow sizes in powers of 10^3 (SI multiples).\n");
fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
exit(1);
}
static struct option long_options[] = {
/* { "byte-count", 1, NULL, 'b' }, */
+ { "human-readable", 0, NULL, 'h' },
+ { "si", 0, NULL, 'H' },
{ 0, 0, 0, 0}
};
@@ -117,14 +121,21 @@
char *search = NULL;
int ret;
int option_index = 0;
+ int format = PRETTY_SIZE_RAW;
while(1) {
int c;
- c = getopt_long(ac, av, "", long_options,
+ c = getopt_long(ac, av, "hH", long_options,
&option_index);
if (c < 0)
break;
switch(c) {
+ case 'H':
+ format = PRETTY_SIZE_ISO;
+ break;
+ case 'h':
+ format = PRETTY_SIZE_BINARY;
+ break;
default:
print_usage();
}
@@ -144,7 +155,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;
Index: btrfs-progs-unstable/man/btrfs-show.8.in
===================================================================
--- btrfs-progs-unstable.orig/man/btrfs-show.8.in 2010-10-20 20:15:29.000000000 +0100
+++ btrfs-progs-unstable/man/btrfs-show.8.in 2010-10-20 20:17:30.000000000 +0100
@@ -2,13 +2,19 @@
.SH NAME
btrfs-show \- scan the /dev directory for btrfs partitions and print results.
.SH SYNOPSIS
-.B btrfs-show
+.B btrfs-show [options]
.SH DESCRIPTION
.B btrfs-show
is used to scan the /dev directory for btrfs partitions and display brief
information such as lable, uuid, etc of each btrfs partition.
.SH OPTIONS
-none
+.TP
+\fB\-h\fR, \fB\-\-human\-readable\fR
+Show values in multiples of 2^10.
+.TP
+\fB\-H\fR, \fB\-\-si\fR
+Show values in multiples of 10^3 (SI multiples).
+
.SH AVAILABILITY
.B btrfs-show
is part of btrfs-progs. Btrfs is currently under heavy development,
--
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
--- I spent most of my money on drink, women and fast cars. The ---
rest I wasted. -- James Hunt
prev parent reply other threads:[~2010-10-21 19:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-21 19:01 [patch v2 0/4] Size reporting in userspace tools Hugo Mills
2010-10-21 19:01 ` [patch v2 1/4] Update pretty-printer for different systems of counting multiples Hugo Mills
2010-10-21 19:01 ` [patch v2 2/4] Add an option to show ISO, binary or raw bytes counts using df Hugo Mills
2010-10-22 7:55 ` Goffredo Baroncelli
2010-10-21 19:01 ` [patch v2 3/4] Add an option to show ISO, binary or raw bytes counts using show Hugo Mills
2010-10-22 7:57 ` Goffredo Baroncelli
2010-10-21 19:01 ` Hugo Mills [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101021190203.471102162@carfax.org.uk \
--to=hugo@carfax.org.uk \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox