public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: "mail@bernhard-voelker.de" <mail@bernhard-voelker.de>
To: Karel Zak <kzak@redhat.com>
Cc: Simon de Vlieger <simon@ikanobori.jp>,
	"util-linux@vger.kernel.org" <util-linux@vger.kernel.org>
Subject: Re: [PATCH] hexdump: adjust -s and -n option in the man page [was: hexsyntax.c using strtol on the offset parameter]
Date: Mon, 26 Mar 2012 11:39:46 +0200 (CEST)	[thread overview]
Message-ID: <1961842217.201279.1332754786305.JavaMail.open-xchange@email.1und1.de> (raw)
In-Reply-To: <20120323171936.GH2040@x2.net.home>

[-- Attachment #1: Type: text/plain, Size: 720 bytes --]

 On March 26, 2012 at 10:42 AM Karel Zak <kzak@redhat.com> wrote:

> Hi Berny,
> 
> > On Mon, Mar 26, 2012 at 09:20:26AM +0200, mail@bernhard-voelker.de
wrote:
> > I have derived my patch proposal from the info pages of coreutils, as
there
> > has recently been a discussion about the clearest wording.
> > I don't think all users are aware what's the difference between
> > "binary (2^N) suffixes KiB" and "decimal (10^N) suffixes KB".
> 
> hmm, good point, send patch that fix the problem in all the man pages.
> 
> > BTW: why omitting the Z and the Y suffix in the man page?
> Send patch ;-)

Attached:

* [PATCH 1/2] wipefs: use strtosize() for -o
* [PATCH 2/2] docs: clarify KiB vs. KB in man pages

Have fun,
Berny

