aboutsummaryrefslogtreecommitdiffstats
path: root/fs/debugfs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-01-25 14:31:32 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2015-01-25 16:52:52 -0500
commit680b302409cdc87c2000a31f2ceb2951bd642260 (patch)
tree10ba80adfd51d79dcc978d9d6071501970d6beb1 /fs/debugfs
parent3473cde5655cf4501cadb8ed11ab8aad1484b377 (diff)
fold debugfs_mknod() into callers
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/debugfs')
-rw-r--r--fs/debugfs/inode.c68
1 files changed, 31 insertions, 37 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 778c0e32eb51..b765c04eba20 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -69,21 +69,6 @@ static struct inode *debugfs_get_inode(struct super_block *sb, umode_t mode, dev
69 return inode; 69 return inode;
70} 70}
71 71
72/* SMP-safe */
73static int debugfs_mknod(struct dentry *dentry,
74 umode_t mode, void *data,
75 const struct file_operations *fops)
76{
77 struct inode *inode;
78
79 inode = debugfs_get_inode(dentry->d_sb, mode, 0, data, fops);
80 if (unlikely(!inode))
81 return -EPERM;
82 d_instantiate(dentry, inode);
83 dget(dentry);
84 return 0;
85}
86
87static inline int debugfs_positive(struct dentry *dentry) 72static inline int debugfs_positive(struct dentry *dentry)
88{ 73{
89 return dentry->d_inode && !d_unhashed(dentry); 74 return dentry->d_inode && !d_unhashed(dentry);
@@ -339,7 +324,7 @@ struct dentry *debugfs_create_file(const char *name, umode_t mode,
339 const struct file_operations *fops) 324 const struct file_operations *fops)
340{ 325{
341 struct dentry *dentry; 326 struct dentry *dentry;
342 int error; 327 struct inode *inode;
343 328
344 if (!(mode & S_IFMT)) 329 if (!(mode & S_IFMT))
345 mode |= S_IFREG; 330 mode |= S_IFREG;
@@ -349,10 +334,14 @@ struct dentry *debugfs_create_file(const char *name, umode_t mode,
349 if (IS_ERR(dentry)) 334 if (IS_ERR(dentry))
350 return NULL; 335 return NULL;
351 336
352 error = debugfs_mknod(dentry, mode, data, fops); 337 inode = debugfs_get_inode(dentry->d_sb, mode, 0, data, fops);
353 if (!error) 338 if (unlikely(!inode))
354 fsnotify_create(dentry->d_parent->d_inode, dentry); 339 return end_creating(dentry, -ENOMEM);
355 return end_creating(dentry, error); 340
341 d_instantiate(dentry, inode);
342 dget(dentry);
343 fsnotify_create(dentry->d_parent->d_inode, dentry);
344 return end_creating(dentry, 0);
356} 345}
357EXPORT_SYMBOL_GPL(debugfs_create_file); 346EXPORT_SYMBOL_GPL(debugfs_create_file);
358 347
@@ -377,18 +366,22 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
377struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) 366struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
378{ 367{
379 struct dentry *dentry = start_creating(name, parent); 368 struct dentry *dentry = start_creating(name, parent);
380 int error; 369 struct inode *inode;
381 370
382 if (IS_ERR(dentry)) 371 if (IS_ERR(dentry))
383 return NULL; 372 return NULL;
384 373
385 error = debugfs_mknod(dentry, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, 374 inode = debugfs_get_inode(dentry->d_sb,
386 NULL, NULL); 375 S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
387 if (!error) { 376 0, NULL, NULL);
388 inc_nlink(dentry->d_parent->d_inode); 377 if (unlikely(!inode))
389 fsnotify_mkdir(dentry->d_parent->d_inode, dentry); 378 return end_creating(dentry, -ENOMEM);
390 } 379
391 return end_creating(dentry, error); 380 d_instantiate(dentry, inode);
381 dget(dentry);
382 inc_nlink(dentry->d_parent->d_inode);
383 fsnotify_mkdir(dentry->d_parent->d_inode, dentry);
384 return end_creating(dentry, 0);
392} 385}
393EXPORT_SYMBOL_GPL(debugfs_create_dir); 386EXPORT_SYMBOL_GPL(debugfs_create_dir);
394 387
@@ -419,25 +412,26 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
419 const char *target) 412 const char *target)
420{ 413{
421 struct dentry *dentry; 414 struct dentry *dentry;
422 char *link; 415 struct inode *inode;
423 int error; 416 char *link = kstrdup(target, GFP_KERNEL);
424
425 link = kstrdup(target, GFP_KERNEL);
426 if (!link) 417 if (!link)
427 return NULL; 418 return NULL;
428 419
429 dentry = start_creating(name, parent); 420 dentry = start_creating(name, parent);
430
431 if (IS_ERR(dentry)) { 421 if (IS_ERR(dentry)) {
432 kfree(link); 422 kfree(link);
433 return NULL; 423 return NULL;
434 } 424 }
435 425
436 error = debugfs_mknod(dentry, S_IFLNK | S_IRWXUGO, link, NULL); 426 inode = debugfs_get_inode(dentry->d_sb, S_IFLNK | S_IRWXUGO, 0,
437 if (error) 427 link, NULL);
428 if (unlikely(!inode)) {
438 kfree(link); 429 kfree(link);
439 430 return end_creating(dentry, -ENOMEM);
440 return end_creating(dentry, error); 431 }
432 d_instantiate(dentry, inode);
433 dget(dentry);
434 return end_creating(dentry, 0);
441} 435}
442EXPORT_SYMBOL_GPL(debugfs_create_symlink); 436EXPORT_SYMBOL_GPL(debugfs_create_symlink);
443 437