diff options
author | Karel Zak | 2010-03-30 14:05:58 +0200 |
---|---|---|
committer | Karel Zak | 2010-03-30 14:45:29 +0200 |
commit | 69cc2ec06158d7849e6ae8c95f944f044e7b380d (patch) | |
tree | 61d3baa962d109d333897f640fc61986364dc3c7 /misc-utils/wipefs.c | |
parent | blkid: support suffixes for -O <offset> and -S <size> (diff) | |
download | kernel-qcow2-util-linux-69cc2ec06158d7849e6ae8c95f944f044e7b380d.tar.gz kernel-qcow2-util-linux-69cc2ec06158d7849e6ae8c95f944f044e7b380d.tar.xz kernel-qcow2-util-linux-69cc2ec06158d7849e6ae8c95f944f044e7b380d.zip |
wipefs: support suffixes for --offset
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/wipefs.c')
-rw-r--r-- | misc-utils/wipefs.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c index 489105e49..7cee1e514 100644 --- a/misc-utils/wipefs.c +++ b/misc-utils/wipefs.c @@ -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) { |