proc.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* FS-Cache statistics viewing interface
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #define FSCACHE_DEBUG_LEVEL OPERATION
  12. #include <linux/module.h>
  13. #include <linux/proc_fs.h>
  14. #include <linux/seq_file.h>
  15. #include "internal.h"
  16. /*
  17. * initialise the /proc/fs/fscache/ directory
  18. */
  19. int __init fscache_proc_init(void)
  20. {
  21. _enter("");
  22. if (!proc_mkdir("fs/fscache", NULL))
  23. goto error_dir;
  24. #ifdef CONFIG_FSCACHE_STATS
  25. if (!proc_create("fs/fscache/stats", S_IFREG | 0444, NULL,
  26. &fscache_stats_fops))
  27. goto error_stats;
  28. #endif
  29. #ifdef CONFIG_FSCACHE_HISTOGRAM
  30. if (!proc_create("fs/fscache/histogram", S_IFREG | 0444, NULL,
  31. &fscache_histogram_fops))
  32. goto error_histogram;
  33. #endif
  34. #ifdef CONFIG_FSCACHE_OBJECT_LIST
  35. if (!proc_create("fs/fscache/objects", S_IFREG | 0444, NULL,
  36. &fscache_objlist_fops))
  37. goto error_objects;
  38. #endif
  39. _leave(" = 0");
  40. return 0;
  41. #ifdef CONFIG_FSCACHE_OBJECT_LIST
  42. error_objects:
  43. #endif
  44. #ifdef CONFIG_FSCACHE_HISTOGRAM
  45. remove_proc_entry("fs/fscache/histogram", NULL);
  46. error_histogram:
  47. #endif
  48. #ifdef CONFIG_FSCACHE_STATS
  49. remove_proc_entry("fs/fscache/stats", NULL);
  50. error_stats:
  51. #endif
  52. remove_proc_entry("fs/fscache", NULL);
  53. error_dir:
  54. _leave(" = -ENOMEM");
  55. return -ENOMEM;
  56. }
  57. /*
  58. * clean up the /proc/fs/fscache/ directory
  59. */
  60. void fscache_proc_cleanup(void)
  61. {
  62. #ifdef CONFIG_FSCACHE_OBJECT_LIST
  63. remove_proc_entry("fs/fscache/objects", NULL);
  64. #endif
  65. #ifdef CONFIG_FSCACHE_HISTOGRAM
  66. remove_proc_entry("fs/fscache/histogram", NULL);
  67. #endif
  68. #ifdef CONFIG_FSCACHE_STATS
  69. remove_proc_entry("fs/fscache/stats", NULL);
  70. #endif
  71. remove_proc_entry("fs/fscache", NULL);
  72. }