]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
wipefs: support suffixes for --offset
authorKarel Zak <kzak@redhat.com>
Tue, 30 Mar 2010 12:05:58 +0000 (14:05 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 30 Mar 2010 12:45:29 +0000 (14:45 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/Makefile.am
misc-utils/wipefs.8
misc-utils/wipefs.c

index c41947868fe543841b9db45716da2b8c6b4648f7..b5b7daa64c5c2679ec5199fe72fd0b49aa93b0a0 100644 (file)
@@ -40,6 +40,7 @@ blkid_LDADD = $(ul_libblkid_la)
 blkid_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir)
 findfs_LDADD = $(ul_libblkid_la)
 findfs_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir)
+wipefs_SOURCES = wipefs.c ../lib/strtosize.c
 wipefs_LDADD = $(ul_libblkid_la)
 wipefs_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir)
 if HAVE_STATIC_BLKID
index 109c0a6b4d1938dd69a645ad67048e988dcb8dd2..973f2ef2240a973ed68f9a9ae8861485e21ef382 100644 (file)
@@ -31,6 +31,10 @@ Causes everything to be done except for the write() call.
 Specifies location (in bytes) of the signature which should be erased from the
 device. The offset number may include a "0x" prefix, and then the number will be
 read as a hex value. It is possible to specify multiple -o 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.
 .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'.
index 489105e49f4368cc4675dc43d48cc9ab16df148e..7cee1e5142a24e849b839818cd4b492a745933fb 100644 (file)
@@ -34,6 +34,7 @@
 #include <blkid.h>
 
 #include "nls.h"
+#include "strtosize.h"
 
 struct wipe_desc {
        loff_t          offset;         /* magic string offset */
@@ -305,22 +306,14 @@ do_wipe(struct wipe_desc *wp, const char *fname, int noact)
 static loff_t
 strtoll_offset(const char *str)
 {
-       char *end = NULL;
-       loff_t off;
+       uintmax_t sz;
 
-       errno = 0;
-       off = strtoll(str, &end, 0);
-
-       if ((errno == ERANGE && (off == LLONG_MAX || off == LONG_MIN)) ||
-           (errno != 0 && off == 0))
-               err(EXIT_FAILURE, _("invalid offset '%s' value specified"), str);
-
-       if (*end != '\0')
+       if (strtosize(str, &sz))
                errx(EXIT_FAILURE, _("invalid offset '%s' value specified"), str);
-
-       return off;
+       return sz;
 }
 
+
 static void __attribute__((__noreturn__))
 usage(FILE *out)
 {