1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Top level header file for LProc SNMP
22 * Author: Hariharan Thantry thantry@users.sourceforge.net
24 #ifndef _LPROCFS_SNMP_H
25 #define _LPROCFS_SNMP_H
27 #include <linux/autoconf.h>
28 #include <linux/proc_fs.h>
31 #ifdef CONFIG_PROC_FS /* Ensure that /proc is configured */
38 read_proc_t *read_fptr;
39 write_proc_t *write_fptr;
43 struct lprocfs_static_vars {
44 struct lprocfs_vars *module_vars;
45 struct lprocfs_vars *obd_vars;
49 extern struct proc_dir_entry *proc_lustre_root;
51 extern void lprocfs_init_vars(struct lprocfs_static_vars *var);
52 extern void lprocfs_init_multi_vars(unsigned int idx,
53 struct lprocfs_static_vars *var);
55 #define LPROCFS_INIT_MULTI_VARS(array, size) \
56 void lprocfs_init_multi_vars(unsigned int idx, \
57 struct lprocfs_static_vars *x) \
59 struct lprocfs_static_vars *glob = (struct lprocfs_static_vars*)array; \
61 LASSERT(idx < (unsigned int)(size)); \
62 x->module_vars = glob[idx].module_vars; \
63 x->obd_vars = glob[idx].obd_vars; \
66 #define LPROCFS_INIT_VARS(vclass, vinstance) \
67 void lprocfs_init_vars(struct lprocfs_static_vars *x) \
69 x->module_vars = vclass; \
70 x->obd_vars = vinstance; \
74 /* lprocfs_status.c */
75 extern int lprocfs_add_vars(struct proc_dir_entry *root,
76 struct lprocfs_vars *var,
79 extern struct proc_dir_entry *lprocfs_register(const char *name,
80 struct proc_dir_entry *parent,
81 struct lprocfs_vars *list,
84 extern void lprocfs_remove(struct proc_dir_entry *root);
87 extern int lprocfs_obd_attach(struct obd_device *dev, struct lprocfs_vars *list);
88 extern int lprocfs_obd_detach(struct obd_device *dev);
90 /* Generic callbacks */
92 extern int lprocfs_rd_u64(char *page, char **start, off_t off,
93 int count, int *eof, void *data);
94 extern int lprocfs_rd_uuid(char *page, char **start, off_t off,
95 int count, int *eof, void *data);
96 extern int lprocfs_rd_name(char *page, char **start, off_t off,
97 int count, int *eof, void *data);
98 extern int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
99 int count, int *eof, void *data);
100 extern int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
101 int count, int *eof, void *data);
102 extern int lprocfs_rd_numrefs(char *page, char **start, off_t off,
103 int count, int *eof, void *data);
107 extern int lprocfs_rd_blksize(char *page, char **start, off_t off,
108 int count, int *eof, struct statfs *sfs);
109 extern int lprocfs_rd_kbytestotal(char *page, char **start, off_t off,
110 int count, int *eof, struct statfs *sfs);
111 extern int lprocfs_rd_kbytesfree(char *page, char **start, off_t off,
112 int count, int *eof, struct statfs *sfs);
113 extern int lprocfs_rd_filestotal(char *page, char **start, off_t off,
114 int count, int *eof, struct statfs *sfs);
115 extern int lprocfs_rd_filesfree(char *page, char **start, off_t off,
116 int count, int *eof, struct statfs *sfs);
117 extern int lprocfs_rd_filegroups(char *page, char **start, off_t off,
118 int count, int *eof, struct statfs *sfs);
120 #define DEFINE_LPROCFS_STATFS_FCT(fct_name, get_statfs_fct) \
121 int fct_name(char *page, char **start, off_t off, \
122 int count, int *eof, void *data) \
125 int rc = get_statfs_fct((struct obd_device*)data, &sfs); \
127 ? lprocfs_##fct_name (page, start, off, count, eof, &sfs) \
133 static inline struct proc_dir_entry *
134 lprocfs_register(const char *name, struct proc_dir_entry *parent,
135 struct lprocfs_vars *list, void *data) { return NULL; }
136 static inline int lprocfs_add_vars(struct proc_dir_entry *root,
137 struct lprocfs_vars *var,
138 void *data) { return 0; }
139 static inline void lprocfs_remove(struct proc_dir_entry *root) {};
141 static inline int lprocfs_obd_attach(struct obd_device *dev,
142 struct lprocfs_vars *list) { return 0; }
143 static inline int lprocfs_obd_detach(struct obd_device *dev) { return 0; }
144 static inline int lprocfs_rd_u64(char *page, char **start, off_t off,
145 int count, int *eof, void *data) { return 0; }
146 static inline int lprocfs_rd_uuid(char *page, char **start, off_t off,
147 int count, int *eof, void *data) { return 0; }
148 static inline int lprocfs_rd_name(char *page, char **start, off_t off,
149 int count, int *eof, void *data) { return 0; }
150 static inline int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
151 int count, int *eof, void *data) { return 0; }
152 static inline int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
153 int count, int *eof, void *data) { return 0; }
154 static inline int lprocfs_rd_numrefs(char *page, char **start, off_t off,
155 int count, int *eof, void *data) { return 0; }
160 int lprocfs_rd_blksize(char *page, char **start, off_t off,
161 int count, int *eof, struct statfs *sfs) { return 0; }
163 int lprocfs_rd_kbytestotal(char *page, char **start, off_t off,
164 int count, int *eof, struct statfs *sfs) { return 0; }
166 int lprocfs_rd_kbytesfree(char *page, char **start, off_t off,
167 int count, int *eof, struct statfs *sfs) { return 0; }
169 int lprocfs_rd_filestotal(char *page, char **start, off_t off,
170 int count, int *eof, struct statfs *sfs) { return 0; }
172 int lprocfs_rd_filesfree(char *page, char **start, off_t off,
173 int count, int *eof, struct statfs *sfs) { return 0; }
175 int lprocfs_rd_filegroups(char *page, char **start, off_t off,
176 int count, int *eof, struct statfs *sfs) { return 0; }
178 #define DEFINE_LPROCFS_STATFS_FCT(fct_name, get_statfs_fct) \
179 int fct_name(char *page, char **start, off_t off, \
180 int count, int *eof, void *data) { *eof = 1; return 0; }
184 #endif /* LPROCFS_SNMP_H */