aboutsummaryrefslogtreecommitdiffstats
path: root/fs/debugfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/debugfs')
-rw-r--r--fs/debugfs/file.c22
-rw-r--r--fs/debugfs/inode.c35
2 files changed, 20 insertions, 37 deletions
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 0210898458b2..90f76575c056 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -43,6 +43,7 @@ const struct file_operations debugfs_file_operations = {
43 .read = default_read_file, 43 .read = default_read_file,
44 .write = default_write_file, 44 .write = default_write_file,
45 .open = default_open, 45 .open = default_open,
46 .llseek = noop_llseek,
46}; 47};
47 48
48static void *debugfs_follow_link(struct dentry *dentry, struct nameidata *nd) 49static void *debugfs_follow_link(struct dentry *dentry, struct nameidata *nd)
@@ -427,26 +428,17 @@ static ssize_t write_file_bool(struct file *file, const char __user *user_buf,
427 size_t count, loff_t *ppos) 428 size_t count, loff_t *ppos)
428{ 429{
429 char buf[32]; 430 char buf[32];
430 int buf_size; 431 size_t buf_size;
432 bool bv;
431 u32 *val = file->private_data; 433 u32 *val = file->private_data;
432 434
433 buf_size = min(count, (sizeof(buf)-1)); 435 buf_size = min(count, (sizeof(buf)-1));
434 if (copy_from_user(buf, user_buf, buf_size)) 436 if (copy_from_user(buf, user_buf, buf_size))
435 return -EFAULT; 437 return -EFAULT;
436 438
437 switch (buf[0]) { 439 if (strtobool(buf, &bv) == 0)
438 case 'y': 440 *val = bv;
439 case 'Y': 441
440 case '1':
441 *val = 1;
442 break;
443 case 'n':
444 case 'N':
445 case '0':
446 *val = 0;
447 break;
448 }
449
450 return count; 442 return count;
451} 443}
452 444
@@ -454,6 +446,7 @@ static const struct file_operations fops_bool = {
454 .read = read_file_bool, 446 .read = read_file_bool,
455 .write = write_file_bool, 447 .write = write_file_bool,
456 .open = default_open, 448 .open = default_open,
449 .llseek = default_llseek,
457}; 450};
458 451
459/** 452/**
@@ -498,6 +491,7 @@ static ssize_t read_file_blob(struct file *file, char __user *user_buf,
498static const struct file_operations fops_blob = { 491static const struct file_operations fops_blob = {
499 .read = read_file_blob, 492 .read = read_file_blob,
500 .open = default_open, 493 .open = default_open,
494 .llseek = default_llseek,
501}; 495};
502 496
503/** 497/**
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 30a87b3dbcac..e7a7a2f07324 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -13,9 +13,6 @@
13 * 13 *
14 */ 14 */
15 15
16/* uncomment to get debug messages from the debug filesystem, ah the irony. */
17/* #define DEBUG */
18
19#include <linux/module.h> 16#include <linux/module.h>
20#include <linux/fs.h> 17#include <linux/fs.h>
21#include <linux/mount.h> 18#include <linux/mount.h>
@@ -40,6 +37,7 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d
40 struct inode *inode = new_inode(sb); 37 struct inode *inode = new_inode(sb);
41 38
42 if (inode) { 39 if (inode) {
40 inode->i_ino = get_next_ino();
43 inode->i_mode = mode; 41 inode->i_mode = mode;
44 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 42 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
45 switch (mode & S_IFMT) { 43 switch (mode & S_IFMT) {
@@ -134,17 +132,17 @@ static int debug_fill_super(struct super_block *sb, void *data, int silent)
134 return simple_fill_super(sb, DEBUGFS_MAGIC, debug_files); 132 return simple_fill_super(sb, DEBUGFS_MAGIC, debug_files);
135} 133}
136 134
137static int debug_get_sb(struct file_system_type *fs_type, 135static struct dentry *debug_mount(struct file_system_type *fs_type,
138 int flags, const char *dev_name, 136 int flags, const char *dev_name,
139 void *data, struct vfsmount *mnt) 137 void *data)
140{ 138{
141 return get_sb_single(fs_type, flags, data, debug_fill_super, mnt); 139 return mount_single(fs_type, flags, data, debug_fill_super);
142} 140}
143 141
144static struct file_system_type debug_fs_type = { 142static struct file_system_type debug_fs_type = {
145 .owner = THIS_MODULE, 143 .owner = THIS_MODULE,
146 .name = "debugfs", 144 .name = "debugfs",
147 .get_sb = debug_get_sb, 145 .mount = debug_mount,
148 .kill_sb = kill_litter_super, 146 .kill_sb = kill_litter_super,
149}; 147};
150 148
@@ -309,7 +307,7 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
309} 307}
310EXPORT_SYMBOL_GPL(debugfs_create_symlink); 308EXPORT_SYMBOL_GPL(debugfs_create_symlink);
311 309
312static void __debugfs_remove(struct dentry *dentry, struct dentry *parent) 310static int __debugfs_remove(struct dentry *dentry, struct dentry *parent)
313{ 311{
314 int ret = 0; 312 int ret = 0;
315 313
@@ -332,6 +330,7 @@ static void __debugfs_remove(struct dentry *dentry, struct dentry *parent)
332 dput(dentry); 330 dput(dentry);
333 } 331 }
334 } 332 }
333 return ret;
335} 334}
336 335
337/** 336/**
@@ -350,7 +349,8 @@ static void __debugfs_remove(struct dentry *dentry, struct dentry *parent)
350void debugfs_remove(struct dentry *dentry) 349void debugfs_remove(struct dentry *dentry)
351{ 350{
352 struct dentry *parent; 351 struct dentry *parent;
353 352 int ret;
353
354 if (!dentry) 354 if (!dentry)
355 return; 355 return;
356 356
@@ -359,9 +359,10 @@ void debugfs_remove(struct dentry *dentry)
359 return; 359 return;
360 360
361 mutex_lock(&parent->d_inode->i_mutex); 361 mutex_lock(&parent->d_inode->i_mutex);
362 __debugfs_remove(dentry, parent); 362 ret = __debugfs_remove(dentry, parent);
363 mutex_unlock(&parent->d_inode->i_mutex); 363 mutex_unlock(&parent->d_inode->i_mutex);
364 simple_release_fs(&debugfs_mount, &debugfs_mount_count); 364 if (!ret)
365 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
365} 366}
366EXPORT_SYMBOL_GPL(debugfs_remove); 367EXPORT_SYMBOL_GPL(debugfs_remove);
367 368
@@ -539,17 +540,5 @@ static int __init debugfs_init(void)
539 540
540 return retval; 541 return retval;
541} 542}
542
543static void __exit debugfs_exit(void)
544{
545 debugfs_registered = false;
546
547 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
548 unregister_filesystem(&debug_fs_type);
549 kobject_put(debug_kobj);
550}
551
552core_initcall(debugfs_init); 543core_initcall(debugfs_init);
553module_exit(debugfs_exit);
554MODULE_LICENSE("GPL");
555 544