]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Add a proc_dointvec_unsigned() sysctl handler for positive value cases.
authorDave Young <hidave.darkstar@gmail.com>
Wed, 3 Aug 2011 00:53:03 +0000 (10:53 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 22 Aug 2011 03:27:18 +0000 (13:27 +1000)
Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/sysctl.h
kernel/sysctl.c

index 991736ef96876a4227f2b7447f43c9bd174f95e0..2487af98839789b10b871f9a95ad26e3908e4feb 100644 (file)
@@ -973,6 +973,8 @@ extern int proc_dointvec_minmax(struct ctl_table *, int,
                                void __user *, size_t *, loff_t *);
 extern int proc_dointvec_bool(struct ctl_table *, int,
                                void __user *, size_t *, loff_t *);
+extern int proc_dointvec_unsigned(struct ctl_table *, int,
+                               void __user *, size_t *, loff_t *);
 extern int proc_dointvec_jiffies(struct ctl_table *, int,
                                 void __user *, size_t *, loff_t *);
 extern int proc_dointvec_userhz_jiffies(struct ctl_table *, int,
index b09b6be2ab1908d13a4dd30f60d95c8ffbdbb75d..3637115bc32cad093b033986dce4681954acbc88 100644 (file)
@@ -2490,6 +2490,32 @@ int proc_dointvec_bool(struct ctl_table *table, int write,
 }
 EXPORT_SYMBOL(proc_dointvec_bool);
 
+/**
+ * proc_dointvec_unsigned - read a vector of integers with positive values
+ * @table: the sysctl table
+ * @write: %TRUE if this is a write to the sysctl file
+ * @buffer: the user buffer
+ * @lenp: the size of the user buffer
+ * @ppos: file position
+ *
+ * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
+ * values from/to the user buffer, treated as an ASCII string.
+ *
+ * This routine will ensure the values are positive.
+ *
+ * Returns 0 on success.
+ */
+int proc_dointvec_unsigned(struct ctl_table *table, int write,
+                 void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       struct do_proc_dointvec_minmax_conv_param param = {
+               .min = &zero,
+       };
+       return do_proc_dointvec(table, write, buffer, lenp, ppos,
+                               do_proc_dointvec_minmax_conv, &param);
+}
+EXPORT_SYMBOL(proc_dointvec_unsigned);
+
 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
                                     void __user *buffer,
                                     size_t *lenp, loff_t *ppos,