Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /* FS-Cache statistics viewing interface
0003  *
0004  * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
0005  * Written by David Howells (dhowells@redhat.com)
0006  */
0007 
0008 #define FSCACHE_DEBUG_LEVEL CACHE
0009 #include <linux/module.h>
0010 #include <linux/proc_fs.h>
0011 #include <linux/seq_file.h>
0012 #include "internal.h"
0013 
0014 /*
0015  * initialise the /proc/fs/fscache/ directory
0016  */
0017 int __init fscache_proc_init(void)
0018 {
0019     if (!proc_mkdir("fs/fscache", NULL))
0020         goto error_dir;
0021 
0022     if (!proc_create_seq("fs/fscache/caches", S_IFREG | 0444, NULL,
0023                  &fscache_caches_seq_ops))
0024         goto error;
0025 
0026     if (!proc_create_seq("fs/fscache/volumes", S_IFREG | 0444, NULL,
0027                  &fscache_volumes_seq_ops))
0028         goto error;
0029 
0030     if (!proc_create_seq("fs/fscache/cookies", S_IFREG | 0444, NULL,
0031                  &fscache_cookies_seq_ops))
0032         goto error;
0033 
0034 #ifdef CONFIG_FSCACHE_STATS
0035     if (!proc_create_single("fs/fscache/stats", S_IFREG | 0444, NULL,
0036                 fscache_stats_show))
0037         goto error;
0038 #endif
0039 
0040     return 0;
0041 
0042 error:
0043     remove_proc_entry("fs/fscache", NULL);
0044 error_dir:
0045     return -ENOMEM;
0046 }
0047 
0048 /*
0049  * clean up the /proc/fs/fscache/ directory
0050  */
0051 void fscache_proc_cleanup(void)
0052 {
0053     remove_proc_subtree("fs/fscache", NULL);
0054 }