Whamcloud - gitweb
LU-7334 lprocfs: Refactored string to value helpers
[fs/lustre-release.git] / lustre / lov / lproc_lov.c
index 4732a35..ac3bb1a 100644 (file)
@@ -60,19 +60,22 @@ static ssize_t lov_stripesize_seq_write(struct file *file,
                                        size_t count, loff_t *off)
 {
        struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
-        struct lov_desc *desc;
-        __u64 val;
-        int rc;
-
-        LASSERT(dev != NULL);
-        desc = &dev->u.lov.desc;
-        rc = lprocfs_write_u64_helper(buffer, count, &val);
-        if (rc)
-                return rc;
-
-        lov_fix_desc_stripe_size(&val);
-        desc->ld_default_stripe_size = val;
-        return count;
+       struct lov_desc *desc;
+       __s64 val;
+       int rc;
+
+       LASSERT(dev != NULL);
+       desc = &dev->u.lov.desc;
+       rc = lprocfs_str_to_s64(buffer, count, &val);
+       if (rc)
+               return rc;
+       if (val < 0)
+               return -ERANGE;
+
+       lov_fix_desc_stripe_size(&val);
+       desc->ld_default_stripe_size = val;
+
+       return count;
 }
 LPROC_SEQ_FOPS(lov_stripesize);
 
@@ -92,18 +95,21 @@ static ssize_t lov_stripeoffset_seq_write(struct file *file,
                                          size_t count, loff_t *off)
 {
        struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
-        struct lov_desc *desc;
-        __u64 val;
-        int rc;
-
-        LASSERT(dev != NULL);
-        desc = &dev->u.lov.desc;
-        rc = lprocfs_write_u64_helper(buffer, count, &val);
-        if (rc)
-                return rc;
-
-        desc->ld_default_stripe_offset = val;
-        return count;
+       struct lov_desc *desc;
+       __s64 val;
+       int rc;
+
+       LASSERT(dev != NULL);
+       desc = &dev->u.lov.desc;
+       rc = lprocfs_str_to_s64(buffer, count, &val);
+       if (rc)
+               return rc;
+       if (val < 0)
+               return -ERANGE;
+
+       desc->ld_default_stripe_offset = val;
+
+       return count;
 }
 LPROC_SEQ_FOPS(lov_stripeoffset);
 
@@ -123,18 +129,23 @@ static ssize_t lov_stripetype_seq_write(struct file *file,
                                        size_t count, loff_t *off)
 {
        struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
-        struct lov_desc *desc;
-        int val, rc;
-
-        LASSERT(dev != NULL);
-        desc = &dev->u.lov.desc;
-        rc = lprocfs_write_helper(buffer, count, &val);
-        if (rc)
-                return rc;
-
-        lov_fix_desc_pattern(&val);
-        desc->ld_pattern = val;
-        return count;
+       struct lov_desc *desc;
+       int pattern, rc;
+       __s64 val;
+
+       LASSERT(dev != NULL);
+       desc = &dev->u.lov.desc;
+       rc = lprocfs_str_to_s64(buffer, count, &val);
+       if (rc)
+               return rc;
+       if (val < INT_MIN || val > INT_MAX)
+               return -ERANGE;
+
+       pattern = val;
+       lov_fix_desc_pattern(&pattern);
+       desc->ld_pattern = pattern;
+
+       return count;
 }
 LPROC_SEQ_FOPS(lov_stripetype);
 
@@ -155,18 +166,24 @@ static ssize_t lov_stripecount_seq_write(struct file *file,
                                         size_t count, loff_t *off)
 {
        struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
-        struct lov_desc *desc;
-        int val, rc;
-
-        LASSERT(dev != NULL);
-        desc = &dev->u.lov.desc;
-        rc = lprocfs_write_helper(buffer, count, &val);
-        if (rc)
-                return rc;
-
-        lov_fix_desc_stripe_count(&val);
-        desc->ld_default_stripe_count = val;
-        return count;
+       struct lov_desc *desc;
+       int rc;
+       __u32 stripe_count;
+       __s64 val;
+
+       LASSERT(dev != NULL);
+       desc = &dev->u.lov.desc;
+       rc = lprocfs_str_to_s64(buffer, count, &val);
+       if (rc)
+               return rc;
+       if (val < 0)
+               return -ERANGE;
+
+       stripe_count = val;
+       lov_fix_desc_stripe_count(&stripe_count);
+       desc->ld_default_stripe_count = stripe_count;
+
+       return count;
 }
 LPROC_SEQ_FOPS(lov_stripecount);