Skip to content

Commit c0f92ba

Browse files
fweisbecIngo Molnar
authored andcommitted
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>
1 parent b8b9426 commit c0f92ba

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎fs/debugfs/inode.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
static struct vfsmount *debugfs_mount;
3232
static int debugfs_mount_count;
33+
static bool debugfs_registered;
3334

3435
static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t dev)
3536
{
@@ -496,6 +497,16 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
496497
}
497498
EXPORT_SYMBOL_GPL(debugfs_rename);
498499

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+
499510
static struct kobject *debug_kobj;
500511

501512
static int __init debugfs_init(void)
@@ -509,11 +520,16 @@ static int __init debugfs_init(void)
509520
retval = register_filesystem(&debug_fs_type);
510521
if (retval)
511522
kobject_put(debug_kobj);
523+
else
524+
debugfs_registered = true;
525+
512526
return retval;
513527
}
514528

515529
static void __exit debugfs_exit(void)
516530
{
531+
debugfs_registered = false;
532+
517533
simple_release_fs(&debugfs_mount, &debugfs_mount_count);
518534
unregister_filesystem(&debug_fs_type);
519535
kobject_put(debug_kobj);

‎include/linux/debugfs.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ struct dentry *debugfs_create_bool(const char *name, mode_t mode,
7171
struct dentry *debugfs_create_blob(const char *name, mode_t mode,
7272
struct dentry *parent,
7373
struct debugfs_blob_wrapper *blob);
74+
75+
bool debugfs_initialized(void);
76+
7477
#else
7578

7679
#include <linux/err.h>
@@ -183,6 +186,11 @@ static inline struct dentry *debugfs_create_blob(const char *name, mode_t mode,
183186
return ERR_PTR(-ENODEV);
184187
}
185188

189+
static inline bool debugfs_initialized(void)
190+
{
191+
return false;
192+
}
193+
186194
#endif
187195

188196
#endif

0 commit comments

Comments
 (0)