*/
#define EXPORT_SYMTAB
+#define DEBUG_SUBSYSTEM S_CLASS
+#ifdef __KERNEL__
#include <linux/config.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/slab.h>
#include <linux/types.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
+#include <asm/statfs.h>
+#endif
+
+#else
+#include <liblustre.h>
+#endif
-#define DEBUG_SUBSYSTEM S_CLASS
#include <linux/obd_class.h>
#include <linux/lprocfs_status.h>
{
struct proc_dir_entry *temp = root;
struct proc_dir_entry *rm_entry;
- struct proc_dir_entry *parent = root->parent;
+ struct proc_dir_entry *parent;
+
+ LASSERT(root != NULL);
+ parent = root->parent;
+ LASSERT(parent != NULL);
while (1) {
while (temp->subdir)
newchild = lprocfs_srch(parent, name);
if (newchild) {
CERROR(" Lproc: Attempting to register %s more than once \n",
- name);
- return NULL;
+ name);
+ return ERR_PTR(-EALREADY);
}
newchild = proc_mkdir(name, parent);
int lprocfs_rd_u64(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
+ LASSERT(data != NULL);
*eof = 1;
return snprintf(page, count, LPU64"\n", *(__u64 *)data);
}
{
struct obd_device* dev = (struct obd_device*)data;
+ LASSERT(dev != NULL);
*eof = 1;
return snprintf(page, count, "%s\n", dev->obd_uuid.uuid);
}
{
struct obd_device* dev = (struct obd_device *)data;
+ LASSERT(dev != NULL);
+ LASSERT(dev->obd_name != NULL);
*eof = 1;
return snprintf(page, count, "%s\n", dev->obd_name);
}
int lprocfs_rd_blksize(char* page, char **start, off_t off, int count,
int *eof, struct statfs *sfs)
{
+ LASSERT(sfs != NULL);
*eof = 1;
-
return snprintf(page, count, "%lu\n", sfs->f_bsize);
}
int lprocfs_rd_kbytestotal(char* page, char **start, off_t off, int count,
int *eof, struct statfs *sfs)
{
- __u32 blk_size = sfs->f_bsize >> 10;
- __u64 result = sfs->f_blocks;
+ __u32 blk_size;
+ __u64 result;
+
+ LASSERT(sfs != NULL);
+ blk_size = sfs->f_bsize >> 10;
+ result = sfs->f_blocks;
while (blk_size >>= 1)
result <<= 1;
int lprocfs_rd_kbytesfree(char* page, char **start, off_t off, int count,
int *eof, struct statfs *sfs)
{
- __u32 blk_size = sfs->f_bsize >> 10;
- __u64 result = sfs->f_bfree;
+ __u32 blk_size;
+ __u64 result;
+
+ LASSERT(sfs != NULL);
+ blk_size = sfs->f_bsize >> 10;
+ result = sfs->f_bfree;
while (blk_size >>= 1)
result <<= 1;
int lprocfs_rd_filestotal(char* page, char **start, off_t off, int count,
int *eof, struct statfs *sfs)
{
+ LASSERT(sfs != NULL);
*eof = 1;
return snprintf(page, count, "%ld\n", sfs->f_files);
}
int lprocfs_rd_filesfree(char* page, char **start, off_t off, int count,
int *eof, struct statfs *sfs)
{
+ LASSERT(sfs != NULL);
*eof = 1;
return snprintf(page, count, "%ld\n", sfs->f_ffree);
}
int *eof, void *data)
{
struct obd_device* obd = (struct obd_device*)data;
- struct client_obd* cli = &obd->u.cli;
+ struct client_obd* cli;
+
+ LASSERT(obd != NULL);
+ cli = &obd->u.cli;
+ *eof = 1;
return snprintf(page, count, "%s\n", cli->cl_target_uuid.uuid);
}
int *eof, void *data)
{
struct obd_device *obd = (struct obd_device*)data;
- struct ptlrpc_connection *conn = obd->u.cli.cl_import.imp_connection;
+ struct ptlrpc_connection *conn;
+ LASSERT(obd != NULL);
+ conn = obd->u.cli.cl_import.imp_connection;
+ LASSERT(conn != NULL);
*eof = 1;
return snprintf(page, count, "%s\n", conn->c_remote_uuid.uuid);
}
{
struct obd_type* class = (struct obd_type*) data;
+ LASSERT(class != NULL);
*eof = 1;
return snprintf(page, count, "%d\n", class->typ_refcnt);
}
int lprocfs_obd_attach(struct obd_device *dev, struct lprocfs_vars *list)
{
int rc = 0;
+
+ LASSERT(dev != NULL);
+ LASSERT(dev->obd_type != NULL);
+ LASSERT(dev->obd_type->typ_procroot != NULL);
+
dev->obd_proc_entry = lprocfs_register(dev->obd_name,
dev->obd_type->typ_procroot,
list, dev);
if (IS_ERR(dev->obd_proc_entry)) {
rc = PTR_ERR(dev->obd_proc_entry);
- dev->obd_proc_entry = NULL;
+ dev->obd_proc_entry = NULL;
}
return rc;
}