This pulls the code for opening a file, after its handle has been converted to a struct path, into a new helper function. This function will be used by io_uring once io_uring supports open_by_handle_at(2). Signed-off-by: Thomas Bertschinger <tahbertschinger@xxxxxxxxx> --- fs/fhandle.c | 21 +++++++++++++++------ fs/internal.h | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/fs/fhandle.c b/fs/fhandle.c index 36e194dd4cb6..91b0d340a4d1 100644 --- a/fs/fhandle.c +++ b/fs/fhandle.c @@ -402,6 +402,20 @@ int handle_to_path(int mountdirfd, struct file_handle *handle, return retval; } +struct file *do_filp_path_open(struct path *path, int open_flag) +{ + const struct export_operations *eops; + struct file *file; + + eops = path->mnt->mnt_sb->s_export_op; + if (eops->open) + file = eops->open(path, open_flag); + else + file = file_open_root(path, "", open_flag, 0); + + return file; +} + static long do_handle_open(int mountdirfd, struct file_handle __user *ufh, int open_flag) { @@ -409,7 +423,6 @@ static long do_handle_open(int mountdirfd, struct file_handle __user *ufh, long retval = 0; struct path path __free(path_put) = {}; struct file *file; - const struct export_operations *eops; handle = get_user_handle(ufh); if (IS_ERR(handle)) @@ -423,11 +436,7 @@ static long do_handle_open(int mountdirfd, struct file_handle __user *ufh, if (fd < 0) return fd; - eops = path.mnt->mnt_sb->s_export_op; - if (eops->open) - file = eops->open(&path, open_flag); - else - file = file_open_root(&path, "", open_flag, 0); + file = do_filp_path_open(&path, open_flag); if (IS_ERR(file)) return PTR_ERR(file); diff --git a/fs/internal.h b/fs/internal.h index ab80f83ded47..599e0d7b450e 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -366,4 +366,5 @@ long do_sys_name_to_handle_at(int dfd, const char __user *name, struct file_handle *get_user_handle(struct file_handle __user *ufh); int handle_to_path(int mountdirfd, struct file_handle *handle, struct path *path, unsigned int o_flags); +struct file *do_filp_path_open(struct path *path, int open_flag); #endif /* CONFIG_FHANDLE */ -- 2.51.0