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 | |
8 | #define FSCACHE_DEBUG_LEVEL CACHE |
9 | #include <linux/module.h> |
10 | #include <linux/proc_fs.h> |
11 | #include <linux/seq_file.h> |
12 | #include "internal.h" |
13 | |
14 | /* |
15 | * Add files to /proc/fs/netfs/. |
16 | */ |
17 | int __init fscache_proc_init(void) |
18 | { |
19 | if (!proc_symlink("fs/fscache" , NULL, "netfs" )) |
20 | goto error_sym; |
21 | |
22 | if (!proc_create_seq("fs/netfs/caches" , S_IFREG | 0444, NULL, |
23 | &fscache_caches_seq_ops)) |
24 | goto error; |
25 | |
26 | if (!proc_create_seq("fs/netfs/volumes" , S_IFREG | 0444, NULL, |
27 | &fscache_volumes_seq_ops)) |
28 | goto error; |
29 | |
30 | if (!proc_create_seq("fs/netfs/cookies" , S_IFREG | 0444, NULL, |
31 | &fscache_cookies_seq_ops)) |
32 | goto error; |
33 | return 0; |
34 | |
35 | error: |
36 | remove_proc_entry("fs/fscache" , NULL); |
37 | error_sym: |
38 | return -ENOMEM; |
39 | } |
40 | |
41 | /* |
42 | * Clean up the /proc/fs/fscache symlink. |
43 | */ |
44 | void fscache_proc_cleanup(void) |
45 | { |
46 | remove_proc_subtree("fs/fscache" , NULL); |
47 | } |
48 | |