Loading...
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 * initialise the /proc/fs/fscache/ directory
16 */
17int __init fscache_proc_init(void)
18{
19 if (!proc_mkdir("fs/fscache", NULL))
20 goto error_dir;
21
22 if (!proc_create_seq("fs/fscache/caches", S_IFREG | 0444, NULL,
23 &fscache_caches_seq_ops))
24 goto error;
25
26 if (!proc_create_seq("fs/fscache/volumes", S_IFREG | 0444, NULL,
27 &fscache_volumes_seq_ops))
28 goto error;
29
30 if (!proc_create_seq("fs/fscache/cookies", S_IFREG | 0444, NULL,
31 &fscache_cookies_seq_ops))
32 goto error;
33
34#ifdef CONFIG_FSCACHE_STATS
35 if (!proc_create_single("fs/fscache/stats", S_IFREG | 0444, NULL,
36 fscache_stats_show))
37 goto error;
38#endif
39
40 return 0;
41
42error:
43 remove_proc_entry("fs/fscache", NULL);
44error_dir:
45 return -ENOMEM;
46}
47
48/*
49 * clean up the /proc/fs/fscache/ directory
50 */
51void fscache_proc_cleanup(void)
52{
53 remove_proc_subtree("fs/fscache", NULL);
54}
1// SPDX-License-Identifier: GPL-2.0-or-later
2/* FS-Cache statistics viewing interface
3 *
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 */
7
8#define FSCACHE_DEBUG_LEVEL OPERATION
9#include <linux/module.h>
10#include <linux/proc_fs.h>
11#include <linux/seq_file.h>
12#include "internal.h"
13
14/*
15 * initialise the /proc/fs/fscache/ directory
16 */
17int __init fscache_proc_init(void)
18{
19 _enter("");
20
21 if (!proc_mkdir("fs/fscache", NULL))
22 goto error_dir;
23
24#ifdef CONFIG_FSCACHE_STATS
25 if (!proc_create_single("fs/fscache/stats", S_IFREG | 0444, NULL,
26 fscache_stats_show))
27 goto error_stats;
28#endif
29
30#ifdef CONFIG_FSCACHE_HISTOGRAM
31 if (!proc_create_seq("fs/fscache/histogram", S_IFREG | 0444, NULL,
32 &fscache_histogram_ops))
33 goto error_histogram;
34#endif
35
36#ifdef CONFIG_FSCACHE_OBJECT_LIST
37 if (!proc_create("fs/fscache/objects", S_IFREG | 0444, NULL,
38 &fscache_objlist_proc_ops))
39 goto error_objects;
40#endif
41
42 _leave(" = 0");
43 return 0;
44
45#ifdef CONFIG_FSCACHE_OBJECT_LIST
46error_objects:
47#endif
48#ifdef CONFIG_FSCACHE_HISTOGRAM
49 remove_proc_entry("fs/fscache/histogram", NULL);
50error_histogram:
51#endif
52#ifdef CONFIG_FSCACHE_STATS
53 remove_proc_entry("fs/fscache/stats", NULL);
54error_stats:
55#endif
56 remove_proc_entry("fs/fscache", NULL);
57error_dir:
58 _leave(" = -ENOMEM");
59 return -ENOMEM;
60}
61
62/*
63 * clean up the /proc/fs/fscache/ directory
64 */
65void fscache_proc_cleanup(void)
66{
67#ifdef CONFIG_FSCACHE_OBJECT_LIST
68 remove_proc_entry("fs/fscache/objects", NULL);
69#endif
70#ifdef CONFIG_FSCACHE_HISTOGRAM
71 remove_proc_entry("fs/fscache/histogram", NULL);
72#endif
73#ifdef CONFIG_FSCACHE_STATS
74 remove_proc_entry("fs/fscache/stats", NULL);
75#endif
76 remove_proc_entry("fs/fscache", NULL);
77}