summaryrefslogtreecommitdiff
path: root/btrfs-select-super.c
diff options
context:
space:
mode:
Diffstat (limited to 'btrfs-select-super.c')
-rw-r--r--btrfs-select-super.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/btrfs-select-super.c b/btrfs-select-super.c
index 6a458b8..15e6921 100644
--- a/btrfs-select-super.c
+++ b/btrfs-select-super.c
@@ -43,7 +43,7 @@ int main(int ac, char **av)
{
struct btrfs_root *root;
int ret;
- int num = 0;
+ u64 num = 0;
u64 bytenr = 0;
while(1) {
@@ -53,8 +53,14 @@ int main(int ac, char **av)
break;
switch(c) {
case 's':
- num = atol(optarg);
- bytenr = btrfs_sb_offset(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));
break;
default:
print_usage();