jfs_debug.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (C) International Business Machines Corp., 2000-2004
  3. * Portions Copyright (C) Christoph Hellwig, 2001-2002
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  13. * the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/fs.h>
  20. #include <linux/ctype.h>
  21. #include <linux/module.h>
  22. #include <linux/proc_fs.h>
  23. #include <linux/seq_file.h>
  24. #include <linux/uaccess.h>
  25. #include "jfs_incore.h"
  26. #include "jfs_filsys.h"
  27. #include "jfs_debug.h"
  28. #ifdef PROC_FS_JFS /* see jfs_debug.h */
  29. #ifdef CONFIG_JFS_DEBUG
  30. static int jfs_loglevel_proc_show(struct seq_file *m, void *v)
  31. {
  32. seq_printf(m, "%d\n", jfsloglevel);
  33. return 0;
  34. }
  35. static int jfs_loglevel_proc_open(struct inode *inode, struct file *file)
  36. {
  37. return single_open(file, jfs_loglevel_proc_show, NULL);
  38. }
  39. static ssize_t jfs_loglevel_proc_write(struct file *file,
  40. const char __user *buffer, size_t count, loff_t *ppos)
  41. {
  42. char c;
  43. if (get_user(c, buffer))
  44. return -EFAULT;
  45. /* yes, I know this is an ASCIIism. --hch */
  46. if (c < '0' || c > '9')
  47. return -EINVAL;
  48. jfsloglevel = c - '0';
  49. return count;
  50. }
  51. static const struct file_operations jfs_loglevel_proc_fops = {
  52. .open = jfs_loglevel_proc_open,
  53. .read = seq_read,
  54. .llseek = seq_lseek,
  55. .release = single_release,
  56. .write = jfs_loglevel_proc_write,
  57. };
  58. #endif
  59. void jfs_proc_init(void)
  60. {
  61. struct proc_dir_entry *base;
  62. base = proc_mkdir("fs/jfs", NULL);
  63. if (!base)
  64. return;
  65. #ifdef CONFIG_JFS_STATISTICS
  66. proc_create_single("lmstats", 0, base, jfs_lmstats_proc_show);
  67. proc_create_single("txstats", 0, base, jfs_txstats_proc_show);
  68. proc_create_single("xtstat", 0, base, jfs_xtstat_proc_show);
  69. proc_create_single("mpstat", 0, base, jfs_mpstat_proc_show);
  70. #endif
  71. #ifdef CONFIG_JFS_DEBUG
  72. proc_create_single("TxAnchor", 0, base, jfs_txanchor_proc_show);
  73. proc_create("loglevel", 0, base, &jfs_loglevel_proc_fops);
  74. #endif
  75. }
  76. void jfs_proc_clean(void)
  77. {
  78. remove_proc_subtree("fs/jfs", NULL);
  79. }
  80. #endif /* PROC_FS_JFS */