unsigned long count, __s64 *val,
char defunit);
+extern int lprocfs_str_with_units_to_u64(const char __user *buffer,
+ unsigned long count, __u64 *val,
+ char defunit);
+
char *lprocfs_strnstr(const char *s1, const char *s2, size_t len);
char *lprocfs_find_named_value(const char *buffer, const char *name,
size_t *count);
return 0;
}
+/* identical to s64 version, but does not handle overflow */
+static int str_to_u64_internal(const char __user *buffer, unsigned long count,
+ __u64 *val, __u64 def_mult, bool allow_units)
+{
+ char kernbuf[22];
+ unsigned int offset = 0;
+ int rc = 0;
+
+ if (count > (sizeof(kernbuf) - 1))
+ return -EINVAL;
+
+ if (copy_from_user(kernbuf, buffer, count))
+ return -EFAULT;
+
+ kernbuf[count] = '\0';
+
+ rc = str_to_u64_parse(kernbuf + offset, count - offset,
+ val, def_mult, allow_units);
+ if (rc)
+ return rc;
+
+ return 0;
+}
/**
* Convert a user string into a signed 64 bit number. This function produces
* an error when the value parsed from the string times multiplier underflows or
}
EXPORT_SYMBOL(lprocfs_str_with_units_to_s64);
+/* identical to s64 version above, but does not handle overflow */
+int lprocfs_str_with_units_to_u64(const char __user *buffer,
+ unsigned long count, __u64 *val, char defunit)
+{
+ __u64 mult = 1;
+ int rc;
+
+ if (defunit != '1') {
+ rc = get_mult(defunit, &mult);
+ if (rc)
+ return rc;
+ }
+
+ return str_to_u64_internal(buffer, count, val, mult, true);
+}
+EXPORT_SYMBOL(lprocfs_str_with_units_to_u64);
+
char *lprocfs_strnstr(const char *s1, const char *s2, size_t len)
{
size_t l2;
struct seq_file *m = file->private_data;
struct dt_device *dt = m->private;
struct osd_device *osd = osd_dt_dev(dt);
- s64 val;
+ u64 val;
int rc;
LASSERT(osd != NULL);
if (unlikely(osd->od_mnt == NULL))
return -EINPROGRESS;
- rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '1');
+ rc = lprocfs_str_with_units_to_u64(buffer, count, &val, '1');
if (rc)
return rc;
- if (val < 0)
- return -ERANGE;
osd->od_readcache_max_filesize = val > OSD_MAX_CACHE_SIZE ?
OSD_MAX_CACHE_SIZE : val;
struct seq_file *m = file->private_data;
struct dt_device *dt = m->private;
struct osd_device *osd = osd_dt_dev(dt);
- s64 val;
+ u64 val;
int rc;
LASSERT(osd != NULL);
if (unlikely(osd->od_os == NULL))
return -EINPROGRESS;
- rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '1');
+ rc = lprocfs_str_with_units_to_u64(buffer, count, &val, '1');
if (rc)
return rc;
- if (val < 0)
- return -ERANGE;
osd->od_readcache_max_filesize = val > OSD_MAX_CACHE_SIZE ?
OSD_MAX_CACHE_SIZE : val;