btrfs-progs: subvolume-list: use user ino lookup

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 <sweettea-kernel@dorminy.me>
This commit is contained in:
Sweet Tea Dorminy 2024-03-21 15:17:31 -04:00
parent ea2c8e61a1
commit 0cc8c32045
1 changed files with 5 additions and 3 deletions

View File

@ -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) 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; int ret;
if (ri->path) if (ri->path)
@ -780,9 +780,9 @@ static int lookup_ino_path(int fd, struct root_info *ri)
memset(&args, 0, sizeof(args)); memset(&args, 0, sizeof(args));
args.treeid = ri->ref_tree; 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 (ret < 0) {
if (errno == ENOENT) { if (errno == ENOENT) {
ri->ref_tree = 0; ri->ref_tree = 0;
@ -792,6 +792,8 @@ static int lookup_ino_path(int fd, struct root_info *ri)
return ret; return ret;
} }
strcpy(ri->name, args.name);
if (args.name[0]) { if (args.name[0]) {
/* /*
* we're in a subdirectory of ref_tree, the kernel ioctl * we're in a subdirectory of ref_tree, the kernel ioctl