diff options
author | Miklos Szeredi <mszeredi@redhat.com> | 2024-05-02 21:35:57 +0300 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2024-05-02 21:35:57 +0300 |
commit | 9a87907de3597a339cc129229d1a20bc7365ea5f (patch) | |
tree | a3a6e2b3784ee2e895ceb5668ca5bb1de754b1fa /fs/backing-file.c | |
parent | ed30a4a51bb196781c8058073ea720133a65596f (diff) | |
download | linux-9a87907de3597a339cc129229d1a20bc7365ea5f.tar.xz |
ovl: implement tmpfile
Combine inode creation with opening a file.
There are six separate objects that are being set up: the backing inode,
dentry and file, and the overlay inode, dentry and file. Cleanup in case
of an error is a bit of a challenge and is difficult to test, so careful
review is needed.
All tmpfile testcases except generic/509 now run/pass, and no regressions
are observed with full xfstests.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Diffstat (limited to 'fs/backing-file.c')
-rw-r--r-- | fs/backing-file.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/fs/backing-file.c b/fs/backing-file.c index 740185198db3..afb557446c27 100644 --- a/fs/backing-file.c +++ b/fs/backing-file.c @@ -52,6 +52,29 @@ struct file *backing_file_open(const struct path *user_path, int flags, } EXPORT_SYMBOL_GPL(backing_file_open); +struct file *backing_tmpfile_open(const struct path *user_path, int flags, + const struct path *real_parentpath, + umode_t mode, const struct cred *cred) +{ + struct mnt_idmap *real_idmap = mnt_idmap(real_parentpath->mnt); + struct file *f; + int error; + + f = alloc_empty_backing_file(flags, cred); + if (IS_ERR(f)) + return f; + + path_get(user_path); + *backing_file_user_path(f) = *user_path; + error = vfs_tmpfile(real_idmap, real_parentpath, f, mode); + if (error) { + fput(f); + f = ERR_PTR(error); + } + return f; +} +EXPORT_SYMBOL(backing_tmpfile_open); + struct backing_aio { struct kiocb iocb; refcount_t ref; |