btrfs-progs: add the error message when open fails
authorTsutomu Itoh <t-itoh@jp.fujitsu.com>
Thu, 9 Jun 2016 01:23:15 +0000 (10:23 +0900)
committerDavid Sterba <dsterba@suse.com>
Wed, 13 Jul 2016 16:44:52 +0000 (18:44 +0200)
When open in btrfs_open_devices failed, only the following message is
displayed. Therefore the user doesn't understand the reason why open
failed.

  # btrfs check /dev/sdb8
  Couldn't open file system

This patch adds the error message when open fails.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
volumes.c

index ccfa732..b42a412 100644 (file)
--- a/volumes.c
+++ b/volumes.c
@@ -227,6 +227,8 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int flags)
                fd = open(device->name, flags);
                if (fd < 0) {
                        ret = -errno;
+                       error("cannot open device '%s': %s", device->name,
+                                       strerror(errno));
                        goto fail;
                }