summaryrefslogtreecommitdiffstats
path: root/mount/lomount.c
diff options
context:
space:
mode:
authorKarel Zak2010-03-30 14:40:33 +0200
committerKarel Zak2010-03-30 15:09:41 +0200
commitca1e1363e773202b5739e264e83703da8600ab0b (patch)
tree3b81ea3f6f4c5254062ae69f885656cb04a29485 /mount/lomount.c
parentfallocate: support suffixes for --offset and --lenght (diff)
downloadkernel-qcow2-util-linux-ca1e1363e773202b5739e264e83703da8600ab0b.tar.gz
kernel-qcow2-util-linux-ca1e1363e773202b5739e264e83703da8600ab0b.tar.xz
kernel-qcow2-util-linux-ca1e1363e773202b5739e264e83703da8600ab0b.zip
losetup: support suffixes and hex numbers for --offset and --sizelimit
Reported-By: Liu Aleaxander <aleaxander@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount/lomount.c')
-rw-r--r--mount/lomount.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/mount/lomount.c b/mount/lomount.c
index 67712c610..6130be1dd 100644
--- a/mount/lomount.c
+++ b/mount/lomount.c
@@ -881,6 +881,8 @@ find_unused_loop_device (void) {
#include <getopt.h>
#include <stdarg.h>
+#include "strtosize.h"
+
static void
usage(void) {
fprintf(stderr, _("\nUsage:\n"
@@ -913,7 +915,7 @@ main(int argc, char **argv) {
int showdev = 0;
int ro = 0;
int pfd = -1;
- unsigned long long off, slimit;
+ uintmax_t off = 0, slimit = 0;
struct option longopts[] = {
{ "all", 0, 0, 'a' },
{ "set-capacity", 0, 0, 'c' },
@@ -936,8 +938,6 @@ main(int argc, char **argv) {
textdomain(PACKAGE);
capacity = delete = find = all = 0;
- off = 0;
- slimit = 0;
assoc = offset = sizelimit = encryption = passfd = NULL;
progname = argv[0];
@@ -1015,11 +1015,15 @@ main(int argc, char **argv) {
usage();
}
- if (offset && sscanf(offset, "%llu", &off) != 1)
+ if (offset && strtosize(offset, &off)) {
+ error(_("%s: invalid offset '%s' specified"), progname, offset);
usage();
-
- if (sizelimit && sscanf(sizelimit, "%llu", &slimit) != 1)
+ }
+ if (sizelimit && strtosize(sizelimit, &slimit)) {
+ error(_("%s: invalid sizelimit '%s' specified"),
+ progname, sizelimit);
usage();
+ }
if (all)
return show_used_loop_devices();