Implement support for O_TMPFILE by re-using the existing infrastructure for mkdir, symlink, mknod, etc. The server should reply to the tmpfile request by sending a fuse_entry_out describing the newly created tmpfile. Signed-off-by: Chirantan Ekbote <chirantan@xxxxxxxxxxxx> --- fs/fuse/dir.c | 21 +++++++++++++++++++++ fs/fuse/file.c | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index ff7dbeb16f88d..1ab52e7ec1625 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -751,6 +751,26 @@ static int fuse_mkdir(struct inode *dir, struct dentry *entry, umode_t mode) return create_new_entry(fm, &args, dir, entry, S_IFDIR); } +static int fuse_tmpfile(struct inode *dir, struct dentry *entry, umode_t mode) +{ + struct fuse_tmpfile_in inarg; + struct fuse_mount *fm = get_fuse_mount(dir); + FUSE_ARGS(args); + + if (!fm->fc->dont_mask) + mode &= ~current_umask(); + + memset(&inarg, 0, sizeof(inarg)); + inarg.mode = mode; + inarg.umask = current_umask(); + args.opcode = FUSE_TMPFILE; + args.in_numargs = 1; + args.in_args[0].size = sizeof(inarg); + args.in_args[0].value = &inarg; + + return create_new_entry(fm, &args, dir, entry, S_IFREG); +} + static int fuse_symlink(struct inode *dir, struct dentry *entry, const char *link) { @@ -1818,6 +1838,7 @@ static const struct inode_operations fuse_dir_inode_operations = { .listxattr = fuse_listxattr, .get_acl = fuse_get_acl, .set_acl = fuse_set_acl, + .tmpfile = fuse_tmpfile, }; static const struct file_operations fuse_dir_operations = { diff --git a/fs/fuse/file.c b/fs/fuse/file.c index c03034e8c1529..8ecf85699a014 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -39,7 +39,8 @@ static int fuse_send_open(struct fuse_mount *fm, u64 nodeid, struct file *file, FUSE_ARGS(args); memset(&inarg, 0, sizeof(inarg)); - inarg.flags = file->f_flags & ~(O_CREAT | O_EXCL | O_NOCTTY); + inarg.flags = + file->f_flags & ~(O_CREAT | O_EXCL | O_NOCTTY | O_TMPFILE); if (!fm->fc->atomic_o_trunc) inarg.flags &= ~O_TRUNC; args.opcode = opcode; -- 2.29.2.222.g5d2a92d10f8-goog