Skip to content

Commit

Permalink
btrfs-progs: subvolume-list: use user ino lookup
Browse files Browse the repository at this point in the history
The user ioctl works in all cases, so don't limit subvolume list to root
by using the root-only ioctl. Subvolume list itself still uses the
root-only tree search ioctl, but this is a step toward making subvolume
list user-capable.

Signed-off-by: Sweet Tea Dorminy <[email protected]>
  • Loading branch information
sweettea committed Mar 21, 2024
1 parent ea2c8e6 commit 0cc8c32
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmds/subvolume-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ static int resolve_root(struct rb_root *rl, struct root_info *ri,
*/
static int lookup_ino_path(int fd, struct root_info *ri)
{
struct btrfs_ioctl_ino_lookup_args args;
struct btrfs_ioctl_ino_lookup_user_args args;
int ret;

if (ri->path)
Expand All @@ -780,9 +780,9 @@ static int lookup_ino_path(int fd, struct root_info *ri)

memset(&args, 0, sizeof(args));
args.treeid = ri->ref_tree;
args.objectid = ri->dir_id;
args.dirid = ri->dir_id;

ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP_USER, &args);
if (ret < 0) {
if (errno == ENOENT) {
ri->ref_tree = 0;
Expand All @@ -792,6 +792,8 @@ static int lookup_ino_path(int fd, struct root_info *ri)
return ret;
}

strcpy(ri->name, args.name);

if (args.name[0]) {
/*
* we're in a subdirectory of ref_tree, the kernel ioctl
Expand Down

0 comments on commit 0cc8c32

Please sign in to comment.