.fops = &libcfs_fops,
};
-int lprocfs_call_handler(void *data, int write, loff_t *ppos,
- void __user *buffer, size_t *lenp,
- int (*handler)(void *data, int write, loff_t pos,
- void __user *buffer, int len))
-{
- int rc = handler(data, write, *ppos, buffer, *lenp);
-
- if (rc < 0)
- return rc;
-
- if (write) {
- *ppos += *lenp;
- } else {
- *lenp = rc;
- *ppos += rc;
- }
- return 0;
-}
-EXPORT_SYMBOL(lprocfs_call_handler);
-
-static int __proc_dobitmasks(void *data, int write,
- loff_t pos, void __user *buffer, int nob)
+static int proc_dobitmasks(struct ctl_table *table, int write,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
{
const int tmpstrlen = 512;
char *tmpstr = NULL;
int rc;
- unsigned int *mask = data;
+ size_t nob = *lenp;
+ loff_t pos = *ppos;
+ unsigned int *mask = table->data;
int is_subsys = (mask == &libcfs_subsystem_debug) ? 1 : 0;
int is_printk = (mask == &libcfs_printk) ? 1 : 0;
return rc;
}
-static int proc_dobitmasks(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp, loff_t *ppos)
-{
- return lprocfs_call_handler(table->data, write, ppos, buffer, lenp,
- __proc_dobitmasks);
-}
-
static int min_watchdog_ratelimit; /* disable ratelimiting */
static int max_watchdog_ratelimit = (24*60*60); /* limit to once per day */
-static int __proc_dump_kernel(void *data, int write,
- loff_t pos, void __user *buffer, int nob)
+static int proc_dump_kernel(struct ctl_table *table, int write,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
{
+ size_t nob = *lenp;
+
if (!write)
return 0;
return cfs_trace_dump_debug_buffer_usrstr(buffer, nob);
}
-static int proc_dump_kernel(struct ctl_table *table, int write,
+static int proc_daemon_file(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
- return lprocfs_call_handler(table->data, write, ppos, buffer, lenp,
- __proc_dump_kernel);
-}
+ size_t nob = *lenp;
+ loff_t pos = *ppos;
-static int __proc_daemon_file(void *data, int write,
- loff_t pos, void __user *buffer, int nob)
-{
if (!write) {
int len = strlen(cfs_tracefile);
return cfs_trace_daemon_command_usrstr(buffer, nob);
}
-static int proc_daemon_file(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp, loff_t *ppos)
-{
- return lprocfs_call_handler(table->data, write, ppos, buffer, lenp,
- __proc_daemon_file);
-}
-
static int libcfs_force_lbug(struct ctl_table *table, int write,
void __user *buffer,
size_t *lenp, loff_t *ppos)
return len;
}
-static int __proc_cpt_table(void *data, int write,
- loff_t pos, void __user *buffer, int nob)
+static int proc_cpt_table(struct ctl_table *table, int write,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
{
+ size_t nob = *lenp;
+ loff_t pos = *ppos;
char *buf = NULL;
int len = 4096;
int rc = 0;
return rc;
}
-static int proc_cpt_table(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp, loff_t *ppos)
-{
- return lprocfs_call_handler(table->data, write, ppos, buffer, lenp,
- __proc_cpt_table);
-}
-
-static int __proc_cpt_distance(void *data, int write,
- loff_t pos, void __user *buffer, int nob)
+static int proc_cpt_distance(struct ctl_table *table, int write,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
{
+ size_t nob = *lenp;
+ loff_t pos = *ppos;
char *buf = NULL;
int len = 4096;
int rc = 0;
return rc;
}
-static int proc_cpt_distance(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp, loff_t *ppos)
-{
- return lprocfs_call_handler(table->data, write, ppos, buffer, lenp,
- __proc_cpt_distance);
-}
-
static struct ctl_table lnet_table[] = {
{
.procname = "debug",
size_t count, loff_t *ppos)
{
struct ctl_table *table = filp->private_data;
+ loff_t old_pos = *ppos;
ssize_t rc = -EINVAL;
- if (table) {
- rc = table->proc_handler(table, 0, buf, &count, ppos);
- if (!rc)
- rc = count;
- }
+ if (table)
+ rc = table->proc_handler(table, 0, (void __user *)buf,
+ &count, ppos);
+ /*
+ * On success, the length read is either in error or in count.
+ * If ppos changed, then use count, else use error
+ */
+ if (!rc && *ppos != old_pos)
+ rc = count;
+ else if (rc > 0)
+ *ppos += rc;
return rc;
}
size_t count, loff_t *ppos)
{
struct ctl_table *table = filp->private_data;
+ loff_t old_pos = *ppos;
ssize_t rc = -EINVAL;
- if (table) {
+ if (table)
rc = table->proc_handler(table, 1, (void __user *)buf, &count,
ppos);
- if (!rc)
- rc = count;
- }
+ if (rc)
+ return rc;
- return rc;
+ if (*ppos == old_pos)
+ *ppos += count;
+
+ return count;
}
static const struct file_operations lnet_debugfs_file_operations_rw = {