proc_dointvec() and write
The commit 00b7c3395aec3df43de5bd02a3c5a099ca51169f "sysctl: refactor integer handling proc code" modified the behaviour of writing to /proc.
Before the commit, write("1\n") to /proc/sys/kernel/printk succeeded. But now it returns EINVAL. Is this intended change? If not, how about this patch?
J. R. Okajima
kernel/sysctl.c +3 -1
@@ -2262,6 +2272,8 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,if (write) { left -=proc_skip_spaces (&kbuf); +if (!left) +break ; err =proc_get_long (&kbuf, &left, &lval, &neg, proc_wspace_sep,sizeof (proc_wspace_sep),NULL );
@@ -2288,7 +2306,7 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,if (!write && !first && left && !err) err =proc_put_char (&buffer, &left,'\n' ); -if (write && !err) +if (write && !err && left) left -=proc_skip_spaces (&kbuf); free:if (write) {
Quoted 8 lines · J. R. Okajima
The commit
00b7c3395aec3df43de5bd02a3c5a099ca51169f"sysctl: refactor integer handling proc code" modified the behaviour of writing to /proc.Before the commit,
write("1\n")to/proc/sys/kernel/printksucceeded. But now it returns EINVAL. Is this intended change? If not, how about this patch?
Hmm, odd, I tested other proc files, I see no problem. I am wondering why /proc/sys/kernel/printk is special here.
I will be back later.
Quoted 26 lines
J. R. Okajima
kernel/sysctl.c +3
-1@@ -2262,6 +2272,8 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,if (write) { left -=proc_skip_spaces (&kbuf); +if (!left) +break ; err =proc_get_long (&kbuf,&left,&lval,&neg, proc_wspace_sep,sizeof (proc_wspace_sep),NULL );@@ -2288,7 +2306,7 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,if (!write&& !first&& left&& !err) err =proc_put_char (&buffer,&left,'\n' ); -if (write&& !err) +if (write&& !err&& left) left -=proc_skip_spaces (&kbuf); free:if (write) {
Cong Wang:
Quoted 2 lines
Hmm, odd, I tested other proc files, I see no problem. I am wondering why
/proc/sys/kernel/printkis special here.
The condition is,
- the entry has multiple values, .maxlen = N * sizeof(foo)
- the entry is writable, .mode = 0644 (or something)
In sysctl.c, only "printk" and "acct" match.
J. R. Okajima
Quoted 9 lines · J. R. Okajima
Cong Wang:
Quoted 2 lines
Hmm, odd, I tested other proc files, I see no problem. I am wondering why
/proc/sys/kernel/printkis special here.The condition is,
- the entry has multiple values, .maxlen = N * sizeof(foo)
- the entry is writable, .mode = 0644 (or something)In
sysctl.c, only "printk" and "acct" match.
Hmm, right, I missed this case during testing.
Your patch looks correct for me. Would you mind to send your patch again with your Signed-off-by?
Thank you!
PATCH 1/1 proc_dointvec, write a single value
The commit 00b7c3395aec3df43de5bd02a3c5a099ca51169f
"sysctl: refactor integer handling proc code"
modified the behaviour of writing to /proc.
Before the commit, write("1\n") to /proc/sys/kernel/printk succeeded. But now it returns EINVAL.
This commit supports writing a single value to a multi-valued entry.
--- kernel/sysctl.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
kernel/sysctl.c +3 -1
@@ -2262,6 +2262,8 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,if (write) { left -=proc_skip_spaces (&kbuf); +if (!left) +break ; err =proc_get_long (&kbuf, &left, &lval, &neg, proc_wspace_sep,sizeof (proc_wspace_sep),NULL );
@@ -2288,7 +2290,7 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,if (!write && !first && left && !err) err =proc_put_char (&buffer, &left,'\n' ); -if (write && !err) +if (write && !err && left) left -=proc_skip_spaces (&kbuf); free:if (write) {
Signature · 1 line
1.6.6.1
Re: [PATCH] proc_dointvec, write a single value
Quoted 9 lines · J. R. Okajima
The commit
00b7c3395aec3df43de5bd02a3c5a099ca51169f
"sysctl: refactor integer handling proc code"
modified the behaviour of writing to /proc.
Before the commit,write("1\n")to/proc/sys/kernel/printksucceeded. But now it returns EINVAL.This commit supports writing a single value to a multi-valued entry.
Signed-off-by J. R. Okajima<[email protected]>
Thanks a lot!
Quoted 26 lines
--- kernel/sysctl.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)kernel/sysctl.c +3
-1@@ -2262,6 +2262,8 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,if (write) { left -=proc_skip_spaces (&kbuf); +if (!left) +break ; err =proc_get_long (&kbuf,&left,&lval,&neg, proc_wspace_sep,sizeof (proc_wspace_sep),NULL );@@ -2288,7 +2290,7 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,if (!write&& !first&& left&& !err) err =proc_put_char (&buffer,&left,'\n' ); -if (write&& !err) +if (write&& !err&& left) left -=proc_skip_spaces (&kbuf); free:if (write) {
Re: [PATCH] proc_dointvec, write a single value
From: Cong Wang <[email protected]>
Date: Tue, 25 May 2010 20:23:47 +0800
Quoted 8 lines · J. R. Okajima
Quoted 7 lines
The commit
00b7c3395aec3df43de5bd02a3c5a099ca51169f"sysctl: refactor integer handling proc code" modified the behaviour of writing to /proc. Before the commit,write("1\n")to/proc/sys/kernel/printksucceeded. But
now it returns EINVAL.
Quoted 5 lines
Quoted 3 lines
This commit supports writing a single value to a multi-valued entry.
Signed-off-by J. R. Okajima<[email protected]>Reviewed-and-tested-by WANG Cong <[email protected]>
Since the regression causing change came in via the net tree I'll integrate this fix too, applied, thanks!
Re: [PATCH] proc_dointvec, write a single value
Quoted 11 lines · David Miller
From: Cong Wang <[email protected]>
Date: Tue, 25 May 2010 20:23:47 +0800Quoted 8 lines · J. R. Okajima
Quoted 7 lines
The commit
00b7c3395aec3df43de5bd02a3c5a099ca51169f"sysctl: refactor integer handling proc code" modified the behaviour of writing to /proc. Before the commit,write("1\n")to/proc/sys/kernel/printksucceeded. But
now it returns EINVAL.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
This commit supports writing a single value to a multi-valued entry.
Signed-off-by J. R. Okajima<[email protected]>Reviewed-and-tested-by WANG Cong <[email protected]>Since the regression causing change came in via the net tree I'll integrate this fix too, applied, thanks!
Thanks, guys for fixing this.
I hate to see my review comments show up like this in practice. I had really hoped those unnecessary changes to proc would have been dropped from that patchset. Oh well.
Eric