]> Pileus Git - ~andy/linux/commitdiff
vfs: new helper - d_make_root()
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 8 Jan 2012 21:49:21 +0000 (16:49 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 10 Jan 2012 00:23:45 +0000 (19:23 -0500)
d_alloc_root() with iput() in case of allocation failure...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/dcache.c
include/linux/dcache.h

index b209d73f9a984d0d4aa184f8c3fe4eb63a60b603..3c6d3113a255c7af1519fdb6aa1c211ec092e992 100644 (file)
@@ -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;
index ed9f74f6c519a1f071348d691d69c7ed5795e938..a47bda5f76db125288898fb1aea2f098bc2dfa42 100644 (file)
@@ -249,6 +249,7 @@ extern int d_invalidate(struct dentry *);
 
 /* only used at mount-time */
 extern struct dentry * d_alloc_root(struct inode *);
+extern struct dentry * d_make_root(struct inode *);
 
 /* <clickety>-<click> the ramfs-type tree */
 extern void d_genocide(struct dentry *);