mirror of
https://github.com/kdave/btrfs-progs
synced 2025-03-06 18:58:01 +00:00
btrfs-progs: move lookup_path_rootid to library utils
The refactoring in commit1c85c3de5a
has broken use of libbtrfs that does not exhibit during build but at the run time. Fixes:1c85c3de5a
Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=600078 Reported-by: Mike Gilbert <floppymaster@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
f8278f94ff
commit
e5362f5feb
30
utils-lib.c
30
utils-lib.c
@ -2,9 +2,13 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <ioctl.h>
|
||||||
|
|
||||||
#if BTRFS_FLAT_INCLUDES
|
#if BTRFS_FLAT_INCLUDES
|
||||||
|
#include "ctree.h"
|
||||||
#else
|
#else
|
||||||
|
#include <btrfs/ctree.h>
|
||||||
#endif /* BTRFS_FLAT_INCLUDES */
|
#endif /* BTRFS_FLAT_INCLUDES */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -38,3 +42,29 @@ u64 arg_strtou64(const char *str)
|
|||||||
}
|
}
|
||||||
return value;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
25
utils.c
25
utils.c
@ -3646,31 +3646,6 @@ int ask_user(const char *question)
|
|||||||
(!strcasecmp(answer, "yes") || !strcasecmp(answer, "y"));
|
(!strcasecmp(answer, "yes") || !strcasecmp(answer, "y"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 0 if a btrfs mount point is found
|
||||||
* return 1 if a mount point is found but not btrfs
|
* return 1 if a mount point is found but not btrfs
|
||||||
|
Loading…
Reference in New Issue
Block a user