wipefs: support suffixes for --offset
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
8ab912cfa6
commit
69cc2ec061
|
@ -40,6 +40,7 @@ blkid_LDADD = $(ul_libblkid_la)
|
||||||
blkid_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir)
|
blkid_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir)
|
||||||
findfs_LDADD = $(ul_libblkid_la)
|
findfs_LDADD = $(ul_libblkid_la)
|
||||||
findfs_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir)
|
findfs_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir)
|
||||||
|
wipefs_SOURCES = wipefs.c ../lib/strtosize.c
|
||||||
wipefs_LDADD = $(ul_libblkid_la)
|
wipefs_LDADD = $(ul_libblkid_la)
|
||||||
wipefs_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir)
|
wipefs_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir)
|
||||||
if HAVE_STATIC_BLKID
|
if HAVE_STATIC_BLKID
|
||||||
|
|
|
@ -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
|
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
|
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.
|
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"
|
.IP "\fB\-p, \-\-parsable\fP"
|
||||||
Print out in parsable instead of printable format. Encode all potentially unsafe
|
Print out in parsable instead of printable format. Encode all potentially unsafe
|
||||||
characters of a string to the corresponding hex value prefixed by '\\x'.
|
characters of a string to the corresponding hex value prefixed by '\\x'.
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <blkid.h>
|
#include <blkid.h>
|
||||||
|
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
|
#include "strtosize.h"
|
||||||
|
|
||||||
struct wipe_desc {
|
struct wipe_desc {
|
||||||
loff_t offset; /* magic string offset */
|
loff_t offset; /* magic string offset */
|
||||||
|
@ -305,22 +306,14 @@ do_wipe(struct wipe_desc *wp, const char *fname, int noact)
|
||||||
static loff_t
|
static loff_t
|
||||||
strtoll_offset(const char *str)
|
strtoll_offset(const char *str)
|
||||||
{
|
{
|
||||||
char *end = NULL;
|
uintmax_t sz;
|
||||||
loff_t off;
|
|
||||||
|
|
||||||
errno = 0;
|
if (strtosize(str, &sz))
|
||||||
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')
|
|
||||||
errx(EXIT_FAILURE, _("invalid offset '%s' value specified"), str);
|
errx(EXIT_FAILURE, _("invalid offset '%s' value specified"), str);
|
||||||
|
return sz;
|
||||||
return off;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void __attribute__((__noreturn__))
|
static void __attribute__((__noreturn__))
|
||||||
usage(FILE *out)
|
usage(FILE *out)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue