inode.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. /*
  2. * inode.c - part of debugfs, a tiny little debug file system
  3. *
  4. * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
  5. * Copyright (C) 2004 IBM Inc.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License version
  9. * 2 as published by the Free Software Foundation.
  10. *
  11. * debugfs is for people to use instead of /proc or /sys.
  12. * See Documentation/DocBook/kernel-api for more details.
  13. *
  14. */
  15. #include <linux/module.h>
  16. #include <linux/fs.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. #define DEBUGFS_DEFAULT_MODE 0755
  30. static struct vfsmount *debugfs_mount;
  31. static int debugfs_mount_count;
  32. static bool debugfs_registered;
  33. static struct inode *debugfs_get_inode(struct super_block *sb, umode_t mode, dev_t dev,
  34. void *data, const struct file_operations *fops)
  35. {
  36. struct inode *inode = new_inode(sb);
  37. if (inode) {
  38. inode->i_ino = get_next_ino();
  39. inode->i_mode = mode;
  40. inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
  41. switch (mode & S_IFMT) {
  42. default:
  43. init_special_inode(inode, mode, dev);
  44. break;
  45. case S_IFREG:
  46. inode->i_fop = fops ? fops : &debugfs_file_operations;
  47. inode->i_private = data;
  48. break;
  49. case S_IFLNK:
  50. inode->i_op = &debugfs_link_operations;
  51. inode->i_fop = fops;
  52. inode->i_private = data;
  53. break;
  54. case S_IFDIR:
  55. inode->i_op = &simple_dir_inode_operations;
  56. inode->i_fop = fops ? fops : &simple_dir_operations;
  57. inode->i_private = data;
  58. /* directory inodes start off with i_nlink == 2
  59. * (for "." entry) */
  60. inc_nlink(inode);
  61. break;
  62. }
  63. }
  64. return inode;
  65. }
  66. /* SMP-safe */
  67. static int debugfs_mknod(struct inode *dir, struct dentry *dentry,
  68. umode_t mode, dev_t dev, void *data,
  69. const struct file_operations *fops)
  70. {
  71. struct inode *inode;
  72. int error = -EPERM;
  73. if (dentry->d_inode)
  74. return -EEXIST;
  75. inode = debugfs_get_inode(dir->i_sb, mode, dev, data, fops);
  76. if (inode) {
  77. d_instantiate(dentry, inode);
  78. dget(dentry);
  79. error = 0;
  80. }
  81. return error;
  82. }
  83. static int debugfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode,
  84. void *data, const struct file_operations *fops)
  85. {
  86. int res;
  87. mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR;
  88. res = debugfs_mknod(dir, dentry, mode, 0, data, fops);
  89. if (!res) {
  90. inc_nlink(dir);
  91. fsnotify_mkdir(dir, dentry);
  92. }
  93. return res;
  94. }
  95. static int debugfs_link(struct inode *dir, struct dentry *dentry, umode_t mode,
  96. void *data, const struct file_operations *fops)
  97. {
  98. mode = (mode & S_IALLUGO) | S_IFLNK;
  99. return debugfs_mknod(dir, dentry, mode, 0, data, fops);
  100. }
  101. static int debugfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
  102. void *data, const struct file_operations *fops)
  103. {
  104. int res;
  105. mode = (mode & S_IALLUGO) | S_IFREG;
  106. res = debugfs_mknod(dir, dentry, mode, 0, data, fops);
  107. if (!res)
  108. fsnotify_create(dir, dentry);
  109. return res;
  110. }
  111. static inline int debugfs_positive(struct dentry *dentry)
  112. {
  113. return dentry->d_inode && !d_unhashed(dentry);
  114. }
  115. struct debugfs_mount_opts {
  116. uid_t uid;
  117. gid_t gid;
  118. umode_t mode;
  119. };
  120. enum {
  121. Opt_uid,
  122. Opt_gid,
  123. Opt_mode,
  124. Opt_err
  125. };
  126. static const match_table_t tokens = {
  127. {Opt_uid, "uid=%u"},
  128. {Opt_gid, "gid=%u"},
  129. {Opt_mode, "mode=%o"},
  130. {Opt_err, NULL}
  131. };
  132. struct debugfs_fs_info {
  133. struct debugfs_mount_opts mount_opts;
  134. };
  135. static int debugfs_parse_options(char *data, struct debugfs_mount_opts *opts)
  136. {
  137. substring_t args[MAX_OPT_ARGS];
  138. int option;
  139. int token;
  140. char *p;
  141. opts->mode = DEBUGFS_DEFAULT_MODE;
  142. while ((p = strsep(&data, ",")) != NULL) {
  143. if (!*p)
  144. continue;
  145. token = match_token(p, tokens, args);
  146. switch (token) {
  147. case Opt_uid:
  148. if (match_int(&args[0], &option))
  149. return -EINVAL;
  150. opts->uid = option;
  151. break;
  152. case Opt_gid:
  153. if (match_octal(&args[0], &option))
  154. return -EINVAL;
  155. opts->gid = option;
  156. break;
  157. case Opt_mode:
  158. if (match_octal(&args[0], &option))
  159. return -EINVAL;
  160. opts->mode = option & S_IALLUGO;
  161. break;
  162. /*
  163. * We might like to report bad mount options here;
  164. * but traditionally debugfs has ignored all mount options
  165. */
  166. }
  167. }
  168. return 0;
  169. }
  170. static int debugfs_apply_options(struct super_block *sb)
  171. {
  172. struct debugfs_fs_info *fsi = sb->s_fs_info;
  173. struct inode *inode = sb->s_root->d_inode;
  174. struct debugfs_mount_opts *opts = &fsi->mount_opts;
  175. inode->i_mode &= ~S_IALLUGO;
  176. inode->i_mode |= opts->mode;
  177. inode->i_uid = opts->uid;
  178. inode->i_gid = opts->gid;
  179. return 0;
  180. }
  181. static int debugfs_remount(struct super_block *sb, int *flags, char *data)
  182. {
  183. int err;
  184. struct debugfs_fs_info *fsi = sb->s_fs_info;
  185. err = debugfs_parse_options(data, &fsi->mount_opts);
  186. if (err)
  187. goto fail;
  188. debugfs_apply_options(sb);
  189. fail:
  190. return err;
  191. }
  192. static int debugfs_show_options(struct seq_file *m, struct dentry *root)
  193. {
  194. struct debugfs_fs_info *fsi = root->d_sb->s_fs_info;
  195. struct debugfs_mount_opts *opts = &fsi->mount_opts;
  196. if (opts->uid != 0)
  197. seq_printf(m, ",uid=%u", opts->uid);
  198. if (opts->gid != 0)
  199. seq_printf(m, ",gid=%u", opts->gid);
  200. if (opts->mode != DEBUGFS_DEFAULT_MODE)
  201. seq_printf(m, ",mode=%o", opts->mode);
  202. return 0;
  203. }
  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. };
  209. static int debug_fill_super(struct super_block *sb, void *data, int silent)
  210. {
  211. static struct tree_descr debug_files[] = {{""}};
  212. struct debugfs_fs_info *fsi;
  213. int err;
  214. save_mount_options(sb, data);
  215. fsi = kzalloc(sizeof(struct debugfs_fs_info), GFP_KERNEL);
  216. sb->s_fs_info = fsi;
  217. if (!fsi) {
  218. err = -ENOMEM;
  219. goto fail;
  220. }
  221. err = debugfs_parse_options(data, &fsi->mount_opts);
  222. if (err)
  223. goto fail;
  224. err = simple_fill_super(sb, DEBUGFS_MAGIC, debug_files);
  225. if (err)
  226. goto fail;
  227. sb->s_op = &debugfs_super_operations;
  228. debugfs_apply_options(sb);
  229. return 0;
  230. fail:
  231. kfree(fsi);
  232. sb->s_fs_info = NULL;
  233. return err;
  234. }
  235. static struct dentry *debug_mount(struct file_system_type *fs_type,
  236. int flags, const char *dev_name,
  237. void *data)
  238. {
  239. return mount_single(fs_type, flags, data, debug_fill_super);
  240. }
  241. static struct file_system_type debug_fs_type = {
  242. .owner = THIS_MODULE,
  243. .name = "debugfs",
  244. .mount = debug_mount,
  245. .kill_sb = kill_litter_super,
  246. };
  247. struct dentry *__create_file(const char *name, umode_t mode,
  248. struct dentry *parent, void *data,
  249. const struct file_operations *fops)
  250. {
  251. struct dentry *dentry = NULL;
  252. int error;
  253. pr_debug("debugfs: creating file '%s'\n",name);
  254. error = simple_pin_fs(&debug_fs_type, &debugfs_mount,
  255. &debugfs_mount_count);
  256. if (error)
  257. goto exit;
  258. /* If the parent is not specified, we create it in the root.
  259. * We need the root dentry to do this, which is in the super
  260. * block. A pointer to that is in the struct vfsmount that we
  261. * have around.
  262. */
  263. if (!parent)
  264. parent = debugfs_mount->mnt_root;
  265. dentry = NULL;
  266. mutex_lock(&parent->d_inode->i_mutex);
  267. dentry = lookup_one_len(name, parent, strlen(name));
  268. if (!IS_ERR(dentry)) {
  269. switch (mode & S_IFMT) {
  270. case S_IFDIR:
  271. error = debugfs_mkdir(parent->d_inode, dentry, mode,
  272. data, fops);
  273. break;
  274. case S_IFLNK:
  275. error = debugfs_link(parent->d_inode, dentry, mode,
  276. data, fops);
  277. break;
  278. default:
  279. error = debugfs_create(parent->d_inode, dentry, mode,
  280. data, fops);
  281. break;
  282. }
  283. dput(dentry);
  284. } else
  285. error = PTR_ERR(dentry);
  286. mutex_unlock(&parent->d_inode->i_mutex);
  287. if (error) {
  288. dentry = NULL;
  289. simple_release_fs(&debugfs_mount, &debugfs_mount_count);
  290. }
  291. exit:
  292. return dentry;
  293. }
  294. /**
  295. * debugfs_create_file - create a file in the debugfs filesystem
  296. * @name: a pointer to a string containing the name of the file to create.
  297. * @mode: the permission that the file should have.
  298. * @parent: a pointer to the parent dentry for this file. This should be a
  299. * directory dentry if set. If this paramater is NULL, then the
  300. * file will be created in the root of the debugfs filesystem.
  301. * @data: a pointer to something that the caller will want to get to later
  302. * on. The inode.i_private pointer will point to this value on
  303. * the open() call.
  304. * @fops: a pointer to a struct file_operations that should be used for
  305. * this file.
  306. *
  307. * This is the basic "create a file" function for debugfs. It allows for a
  308. * wide range of flexibility in creating a file, or a directory (if you want
  309. * to create a directory, the debugfs_create_dir() function is
  310. * recommended to be used instead.)
  311. *
  312. * This function will return a pointer to a dentry if it succeeds. This
  313. * pointer must be passed to the debugfs_remove() function when the file is
  314. * to be removed (no automatic cleanup happens if your module is unloaded,
  315. * you are responsible here.) If an error occurs, %NULL will be returned.
  316. *
  317. * If debugfs is not enabled in the kernel, the value -%ENODEV will be
  318. * returned.
  319. */
  320. struct dentry *debugfs_create_file(const char *name, umode_t mode,
  321. struct dentry *parent, void *data,
  322. const struct file_operations *fops)
  323. {
  324. switch (mode & S_IFMT) {
  325. case S_IFREG:
  326. case 0:
  327. break;
  328. default:
  329. BUG();
  330. }
  331. return __create_file(name, mode, parent, data, fops);
  332. }
  333. EXPORT_SYMBOL_GPL(debugfs_create_file);
  334. /**
  335. * debugfs_create_dir - create a directory in the debugfs filesystem
  336. * @name: a pointer to a string containing the name of the directory to
  337. * create.
  338. * @parent: a pointer to the parent dentry for this file. This should be a
  339. * directory dentry if set. If this paramater is NULL, then the
  340. * directory will be created in the root of the debugfs filesystem.
  341. *
  342. * This function creates a directory in debugfs with the given name.
  343. *
  344. * This function will return a pointer to a dentry if it succeeds. This
  345. * pointer must be passed to the debugfs_remove() function when the file is
  346. * to be removed (no automatic cleanup happens if your module is unloaded,
  347. * you are responsible here.) If an error occurs, %NULL will be returned.
  348. *
  349. * If debugfs is not enabled in the kernel, the value -%ENODEV will be
  350. * returned.
  351. */
  352. struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
  353. {
  354. return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
  355. parent, NULL, NULL);
  356. }
  357. EXPORT_SYMBOL_GPL(debugfs_create_dir);
  358. /**
  359. * debugfs_create_symlink- create a symbolic link in the debugfs filesystem
  360. * @name: a pointer to a string containing the name of the symbolic link to
  361. * create.
  362. * @parent: a pointer to the parent dentry for this symbolic link. This
  363. * should be a directory dentry if set. If this paramater is NULL,
  364. * then the symbolic link will be created in the root of the debugfs
  365. * filesystem.
  366. * @target: a pointer to a string containing the path to the target of the
  367. * symbolic link.
  368. *
  369. * This function creates a symbolic link with the given name in debugfs that
  370. * links to the given target path.
  371. *
  372. * This function will return a pointer to a dentry if it succeeds. This
  373. * pointer must be passed to the debugfs_remove() function when the symbolic
  374. * link is to be removed (no automatic cleanup happens if your module is
  375. * unloaded, you are responsible here.) If an error occurs, %NULL will be
  376. * returned.
  377. *
  378. * If debugfs is not enabled in the kernel, the value -%ENODEV will be
  379. * returned.
  380. */
  381. struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
  382. const char *target)
  383. {
  384. struct dentry *result;
  385. char *link;
  386. link = kstrdup(target, GFP_KERNEL);
  387. if (!link)
  388. return NULL;
  389. result = __create_file(name, S_IFLNK | S_IRWXUGO, parent, link, NULL);
  390. if (!result)
  391. kfree(link);
  392. return result;
  393. }
  394. EXPORT_SYMBOL_GPL(debugfs_create_symlink);
  395. static int __debugfs_remove(struct dentry *dentry, struct dentry *parent)
  396. {
  397. int ret = 0;
  398. if (debugfs_positive(dentry)) {
  399. if (dentry->d_inode) {
  400. dget(dentry);
  401. switch (dentry->d_inode->i_mode & S_IFMT) {
  402. case S_IFDIR:
  403. ret = simple_rmdir(parent->d_inode, dentry);
  404. break;
  405. case S_IFLNK:
  406. kfree(dentry->d_inode->i_private);
  407. /* fall through */
  408. default:
  409. simple_unlink(parent->d_inode, dentry);
  410. break;
  411. }
  412. if (!ret)
  413. d_delete(dentry);
  414. dput(dentry);
  415. }
  416. }
  417. return ret;
  418. }
  419. /**
  420. * debugfs_remove - removes a file or directory from the debugfs filesystem
  421. * @dentry: a pointer to a the dentry of the file or directory to be
  422. * removed.
  423. *
  424. * This function removes a file or directory in debugfs that was previously
  425. * created with a call to another debugfs function (like
  426. * debugfs_create_file() or variants thereof.)
  427. *
  428. * This function is required to be called in order for the file to be
  429. * removed, no automatic cleanup of files will happen when a module is
  430. * removed, you are responsible here.
  431. */
  432. void debugfs_remove(struct dentry *dentry)
  433. {
  434. struct dentry *parent;
  435. int ret;
  436. if (!dentry)
  437. return;
  438. parent = dentry->d_parent;
  439. if (!parent || !parent->d_inode)
  440. return;
  441. mutex_lock(&parent->d_inode->i_mutex);
  442. ret = __debugfs_remove(dentry, parent);
  443. mutex_unlock(&parent->d_inode->i_mutex);
  444. if (!ret)
  445. simple_release_fs(&debugfs_mount, &debugfs_mount_count);
  446. }
  447. EXPORT_SYMBOL_GPL(debugfs_remove);
  448. /**
  449. * debugfs_remove_recursive - recursively removes a directory
  450. * @dentry: a pointer to a the dentry of the directory to be removed.
  451. *
  452. * This function recursively removes a directory tree in debugfs that
  453. * was previously created with a call to another debugfs function
  454. * (like debugfs_create_file() or variants thereof.)
  455. *
  456. * This function is required to be called in order for the file to be
  457. * removed, no automatic cleanup of files will happen when a module is
  458. * removed, you are responsible here.
  459. */
  460. void debugfs_remove_recursive(struct dentry *dentry)
  461. {
  462. struct dentry *child;
  463. struct dentry *parent;
  464. if (!dentry)
  465. return;
  466. parent = dentry->d_parent;
  467. if (!parent || !parent->d_inode)
  468. return;
  469. parent = dentry;
  470. mutex_lock(&parent->d_inode->i_mutex);
  471. while (1) {
  472. /*
  473. * When all dentries under "parent" has been removed,
  474. * walk up the tree until we reach our starting point.
  475. */
  476. if (list_empty(&parent->d_subdirs)) {
  477. mutex_unlock(&parent->d_inode->i_mutex);
  478. if (parent == dentry)
  479. break;
  480. parent = parent->d_parent;
  481. mutex_lock(&parent->d_inode->i_mutex);
  482. }
  483. child = list_entry(parent->d_subdirs.next, struct dentry,
  484. d_u.d_child);
  485. next_sibling:
  486. /*
  487. * If "child" isn't empty, walk down the tree and
  488. * remove all its descendants first.
  489. */
  490. if (!list_empty(&child->d_subdirs)) {
  491. mutex_unlock(&parent->d_inode->i_mutex);
  492. parent = child;
  493. mutex_lock(&parent->d_inode->i_mutex);
  494. continue;
  495. }
  496. __debugfs_remove(child, parent);
  497. if (parent->d_subdirs.next == &child->d_u.d_child) {
  498. /*
  499. * Try the next sibling.
  500. */
  501. if (child->d_u.d_child.next != &parent->d_subdirs) {
  502. child = list_entry(child->d_u.d_child.next,
  503. struct dentry,
  504. d_u.d_child);
  505. goto next_sibling;
  506. }
  507. /*
  508. * Avoid infinite loop if we fail to remove
  509. * one dentry.
  510. */
  511. mutex_unlock(&parent->d_inode->i_mutex);
  512. break;
  513. }
  514. simple_release_fs(&debugfs_mount, &debugfs_mount_count);
  515. }
  516. parent = dentry->d_parent;
  517. mutex_lock(&parent->d_inode->i_mutex);
  518. __debugfs_remove(dentry, parent);
  519. mutex_unlock(&parent->d_inode->i_mutex);
  520. simple_release_fs(&debugfs_mount, &debugfs_mount_count);
  521. }
  522. EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
  523. /**
  524. * debugfs_rename - rename a file/directory in the debugfs filesystem
  525. * @old_dir: a pointer to the parent dentry for the renamed object. This
  526. * should be a directory dentry.
  527. * @old_dentry: dentry of an object to be renamed.
  528. * @new_dir: a pointer to the parent dentry where the object should be
  529. * moved. This should be a directory dentry.
  530. * @new_name: a pointer to a string containing the target name.
  531. *
  532. * This function renames a file/directory in debugfs. The target must not
  533. * exist for rename to succeed.
  534. *
  535. * This function will return a pointer to old_dentry (which is updated to
  536. * reflect renaming) if it succeeds. If an error occurs, %NULL will be
  537. * returned.
  538. *
  539. * If debugfs is not enabled in the kernel, the value -%ENODEV will be
  540. * returned.
  541. */
  542. struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
  543. struct dentry *new_dir, const char *new_name)
  544. {
  545. int error;
  546. struct dentry *dentry = NULL, *trap;
  547. const char *old_name;
  548. trap = lock_rename(new_dir, old_dir);
  549. /* Source or destination directories don't exist? */
  550. if (!old_dir->d_inode || !new_dir->d_inode)
  551. goto exit;
  552. /* Source does not exist, cyclic rename, or mountpoint? */
  553. if (!old_dentry->d_inode || old_dentry == trap ||
  554. d_mountpoint(old_dentry))
  555. goto exit;
  556. dentry = lookup_one_len(new_name, new_dir, strlen(new_name));
  557. /* Lookup failed, cyclic rename or target exists? */
  558. if (IS_ERR(dentry) || dentry == trap || dentry->d_inode)
  559. goto exit;
  560. old_name = fsnotify_oldname_init(old_dentry->d_name.name);
  561. error = simple_rename(old_dir->d_inode, old_dentry, new_dir->d_inode,
  562. dentry);
  563. if (error) {
  564. fsnotify_oldname_free(old_name);
  565. goto exit;
  566. }
  567. d_move(old_dentry, dentry);
  568. fsnotify_move(old_dir->d_inode, new_dir->d_inode, old_name,
  569. S_ISDIR(old_dentry->d_inode->i_mode),
  570. NULL, old_dentry);
  571. fsnotify_oldname_free(old_name);
  572. unlock_rename(new_dir, old_dir);
  573. dput(dentry);
  574. return old_dentry;
  575. exit:
  576. if (dentry && !IS_ERR(dentry))
  577. dput(dentry);
  578. unlock_rename(new_dir, old_dir);
  579. return NULL;
  580. }
  581. EXPORT_SYMBOL_GPL(debugfs_rename);
  582. /**
  583. * debugfs_initialized - Tells whether debugfs has been registered
  584. */
  585. bool debugfs_initialized(void)
  586. {
  587. return debugfs_registered;
  588. }
  589. EXPORT_SYMBOL_GPL(debugfs_initialized);
  590. static struct kobject *debug_kobj;
  591. static int __init debugfs_init(void)
  592. {
  593. int retval;
  594. debug_kobj = kobject_create_and_add("debug", kernel_kobj);
  595. if (!debug_kobj)
  596. return -EINVAL;
  597. retval = register_filesystem(&debug_fs_type);
  598. if (retval)
  599. kobject_put(debug_kobj);
  600. else
  601. debugfs_registered = true;
  602. return retval;
  603. }
  604. core_initcall(debugfs_init);