Blame view

fs/fscache/proc.c 1.69 KB
2874c5fd2   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-or-later
7394daa8c   David Howells   FS-Cache: Add use...
2
3
4
5
  /* FS-Cache statistics viewing interface
   *
   * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
   * Written by David Howells (dhowells@redhat.com)
7394daa8c   David Howells   FS-Cache: Add use...
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
   */
  
  #define FSCACHE_DEBUG_LEVEL OPERATION
  #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)
  {
  	_enter("");
  
  	if (!proc_mkdir("fs/fscache", NULL))
  		goto error_dir;
  
  #ifdef CONFIG_FSCACHE_STATS
3f3942aca   Christoph Hellwig   proc: introduce p...
25
26
  	if (!proc_create_single("fs/fscache/stats", S_IFREG | 0444, NULL,
  			fscache_stats_show))
7394daa8c   David Howells   FS-Cache: Add use...
27
28
29
30
  		goto error_stats;
  #endif
  
  #ifdef CONFIG_FSCACHE_HISTOGRAM
fddda2b7b   Christoph Hellwig   proc: introduce p...
31
32
  	if (!proc_create_seq("fs/fscache/histogram", S_IFREG | 0444, NULL,
  			 &fscache_histogram_ops))
7394daa8c   David Howells   FS-Cache: Add use...
33
34
  		goto error_histogram;
  #endif
4fbf4291a   David Howells   FS-Cache: Allow t...
35
36
37
38
39
  #ifdef CONFIG_FSCACHE_OBJECT_LIST
  	if (!proc_create("fs/fscache/objects", S_IFREG | 0444, NULL,
  			 &fscache_objlist_fops))
  		goto error_objects;
  #endif
7394daa8c   David Howells   FS-Cache: Add use...
40
41
  	_leave(" = 0");
  	return 0;
4fbf4291a   David Howells   FS-Cache: Allow t...
42
43
44
  #ifdef CONFIG_FSCACHE_OBJECT_LIST
  error_objects:
  #endif
7394daa8c   David Howells   FS-Cache: Add use...
45
  #ifdef CONFIG_FSCACHE_HISTOGRAM
4fbf4291a   David Howells   FS-Cache: Allow t...
46
  	remove_proc_entry("fs/fscache/histogram", NULL);
7394daa8c   David Howells   FS-Cache: Add use...
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  error_histogram:
  #endif
  #ifdef CONFIG_FSCACHE_STATS
  	remove_proc_entry("fs/fscache/stats", NULL);
  error_stats:
  #endif
  	remove_proc_entry("fs/fscache", NULL);
  error_dir:
  	_leave(" = -ENOMEM");
  	return -ENOMEM;
  }
  
  /*
   * clean up the /proc/fs/fscache/ directory
   */
  void fscache_proc_cleanup(void)
  {
4fbf4291a   David Howells   FS-Cache: Allow t...
64
65
66
  #ifdef CONFIG_FSCACHE_OBJECT_LIST
  	remove_proc_entry("fs/fscache/objects", NULL);
  #endif
7394daa8c   David Howells   FS-Cache: Add use...
67
68
69
70
71
72
73
74
  #ifdef CONFIG_FSCACHE_HISTOGRAM
  	remove_proc_entry("fs/fscache/histogram", NULL);
  #endif
  #ifdef CONFIG_FSCACHE_STATS
  	remove_proc_entry("fs/fscache/stats", NULL);
  #endif
  	remove_proc_entry("fs/fscache", NULL);
  }