diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/obdclass/lprocfs_status.c')
-rw-r--r-- | drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 3b7dfc367722..ddab94d7ee82 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -45,6 +45,7 @@ #include "../include/lprocfs_status.h" #include "../include/lustre/lustre_idl.h" #include <linux/seq_file.h> +#include <linux/ctype.h> static const char * const obd_connect_names[] = { "read_only", @@ -1849,7 +1850,7 @@ int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult) } EXPORT_SYMBOL(lprocfs_seq_read_frac_helper); -int lprocfs_write_u64_helper(const char *buffer, unsigned long count, +int lprocfs_write_u64_helper(const char __user *buffer, unsigned long count, __u64 *val) { return lprocfs_write_frac_u64_helper(buffer, count, val, 1); @@ -1862,6 +1863,7 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count, char kernbuf[22], *end, *pbuf; __u64 whole, frac = 0, units; unsigned frac_d = 1; + int sign = 1; if (count > (sizeof(kernbuf) - 1)) return -EINVAL; @@ -1872,7 +1874,7 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count, kernbuf[count] = '\0'; pbuf = kernbuf; if (*pbuf == '-') { - mult = -mult; + sign = -1; pbuf++; } @@ -1880,7 +1882,7 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count, if (pbuf == end) return -EINVAL; - if (end != NULL && *end == '.') { + if (*end == '.') { int i; pbuf = end + 1; @@ -1895,25 +1897,25 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count, } units = 1; - switch (*end) { - case 'p': case 'P': + switch (tolower(*end)) { + case 'p': units <<= 10; - case 't': case 'T': + case 't': units <<= 10; - case 'g': case 'G': + case 'g': units <<= 10; - case 'm': case 'M': + case 'm': units <<= 10; - case 'k': case 'K': + case 'k': units <<= 10; } /* Specified units override the multiplier */ - if (units) - mult = mult < 0 ? -units : units; + if (units > 1) + mult = units; frac *= mult; do_div(frac, frac_d); - *val = whole * mult + frac; + *val = sign * (whole * mult + frac); return 0; } EXPORT_SYMBOL(lprocfs_write_frac_u64_helper); |