From: Dave Young <hidave.darkstar@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>, David Miller <davem@davemloft.net>,
Don Zickus <dzickus@redhat.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 03/04 v2] sysctl: add proc_dointvec_unsigned handler
Date: Fri, 4 Mar 2011 23:47:06 +0800 [thread overview]
Message-ID: <20110304154706.GC14672@darkstar> (raw)
Add proc_dointvec_unsigned sysctl handler for positive value cases
Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
---
include/linux/sysctl.h | 2 ++
kernel/sysctl.c | 26 ++++++++++++++++++++++++++
2 files changed, 28 insertions(+)
--- linux-2.6.orig/kernel/sysctl.c 2011-03-03 11:17:21.796661240 +0800
+++ linux-2.6/kernel/sysctl.c 2011-03-03 11:17:39.126661201 +0800
@@ -2459,6 +2459,32 @@ int proc_dointvec_bool(struct ctl_table
}
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, ¶m);
+}
+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,
--- linux-2.6.orig/include/linux/sysctl.h 2011-03-03 11:16:16.000000000 +0800
+++ linux-2.6/include/linux/sysctl.h 2011-03-03 11:18:15.529994450 +0800
@@ -972,6 +972,8 @@ extern int proc_dointvec_minmax(struct c
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,
reply other threads:[~2011-03-04 15:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110304154706.GC14672@darkstar \
--to=hidave.darkstar@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=dzickus@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.