55 lines
1.2 KiB
C
Raw Normal View History

2026-01-21 18:59:54 +08:00
// SPDX-License-Identifier: GPL-2.0-or-later
/* FS-Cache statistics viewing interface
*
2026-01-29 22:25:33 +08:00
* Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
2026-01-21 18:59:54 +08:00
* Written by David Howells (dhowells@redhat.com)
*/
2026-01-29 22:25:33 +08:00
#define FSCACHE_DEBUG_LEVEL CACHE
2026-01-21 18:59:54 +08:00
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include "internal.h"
/*
* initialise the /proc/fs/fscache/ directory
*/
int __init fscache_proc_init(void)
{
if (!proc_mkdir("fs/fscache", NULL))
goto error_dir;
2026-01-29 22:25:33 +08:00
if (!proc_create_seq("fs/fscache/caches", S_IFREG | 0444, NULL,
&fscache_caches_seq_ops))
goto error;
2026-01-21 18:59:54 +08:00
2026-01-29 22:25:33 +08:00
if (!proc_create_seq("fs/fscache/volumes", S_IFREG | 0444, NULL,
&fscache_volumes_seq_ops))
goto error;
2026-01-21 18:59:54 +08:00
2026-01-29 22:25:33 +08:00
if (!proc_create_seq("fs/fscache/cookies", S_IFREG | 0444, NULL,
&fscache_cookies_seq_ops))
goto error;
#ifdef CONFIG_FSCACHE_STATS
if (!proc_create_single("fs/fscache/stats", S_IFREG | 0444, NULL,
fscache_stats_show))
goto error;
2026-01-21 18:59:54 +08:00
#endif
return 0;
2026-01-29 22:25:33 +08:00
error:
2026-01-21 18:59:54 +08:00
remove_proc_entry("fs/fscache", NULL);
error_dir:
return -ENOMEM;
}
/*
* clean up the /proc/fs/fscache/ directory
*/
void fscache_proc_cleanup(void)
{
2026-01-29 22:25:33 +08:00
remove_proc_subtree("fs/fscache", NULL);
2026-01-21 18:59:54 +08:00
}