summaryrefslogtreecommitdiff
path: root/cmds-subvolume.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-01-13 17:45:39 +0100
committerDavid Sterba <dsterba@suse.com>2016-01-14 11:07:10 +0100
commit7afde59e38e78fa7c99d0b0d36718645c6a77c91 (patch)
tree5e2c095b356a1505a3bab1345d27ebdcd103abab /cmds-subvolume.c
parent33ac47b5fb0b7202ac32b6ab018a5212b790c4f1 (diff)
btrfs-progs: let test_issubvolume return the exact error
Return any error from stat, minor cleanups. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-subvolume.c')
-rw-r--r--cmds-subvolume.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index d4ef1021..9866c775 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -223,20 +223,20 @@ out:
}
/*
- * test if path is a subvolume:
- * this function return
- * 0-> path exists but it is not a subvolume
- * 1-> path exists and it is a subvolume
- * -1 -> path is unaccessible
+ * Test if path is a subvolume
+ * Returns:
+ * 0 - path exists but it is not a subvolume
+ * 1 - path exists and it is a subvolume
+ * < 0 - error
*/
-int test_issubvolume(char *path)
+int test_issubvolume(const char *path)
{
struct stat st;
int res;
res = stat(path, &st);
- if(res < 0 )
- return -1;
+ if (res < 0)
+ return -errno;
return (st.st_ino == BTRFS_FIRST_FREE_OBJECTID)
&& S_ISDIR(st.st_mode);