btrfs-progs: handle errors from test_isdir
authorDavid Sterba <dsterba@suse.com>
Wed, 13 Jan 2016 17:04:22 +0000 (18:04 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 14 Jan 2016 10:07:09 +0000 (11:07 +0100)
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-subvolume.c

index 26af0a7..6ff41e2 100644 (file)
@@ -158,6 +158,10 @@ static int cmd_subvol_create(int argc, char **argv)
 
        retval = 1;     /* failure */
        res = test_isdir(dst);
+       if (res < 0 && res != -ENOENT) {
+               error("cannot access %s: %s", dst, strerror(-res));
+               goto out;
+       }
        if (res >= 0) {
                error("target path already exists: %s", dst);
                goto out;
@@ -684,6 +688,10 @@ static int cmd_subvol_snapshot(int argc, char **argv)
        }
 
        res = test_isdir(dst);
+       if (res < 0 && res != -ENOENT) {
+               error("cannot access %s: %s", dst, strerror(-res));
+               goto out;
+       }
        if (res == 0) {
                error("'%s' exists and it is not a directory", dst);
                goto out;