Linux Audio

Check our new training course

Loading...
v6.2
 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}
v3.1
 
 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
12#define FSCACHE_DEBUG_LEVEL OPERATION
13#include <linux/module.h>
14#include <linux/proc_fs.h>
15#include <linux/seq_file.h>
16#include "internal.h"
17
18/*
19 * initialise the /proc/fs/fscache/ directory
20 */
21int __init fscache_proc_init(void)
22{
23	_enter("");
24
25	if (!proc_mkdir("fs/fscache", NULL))
26		goto error_dir;
27
 
 
 
 
 
 
 
 
 
 
 
 
28#ifdef CONFIG_FSCACHE_STATS
29	if (!proc_create("fs/fscache/stats", S_IFREG | 0444, NULL,
30			 &fscache_stats_fops))
31		goto error_stats;
32#endif
33
34#ifdef CONFIG_FSCACHE_HISTOGRAM
35	if (!proc_create("fs/fscache/histogram", S_IFREG | 0444, NULL,
36			 &fscache_histogram_fops))
37		goto error_histogram;
38#endif
39
40#ifdef CONFIG_FSCACHE_OBJECT_LIST
41	if (!proc_create("fs/fscache/objects", S_IFREG | 0444, NULL,
42			 &fscache_objlist_fops))
43		goto error_objects;
44#endif
45
46	_leave(" = 0");
47	return 0;
48
49#ifdef CONFIG_FSCACHE_OBJECT_LIST
50error_objects:
51#endif
52#ifdef CONFIG_FSCACHE_HISTOGRAM
53	remove_proc_entry("fs/fscache/histogram", NULL);
54error_histogram:
55#endif
56#ifdef CONFIG_FSCACHE_STATS
57	remove_proc_entry("fs/fscache/stats", NULL);
58error_stats:
59#endif
60	remove_proc_entry("fs/fscache", NULL);
61error_dir:
62	_leave(" = -ENOMEM");
63	return -ENOMEM;
64}
65
66/*
67 * clean up the /proc/fs/fscache/ directory
68 */
69void fscache_proc_cleanup(void)
70{
71#ifdef CONFIG_FSCACHE_OBJECT_LIST
72	remove_proc_entry("fs/fscache/objects", NULL);
73#endif
74#ifdef CONFIG_FSCACHE_HISTOGRAM
75	remove_proc_entry("fs/fscache/histogram", NULL);
76#endif
77#ifdef CONFIG_FSCACHE_STATS
78	remove_proc_entry("fs/fscache/stats", NULL);
79#endif
80	remove_proc_entry("fs/fscache", NULL);
81}