Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fuse: support FSCONFIG_SET_FD for "fd" option

This is not only cleaner to use in userspace (no need to sprintf the fd to
a string) but also allows userspace to detect that the devfd can be closed
after the fsconfig call.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

+11 -7
+11 -7
fs/fuse/inode.c
··· 791 791 792 792 static const struct fs_parameter_spec fuse_fs_parameters[] = { 793 793 fsparam_string ("source", OPT_SOURCE), 794 - fsparam_u32 ("fd", OPT_FD), 794 + fsparam_fd ("fd", OPT_FD), 795 795 fsparam_u32oct ("rootmode", OPT_ROOTMODE), 796 796 fsparam_uid ("user_id", OPT_USER_ID), 797 797 fsparam_gid ("group_id", OPT_GROUP_ID), ··· 803 803 {} 804 804 }; 805 805 806 - static int fuse_opt_fd(struct fs_context *fsc, int fd) 806 + static int fuse_opt_fd(struct fs_context *fsc, struct file *file) 807 807 { 808 808 struct fuse_fs_context *ctx = fsc->fs_private; 809 - struct file *file __free(fput) = fget(fd); 810 - 811 - if (!file) 812 - return -EBADF; 813 809 814 810 if (file->f_op != &fuse_dev_operations) 815 811 return invalfc(fsc, "fd is not a fuse device"); ··· 861 865 return 0; 862 866 863 867 case OPT_FD: 864 - return fuse_opt_fd(fsc, result.uint_32); 868 + if (param->type == fs_value_is_file) { 869 + return fuse_opt_fd(fsc, param->file); 870 + } else { 871 + struct file *file __free(fput) = fget(result.uint_32); 872 + if (!file) 873 + return -EBADF; 874 + 875 + return fuse_opt_fd(fsc, file); 876 + } 865 877 866 878 case OPT_ROOTMODE: 867 879 if (!fuse_valid_type(result.uint_32))