diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /fs/anon_inodes.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'fs/anon_inodes.c')
-rw-r--r-- | fs/anon_inodes.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c index 2ca7a7cafdbf..e4b75d6eda83 100644 --- a/fs/anon_inodes.c +++ b/fs/anon_inodes.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/file.h> | 12 | #include <linux/file.h> |
13 | #include <linux/poll.h> | 13 | #include <linux/poll.h> |
14 | #include <linux/sched.h> | 14 | #include <linux/sched.h> |
15 | #include <linux/slab.h> | ||
16 | #include <linux/init.h> | 15 | #include <linux/init.h> |
17 | #include <linux/fs.h> | 16 | #include <linux/fs.h> |
18 | #include <linux/mount.h> | 17 | #include <linux/mount.h> |
@@ -35,14 +34,13 @@ static int anon_inodefs_get_sb(struct file_system_type *fs_type, int flags, | |||
35 | mnt); | 34 | mnt); |
36 | } | 35 | } |
37 | 36 | ||
38 | static int anon_inodefs_delete_dentry(struct dentry *dentry) | 37 | /* |
38 | * anon_inodefs_dname() is called from d_path(). | ||
39 | */ | ||
40 | static char *anon_inodefs_dname(struct dentry *dentry, char *buffer, int buflen) | ||
39 | { | 41 | { |
40 | /* | 42 | return dynamic_dname(dentry, buffer, buflen, "anon_inode:%s", |
41 | * We faked vfs to believe the dentry was hashed when we created it. | 43 | dentry->d_name.name); |
42 | * Now we restore the flag so that dput() will work correctly. | ||
43 | */ | ||
44 | dentry->d_flags |= DCACHE_UNHASHED; | ||
45 | return 1; | ||
46 | } | 44 | } |
47 | 45 | ||
48 | static struct file_system_type anon_inode_fs_type = { | 46 | static struct file_system_type anon_inode_fs_type = { |
@@ -51,7 +49,7 @@ static struct file_system_type anon_inode_fs_type = { | |||
51 | .kill_sb = kill_anon_super, | 49 | .kill_sb = kill_anon_super, |
52 | }; | 50 | }; |
53 | static const struct dentry_operations anon_inodefs_dentry_operations = { | 51 | static const struct dentry_operations anon_inodefs_dentry_operations = { |
54 | .d_delete = anon_inodefs_delete_dentry, | 52 | .d_dname = anon_inodefs_dname, |
55 | }; | 53 | }; |
56 | 54 | ||
57 | /* | 55 | /* |
@@ -88,7 +86,7 @@ struct file *anon_inode_getfile(const char *name, | |||
88 | void *priv, int flags) | 86 | void *priv, int flags) |
89 | { | 87 | { |
90 | struct qstr this; | 88 | struct qstr this; |
91 | struct dentry *dentry; | 89 | struct path path; |
92 | struct file *file; | 90 | struct file *file; |
93 | int error; | 91 | int error; |
94 | 92 | ||
@@ -106,10 +104,11 @@ struct file *anon_inode_getfile(const char *name, | |||
106 | this.name = name; | 104 | this.name = name; |
107 | this.len = strlen(name); | 105 | this.len = strlen(name); |
108 | this.hash = 0; | 106 | this.hash = 0; |
109 | dentry = d_alloc(anon_inode_mnt->mnt_sb->s_root, &this); | 107 | path.dentry = d_alloc(anon_inode_mnt->mnt_sb->s_root, &this); |
110 | if (!dentry) | 108 | if (!path.dentry) |
111 | goto err_module; | 109 | goto err_module; |
112 | 110 | ||
111 | path.mnt = mntget(anon_inode_mnt); | ||
113 | /* | 112 | /* |
114 | * We know the anon_inode inode count is always greater than zero, | 113 | * We know the anon_inode inode count is always greater than zero, |
115 | * so we can avoid doing an igrab() and we can use an open-coded | 114 | * so we can avoid doing an igrab() and we can use an open-coded |
@@ -117,27 +116,24 @@ struct file *anon_inode_getfile(const char *name, | |||
117 | */ | 116 | */ |
118 | atomic_inc(&anon_inode_inode->i_count); | 117 | atomic_inc(&anon_inode_inode->i_count); |
119 | 118 | ||
120 | dentry->d_op = &anon_inodefs_dentry_operations; | 119 | path.dentry->d_op = &anon_inodefs_dentry_operations; |
121 | /* Do not publish this dentry inside the global dentry hash table */ | 120 | d_instantiate(path.dentry, anon_inode_inode); |
122 | dentry->d_flags &= ~DCACHE_UNHASHED; | ||
123 | d_instantiate(dentry, anon_inode_inode); | ||
124 | 121 | ||
125 | error = -ENFILE; | 122 | error = -ENFILE; |
126 | file = alloc_file(anon_inode_mnt, dentry, | 123 | file = alloc_file(&path, OPEN_FMODE(flags), fops); |
127 | FMODE_READ | FMODE_WRITE, fops); | ||
128 | if (!file) | 124 | if (!file) |
129 | goto err_dput; | 125 | goto err_dput; |
130 | file->f_mapping = anon_inode_inode->i_mapping; | 126 | file->f_mapping = anon_inode_inode->i_mapping; |
131 | 127 | ||
132 | file->f_pos = 0; | 128 | file->f_pos = 0; |
133 | file->f_flags = O_RDWR | (flags & O_NONBLOCK); | 129 | file->f_flags = flags & (O_ACCMODE | O_NONBLOCK); |
134 | file->f_version = 0; | 130 | file->f_version = 0; |
135 | file->private_data = priv; | 131 | file->private_data = priv; |
136 | 132 | ||
137 | return file; | 133 | return file; |
138 | 134 | ||
139 | err_dput: | 135 | err_dput: |
140 | dput(dentry); | 136 | path_put(&path); |
141 | err_module: | 137 | err_module: |
142 | module_put(fops->owner); | 138 | module_put(fops->owner); |
143 | return ERR_PTR(error); | 139 | return ERR_PTR(error); |
@@ -212,6 +208,7 @@ static struct inode *anon_inode_mkinode(void) | |||
212 | inode->i_mode = S_IRUSR | S_IWUSR; | 208 | inode->i_mode = S_IRUSR | S_IWUSR; |
213 | inode->i_uid = current_fsuid(); | 209 | inode->i_uid = current_fsuid(); |
214 | inode->i_gid = current_fsgid(); | 210 | inode->i_gid = current_fsgid(); |
211 | inode->i_flags |= S_PRIVATE; | ||
215 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 212 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
216 | return inode; | 213 | return inode; |
217 | } | 214 | } |