[-- Attachment #2: strtosize-man.patch --]
[-- Type: application/octet-stream, Size: 7547 bytes --]

From f61110adcceaecee78c78f40f02504b5c2aacb56 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <mail@bernhard-voelker.de>
Date: Mon, 26 Mar 2012 11:23:12 +0200
Subject: [PATCH 1/2] wipefs: use strtosize() for -o

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
---
 misc-utils/wipefs.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c
index 74de3a3..3681fee 100644
--- a/misc-utils/wipefs.c
+++ b/misc-utils/wipefs.c
@@ -385,6 +385,7 @@ main(int argc, char **argv)
 {
 	struct wipe_desc *wp0 = NULL, *wp;
 	int c, all = 0, has_offset = 0, noact = 0, mode = 0, quiet = 0;
+	uintmax_t offset;
 
 	static const struct option longopts[] = {
 	    { "all",       0, 0, 'a' },
@@ -413,8 +414,11 @@ main(int argc, char **argv)
 		case 'n':
 			noact++;
 			break;
-		case 'o':
-			wp0 = add_offset(wp0, strtoll_offset(optarg), 1);
+		case 'o': {
+			if (strtosize(optarg, &offset)
+				errx(EXIT_FAILURE,
+				     _("invalid offset '%s' specified"), optarg);
+			wp0 = add_offset(wp0, offset, 1);
 			has_offset++;
 			break;
 		case 'p':
-- 
1.7.9


From f5956cee4c7e6d57a0fe00af2937617d698adbd9 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <mail@bernhard-voelker.de>
Date: Mon, 26 Mar 2012 11:30:16 +0200
Subject: [PATCH 2/2] docs: clarify KiB vs. KB in man pages

Update the man pages of blkid, wipefs, fallocate, fstrim, losetup
and hexdump to clarify the suffixes for the numerical values of the
offset and size/length arguments regarding KiB=1024 vs KB=1000.
Also mention the ZiB/YiB and ZB/YB suffixes supported by strtosize().

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
---
 misc-utils/blkid.8    |    7 ++++---
 misc-utils/wipefs.8   |    7 ++++---
 sys-utils/fallocate.1 |    7 ++++---
 sys-utils/fstrim.8    |    7 ++++---
 sys-utils/losetup.8   |    7 ++++---
 text-utils/hexdump.1  |    7 ++++---
 6 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/misc-utils/blkid.8 b/misc-utils/blkid.8
index c8a3121..80363ac 100644
--- a/misc-utils/blkid.8
+++ b/misc-utils/blkid.8
@@ -69,9 +69,10 @@ has two main forms of operation: either searching for a device with a
 specific NAME=value pair, or displaying NAME=value pairs for one or
 more specified devices.
 .SH OPTIONS
-The \fIsize\fR and \fIoffset\fR arguments may be followed by binary (2^N) 
-suffixes KiB, MiB, GiB, TiB, PiB and EiB (the "iB" is optional, e.g. "K" has the
-same meaning as "KiB") or decimal (10^N) suffixes KB, MB, GB, PB and EB.
+The \fIsize\fR and \fIoffset\fR arguments may be followed by the multiplicative
+suffixes KiB=1024, MiB=1024*1024, and so on for GiB, TiB, PiB, EiB, ZiB and YiB
+(the "iB" is optional, e.g. "K" has the same meaning as "KiB") or the suffixes 
+KB=1000, MB=1000*1000, and so on for GB, PB, EB, ZB and YB.
 .TP
 .BI \-c " cachefile"
 Read from
diff --git a/misc-utils/wipefs.8 b/misc-utils/wipefs.8
index cee8ef7..85d9576 100644
--- a/misc-utils/wipefs.8
+++ b/misc-utils/wipefs.8
@@ -47,9 +47,10 @@ Specify the location (in bytes) of the signature which should be erased from the
 device.  The \fIoffset\fR number may include a "0x" prefix; then the number will be
 interpreted as a hex value.  It is possible to specify multiple \fB-o\fR options.
 
-The \fIoffset\fR argument may be followed by binary (2^N) suffixes KiB, MiB,
-GiB, TiB, PiB and EiB (the "iB" is optional, e.g. "K" has the same meaning as
-"KiB") or decimal (10^N) suffixes KB, MB, GB, PB and EB.
+The \fIoffset\fR argument may be followed by the multiplicative
+suffixes KiB=1024, MiB=1024*1024, and so on for GiB, TiB, PiB, EiB, ZiB and YiB
+(the "iB" is optional, e.g. "K" has the same meaning as "KiB") or the suffixes 
+KB=1000, MB=1000*1000, and so on for GB, PB, EB, ZB and YB.
 .IP "\fB\-p, \-\-parsable\fP"
 Print out in parsable instead of printable format.  Encode all potentially unsafe
 characters of a string to the corresponding hex value prefixed by '\\x'.
diff --git a/sys-utils/fallocate.1 b/sys-utils/fallocate.1
index 653ebfb..a6eae8f 100644
--- a/sys-utils/fallocate.1
+++ b/sys-utils/fallocate.1
@@ -26,9 +26,10 @@ The exit code returned by
 is 0 on success and 1 on failure.
 .PP
 .SH OPTIONS
-The \fIlength\fR and \fIoffset\fR arguments may be followed by binary (2^N)
-suffixes KiB, MiB, GiB, TiB, PiB and EiB (the "iB" is optional, e.g. "K" has the
-same meaning as "KiB") or decimal (10^N) suffixes KB, MB, GB, PB and EB.
+The \fIlength\fR and \fIoffset\fR arguments may be followed by the multiplicative
+suffixes KiB=1024, MiB=1024*1024, and so on for GiB, TiB, PiB, EiB, ZiB and YiB
+(the "iB" is optional, e.g. "K" has the same meaning as "KiB") or the suffixes 
+KB=1000, MB=1000*1000, and so on for GB, PB, EB, ZB and YB.
 .IP "\fB\-n, \-\-keep-size\fP"
 Do not modify the apparent length of the file.  This may effectively allocate
 blocks past EOF, which can be removed with a truncate.
diff --git a/sys-utils/fstrim.8 b/sys-utils/fstrim.8
index 18b5eaf..a235703 100644
--- a/sys-utils/fstrim.8
+++ b/sys-utils/fstrim.8
@@ -31,9 +31,10 @@ is mounted.
 
 .SH OPTIONS
 The \fIoffset\fR, \fIlength\fR, and \fIminimum-free-extent\fR arguments may be
-followed by binary (2^N) suffixes KiB, MiB, GiB, TiB, PiB and EiB (the "iB" is
-optional, e.g. "K" has the same meaning as "KiB") or decimal (10^N) suffixes
-KB, MB, GB, PB and EB.
+followed by the multiplicative suffixes KiB=1024, MiB=1024*1024, and so on for
+GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g. "K" has the same
+meaning as "KiB") or the suffixes KB=1000, MB=1000*1000, and so on for GB, PB,
+EB, ZB and YB.
 .IP "\fB\-h, \-\-help\fP"
 Print help and exit.
 .IP "\fB\-o, \-\-offset\fP \fIoffset\fP"
diff --git a/sys-utils/losetup.8 b/sys-utils/losetup.8
index f50b072..fd16cff 100644
--- a/sys-utils/losetup.8
+++ b/sys-utils/losetup.8
@@ -69,9 +69,10 @@ to detach loop devices and to query the status of a loop device. If only the
 device is shown.
 
 .SH OPTIONS
-The \fIsize\fR and \fIoffset\fR arguments may be followed by binary (2^N)
-suffixes KiB, MiB, GiB, TiB, PiB and EiB (the "iB" is optional, e.g. "K" has the
-same meaning as "KiB") or decimal (10^N) suffixes KB, MB, GB, PB and EB.
++The \fIsize\fR and \fIoffset\fR arguments may be followed by the multiplicative
++suffixes KiB=1024, MiB=1024*1024, and so on for GiB, TiB, PiB, EiB, ZiB and YiB
++(the "iB" is optional, e.g. "K" has the same meaning as "KiB") or the suffixes 
++KB=1000, MB=1000*1000, and so on for GB, PB, EB, ZB and YB.
 
 .IP "\fB\-a, \-\-all\fP"
 show status of all loop devices. Note that not all information are accessible
diff --git a/text-utils/hexdump.1 b/text-utils/hexdump.1
index 0b3a525..84ecaf4 100644
--- a/text-utils/hexdump.1
+++ b/text-utils/hexdump.1
@@ -44,9 +44,10 @@ utility is a filter which displays the specified files, or
 standard input if no files are specified, in a user-specified
 format.
 .SH OPTIONS
-The \fIlength\fR and \fIoffset\fR arguments may be followed by binary (2^N)
-suffixes KiB, MiB, GiB, TiB, PiB and EiB (the "iB" is optional, e.g. "K" has the
-same meaning as "KiB") or decimal (10^N) suffixes KB, MB, GB, PB and EB.
+The \fIlength\fR and \fIoffset\fR arguments may be followed by the multiplicative
+suffixes KiB=1024, MiB=1024*1024, and so on for GiB, TiB, PiB, EiB, ZiB and YiB
+(the "iB" is optional, e.g. "K" has the same meaning as "KiB") or the suffixes
+KB=1000, MB=1000*1000, and so on for GB, PB, EB, ZB and YB.
 .TP
 .B \-b
 \fIOne-byte octal display\fR.  Display the input offset in hexadecimal,
-- 
1.7.9


  parent reply	other threads:[~2012-03-26  9:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-22 11:58 [PATCH] hexdump: adjust -s and -n option in the man page [was: hexsyntax.c using strtol on the offset parameter] Bernhard Voelker
2012-03-23 17:19 ` Karel Zak
2012-03-26  7:20   ` mail
2012-03-26  8:41     ` Karel Zak
2012-03-26  9:39   ` mail [this message]
2012-03-26  9:50     ` mail
2012-03-30 13:34       ` Karel Zak
2012-03-30 13:26     ` Karel Zak

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=1961842217.201279.1332754786305.JavaMail.open-xchange@email.1und1.de \
    --to=mail@bernhard-voelker.de \
    --cc=kzak@redhat.com \
    --cc=simon@ikanobori.jp \
    --cc=util-linux@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