summaryrefslogtreecommitdiffstats
path: root/fs/dcache.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-01-08 22:49:21 +0100
committerAl Viro <viro@zeniv.linux.org.uk>2012-01-10 01:23:45 +0100
commitadc0e91ab142abe93f5b0d7980ada8a7676231fe (patch)
tree27ee89f960b7e2d6cd5179d914bc252324122c26 /fs/dcache.c
parentdcache: use a dispose list in select_parent (diff)
downloadlinux-adc0e91ab142abe93f5b0d7980ada8a7676231fe.tar.xz
linux-adc0e91ab142abe93f5b0d7980ada8a7676231fe.zip
vfs: new helper - d_make_root()
d_alloc_root() with iput() in case of allocation failure... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r--fs/dcache.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index b209d73f9a98..3c6d3113a255 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1440,6 +1440,23 @@ struct dentry * d_alloc_root(struct inode * root_inode)
}
EXPORT_SYMBOL(d_alloc_root);
+struct dentry *d_make_root(struct inode *root_inode)
+{
+ struct dentry *res = NULL;
+
+ if (root_inode) {
+ static const struct qstr name = { .name = "/", .len = 1 };
+
+ res = __d_alloc(root_inode->i_sb, &name);
+ if (res)
+ d_instantiate(res, root_inode);
+ else
+ iput(root_inode);
+ }
+ return res;
+}
+EXPORT_SYMBOL(d_make_root);
+
static struct dentry * __d_find_any_alias(struct inode *inode)
{
struct dentry *alias;