summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-06-06 02:17:13 +0200
committerDavid Sterba <dsterba@suse.cz>2015-06-08 17:50:46 +0200
commit1bcedaae799d117957e36f8ffddc0d9d84274c2d (patch)
tree0db3fc17d8b0a27b1cb9787a0359c08e34e45c3a
parent49ac5f50b5d466c92be25c83aa354c64c1f00ca3 (diff)
btrfs-progs: mkfs: do not try to register non-block-devices
A mkfs on a regular file will try to call the DEV_SCAN ioctl that will take the loop through the kernel and fail: ERROR: device scan failed './test.img' - Block device required If a user without permission to open the control device tries to mkfs a regular file, an error message is printed: failed to open /dev/btrfs-control skipping device registration: Permission denied So we should not try to pass a non-block-device besides that this makes the --quiet option more quiet. Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--mkfs.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/mkfs.c b/mkfs.c
index 08257657..c069d369 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1482,7 +1482,8 @@ int main(int ac, char **av)
trans = btrfs_start_transaction(root, 1);
- btrfs_register_one_device(file);
+ if (is_block_device(file))
+ btrfs_register_one_device(file);
if (dev_cnt == 0)
goto raid_groups;
@@ -1531,7 +1532,8 @@ int main(int ac, char **av)
(unsigned long long)device->devid);
}
- btrfs_register_one_device(file);
+ if (is_block_device(file))
+ btrfs_register_one_device(file);
}
raid_groups: