btrfs-progs: move test_issubvolume() to utils.c
authorAnand Jain <anand.jain@oracle.com>
Mon, 21 Mar 2016 07:21:01 +0000 (15:21 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 30 Mar 2016 14:25:13 +0000 (16:25 +0200)
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-subvolume.c
utils.c
utils.h

index 3953d7c..f62ab95 100644 (file)
@@ -224,33 +224,6 @@ out:
        return retval;
 }
 
-/*
- * 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(const char *path)
-{
-       struct stat     st;
-       struct statfs stfs;
-       int             res;
-
-       res = stat(path, &st);
-       if (res < 0)
-               return -errno;
-
-       if (st.st_ino != BTRFS_FIRST_FREE_OBJECTID || !S_ISDIR(st.st_mode))
-               return 0;
-
-       res = statfs(path, &stfs);
-       if (res < 0)
-               return -errno;
-
-       return (int)stfs.f_type == BTRFS_SUPER_MAGIC;
-}
-
 static int wait_for_commit(int fd)
 {
        int ret;
diff --git a/utils.c b/utils.c
index 09962f8..6dea54f 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -3151,3 +3151,30 @@ int test_issubvolname(const char *name)
        return name[0] != '\0' && !strchr(name, '/') &&
                strcmp(name, ".") && strcmp(name, "..");
 }
+
+/*
+ * 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(const char *path)
+{
+       struct stat     st;
+       struct statfs stfs;
+       int             res;
+
+       res = stat(path, &st);
+       if (res < 0)
+               return -errno;
+
+       if (st.st_ino != BTRFS_FIRST_FREE_OBJECTID || !S_ISDIR(st.st_mode))
+               return 0;
+
+       res = statfs(path, &stfs);
+       if (res < 0)
+               return -errno;
+
+       return (int)stfs.f_type == BTRFS_SUPER_MAGIC;
+}
diff --git a/utils.h b/utils.h
index a4e55bf..32bb020 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -194,6 +194,7 @@ const char* group_profile_str(u64 flags);
 
 int test_minimum_size(const char *file, u32 leafsize);
 int test_issubvolname(const char *name);
+int test_issubvolume(const char *path);
 int test_isdir(const char *path);
 
 /*