lkml.org 
[lkml]   [2011]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectRe: + sysctl-add-proc_dointvec_unsigned-handler.patch added to -mm tree
From
On Fri, May 27, 2011 at 12:51 PM, Alexey Dobriyan <adobriyan@gmail.com> wrote:
> On Thu, May 26, 2011 at 12:59:18PM -0700, Andrew Morton wrote:
>>
>> So... where did we end up with this discussion?
>>
>> There are four patches involved:
>
>> http://userweb.kernel.org/~akpm/mmotm/broken-out/sysctl-add-proc_dointvec_unsigned-handler.patch
>> http://userweb.kernel.org/~akpm/mmotm/broken-out/sysctl-use-proc_dointvec_unsigned-where-appropriate.patch
>
> This still sucks:
> * .extra2 aka max is ignored(!)
> * even if not ignored, API can't be used on array, because min and max
>  boundaries should match wrt length.
>

Andrew, I'm offline last days, sorry for late reply.

Alexey, I updated the patch, do you feel better?

--
Regards
dave
From: Dave Young <hidave.darkstar@gmail.com>

Add a proc_dointvec_unsigned() sysctl handler for positive value cases.

V2 changes:
As to Alexey Dobriyan: do not ignore max in proc_dointvec_unsigned param setup.

Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

include/linux/sysctl.h | 2 ++
kernel/sysctl.c | 27 +++++++++++++++++++++++++++
2 files changed, 29 insertions(+)

--- linux-2.6.orig/include/linux/sysctl.h 2011-04-27 13:58:51.343332511 +0800
+++ linux-2.6/include/linux/sysctl.h 2011-06-01 16:28:07.679536892 +0800
@@ -971,6 +971,8 @@ extern int proc_dointvec(struct ctl_tabl
void __user *, size_t *, loff_t *);
extern int proc_dointvec_minmax(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,
--- linux-2.6.orig/kernel/sysctl.c 2011-06-01 16:08:51.682872883 +0800
+++ linux-2.6/kernel/sysctl.c 2011-06-01 16:29:48.389536662 +0800
@@ -2476,6 +2476,33 @@ int proc_dointvec_minmax(struct ctl_tabl
do_proc_dointvec_minmax_conv, &param);
}

+/**
+ * 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,
+ .max = (int *) table->extra2,
+ };
+ 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,
\
 
 \ /
  Last update: 2011-06-01 10:51    [W:0.093 / U:2.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site