From: Lucian Adrian Grijincu <lucian.grijincu@gmail.com>
To: "David S. Miller" <davem@davemloft.net>,
Alexey Dobriyan <adobriyan@gmail.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Octavian Purdila <tavi@cs.pub.ro>, netdev@vger.kernel.org,
Cc: Lucian Adrian Grijincu <lucian.grijincu@gmail.com>
Subject: [PATCH 2/9] sysctl: use ctl_header_cookie in proc_handler
Date: Fri, 25 Feb 2011 20:52:34 +0200 [thread overview]
Message-ID: <1298659961-23863-3-git-send-email-lucian.grijincu@gmail.com> (raw)
In-Reply-To: <1298659961-23863-1-git-send-email-lucian.grijincu@gmail.com>
TODO: if this patch series gets a positive feedback this patch will be
extended with a kernel-wide change of each proc_handler to add a
'cookie' argument.
Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@gmail.com>
---
fs/proc/proc_sysctl.c | 11 ++++++++++-
include/linux/sysctl.h | 3 +++
2 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 09a1f92..85b6b75 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -135,6 +135,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
struct inode *inode = filp->f_path.dentry->d_inode;
struct ctl_table_header *head = grab_header(inode);
struct ctl_table *table = PROC_I(inode)->sysctl_entry;
+ proc_handler_cookie *phc = (proc_handler_cookie *) table->proc_handler;
ssize_t error;
size_t res;
@@ -156,7 +157,15 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
/* careful: calling conventions are nasty here */
res = count;
- error = table->proc_handler(table, write, buf, &res, ppos);
+ /*XXX Most handlers only use the first 5 arguments (without
+ *XXX @cookie). Changing all handlers is too much of work,
+ *XXX as this is only a RFC patch at the moment.
+ *XXX
+ *XXX This is just a HACK for now, I did this this way to not
+ *XXX waste time changing all the handlers, in the final version
+ *XXX I'll change all the handlers if there's not other solution.
+ */
+ error = phc(table, write, buf, &res, ppos, head->ctl_header_cookie);
if (!error)
error = res;
out:
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 43fed29..3d21832 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -963,6 +963,9 @@ typedef struct ctl_table ctl_table;
typedef int proc_handler (struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *ppos);
+typedef int proc_handler_cookie(struct ctl_table *ctl, int write,
+ void __user *buffer, size_t *lenp,
+ loff_t *ppos, void *ctl_header_cookie);
extern int proc_dostring(struct ctl_table *, int,
void __user *, size_t *, loff_t *);
--
1.7.4.rc1.7.g2cf08.dirty
next prev parent reply other threads:[~2011-02-25 18:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-25 18:52 RFC v1: sysctl: add sysctl header cookie, share tables between nets Lucian Adrian Grijincu
2011-02-25 18:52 ` [PATCH 1/9] sysctl: add ctl_header_cookie Lucian Adrian Grijincu
2011-02-25 18:52 ` Lucian Adrian Grijincu [this message]
2011-02-25 18:52 ` [PATCH 3/9] sysctl: add netns_proc_dointvec and similar handlers Lucian Adrian Grijincu
2011-02-25 18:52 ` [PATCH 4/9] sysctl: ipv4: ipfrag: share ip4_frags_ns_ctl_table between nets Lucian Adrian Grijincu
2011-02-25 18:52 ` [PATCH 5/9] sysctl: net: share netns_core_table " Lucian Adrian Grijincu
2011-02-25 18:52 ` [PATCH 6/9] sysctl: route: share ipv4_route_flush_table " Lucian Adrian Grijincu
2011-02-25 18:52 ` [PATCH 7/9] sysctl: ipv4: share ipv4_net_table " Lucian Adrian Grijincu
2011-02-25 18:52 ` [PATCH 8/9] sysctl: ipv6: share ip6_frags_ns_ctl_table " Lucian Adrian Grijincu
2011-02-25 18:52 ` [PATCH 9/9] sysctl: ipv6: share ip6_ctl_table, ipv6_icmp_table and ipv6_route_table " Lucian Adrian Grijincu
2011-03-03 1:06 ` RFC v1: sysctl: add sysctl header cookie, share tables " David Miller
2011-03-03 9:33 ` Eric W. Biederman
2011-03-03 22:32 ` Lucian Adrian Grijincu
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=1298659961-23863-3-git-send-email-lucian.grijincu@gmail.com \
--to=lucian.grijincu@gmail.com \
--cc=adobriyan@gmail.com \
--cc=davem@davemloft.net \
--cc=ebiederm@xmission.com \
--cc=netdev@vger.kernel.org \
--cc=tavi@cs.pub.ro \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).