proc.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. _leave(" = 0");
  35. return 0;
  36. #ifdef CONFIG_FSCACHE_HISTOGRAM
  37. error_histogram:
  38. #endif
  39. #ifdef CONFIG_FSCACHE_STATS
  40. remove_proc_entry("fs/fscache/stats", NULL);
  41. error_stats:
  42. #endif
  43. remove_proc_entry("fs/fscache", NULL);
  44. error_dir:
  45. _leave(" = -ENOMEM");
  46. return -ENOMEM;
  47. }
  48. /*
  49. * clean up the /proc/fs/fscache/ directory
  50. */
  51. void fscache_proc_cleanup(void)
  52. {
  53. #ifdef CONFIG_FSCACHE_HISTOGRAM
  54. remove_proc_entry("fs/fscache/histogram", NULL);
  55. #endif
  56. #ifdef CONFIG_FSCACHE_STATS
  57. remove_proc_entry("fs/fscache/stats", NULL);
  58. #endif
  59. remove_proc_entry("fs/fscache", NULL);
  60. }