diff options
| author | Miklos Szeredi <mszeredi@redhat.com> | 2026-03-12 22:30:08 +0300 |
|---|---|---|
| committer | Miklos Szeredi <mszeredi@redhat.com> | 2026-04-02 21:53:00 +0300 |
| commit | 2339f9cc9f080eff40432c0343d358ead39a4988 (patch) | |
| tree | de099b8fe04eaeb3144cf61bc79428fd7e2bd49a | |
| parent | 4ae404afd92e36be378eb120a2dc13031cdac7a6 (diff) | |
| download | linux-2339f9cc9f080eff40432c0343d358ead39a4988.tar.xz | |
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>
| -rw-r--r-- | fs/fuse/inode.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index ffe068b13a1e..702a1c619d36 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -791,7 +791,7 @@ enum { static const struct fs_parameter_spec fuse_fs_parameters[] = { fsparam_string ("source", OPT_SOURCE), - fsparam_u32 ("fd", OPT_FD), + fsparam_fd ("fd", OPT_FD), fsparam_u32oct ("rootmode", OPT_ROOTMODE), fsparam_uid ("user_id", OPT_USER_ID), fsparam_gid ("group_id", OPT_GROUP_ID), @@ -803,13 +803,9 @@ static const struct fs_parameter_spec fuse_fs_parameters[] = { {} }; -static int fuse_opt_fd(struct fs_context *fsc, int fd) +static int fuse_opt_fd(struct fs_context *fsc, struct file *file) { struct fuse_fs_context *ctx = fsc->fs_private; - struct file *file __free(fput) = fget(fd); - - if (!file) - return -EBADF; if (file->f_op != &fuse_dev_operations) return invalfc(fsc, "fd is not a fuse device"); @@ -865,7 +861,15 @@ static int fuse_parse_param(struct fs_context *fsc, struct fs_parameter *param) return 0; case OPT_FD: - return fuse_opt_fd(fsc, result.uint_32); + if (param->type == fs_value_is_file) { + return fuse_opt_fd(fsc, param->file); + } else { + struct file *file __free(fput) = fget(result.uint_32); + if (!file) + return -EBADF; + + return fuse_opt_fd(fsc, file); + } case OPT_ROOTMODE: if (!fuse_valid_type(result.uint_32)) |
