summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils-lib.c30
-rw-r--r--utils.c25
2 files changed, 30 insertions, 25 deletions
diff --git a/utils-lib.c b/utils-lib.c
index 79ef35e3..044f93fc 100644
--- a/utils-lib.c
+++ b/utils-lib.c
@@ -2,9 +2,13 @@
#include <unistd.h>
#include <stdlib.h>
#include <limits.h>
+#include <sys/ioctl.h>
+#include <ioctl.h>
#if BTRFS_FLAT_INCLUDES
+#include "ctree.h"
#else
+#include <btrfs/ctree.h>
#endif /* BTRFS_FLAT_INCLUDES */
/*
@@ -38,3 +42,29 @@ u64 arg_strtou64(const char *str)
}
return value;
}
+
+/*
+ * For a given:
+ * - file or directory return the containing tree root id
+ * - subvolume return its own tree id
+ * - BTRFS_EMPTY_SUBVOL_DIR_OBJECTID (directory with ino == 2) the result is
+ * undefined and function returns -1
+ */
+int lookup_path_rootid(int fd, u64 *rootid)
+{
+ struct btrfs_ioctl_ino_lookup_args args;
+ int ret;
+
+ memset(&args, 0, sizeof(args));
+ args.treeid = 0;
+ args.objectid = BTRFS_FIRST_FREE_OBJECTID;
+
+ ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
+ if (ret < 0)
+ return -errno;
+
+ *rootid = args.treeid;
+
+ return 0;
+}
+
diff --git a/utils.c b/utils.c
index c883f38a..69b580ad 100644
--- a/utils.c
+++ b/utils.c
@@ -3647,31 +3647,6 @@ int ask_user(const char *question)
}
/*
- * For a given:
- * - file or directory return the containing tree root id
- * - subvolume return its own tree id
- * - BTRFS_EMPTY_SUBVOL_DIR_OBJECTID (directory with ino == 2) the result is
- * undefined and function returns -1
- */
-int lookup_path_rootid(int fd, u64 *rootid)
-{
- struct btrfs_ioctl_ino_lookup_args args;
- int ret;
-
- memset(&args, 0, sizeof(args));
- args.treeid = 0;
- args.objectid = BTRFS_FIRST_FREE_OBJECTID;
-
- ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
- if (ret < 0)
- return -errno;
-
- *rootid = args.treeid;
-
- return 0;
-}
-
-/*
* return 0 if a btrfs mount point is found
* return 1 if a mount point is found but not btrfs
* return <0 if something goes wrong