1 // SPDX-License-Identifier: GPL-2.0
3 * inode.c - part of debugfs, a tiny little debug file system
5 * Copyright (C) 2004,2019 Greg Kroah-Hartman <greg@kroah.com>
6 * Copyright (C) 2004 IBM Inc.
7 * Copyright (C) 2019 Linux Foundation <gregkh@linuxfoundation.org>
9 * debugfs is for people to use instead of /proc or /sys.
10 * See ./Documentation/core-api/kernel-api.rst for more details.
13 #define pr_fmt(fmt) "debugfs: " fmt
15 #include <linux/module.h>
17 #include <linux/mount.h>
18 #include <linux/pagemap.h>
19 #include <linux/init.h>
20 #include <linux/kobject.h>
21 #include <linux/namei.h>
22 #include <linux/debugfs.h>
23 #include <linux/fsnotify.h>
24 #include <linux/string.h>
25 #include <linux/seq_file.h>
26 #include <linux/parser.h>
27 #include <linux/magic.h>
28 #include <linux/slab.h>
29 #include <linux/security.h>
33 #define DEBUGFS_DEFAULT_MODE 0700
35 static struct vfsmount *debugfs_mount;
36 static int debugfs_mount_count;
37 static bool debugfs_registered;
38 static unsigned int debugfs_allow __ro_after_init = DEFAULT_DEBUGFS_ALLOW_BITS;
41 * Don't allow access attributes to be changed whilst the kernel is locked down
42 * so that we can use the file mode as part of a heuristic to determine whether
43 * to lock down individual files.
45 static int debugfs_setattr(struct dentry *dentry, struct iattr *ia)
47 int ret = security_locked_down(LOCKDOWN_DEBUGFS);
49 if (ret && (ia->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID)))
51 return simple_setattr(dentry, ia);
54 static const struct inode_operations debugfs_file_inode_operations = {
55 .setattr = debugfs_setattr,
57 static const struct inode_operations debugfs_dir_inode_operations = {
58 .lookup = simple_lookup,
59 .setattr = debugfs_setattr,
61 static const struct inode_operations debugfs_symlink_inode_operations = {
62 .get_link = simple_get_link,
63 .setattr = debugfs_setattr,
66 static struct inode *debugfs_get_inode(struct super_block *sb)
68 struct inode *inode = new_inode(sb);
70 inode->i_ino = get_next_ino();
71 inode->i_atime = inode->i_mtime =
72 inode->i_ctime = current_time(inode);
77 struct debugfs_mount_opts {
90 static const match_table_t tokens = {
93 {Opt_mode, "mode=%o"},
97 struct debugfs_fs_info {
98 struct debugfs_mount_opts mount_opts;
101 static int debugfs_parse_options(char *data, struct debugfs_mount_opts *opts)
103 substring_t args[MAX_OPT_ARGS];
110 opts->mode = DEBUGFS_DEFAULT_MODE;
112 while ((p = strsep(&data, ",")) != NULL) {
116 token = match_token(p, tokens, args);
119 if (match_int(&args[0], &option))
121 uid = make_kuid(current_user_ns(), option);
127 if (match_int(&args[0], &option))
129 gid = make_kgid(current_user_ns(), option);
135 if (match_octal(&args[0], &option))
137 opts->mode = option & S_IALLUGO;
140 * We might like to report bad mount options here;
141 * but traditionally debugfs has ignored all mount options
149 static int debugfs_apply_options(struct super_block *sb)
151 struct debugfs_fs_info *fsi = sb->s_fs_info;
152 struct inode *inode = d_inode(sb->s_root);
153 struct debugfs_mount_opts *opts = &fsi->mount_opts;
155 inode->i_mode &= ~S_IALLUGO;
156 inode->i_mode |= opts->mode;
158 inode->i_uid = opts->uid;
159 inode->i_gid = opts->gid;
164 static int debugfs_remount(struct super_block *sb, int *flags, char *data)
167 struct debugfs_fs_info *fsi = sb->s_fs_info;
170 err = debugfs_parse_options(data, &fsi->mount_opts);
174 debugfs_apply_options(sb);
180 static int debugfs_show_options(struct seq_file *m, struct dentry *root)
182 struct debugfs_fs_info *fsi = root->d_sb->s_fs_info;
183 struct debugfs_mount_opts *opts = &fsi->mount_opts;
185 if (!uid_eq(opts->uid, GLOBAL_ROOT_UID))
186 seq_printf(m, ",uid=%u",
187 from_kuid_munged(&init_user_ns, opts->uid));
188 if (!gid_eq(opts->gid, GLOBAL_ROOT_GID))
189 seq_printf(m, ",gid=%u",
190 from_kgid_munged(&init_user_ns, opts->gid));
191 if (opts->mode != DEBUGFS_DEFAULT_MODE)
192 seq_printf(m, ",mode=%o", opts->mode);
197 static void debugfs_free_inode(struct inode *inode)
199 if (S_ISLNK(inode->i_mode))
200 kfree(inode->i_link);
201 free_inode_nonrcu(inode);
204 static const struct super_operations debugfs_super_operations = {
205 .statfs = simple_statfs,
206 .remount_fs = debugfs_remount,
207 .show_options = debugfs_show_options,
208 .free_inode = debugfs_free_inode,
211 static void debugfs_release_dentry(struct dentry *dentry)
213 struct debugfs_fsdata *fsd = dentry->d_fsdata;
215 if ((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT)
221 static struct vfsmount *debugfs_automount(struct path *path)
223 struct debugfs_fsdata *fsd = path->dentry->d_fsdata;
225 return fsd->automount(path->dentry, d_inode(path->dentry)->i_private);
228 static const struct dentry_operations debugfs_dops = {
229 .d_delete = always_delete_dentry,
230 .d_release = debugfs_release_dentry,
231 .d_automount = debugfs_automount,
234 static int debug_fill_super(struct super_block *sb, void *data, int silent)
236 static const struct tree_descr debug_files[] = {{""}};
237 struct debugfs_fs_info *fsi;
240 fsi = kzalloc(sizeof(struct debugfs_fs_info), GFP_KERNEL);
247 err = debugfs_parse_options(data, &fsi->mount_opts);
251 err = simple_fill_super(sb, DEBUGFS_MAGIC, debug_files);
255 sb->s_op = &debugfs_super_operations;
256 sb->s_d_op = &debugfs_dops;
258 debugfs_apply_options(sb);
264 sb->s_fs_info = NULL;
268 static struct dentry *debug_mount(struct file_system_type *fs_type,
269 int flags, const char *dev_name,
272 if (!(debugfs_allow & DEBUGFS_ALLOW_API))
273 return ERR_PTR(-EPERM);
275 return mount_single(fs_type, flags, data, debug_fill_super);
278 static struct file_system_type debug_fs_type = {
279 .owner = THIS_MODULE,
281 .mount = debug_mount,
282 .kill_sb = kill_litter_super,
284 MODULE_ALIAS_FS("debugfs");
287 * debugfs_lookup() - look up an existing debugfs file
288 * @name: a pointer to a string containing the name of the file to look up.
289 * @parent: a pointer to the parent dentry of the file.
291 * This function will return a pointer to a dentry if it succeeds. If the file
292 * doesn't exist or an error occurs, %NULL will be returned. The returned
293 * dentry must be passed to dput() when it is no longer needed.
295 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
298 struct dentry *debugfs_lookup(const char *name, struct dentry *parent)
300 struct dentry *dentry;
302 if (!debugfs_initialized() || IS_ERR_OR_NULL(name) || IS_ERR(parent))
306 parent = debugfs_mount->mnt_root;
308 dentry = lookup_positive_unlocked(name, parent, strlen(name));
313 EXPORT_SYMBOL_GPL(debugfs_lookup);
315 static struct dentry *start_creating(const char *name, struct dentry *parent)
317 struct dentry *dentry;
320 if (!(debugfs_allow & DEBUGFS_ALLOW_API))
321 return ERR_PTR(-EPERM);
323 if (!debugfs_initialized())
324 return ERR_PTR(-ENOENT);
326 pr_debug("creating file '%s'\n", name);
331 error = simple_pin_fs(&debug_fs_type, &debugfs_mount,
332 &debugfs_mount_count);
334 pr_err("Unable to pin filesystem for file '%s'\n", name);
335 return ERR_PTR(error);
338 /* If the parent is not specified, we create it in the root.
339 * We need the root dentry to do this, which is in the super
340 * block. A pointer to that is in the struct vfsmount that we
344 parent = debugfs_mount->mnt_root;
346 inode_lock(d_inode(parent));
347 if (unlikely(IS_DEADDIR(d_inode(parent))))
348 dentry = ERR_PTR(-ENOENT);
350 dentry = lookup_one_len(name, parent, strlen(name));
351 if (!IS_ERR(dentry) && d_really_is_positive(dentry)) {
352 if (d_is_dir(dentry))
353 pr_err("Directory '%s' with parent '%s' already present!\n",
354 name, parent->d_name.name);
356 pr_err("File '%s' in directory '%s' already present!\n",
357 name, parent->d_name.name);
359 dentry = ERR_PTR(-EEXIST);
362 if (IS_ERR(dentry)) {
363 inode_unlock(d_inode(parent));
364 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
370 static struct dentry *failed_creating(struct dentry *dentry)
372 inode_unlock(d_inode(dentry->d_parent));
374 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
375 return ERR_PTR(-ENOMEM);
378 static struct dentry *end_creating(struct dentry *dentry)
380 inode_unlock(d_inode(dentry->d_parent));
384 static struct dentry *__debugfs_create_file(const char *name, umode_t mode,
385 struct dentry *parent, void *data,
386 const struct file_operations *proxy_fops,
387 const struct file_operations *real_fops)
389 struct dentry *dentry;
392 if (!(mode & S_IFMT))
394 BUG_ON(!S_ISREG(mode));
395 dentry = start_creating(name, parent);
400 if (!(debugfs_allow & DEBUGFS_ALLOW_API)) {
401 failed_creating(dentry);
402 return ERR_PTR(-EPERM);
405 inode = debugfs_get_inode(dentry->d_sb);
406 if (unlikely(!inode)) {
407 pr_err("out of free dentries, can not create file '%s'\n",
409 return failed_creating(dentry);
412 inode->i_mode = mode;
413 inode->i_private = data;
415 inode->i_op = &debugfs_file_inode_operations;
416 inode->i_fop = proxy_fops;
417 dentry->d_fsdata = (void *)((unsigned long)real_fops |
418 DEBUGFS_FSDATA_IS_REAL_FOPS_BIT);
420 d_instantiate(dentry, inode);
421 fsnotify_create(d_inode(dentry->d_parent), dentry);
422 return end_creating(dentry);
426 * debugfs_create_file - create a file in the debugfs filesystem
427 * @name: a pointer to a string containing the name of the file to create.
428 * @mode: the permission that the file should have.
429 * @parent: a pointer to the parent dentry for this file. This should be a
430 * directory dentry if set. If this parameter is NULL, then the
431 * file will be created in the root of the debugfs filesystem.
432 * @data: a pointer to something that the caller will want to get to later
433 * on. The inode.i_private pointer will point to this value on
435 * @fops: a pointer to a struct file_operations that should be used for
438 * This is the basic "create a file" function for debugfs. It allows for a
439 * wide range of flexibility in creating a file, or a directory (if you want
440 * to create a directory, the debugfs_create_dir() function is
441 * recommended to be used instead.)
443 * This function will return a pointer to a dentry if it succeeds. This
444 * pointer must be passed to the debugfs_remove() function when the file is
445 * to be removed (no automatic cleanup happens if your module is unloaded,
446 * you are responsible here.) If an error occurs, ERR_PTR(-ERROR) will be
449 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
452 struct dentry *debugfs_create_file(const char *name, umode_t mode,
453 struct dentry *parent, void *data,
454 const struct file_operations *fops)
457 return __debugfs_create_file(name, mode, parent, data,
458 fops ? &debugfs_full_proxy_file_operations :
459 &debugfs_noop_file_operations,
462 EXPORT_SYMBOL_GPL(debugfs_create_file);
465 * debugfs_create_file_unsafe - create a file in the debugfs filesystem
466 * @name: a pointer to a string containing the name of the file to create.
467 * @mode: the permission that the file should have.
468 * @parent: a pointer to the parent dentry for this file. This should be a
469 * directory dentry if set. If this parameter is NULL, then the
470 * file will be created in the root of the debugfs filesystem.
471 * @data: a pointer to something that the caller will want to get to later
472 * on. The inode.i_private pointer will point to this value on
474 * @fops: a pointer to a struct file_operations that should be used for
477 * debugfs_create_file_unsafe() is completely analogous to
478 * debugfs_create_file(), the only difference being that the fops
479 * handed it will not get protected against file removals by the
482 * It is your responsibility to protect your struct file_operation
483 * methods against file removals by means of debugfs_file_get()
484 * and debugfs_file_put(). ->open() is still protected by
487 * Any struct file_operations defined by means of
488 * DEFINE_DEBUGFS_ATTRIBUTE() is protected against file removals and
489 * thus, may be used here.
491 struct dentry *debugfs_create_file_unsafe(const char *name, umode_t mode,
492 struct dentry *parent, void *data,
493 const struct file_operations *fops)
496 return __debugfs_create_file(name, mode, parent, data,
497 fops ? &debugfs_open_proxy_file_operations :
498 &debugfs_noop_file_operations,
501 EXPORT_SYMBOL_GPL(debugfs_create_file_unsafe);
504 * debugfs_create_file_size - create a file in the debugfs filesystem
505 * @name: a pointer to a string containing the name of the file to create.
506 * @mode: the permission that the file should have.
507 * @parent: a pointer to the parent dentry for this file. This should be a
508 * directory dentry if set. If this parameter is NULL, then the
509 * file will be created in the root of the debugfs filesystem.
510 * @data: a pointer to something that the caller will want to get to later
511 * on. The inode.i_private pointer will point to this value on
513 * @fops: a pointer to a struct file_operations that should be used for
515 * @file_size: initial file size
517 * This is the basic "create a file" function for debugfs. It allows for a
518 * wide range of flexibility in creating a file, or a directory (if you want
519 * to create a directory, the debugfs_create_dir() function is
520 * recommended to be used instead.)
522 void debugfs_create_file_size(const char *name, umode_t mode,
523 struct dentry *parent, void *data,
524 const struct file_operations *fops,
527 struct dentry *de = debugfs_create_file(name, mode, parent, data, fops);
530 d_inode(de)->i_size = file_size;
532 EXPORT_SYMBOL_GPL(debugfs_create_file_size);
535 * debugfs_create_dir - create a directory in the debugfs filesystem
536 * @name: a pointer to a string containing the name of the directory to
538 * @parent: a pointer to the parent dentry for this file. This should be a
539 * directory dentry if set. If this parameter is NULL, then the
540 * directory will be created in the root of the debugfs filesystem.
542 * This function creates a directory in debugfs with the given name.
544 * This function will return a pointer to a dentry if it succeeds. This
545 * pointer must be passed to the debugfs_remove() function when the file is
546 * to be removed (no automatic cleanup happens if your module is unloaded,
547 * you are responsible here.) If an error occurs, ERR_PTR(-ERROR) will be
550 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
553 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
555 struct dentry *dentry = start_creating(name, parent);
561 if (!(debugfs_allow & DEBUGFS_ALLOW_API)) {
562 failed_creating(dentry);
563 return ERR_PTR(-EPERM);
566 inode = debugfs_get_inode(dentry->d_sb);
567 if (unlikely(!inode)) {
568 pr_err("out of free dentries, can not create directory '%s'\n",
570 return failed_creating(dentry);
573 inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
574 inode->i_op = &debugfs_dir_inode_operations;
575 inode->i_fop = &simple_dir_operations;
577 /* directory inodes start off with i_nlink == 2 (for "." entry) */
579 d_instantiate(dentry, inode);
580 inc_nlink(d_inode(dentry->d_parent));
581 fsnotify_mkdir(d_inode(dentry->d_parent), dentry);
582 return end_creating(dentry);
584 EXPORT_SYMBOL_GPL(debugfs_create_dir);
587 * debugfs_create_automount - create automount point in the debugfs filesystem
588 * @name: a pointer to a string containing the name of the file to create.
589 * @parent: a pointer to the parent dentry for this file. This should be a
590 * directory dentry if set. If this parameter is NULL, then the
591 * file will be created in the root of the debugfs filesystem.
592 * @f: function to be called when pathname resolution steps on that one.
593 * @data: opaque argument to pass to f().
595 * @f should return what ->d_automount() would.
597 struct dentry *debugfs_create_automount(const char *name,
598 struct dentry *parent,
599 debugfs_automount_t f,
602 struct dentry *dentry = start_creating(name, parent);
603 struct debugfs_fsdata *fsd;
609 fsd = kzalloc(sizeof(*fsd), GFP_KERNEL);
611 failed_creating(dentry);
612 return ERR_PTR(-ENOMEM);
617 if (!(debugfs_allow & DEBUGFS_ALLOW_API)) {
618 failed_creating(dentry);
620 return ERR_PTR(-EPERM);
623 inode = debugfs_get_inode(dentry->d_sb);
624 if (unlikely(!inode)) {
625 pr_err("out of free dentries, can not create automount '%s'\n",
628 return failed_creating(dentry);
631 make_empty_dir_inode(inode);
632 inode->i_flags |= S_AUTOMOUNT;
633 inode->i_private = data;
634 dentry->d_fsdata = fsd;
635 /* directory inodes start off with i_nlink == 2 (for "." entry) */
637 d_instantiate(dentry, inode);
638 inc_nlink(d_inode(dentry->d_parent));
639 fsnotify_mkdir(d_inode(dentry->d_parent), dentry);
640 return end_creating(dentry);
642 EXPORT_SYMBOL(debugfs_create_automount);
645 * debugfs_create_symlink- create a symbolic link in the debugfs filesystem
646 * @name: a pointer to a string containing the name of the symbolic link to
648 * @parent: a pointer to the parent dentry for this symbolic link. This
649 * should be a directory dentry if set. If this parameter is NULL,
650 * then the symbolic link will be created in the root of the debugfs
652 * @target: a pointer to a string containing the path to the target of the
655 * This function creates a symbolic link with the given name in debugfs that
656 * links to the given target path.
658 * This function will return a pointer to a dentry if it succeeds. This
659 * pointer must be passed to the debugfs_remove() function when the symbolic
660 * link is to be removed (no automatic cleanup happens if your module is
661 * unloaded, you are responsible here.) If an error occurs, ERR_PTR(-ERROR)
664 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
667 struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
670 struct dentry *dentry;
672 char *link = kstrdup(target, GFP_KERNEL);
674 return ERR_PTR(-ENOMEM);
676 dentry = start_creating(name, parent);
677 if (IS_ERR(dentry)) {
682 inode = debugfs_get_inode(dentry->d_sb);
683 if (unlikely(!inode)) {
684 pr_err("out of free dentries, can not create symlink '%s'\n",
687 return failed_creating(dentry);
689 inode->i_mode = S_IFLNK | S_IRWXUGO;
690 inode->i_op = &debugfs_symlink_inode_operations;
691 inode->i_link = link;
692 d_instantiate(dentry, inode);
693 return end_creating(dentry);
695 EXPORT_SYMBOL_GPL(debugfs_create_symlink);
697 static void __debugfs_file_removed(struct dentry *dentry)
699 struct debugfs_fsdata *fsd;
702 * Paired with the closing smp_mb() implied by a successful
703 * cmpxchg() in debugfs_file_get(): either
704 * debugfs_file_get() must see a dead dentry or we must see a
705 * debugfs_fsdata instance at ->d_fsdata here (or both).
708 fsd = READ_ONCE(dentry->d_fsdata);
709 if ((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT)
711 if (!refcount_dec_and_test(&fsd->active_users))
712 wait_for_completion(&fsd->active_users_drained);
715 static void remove_one(struct dentry *victim)
717 if (d_is_reg(victim))
718 __debugfs_file_removed(victim);
719 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
723 * debugfs_remove - recursively removes a directory
724 * @dentry: a pointer to a the dentry of the directory to be removed. If this
725 * parameter is NULL or an error value, nothing will be done.
727 * This function recursively removes a directory tree in debugfs that
728 * was previously created with a call to another debugfs function
729 * (like debugfs_create_file() or variants thereof.)
731 * This function is required to be called in order for the file to be
732 * removed, no automatic cleanup of files will happen when a module is
733 * removed, you are responsible here.
735 void debugfs_remove(struct dentry *dentry)
737 if (IS_ERR_OR_NULL(dentry))
740 simple_pin_fs(&debug_fs_type, &debugfs_mount, &debugfs_mount_count);
741 simple_recursive_removal(dentry, remove_one);
742 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
744 EXPORT_SYMBOL_GPL(debugfs_remove);
747 * debugfs_lookup_and_remove - lookup a directory or file and recursively remove it
748 * @name: a pointer to a string containing the name of the item to look up.
749 * @parent: a pointer to the parent dentry of the item.
751 * This is the equlivant of doing something like
752 * debugfs_remove(debugfs_lookup(..)) but with the proper reference counting
753 * handled for the directory being looked up.
755 void debugfs_lookup_and_remove(const char *name, struct dentry *parent)
757 struct dentry *dentry;
759 dentry = debugfs_lookup(name, parent);
763 debugfs_remove(dentry);
766 EXPORT_SYMBOL_GPL(debugfs_lookup_and_remove);
769 * debugfs_rename - rename a file/directory in the debugfs filesystem
770 * @old_dir: a pointer to the parent dentry for the renamed object. This
771 * should be a directory dentry.
772 * @old_dentry: dentry of an object to be renamed.
773 * @new_dir: a pointer to the parent dentry where the object should be
774 * moved. This should be a directory dentry.
775 * @new_name: a pointer to a string containing the target name.
777 * This function renames a file/directory in debugfs. The target must not
778 * exist for rename to succeed.
780 * This function will return a pointer to old_dentry (which is updated to
781 * reflect renaming) if it succeeds. If an error occurs, %NULL will be
784 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
787 struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
788 struct dentry *new_dir, const char *new_name)
791 struct dentry *dentry = NULL, *trap;
792 struct name_snapshot old_name;
798 if (IS_ERR_OR_NULL(old_dentry))
801 trap = lock_rename(new_dir, old_dir);
802 /* Source or destination directories don't exist? */
803 if (d_really_is_negative(old_dir) || d_really_is_negative(new_dir))
805 /* Source does not exist, cyclic rename, or mountpoint? */
806 if (d_really_is_negative(old_dentry) || old_dentry == trap ||
807 d_mountpoint(old_dentry))
809 dentry = lookup_one_len(new_name, new_dir, strlen(new_name));
810 /* Lookup failed, cyclic rename or target exists? */
811 if (IS_ERR(dentry) || dentry == trap || d_really_is_positive(dentry))
814 take_dentry_name_snapshot(&old_name, old_dentry);
816 error = simple_rename(d_inode(old_dir), old_dentry, d_inode(new_dir),
819 release_dentry_name_snapshot(&old_name);
822 d_move(old_dentry, dentry);
823 fsnotify_move(d_inode(old_dir), d_inode(new_dir), &old_name.name,
824 d_is_dir(old_dentry),
826 release_dentry_name_snapshot(&old_name);
827 unlock_rename(new_dir, old_dir);
831 if (dentry && !IS_ERR(dentry))
833 unlock_rename(new_dir, old_dir);
836 return ERR_PTR(-EINVAL);
838 EXPORT_SYMBOL_GPL(debugfs_rename);
841 * debugfs_initialized - Tells whether debugfs has been registered
843 bool debugfs_initialized(void)
845 return debugfs_registered;
847 EXPORT_SYMBOL_GPL(debugfs_initialized);
849 static int __init debugfs_kernel(char *str)
852 if (!strcmp(str, "on"))
853 debugfs_allow = DEBUGFS_ALLOW_API | DEBUGFS_ALLOW_MOUNT;
854 else if (!strcmp(str, "no-mount"))
855 debugfs_allow = DEBUGFS_ALLOW_API;
856 else if (!strcmp(str, "off"))
862 early_param("debugfs", debugfs_kernel);
863 static int __init debugfs_init(void)
867 if (!(debugfs_allow & DEBUGFS_ALLOW_MOUNT))
870 retval = sysfs_create_mount_point(kernel_kobj, "debug");
874 retval = register_filesystem(&debug_fs_type);
876 sysfs_remove_mount_point(kernel_kobj, "debug");
878 debugfs_registered = true;
882 core_initcall(debugfs_init);