Skip to content

Commit 68ea02b

Browse files
committed
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 <[email protected]>
1 parent ea2c8e6 commit 68ea02b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cmds/subvolume-list.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ static int resolve_root(struct rb_root *rl, struct root_info *ri,
769769
*/
770770
static int lookup_ino_path(int fd, struct root_info *ri)
771771
{
772-
struct btrfs_ioctl_ino_lookup_args args;
772+
struct btrfs_ioctl_ino_lookup_user_args args;
773773
int ret;
774774

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

781781
memset(&args, 0, sizeof(args));
782782
args.treeid = ri->ref_tree;
783-
args.objectid = ri->dir_id;
783+
args.dirid = ri->dir_id;
784784

785-
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
785+
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP_USER, &args);
786786
if (ret < 0) {
787787
if (errno == ENOENT) {
788788
ri->ref_tree = 0;
@@ -792,6 +792,12 @@ static int lookup_ino_path(int fd, struct root_info *ri)
792792
return ret;
793793
}
794794

795+
ri->path = malloc(strlen(args.name) + strlen(args.path) + 1);
796+
if (!ri->path) {
797+
error_msg(ERROR_MSG_MEMORY, NULL);
798+
exit(1);
799+
}
800+
795801
if (args.name[0]) {
796802
/*
797803
* we're in a subdirectory of ref_tree, the kernel ioctl

0 commit comments

Comments
 (0)