aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-06-27 16:35:45 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-20 01:44:10 -0400
commit69753a0f14d3cb2e8a70e559ef8d409e4deeac8a (patch)
treee00ca40e65892ff9383bbf2d301d4269dd9327e9
parent2780f1ff6aec0cf708a61c022d475bfcaa648965 (diff)
switch devtmpfs to kern_path_create()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--drivers/base/devtmpfs.c83
1 files changed, 36 insertions, 47 deletions
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index 1a16e1fd7f8a..a49897d05325 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -144,27 +144,21 @@ int devtmpfs_delete_node(struct device *dev)
144 144
145static int dev_mkdir(const char *name, mode_t mode) 145static int dev_mkdir(const char *name, mode_t mode)
146{ 146{
147 struct nameidata nd;
148 struct dentry *dentry; 147 struct dentry *dentry;
148 struct path path;
149 int err; 149 int err;
150 150
151 err = kern_path_parent(name, &nd); 151 dentry = kern_path_create(AT_FDCWD, name, &path, 1);
152 if (err) 152 if (IS_ERR(dentry))
153 return err; 153 return PTR_ERR(dentry);
154 154
155 dentry = lookup_create(&nd, 1); 155 err = vfs_mkdir(path.dentry->d_inode, dentry, mode);
156 if (!IS_ERR(dentry)) { 156 if (!err)
157 err = vfs_mkdir(nd.path.dentry->d_inode, dentry, mode); 157 /* mark as kernel-created inode */
158 if (!err) 158 dentry->d_inode->i_private = &thread;
159 /* mark as kernel-created inode */ 159 dput(dentry);
160 dentry->d_inode->i_private = &thread; 160 mutex_unlock(&path.dentry->d_inode->i_mutex);
161 dput(dentry); 161 path_put(&path);
162 } else {
163 err = PTR_ERR(dentry);
164 }
165
166 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
167 path_put(&nd.path);
168 return err; 162 return err;
169} 163}
170 164
@@ -203,42 +197,37 @@ out:
203 197
204static int handle_create(const char *nodename, mode_t mode, struct device *dev) 198static int handle_create(const char *nodename, mode_t mode, struct device *dev)
205{ 199{
206 struct nameidata nd;
207 struct dentry *dentry; 200 struct dentry *dentry;
201 struct path path;
208 int err; 202 int err;
209 203
210 err = kern_path_parent(nodename, &nd); 204 dentry = kern_path_create(AT_FDCWD, nodename, &path, 0);
211 if (err == -ENOENT) { 205 if (dentry == ERR_PTR(-ENOENT)) {
212 create_path(nodename); 206 create_path(nodename);
213 err = kern_path_parent(nodename, &nd); 207 dentry = kern_path_create(AT_FDCWD, nodename, &path, 0);
214 } 208 }
215 if (err) 209 if (IS_ERR(dentry))
216 return err; 210 return PTR_ERR(dentry);
217 211
218 dentry = lookup_create(&nd, 0); 212 err = vfs_mknod(path.dentry->d_inode,
219 if (!IS_ERR(dentry)) { 213 dentry, mode, dev->devt);
220 err = vfs_mknod(nd.path.dentry->d_inode, 214 if (!err) {
221 dentry, mode, dev->devt); 215 struct iattr newattrs;
222 if (!err) { 216
223 struct iattr newattrs; 217 /* fixup possibly umasked mode */
224 218 newattrs.ia_mode = mode;
225 /* fixup possibly umasked mode */ 219 newattrs.ia_valid = ATTR_MODE;
226 newattrs.ia_mode = mode; 220 mutex_lock(&dentry->d_inode->i_mutex);
227 newattrs.ia_valid = ATTR_MODE; 221 notify_change(dentry, &newattrs);
228 mutex_lock(&dentry->d_inode->i_mutex); 222 mutex_unlock(&dentry->d_inode->i_mutex);
229 notify_change(dentry, &newattrs); 223
230 mutex_unlock(&dentry->d_inode->i_mutex); 224 /* mark as kernel-created inode */
231 225 dentry->d_inode->i_private = &thread;
232 /* mark as kernel-created inode */
233 dentry->d_inode->i_private = &thread;
234 }
235 dput(dentry);
236 } else {
237 err = PTR_ERR(dentry);
238 } 226 }
227 dput(dentry);
239 228
240 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 229 mutex_unlock(&path.dentry->d_inode->i_mutex);
241 path_put(&nd.path); 230 path_put(&path);
242 return err; 231 return err;
243} 232}
244 233