public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* sysctl: add proc_dointvec_bool handler
@ 2011-03-04 15:45 Dave Young
  2011-03-04 15:50 ` Dave Young
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Young @ 2011-03-04 15:45 UTC (permalink / raw)
  To: Andrew Morton, Ingo Molnar, David Miller, Don Zickus,
	linux-kernel

Add proc_dointvec_bool sysctl handler for cases value is limited to 0 and 1

Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
---
 include/linux/sysctl.h |    2 ++
 kernel/sysctl.c        |   27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

--- linux-2.6.orig/kernel/sysctl.c	2011-03-03 11:13:01.986661838 +0800
+++ linux-2.6/kernel/sysctl.c	2011-03-03 11:15:52.196661447 +0800
@@ -2448,6 +2448,33 @@ int proc_dointvec_minmax(struct ctl_tabl
 				do_proc_dointvec_minmax_conv, &param);
 }
 
+/**
+ * proc_dointvec_bool - read a vector of integers with 0/1 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 either 0 or 1.
+ *
+ * Returns 0 on success.
+ */
+int proc_dointvec_bool(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 = &one,
+	};
+	return do_proc_dointvec(table, write, buffer, lenp, ppos,
+				do_proc_dointvec_minmax_conv, &param);
+}
+EXPORT_SYMBOL(proc_dointvec_bool);
+
 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	2010-06-22 14:02:49.000000000 +0800
+++ linux-2.6/include/linux/sysctl.h	2011-03-03 11:16:16.119994725 +0800
@@ -970,6 +970,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_bool(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,

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: sysctl: add proc_dointvec_bool handler
  2011-03-04 15:45 sysctl: add proc_dointvec_bool handler Dave Young
@ 2011-03-04 15:50 ` Dave Young
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Young @ 2011-03-04 15:50 UTC (permalink / raw)
  To: Andrew Morton, Ingo Molnar, David Miller, Don Zickus,
	linux-kernel

On Fri, Mar 4, 2011 at 11:45 PM, Dave Young <hidave.darkstar@gmail.com> wrote:
> Add proc_dointvec_bool sysctl handler for cases value is limited to 0 and 1
>
> Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
> ---
>  include/linux/sysctl.h |    2 ++
>  kernel/sysctl.c        |   27 +++++++++++++++++++++++++++
>  2 files changed, 29 insertions(+)
>
> --- linux-2.6.orig/kernel/sysctl.c      2011-03-03 11:13:01.986661838 +0800
> +++ linux-2.6/kernel/sysctl.c   2011-03-03 11:15:52.196661447 +0800

This one is PATCH 01/04,  I missed the info in subject

-- 
Regards
dave

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-03-04 15:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-04 15:45 sysctl: add proc_dointvec_bool handler Dave Young
2011-03-04 15:50 ` Dave Young

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox