]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
vfs: introduce d_mark_tmpfile_name()
authorPaulo Alcantara <pc@manguebit.org>
Tue, 7 Apr 2026 19:58:09 +0000 (16:58 -0300)
committerSteve French <stfrench@microsoft.com>
Fri, 10 Apr 2026 16:25:34 +0000 (11:25 -0500)
CIFS requires O_TMPFILE dentries to have names of newly created
delete-on-close files in the server so it can build full pathnames
from the root of the share when performing operations on them.

Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: David Howells <dhowells@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-cifs@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/dcache.c
include/linux/dcache.h

index 7ba1801d81329942a38268cd5c69d2e3e3f2f613..fcd5a40cce94e82cd57df584052865f6321e94f7 100644 (file)
@@ -3196,6 +3196,25 @@ void d_mark_tmpfile(struct file *file, struct inode *inode)
 }
 EXPORT_SYMBOL(d_mark_tmpfile);
 
+void d_mark_tmpfile_name(struct file *file, const struct qstr *name)
+{
+       struct dentry *dentry = file->f_path.dentry;
+       char *dname = dentry->d_shortname.string;
+
+       BUG_ON(dname_external(dentry));
+       BUG_ON(d_really_is_positive(dentry));
+       BUG_ON(!d_unlinked(dentry));
+       BUG_ON(name->len > DNAME_INLINE_LEN - 1);
+       spin_lock(&dentry->d_parent->d_lock);
+       spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
+       dentry->__d_name.len = name->len;
+       memcpy(dname, name->name, name->len);
+       dname[name->len] = '\0';
+       spin_unlock(&dentry->d_lock);
+       spin_unlock(&dentry->d_parent->d_lock);
+}
+EXPORT_SYMBOL(d_mark_tmpfile_name);
+
 void d_tmpfile(struct file *file, struct inode *inode)
 {
        struct dentry *dentry = file->f_path.dentry;
index 898c60d21c92b1792c9b1543d11cecaf4e70bcf8..f60819dcfebd3e1f7ad7f3f22c409aa80f1069b3 100644 (file)
@@ -264,6 +264,7 @@ extern void d_invalidate(struct dentry *);
 extern struct dentry * d_make_root(struct inode *);
 
 extern void d_mark_tmpfile(struct file *, struct inode *);
+void d_mark_tmpfile_name(struct file *file, const struct qstr *name);
 extern void d_tmpfile(struct file *, struct inode *);
 
 extern struct dentry *d_find_alias(struct inode *);