diff options
author | Wang Shilong <wangsl.fnst@cn.fujitsu.com> | 2014-02-20 09:30:52 +0800 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-03-21 06:23:20 -0700 |
commit | 64fddab8ac0ad7970cf713cfecba5ab6ae90b09c (patch) | |
tree | 2687a0eb2c5810bfafe6314e0e9718f6e3d37e56 /cmds-check.c | |
parent | 86da12ff869823f4dae20488f3bedeae4a55086d (diff) |
Btrfs-progs: switch to arg_strtou64() part3
Switch to new helper arg_strtou64(), also check if user assign
a valid super copy.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'cmds-check.c')
-rw-r--r-- | cmds-check.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/cmds-check.c b/cmds-check.c index 61c1815a..a2afae6b 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -6388,7 +6388,7 @@ int cmd_check(int argc, char **argv) u64 bytenr = 0; char uuidbuf[BTRFS_UUID_UNPARSED_SIZE]; int ret; - int num; + u64 num; int option_index = 0; int init_csum_tree = 0; int init_extent_tree = 0; @@ -6407,9 +6407,15 @@ int cmd_check(int argc, char **argv) ctree_flags |= OPEN_CTREE_BACKUP_ROOT; break; case 's': - num = atol(optarg); - bytenr = btrfs_sb_offset(num); - printf("using SB copy %d, bytenr %llu\n", num, + num = arg_strtou64(optarg); + if (num >= BTRFS_SUPER_MIRROR_MAX) { + fprintf(stderr, + "ERROR: super mirror should be less than: %d\n", + BTRFS_SUPER_MIRROR_MAX); + exit(1); + } + bytenr = btrfs_sb_offset(((int)num)); + printf("using SB copy %llu, bytenr %llu\n", num, (unsigned long long)bytenr); break; case '?': |