Whamcloud - gitweb
* 1st attempt to prevent duplicate devices being started.
[fs/lustre-release.git] / lustre / llite / lproc_llite.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
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.
11  *
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.
16  *
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.
20  *
21  */
22 #define DEBUG_SUBSYSTEM S_LLITE
23 #include <linux/obd_support.h>
24 #include <linux/obd_class.h>
25 #include <linux/lustre_lite.h>
26 #include <linux/lprocfs.h>
27 #include <linux/string.h>
28 #include <linux/fs.h>
29 #include <linux/lustre_lib.h>
30
31
32 int rd_path(char* page, char **start, off_t off,
33                int count, int *eof, void *data)
34 {
35         
36         return 0;
37
38 }
39 int rd_fstype(char* page, char **start, off_t off,
40                 int count, int *eof, void *data)
41 {
42         int len=0;
43         struct super_block *sb=(struct super_block*)data;
44         
45         len+=snprintf(page, count, "%s\n", sb->s_type->name); 
46         return len;
47 }
48 int rd_blksize(char* page, char **start, off_t off,
49                int count, int *eof, void *data)
50 {
51         int len=0;
52         struct super_block *sb=(struct super_block*)data;
53         struct statfs mystats;
54         (sb->s_op->statfs)(sb, &mystats);
55         len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bsize)); 
56         return len;
57
58 }
59 int rd_blktotal(char* page, char **start, off_t off,
60                 int count, int *eof, void *data)
61 {
62         int len=0;
63         struct super_block *sb=(struct super_block*)data;
64         struct statfs mystats;
65         (sb->s_op->statfs)(sb, &mystats);
66         len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_blocks)); 
67         return len;
68         
69 }
70
71 int rd_blkfree(char* page, char **start, off_t off,
72                int count, int *eof, void *data)
73 {
74         int len=0;
75         struct super_block *sb=(struct super_block*)data;
76         struct statfs mystats;
77         (sb->s_op->statfs)(sb, &mystats);
78         len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bfree)); 
79         return len;
80         
81         
82 }
83
84 int rd_kbfree(char* page, char **start, off_t off,
85               int count, int *eof, void *data)
86 {
87         int len=0;
88         struct super_block *sb=(struct super_block*)data;
89         struct statfs mystats; 
90         long blk_size=0;
91         
92         (sb->s_op->statfs)(sb, &mystats);
93         blk_size=mystats.f_bsize;
94         
95         len+=snprintf(page, count, LPU64"\n", \
96                       (__u64)((mystats.f_bfree)/(blk_size*1024))); 
97         return len; 
98         
99 }
100
101 int rd_numobjects(char* page, char **start, off_t off,
102                   int count, int *eof, void *data)
103 {
104         
105         int len=0;
106         struct super_block *sb=(struct super_block*)data;
107         
108         struct statfs mystats; 
109         
110         
111         (sb->s_op->statfs)(sb, &mystats);
112                 
113         len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_files)); 
114         return len;
115 }
116
117 int rd_objfree(char* page, char **start, off_t off,
118                int count, int *eof, void *data)
119 {
120         
121         int len=0;
122         struct super_block *sb=(struct super_block*)data;
123         
124         struct statfs mystats; 
125         
126         
127         (sb->s_op->statfs)(sb, &mystats);
128                 
129         len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_ffree)); 
130         return len;
131 }
132
133 int rd_objgroups(char* page, char **start, off_t off,
134                  int count, int *eof, void *data)
135 {
136         return 0;
137 }
138 int rd_uuid(char* page, char **start, off_t off,
139             int count, int *eof, void *data)
140 {
141         int len=0;
142         struct super_block *sb=(struct super_block*)data;
143         struct ll_sb_info *sbi=ll_s2sbi(sb);
144         len+=snprintf(page, count, "%s\n", sbi->ll_sb_uuid); 
145         return len;    
146
147 }
148 int rd_dev_name(char* page, char **start, off_t off,
149                     int count, int *eof, void *data)
150 {
151         int len=0;
152         struct obd_device* dev=(struct obd_device*)data;
153         len+=snprintf(page, count, "%s\n", dev->obd_name);
154         return len;
155 }
156
157 int rd_dev_uuid(char* page, char **start, off_t off,
158                     int count, int *eof, void *data)
159 {
160         int len=0;
161         struct obd_device* dev=(struct obd_device*)data;
162         len+=snprintf(page, count, "%s\n", dev->obd_uuid);
163         return len;
164 }
165
166
167 lprocfs_vars_t snmp_var_nm_1[]={
168         {"snmp/uuid", rd_uuid, 0},
169         {"snmp/mntpt_path", rd_path, 0},
170         {"snmp/fs_type", rd_fstype, 0},
171         {"snmp/f_blocksize",rd_blksize, 0},
172         {"snmp/f_blockstotal",rd_blktotal, 0},
173         {"snmp/f_blocksfree",rd_blkfree, 0},
174         {"snmp/f_kbytesfree", rd_kbfree, 0},
175         {"snmp/f_objects", rd_numobjects, 0},
176         {"snmp/f_objectsfree", rd_objfree, 0},
177         {"snmp/f_objectgroups", rd_objgroups, 0},
178         {0}
179 };