Commit 8b230932 authored by Mathias Rav's avatar Mathias Rav Committed by Greg Kroah-Hartman

staging: lustre: Use kstrtouint_from_user in ldlm_rw_uint

Clean up the helper functions used to implement "dump_granted_max" in
debugfs.

Replace the lprocfs_rd_uint() and lprocfs_wr_uint() generic callbacks
with a simpler, more direct implementation of ldlm_rw_uint_fops.

There's a slight change in lustre debugfs write semantics: Using kstrtox
causes EINVAL when the written number is followed by other (garbage)
characters, whereas previously the garbage would be ignored and such a
write would succeed.
Signed-off-by: default avatarMathias Rav <mathiasrav@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 93e7ea8c
......@@ -78,7 +78,25 @@ lprocfs_wr_dump_ns(struct file *file, const char __user *buffer,
LPROC_SEQ_FOPS_WR_ONLY(ldlm, dump_ns);
LPROC_SEQ_FOPS_RW_TYPE(ldlm_rw, uint);
static int ldlm_rw_uint_seq_show(struct seq_file *m, void *v)
{
seq_printf(m, "%u\n", *(unsigned int *)m->private);
return 0;
}
static ssize_t
ldlm_rw_uint_seq_write(struct file *file, const char __user *buffer,
size_t count, loff_t *off)
{
struct seq_file *seq = file->private_data;
if (count == 0)
return 0;
return kstrtouint_from_user(buffer, count, 0,
(unsigned int *)seq->private);
}
LPROC_SEQ_FOPS(ldlm_rw_uint);
static struct lprocfs_vars ldlm_debugfs_list[] = {
{ "dump_namespaces", &ldlm_dump_ns_fops, NULL, 0222 },
......
......@@ -389,40 +389,6 @@ struct dentry *ldebugfs_register(const char *name,
EXPORT_SYMBOL_GPL(ldebugfs_register);
/* Generic callbacks */
int lprocfs_rd_uint(struct seq_file *m, void *data)
{
seq_printf(m, "%u\n", *(unsigned int *)data);
return 0;
}
EXPORT_SYMBOL(lprocfs_rd_uint);
int lprocfs_wr_uint(struct file *file, const char __user *buffer,
unsigned long count, void *data)
{
unsigned *p = data;
char dummy[MAX_STRING_SIZE + 1], *end;
unsigned long tmp;
if (count >= sizeof(dummy))
return -EINVAL;
if (count == 0)
return 0;
if (copy_from_user(dummy, buffer, count))
return -EFAULT;
dummy[count] = '\0';
tmp = simple_strtoul(dummy, &end, 0);
if (dummy == end)
return -EINVAL;
*p = (unsigned int)tmp;
return count;
}
EXPORT_SYMBOL(lprocfs_wr_uint);
static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment