jfs_debug.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (C) International Business Machines Corp., 2000-2004
  4. * Portions Copyright (C) Christoph Hellwig, 2001-2002
  5. */
  6. #include <linux/fs.h>
  7. #include <linux/ctype.h>
  8. #include <linux/module.h>
  9. #include <linux/proc_fs.h>
  10. #include <linux/seq_file.h>
  11. #include <linux/uaccess.h>
  12. #include "jfs_incore.h"
  13. #include "jfs_filsys.h"
  14. #include "jfs_debug.h"
  15. #ifdef PROC_FS_JFS /* see jfs_debug.h */
  16. #ifdef CONFIG_JFS_DEBUG
  17. static int jfs_loglevel_proc_show(struct seq_file *m, void *v)
  18. {
  19. seq_printf(m, "%d\n", jfsloglevel);
  20. return 0;
  21. }
  22. static int jfs_loglevel_proc_open(struct inode *inode, struct file *file)
  23. {
  24. return single_open(file, jfs_loglevel_proc_show, NULL);
  25. }
  26. static ssize_t jfs_loglevel_proc_write(struct file *file,
  27. const char __user *buffer, size_t count, loff_t *ppos)
  28. {
  29. char c;
  30. if (get_user(c, buffer))
  31. return -EFAULT;
  32. /* yes, I know this is an ASCIIism. --hch */
  33. if (c < '0' || c > '9')
  34. return -EINVAL;
  35. jfsloglevel = c - '0';
  36. return count;
  37. }
  38. static const struct proc_ops jfs_loglevel_proc_ops = {
  39. .proc_open = jfs_loglevel_proc_open,
  40. .proc_read = seq_read,
  41. .proc_lseek = seq_lseek,
  42. .proc_release = single_release,
  43. .proc_write = jfs_loglevel_proc_write,
  44. };
  45. #endif
  46. void jfs_proc_init(void)
  47. {
  48. struct proc_dir_entry *base;
  49. base = proc_mkdir("fs/jfs", NULL);
  50. if (!base)
  51. return;
  52. #ifdef CONFIG_JFS_STATISTICS
  53. proc_create_single("lmstats", 0, base, jfs_lmstats_proc_show);
  54. proc_create_single("txstats", 0, base, jfs_txstats_proc_show);
  55. proc_create_single("xtstat", 0, base, jfs_xtstat_proc_show);
  56. proc_create_single("mpstat", 0, base, jfs_mpstat_proc_show);
  57. #endif
  58. #ifdef CONFIG_JFS_DEBUG
  59. proc_create_single("TxAnchor", 0, base, jfs_txanchor_proc_show);
  60. proc_create("loglevel", 0, base, &jfs_loglevel_proc_ops);
  61. #endif
  62. }
  63. void jfs_proc_clean(void)
  64. {
  65. remove_proc_subtree("fs/jfs", NULL);
  66. }
  67. #endif /* PROC_FS_JFS */