inode.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  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. static int debugfs_create_by_name(const char *name, umode_t mode,
  248. struct dentry *parent,
  249. struct dentry **dentry,
  250. void *data,
  251. const struct file_operations *fops)
  252. {
  253. int error = 0;
  254. /* If the parent is not specified, we create it in the root.
  255. * We need the root dentry to do this, which is in the super
  256. * block. A pointer to that is in the struct vfsmount that we
  257. * have around.
  258. */
  259. if (!parent)
  260. parent = debugfs_mount->mnt_root;
  261. *dentry = NULL;
  262. mutex_lock(&parent->d_inode->i_mutex);
  263. *dentry = lookup_one_len(name, parent, strlen(name));
  264. if (!IS_ERR(*dentry)) {
  265. switch (mode & S_IFMT) {
  266. case S_IFDIR:
  267. error = debugfs_mkdir(parent->d_inode, *dentry, mode,
  268. data, fops);
  269. break;
  270. case S_IFLNK:
  271. error = debugfs_link(parent->d_inode, *dentry, mode,
  272. data, fops);
  273. break;
  274. default:
  275. error = debugfs_create(parent->d_inode, *dentry, mode,
  276. data, fops);
  277. break;
  278. }
  279. dput(*dentry);
  280. } else
  281. error = PTR_ERR(*dentry);
  282. mutex_unlock(&parent->d_inode->i_mutex);
  283. return error;
  284. }
  285. /**
  286. * debugfs_create_file - create a file in the debugfs filesystem
  287. * @name: a pointer to a string containing the name of the file to create.
  288. * @mode: the permission that the file should have.
  289. * @parent: a pointer to the parent dentry for this file. This should be a
  290. * directory dentry if set. If this paramater is NULL, then the
  291. * file will be created in the root of the debugfs filesystem.
  292. * @data: a pointer to something that the caller will want to get to later
  293. * on. The inode.i_private pointer will point to this value on
  294. * the open() call.
  295. * @fops: a pointer to a struct file_operations that should be used for
  296. * this file.
  297. *
  298. * This is the basic "create a file" function for debugfs. It allows for a
  299. * wide range of flexibility in creating a file, or a directory (if you want
  300. * to create a directory, the debugfs_create_dir() function is
  301. * recommended to be used instead.)
  302. *
  303. * This function will return a pointer to a dentry if it succeeds. This
  304. * pointer must be passed to the debugfs_remove() function when the file is
  305. * to be removed (no automatic cleanup happens if your module is unloaded,
  306. * you are responsible here.) If an error occurs, %NULL will be returned.
  307. *
  308. * If debugfs is not enabled in the kernel, the value -%ENODEV will be
  309. * returned.
  310. */
  311. struct dentry *debugfs_create_file(const char *name, umode_t mode,
  312. struct dentry *parent, void *data,
  313. const struct file_operations *fops)
  314. {
  315. struct dentry *dentry = NULL;
  316. int error;
  317. pr_debug("debugfs: creating file '%s'\n",name);
  318. error = simple_pin_fs(&debug_fs_type, &debugfs_mount,
  319. &debugfs_mount_count);
  320. if (error)
  321. goto exit;
  322. error = debugfs_create_by_name(name, mode, parent, &dentry,
  323. data, fops);
  324. if (error) {
  325. dentry = NULL;
  326. simple_release_fs(&debugfs_mount, &debugfs_mount_count);
  327. goto exit;
  328. }
  329. exit:
  330. return dentry;
  331. }
  332. EXPORT_SYMBOL_GPL(debugfs_create_file);
  333. /**
  334. * debugfs_create_dir - create a directory in the debugfs filesystem
  335. * @name: a pointer to a string containing the name of the directory to
  336. * create.
  337. * @parent: a pointer to the parent dentry for this file. This should be a
  338. * directory dentry if set. If this paramater is NULL, then the
  339. * directory will be created in the root of the debugfs filesystem.
  340. *
  341. * This function creates a directory in debugfs with the given name.
  342. *
  343. * This function will return a pointer to a dentry if it succeeds. This
  344. * pointer must be passed to the debugfs_remove() function when the file is
  345. * to be removed (no automatic cleanup happens if your module is unloaded,
  346. * you are responsible here.) If an error occurs, %NULL will be returned.
  347. *
  348. * If debugfs is not enabled in the kernel, the value -%ENODEV will be
  349. * returned.
  350. */
  351. struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
  352. {
  353. return debugfs_create_file(name,
  354. 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 = debugfs_create_file(name, S_IFLNK | S_IRWXUGO, parent, link,
  390. NULL);
  391. if (!result)
  392. kfree(link);
  393. return result;
  394. }
  395. EXPORT_SYMBOL_GPL(debugfs_create_symlink);
  396. static int __debugfs_remove(struct dentry *dentry, struct dentry *parent)
  397. {
  398. int ret = 0;
  399. if (debugfs_positive(dentry)) {
  400. if (dentry->d_inode) {
  401. dget(dentry);
  402. switch (dentry->d_inode->i_mode & S_IFMT) {
  403. case S_IFDIR:
  404. ret = simple_rmdir(parent->d_inode, dentry);
  405. break;
  406. case S_IFLNK:
  407. kfree(dentry->d_inode->i_private);
  408. /* fall through */
  409. default:
  410. simple_unlink(parent->d_inode, dentry);
  411. break;
  412. }
  413. if (!ret)
  414. d_delete(dentry);
  415. dput(dentry);
  416. }
  417. }
  418. return ret;
  419. }
  420. /**
  421. * debugfs_remove - removes a file or directory from the debugfs filesystem
  422. * @dentry: a pointer to a the dentry of the file or directory to be
  423. * removed.
  424. *
  425. * This function removes a file or directory in debugfs that was previously
  426. * created with a call to another debugfs function (like
  427. * debugfs_create_file() or variants thereof.)
  428. *
  429. * This function is required to be called in order for the file to be
  430. * removed, no automatic cleanup of files will happen when a module is
  431. * removed, you are responsible here.
  432. */
  433. void debugfs_remove(struct dentry *dentry)
  434. {
  435. struct dentry *parent;
  436. int ret;
  437. if (!dentry)
  438. return;
  439. parent = dentry->d_parent;
  440. if (!parent || !parent->d_inode)
  441. return;
  442. mutex_lock(&parent->d_inode->i_mutex);
  443. ret = __debugfs_remove(dentry, parent);
  444. mutex_unlock(&parent->d_inode->i_mutex);
  445. if (!ret)
  446. simple_release_fs(&debugfs_mount, &debugfs_mount_count);
  447. }
  448. EXPORT_SYMBOL_GPL(debugfs_remove);
  449. /**
  450. * debugfs_remove_recursive - recursively removes a directory
  451. * @dentry: a pointer to a the dentry of the directory to be removed.
  452. *
  453. * This function recursively removes a directory tree in debugfs that
  454. * was previously created with a call to another debugfs function
  455. * (like debugfs_create_file() or variants thereof.)
  456. *
  457. * This function is required to be called in order for the file to be
  458. * removed, no automatic cleanup of files will happen when a module is
  459. * removed, you are responsible here.
  460. */
  461. void debugfs_remove_recursive(struct dentry *dentry)
  462. {
  463. struct dentry *child;
  464. struct dentry *parent;
  465. if (!dentry)
  466. return;
  467. parent = dentry->d_parent;
  468. if (!parent || !parent->d_inode)
  469. return;
  470. parent = dentry;
  471. mutex_lock(&parent->d_inode->i_mutex);
  472. while (1) {
  473. /*
  474. * When all dentries under "parent" has been removed,
  475. * walk up the tree until we reach our starting point.
  476. */
  477. if (list_empty(&parent->d_subdirs)) {
  478. mutex_unlock(&parent->d_inode->i_mutex);
  479. if (parent == dentry)
  480. break;
  481. parent = parent->d_parent;
  482. mutex_lock(&parent->d_inode->i_mutex);
  483. }
  484. child = list_entry(parent->d_subdirs.next, struct dentry,
  485. d_u.d_child);
  486. next_sibling:
  487. /*
  488. * If "child" isn't empty, walk down the tree and
  489. * remove all its descendants first.
  490. */
  491. if (!list_empty(&child->d_subdirs)) {
  492. mutex_unlock(&parent->d_inode->i_mutex);
  493. parent = child;
  494. mutex_lock(&parent->d_inode->i_mutex);
  495. continue;
  496. }
  497. __debugfs_remove(child, parent);
  498. if (parent->d_subdirs.next == &child->d_u.d_child) {
  499. /*
  500. * Try the next sibling.
  501. */
  502. if (child->d_u.d_child.next != &parent->d_subdirs) {
  503. child = list_entry(child->d_u.d_child.next,
  504. struct dentry,
  505. d_u.d_child);
  506. goto next_sibling;
  507. }
  508. /*
  509. * Avoid infinite loop if we fail to remove
  510. * one dentry.
  511. */
  512. mutex_unlock(&parent->d_inode->i_mutex);
  513. break;
  514. }
  515. simple_release_fs(&debugfs_mount, &debugfs_mount_count);
  516. }
  517. parent = dentry->d_parent;
  518. mutex_lock(&parent->d_inode->i_mutex);
  519. __debugfs_remove(dentry, parent);
  520. mutex_unlock(&parent->d_inode->i_mutex);
  521. simple_release_fs(&debugfs_mount, &debugfs_mount_count);
  522. }
  523. EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
  524. /**
  525. * debugfs_rename - rename a file/directory in the debugfs filesystem
  526. * @old_dir: a pointer to the parent dentry for the renamed object. This
  527. * should be a directory dentry.
  528. * @old_dentry: dentry of an object to be renamed.
  529. * @new_dir: a pointer to the parent dentry where the object should be
  530. * moved. This should be a directory dentry.
  531. * @new_name: a pointer to a string containing the target name.
  532. *
  533. * This function renames a file/directory in debugfs. The target must not
  534. * exist for rename to succeed.
  535. *
  536. * This function will return a pointer to old_dentry (which is updated to
  537. * reflect renaming) if it succeeds. If an error occurs, %NULL will be
  538. * returned.
  539. *
  540. * If debugfs is not enabled in the kernel, the value -%ENODEV will be
  541. * returned.
  542. */
  543. struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
  544. struct dentry *new_dir, const char *new_name)
  545. {
  546. int error;
  547. struct dentry *dentry = NULL, *trap;
  548. const char *old_name;
  549. trap = lock_rename(new_dir, old_dir);
  550. /* Source or destination directories don't exist? */
  551. if (!old_dir->d_inode || !new_dir->d_inode)
  552. goto exit;
  553. /* Source does not exist, cyclic rename, or mountpoint? */
  554. if (!old_dentry->d_inode || old_dentry == trap ||
  555. d_mountpoint(old_dentry))
  556. goto exit;
  557. dentry = lookup_one_len(new_name, new_dir, strlen(new_name));
  558. /* Lookup failed, cyclic rename or target exists? */
  559. if (IS_ERR(dentry) || dentry == trap || dentry->d_inode)
  560. goto exit;
  561. old_name = fsnotify_oldname_init(old_dentry->d_name.name);
  562. error = simple_rename(old_dir->d_inode, old_dentry, new_dir->d_inode,
  563. dentry);
  564. if (error) {
  565. fsnotify_oldname_free(old_name);
  566. goto exit;
  567. }
  568. d_move(old_dentry, dentry);
  569. fsnotify_move(old_dir->d_inode, new_dir->d_inode, old_name,
  570. S_ISDIR(old_dentry->d_inode->i_mode),
  571. NULL, old_dentry);
  572. fsnotify_oldname_free(old_name);
  573. unlock_rename(new_dir, old_dir);
  574. dput(dentry);
  575. return old_dentry;
  576. exit:
  577. if (dentry && !IS_ERR(dentry))
  578. dput(dentry);
  579. unlock_rename(new_dir, old_dir);
  580. return NULL;
  581. }
  582. EXPORT_SYMBOL_GPL(debugfs_rename);
  583. /**
  584. * debugfs_initialized - Tells whether debugfs has been registered
  585. */
  586. bool debugfs_initialized(void)
  587. {
  588. return debugfs_registered;
  589. }
  590. EXPORT_SYMBOL_GPL(debugfs_initialized);
  591. static struct kobject *debug_kobj;
  592. static int __init debugfs_init(void)
  593. {
  594. int retval;
  595. debug_kobj = kobject_create_and_add("debug", kernel_kobj);
  596. if (!debug_kobj)
  597. return -EINVAL;
  598. retval = register_filesystem(&debug_fs_type);
  599. if (retval)
  600. kobject_put(debug_kobj);
  601. else
  602. debugfs_registered = true;
  603. return retval;
  604. }
  605. core_initcall(debugfs_init);