Commit c0f92ba99bdeaf35f9c580291b4e1a657c67fbd4

Authored by Frederic Weisbecker
Committed by Ingo Molnar
1 parent b8b9426533

debugfs: function to know if debugfs is initialized

Impact: add new debugfs API

With ftrace, some tracers are registered in early initcalls
and attempt to create files on the debugfs filesystem.
Depending on when they are activated, they can try to create their
file at any time. Some checks can be done on the tracing area
but providing a helper to know if debugfs is registered make it
really more easy.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <1237759847-21025-2-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 2 changed files with 24 additions and 0 deletions Side-by-side Diff

... ... @@ -30,6 +30,7 @@
30 30  
31 31 static struct vfsmount *debugfs_mount;
32 32 static int debugfs_mount_count;
  33 +static bool debugfs_registered;
33 34  
34 35 static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t dev)
35 36 {
... ... @@ -496,6 +497,16 @@
496 497 }
497 498 EXPORT_SYMBOL_GPL(debugfs_rename);
498 499  
  500 +/**
  501 + * debugfs_initialized - Tells whether debugfs has been registered
  502 + */
  503 +bool debugfs_initialized(void)
  504 +{
  505 + return debugfs_registered;
  506 +}
  507 +EXPORT_SYMBOL_GPL(debugfs_initialized);
  508 +
  509 +
499 510 static struct kobject *debug_kobj;
500 511  
501 512 static int __init debugfs_init(void)
502 513  
... ... @@ -509,11 +520,16 @@
509 520 retval = register_filesystem(&debug_fs_type);
510 521 if (retval)
511 522 kobject_put(debug_kobj);
  523 + else
  524 + debugfs_registered = true;
  525 +
512 526 return retval;
513 527 }
514 528  
515 529 static void __exit debugfs_exit(void)
516 530 {
  531 + debugfs_registered = false;
  532 +
517 533 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
518 534 unregister_filesystem(&debug_fs_type);
519 535 kobject_put(debug_kobj);
include/linux/debugfs.h
... ... @@ -71,6 +71,9 @@
71 71 struct dentry *debugfs_create_blob(const char *name, mode_t mode,
72 72 struct dentry *parent,
73 73 struct debugfs_blob_wrapper *blob);
  74 +
  75 +bool debugfs_initialized(void);
  76 +
74 77 #else
75 78  
76 79 #include <linux/err.h>
... ... @@ -181,6 +184,11 @@
181 184 struct debugfs_blob_wrapper *blob)
182 185 {
183 186 return ERR_PTR(-ENODEV);
  187 +}
  188 +
  189 +static inline bool debugfs_initialized(void)
  190 +{
  191 + return false;
184 192 }
185 193  
186 194 #endif