fscache_proc.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 (dhowells@redhat.com)
  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. * Add files to /proc/fs/netfs/.
  14. */
  15. int __init fscache_proc_init(void)
  16. {
  17. if (!proc_symlink("fs/fscache", NULL, "netfs"))
  18. goto error_sym;
  19. if (!proc_create_seq("fs/netfs/caches", S_IFREG | 0444, NULL,
  20. &fscache_caches_seq_ops))
  21. goto error;
  22. if (!proc_create_seq("fs/netfs/volumes", S_IFREG | 0444, NULL,
  23. &fscache_volumes_seq_ops))
  24. goto error;
  25. if (!proc_create_seq("fs/netfs/cookies", S_IFREG | 0444, NULL,
  26. &fscache_cookies_seq_ops))
  27. goto error;
  28. return 0;
  29. error:
  30. remove_proc_entry("fs/fscache", NULL);
  31. error_sym:
  32. return -ENOMEM;
  33. }
  34. /*
  35. * Clean up the /proc/fs/fscache symlink.
  36. */
  37. void fscache_proc_cleanup(void)
  38. {
  39. remove_proc_subtree("fs/fscache", NULL);
  40. }