Skip to content

Commit 30a59dd

Browse files
pcacjrsmfrench
authored andcommitted
vfs: introduce d_mark_tmpfile_name()
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>
1 parent 158f4ff commit 30a59dd

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

fs/dcache.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3196,6 +3196,25 @@ void d_mark_tmpfile(struct file *file, struct inode *inode)
31963196
}
31973197
EXPORT_SYMBOL(d_mark_tmpfile);
31983198

3199+
void d_mark_tmpfile_name(struct file *file, const struct qstr *name)
3200+
{
3201+
struct dentry *dentry = file->f_path.dentry;
3202+
char *dname = dentry->d_shortname.string;
3203+
3204+
BUG_ON(dname_external(dentry));
3205+
BUG_ON(d_really_is_positive(dentry));
3206+
BUG_ON(!d_unlinked(dentry));
3207+
BUG_ON(name->len > DNAME_INLINE_LEN - 1);
3208+
spin_lock(&dentry->d_parent->d_lock);
3209+
spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
3210+
dentry->__d_name.len = name->len;
3211+
memcpy(dname, name->name, name->len);
3212+
dname[name->len] = '\0';
3213+
spin_unlock(&dentry->d_lock);
3214+
spin_unlock(&dentry->d_parent->d_lock);
3215+
}
3216+
EXPORT_SYMBOL(d_mark_tmpfile_name);
3217+
31993218
void d_tmpfile(struct file *file, struct inode *inode)
32003219
{
32013220
struct dentry *dentry = file->f_path.dentry;

include/linux/dcache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ extern void d_invalidate(struct dentry *);
264264
extern struct dentry * d_make_root(struct inode *);
265265

266266
extern void d_mark_tmpfile(struct file *, struct inode *);
267+
void d_mark_tmpfile_name(struct file *file, const struct qstr *name);
267268
extern void d_tmpfile(struct file *, struct inode *);
268269

269270
extern struct dentry *d_find_alias(struct inode *);

0 commit comments

Comments
 (0)