proc.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /* FS-Cache statistics viewing interface
  3. *
  4. * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
  5. * Written by David Howells ([email protected])
  6. */
  7. #define FSCACHE_DEBUG_LEVEL CACHE
  8. #include <linux/module.h>
  9. #include <linux/proc_fs.h>
  10. #include <linux/seq_file.h>
  11. #include "internal.h"
  12. /*
  13. * initialise the /proc/fs/fscache/ directory
  14. */
  15. int __init fscache_proc_init(void)
  16. {
  17. if (!proc_mkdir("fs/fscache", NULL))
  18. goto error_dir;
  19. if (!proc_create_seq("fs/fscache/caches", S_IFREG | 0444, NULL,
  20. &fscache_caches_seq_ops))
  21. goto error;
  22. if (!proc_create_seq("fs/fscache/volumes", S_IFREG | 0444, NULL,
  23. &fscache_volumes_seq_ops))
  24. goto error;
  25. if (!proc_create_seq("fs/fscache/cookies", S_IFREG | 0444, NULL,
  26. &fscache_cookies_seq_ops))
  27. goto error;
  28. #ifdef CONFIG_FSCACHE_STATS
  29. if (!proc_create_single("fs/fscache/stats", S_IFREG | 0444, NULL,
  30. fscache_stats_show))
  31. goto error;
  32. #endif
  33. return 0;
  34. error:
  35. remove_proc_entry("fs/fscache", NULL);
  36. error_dir:
  37. return -ENOMEM;
  38. }
  39. /*
  40. * clean up the /proc/fs/fscache/ directory
  41. */
  42. void fscache_proc_cleanup(void)
  43. {
  44. remove_proc_subtree("fs/fscache", NULL);
  45. }