diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-01-08 16:49:21 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-01-09 19:23:45 -0500 |
commit | adc0e91ab142abe93f5b0d7980ada8a7676231fe (patch) | |
tree | 27ee89f960b7e2d6cd5179d914bc252324122c26 | |
parent | b48f03b319ba78f3abf9a7044d1f436d8d90f4f9 (diff) |
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>
-rw-r--r-- | fs/dcache.c | 17 | ||||
-rw-r--r-- | include/linux/dcache.h | 1 |
2 files changed, 18 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) | |||
1440 | } | 1440 | } |
1441 | EXPORT_SYMBOL(d_alloc_root); | 1441 | EXPORT_SYMBOL(d_alloc_root); |
1442 | 1442 | ||
1443 | struct dentry *d_make_root(struct inode *root_inode) | ||
1444 | { | ||
1445 | struct dentry *res = NULL; | ||
1446 | |||
1447 | if (root_inode) { | ||
1448 | static const struct qstr name = { .name = "/", .len = 1 }; | ||
1449 | |||
1450 | res = __d_alloc(root_inode->i_sb, &name); | ||
1451 | if (res) | ||
1452 | d_instantiate(res, root_inode); | ||
1453 | else | ||
1454 | iput(root_inode); | ||
1455 | } | ||
1456 | return res; | ||
1457 | } | ||
1458 | EXPORT_SYMBOL(d_make_root); | ||
1459 | |||
1443 | static struct dentry * __d_find_any_alias(struct inode *inode) | 1460 | static struct dentry * __d_find_any_alias(struct inode *inode) |
1444 | { | 1461 | { |
1445 | struct dentry *alias; | 1462 | struct dentry *alias; |
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index ed9f74f6c519..a47bda5f76db 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
@@ -249,6 +249,7 @@ extern int d_invalidate(struct dentry *); | |||
249 | 249 | ||
250 | /* only used at mount-time */ | 250 | /* only used at mount-time */ |
251 | extern struct dentry * d_alloc_root(struct inode *); | 251 | extern struct dentry * d_alloc_root(struct inode *); |
252 | extern struct dentry * d_make_root(struct inode *); | ||
252 | 253 | ||
253 | /* <clickety>-<click> the ramfs-type tree */ | 254 | /* <clickety>-<click> the ramfs-type tree */ |
254 | extern void d_genocide(struct dentry *); | 255 | extern void d_genocide(struct dentry *); |