diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-07-07 15:03:58 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-07-20 01:44:17 -0400 |
commit | a4464dbc0ca6a3ab8e9d1206bc05059dae2a559d (patch) | |
tree | d3c9332ab72cf5a4eba483ba1ff83c54ca4c42a0 /fs/libfs.c | |
parent | e3c3d9c838d48c0341c40ea45ee087e3d8c8ea39 (diff) |
Make ->d_sb assign-once and always non-NULL
New helper (non-exported, fs/internal.h-only): __d_alloc(sb, name).
Allocates dentry, sets its ->d_sb to given superblock and sets
->d_op accordingly. Old d_alloc(NULL, name) callers are converted
to that (all of them know what superblock they want). d_alloc()
itself is left only for parent != NULl case; uses __d_alloc(),
inserts result into the list of parent's children.
Note that now ->d_sb is assign-once and never NULL *and*
->d_parent is never NULL either.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/libfs.c')
-rw-r--r-- | fs/libfs.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/libfs.c b/fs/libfs.c index 275ca4749a2e..bd50b11f92da 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -16,6 +16,8 @@ | |||
16 | 16 | ||
17 | #include <asm/uaccess.h> | 17 | #include <asm/uaccess.h> |
18 | 18 | ||
19 | #include "internal.h" | ||
20 | |||
19 | static inline int simple_positive(struct dentry *dentry) | 21 | static inline int simple_positive(struct dentry *dentry) |
20 | { | 22 | { |
21 | return dentry->d_inode && !d_unhashed(dentry); | 23 | return dentry->d_inode && !d_unhashed(dentry); |
@@ -246,13 +248,11 @@ struct dentry *mount_pseudo(struct file_system_type *fs_type, char *name, | |||
246 | root->i_ino = 1; | 248 | root->i_ino = 1; |
247 | root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR; | 249 | root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR; |
248 | root->i_atime = root->i_mtime = root->i_ctime = CURRENT_TIME; | 250 | root->i_atime = root->i_mtime = root->i_ctime = CURRENT_TIME; |
249 | dentry = d_alloc(NULL, &d_name); | 251 | dentry = __d_alloc(s, &d_name); |
250 | if (!dentry) { | 252 | if (!dentry) { |
251 | iput(root); | 253 | iput(root); |
252 | goto Enomem; | 254 | goto Enomem; |
253 | } | 255 | } |
254 | dentry->d_sb = s; | ||
255 | dentry->d_parent = dentry; | ||
256 | d_instantiate(dentry, root); | 256 | d_instantiate(dentry, root); |
257 | s->s_root = dentry; | 257 | s->s_root = dentry; |
258 | s->s_d_op = dops; | 258 | s->s_d_op = dops; |