cifs: call strtobool instead of custom implementation
Subsystems (2)
PATCH 1/1 cifs: call strtobool instead of custom implementation
--- fs/cifs/cifs_debug.c | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-)
fs/cifs/cifs_debug.c +29 -22
@@ -274,6 +274,7 @@ static ssize_t cifs_stats_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc;struct list_head *tmp1, *tmp2, *tmp3;struct TCP_Server_Info *server;
@@ -284,7 +285,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,if (rc)return rc; -if (c =='1' || c =='y' || c =='Y' || c =='0' ) { +if (strtobool (&c, &bv) ==0 ) {#ifdef CONFIG_CIFS_STATS2 atomic_set (&totBufAllocCount,0 );atomic_set (&totSmBufAllocCount,0 );
@@ -451,15 +452,14 @@ static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - cifsFYI =0 ; -else if (c =='1' || c =='y' || c =='Y' ) - cifsFYI =1 ; +if (strtobool (&c, &bv) ==0 ) + cifsFYI = bv;else if ((c >'1' ) && (c <='9' )) cifsFYI = (int ) (c -'0' );/* see cifs_debug.h for meanings */
@@ -490,15 +490,18 @@ static ssize_t cifs_linux_ext_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - linuxExtEnabled =0 ; -else if (c =='1' || c =='y' || c =='Y' ) - linuxExtEnabled =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + linuxExtEnabled = bv;return count; }
@@ -527,15 +530,18 @@ static ssize_t cifs_lookup_cache_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - lookupCacheEnabled =0 ; -else if (c =='1' || c =='y' || c =='Y' ) - lookupCacheEnabled =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + lookupCacheEnabled = bv;return count; }
@@ -564,15 +570,18 @@ static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - traceSMB =0 ; -else if (c =='1' || c =='y' || c =='Y' ) - traceSMB =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + traceSMB = bv;return count; }
@@ -630,6 +639,7 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,unsigned int flags;char flags_string[12 ];char c; +bool bv;if ((count <1 ) || (count >11 ))return -EINVAL ;
@@ -642,11 +652,8 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,if (count <3 ) {/* single char or single char followed by null */ c = flags_string[0 ]; -if (c =='0' || c =='n' || c =='N' ) { - global_secflags =CIFSSEC_DEF ;/* default */ -return count; - }else if (c =='1' || c =='y' || c =='Y' ) { - global_secflags =CIFSSEC_MAX ; +if (strtobool (&c, &bv) ==0 ) { + global_secflags = bv ?CIFSSEC_MAX :CIFSSEC_DEF ;return count; }else if (!isdigit (c)) { cifs_dbg(VFS, "Invalid SecurityFlags: %s\n",
Signature · 1 line
1.9.2
A message that is not in the archive (sent off-list or not yet received): 1398783193-13741-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]
I don't have a strong opinion on whether this change makes it more or less readable. Any other opinions?
Quoted 139 lines · Andy Shevchenko
--- fs/cifs/cifs_debug.c | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-)fs/cifs/cifs_debug.c +29
-23@@ -274,6 +274,7 @@ static ssize_t cifs_stats_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc;struct list_head *tmp1, *tmp2, *tmp3;struct TCP_Server_Info *server;@@ -284,7 +285,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,if (rc)return rc; -if (c =='1' || c =='y' || c =='Y' || c =='0' ) { +if (strtobool (&c, &bv) ==0 ) {#ifdef CONFIG_CIFS_STATS2 atomic_set (&totBufAllocCount,0 );atomic_set (&totSmBufAllocCount,0 );@@ -451,15 +452,14 @@ static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - cifsFYI =0 ; -else if (c =='1' || c =='y' || c =='Y' ) - cifsFYI =1 ; +if (strtobool (&c, &bv) ==0 ) + cifsFYI = bv;else if ((c >'1' ) && (c <='9' )) cifsFYI = (int ) (c -'0' );/* see cifs_debug.h for meanings */ @@ -490,15 +490,18 @@ static ssize_t cifs_linux_ext_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - linuxExtEnabled =0 ; -else if (c =='1' || c =='y' || c =='Y' ) - linuxExtEnabled =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + linuxExtEnabled = bv;return count; }@@ -527,15 +530,18 @@ static ssize_t cifs_lookup_cache_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - lookupCacheEnabled =0 ; -else if (c =='1' || c =='y' || c =='Y' ) - lookupCacheEnabled =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + lookupCacheEnabled = bv;return count; }@@ -564,15 +570,18 @@ static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - traceSMB =0 ; -else if (c =='1' || c =='y' || c =='Y' ) - traceSMB =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + traceSMB = bv;return count; }@@ -630,6 +639,7 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,unsigned int flags;char flags_string[12 ];char c; +bool bv;if ((count <1 ) || (count >11 ))return -EINVAL ;@@ -642,11 +652,8 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,if (count <3 ) {/* single char or single char followed by null */ c = flags_string[0 ]; -if (c =='0' || c =='n' || c =='N' ) { - global_secflags =CIFSSEC_DEF ;/* default */ -return count; - }else if (c =='1' || c =='y' || c =='Y' ) { - global_secflags =CIFSSEC_MAX ; +if (strtobool (&c, &bv) ==0 ) { + global_secflags = bv ?CIFSSEC_MAX :CIFSSEC_DEF ;return count; }else if (!isdigit (c)) { cifs_dbg(VFS, "Invalid SecurityFlags: %s\n", --1.9.2
Signature · 3 lines
Thanks, Steve
Quoted 58 lines · Andy Shevchenko
--- fs/cifs/cifs_debug.c | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-)fs/cifs/cifs_debug.c +6
-8@@ -274,6 +274,7 @@ static ssize_t cifs_stats_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc;struct list_head *tmp1, *tmp2, *tmp3;struct TCP_Server_Info *server;@@ -284,7 +285,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,if (rc)return rc; -if (c =='1' || c =='y' || c =='Y' || c =='0' ) { +if (strtobool (&c, &bv) ==0 ) {#ifdef CONFIG_CIFS_STATS2 atomic_set (&totBufAllocCount,0 );atomic_set (&totSmBufAllocCount,0 );@@ -451,15 +452,14 @@ static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - cifsFYI =0 ; -else if (c =='1' || c =='y' || c =='Y' ) - cifsFYI =1 ; +if (strtobool (&c, &bv) ==0 ) + cifsFYI = bv;else if ((c >'1' ) && (c <='9' )) cifsFYI = (int ) (c -'0' );/* see cifs_debug.h for meanings */ @@ -490,15 +490,18 @@ static ssize_t cifs_linux_ext_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - linuxExtEnabled =0 ; -else if (c =='1' || c =='y' || c =='Y' )
fs/cifs/cifs_debug.c static ssize_t cifs_linux_ext_proc_write(struct file *file, · line 507
Quoted 10 lines
fs/cifs/cifs_debug.c +6
-1- linuxExtEnabled =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + linuxExtEnabled = bv;return count; }
This changes the returned value of cifs_linux_ext_proc_write() to -EINVAL if strtobool() was not able to find a boolean value. Previously setting anything non-bool wouldn't cause this side-effect.
Steve, is it OK to you? This is certainly a visible change in that writing to a proc entry will cause user-space error where it was ignored before.
Quoted 13 lines
fs/cifs/cifs_debug.c +1
-3@@ -527,15 +530,18 @@ static ssize_t cifs_lookup_cache_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - lookupCacheEnabled =0 ; -else if (c =='1' || c =='y' || c =='Y' )
fs/cifs/cifs_debug.c static ssize_t cifs_lookup_cache_proc_write(struct file *file, · line 547
Quoted 10 lines
fs/cifs/cifs_debug.c +6
-1- lookupCacheEnabled =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + lookupCacheEnabled = bv;return count; }
Same here.
Quoted 13 lines
fs/cifs/cifs_debug.c +1
-3@@ -564,15 +570,18 @@ static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - traceSMB =0 ; -else if (c =='1' || c =='y' || c =='Y' )
fs/cifs/cifs_debug.c static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer, · line 587
Quoted 10 lines
fs/cifs/cifs_debug.c +6
-1- traceSMB =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + traceSMB = bv;return count; }
same here.
Quoted 25 lines
fs/cifs/cifs_debug.c +3
-5@@ -630,6 +639,7 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,unsigned int flags;char flags_string[12 ];char c; +bool bv;if ((count <1 ) || (count >11 ))return -EINVAL ;@@ -642,11 +652,8 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,if (count <3 ) {/* single char or single char followed by null */ c = flags_string[0 ]; -if (c =='0' || c =='n' || c =='N' ) { - global_secflags =CIFSSEC_DEF ;/* default */ -return count; - }else if (c =='1' || c =='y' || c =='Y' ) { - global_secflags =CIFSSEC_MAX ; +if (strtobool (&c, &bv) ==0 ) { + global_secflags = bv ?CIFSSEC_MAX :CIFSSEC_DEF ;return count; }else if (!isdigit (c)) { cifs_dbg(VFS, "Invalid SecurityFlags: %s\n",Signature · 1 line
1.9.2
Signature · 1 line
/ Alexander Bokovoy
A message that is not in the archive (sent off-list or not yet received): 20140512044114.GA19939-d+H2oAP8R5zifVmeSVo1ZkB+6BGkLq7r@public.gmane.org
Quoted 73 lines · Alexander Bokovoy
Quoted 58 lines · Andy Shevchenko
--- fs/cifs/cifs_debug.c | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-)fs/cifs/cifs_debug.c +6
-8@@ -274,6 +274,7 @@ static ssize_t cifs_stats_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc;struct list_head *tmp1, *tmp2, *tmp3;struct TCP_Server_Info *server;@@ -284,7 +285,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,if (rc)return rc; -if (c =='1' || c =='y' || c =='Y' || c =='0' ) { +if (strtobool (&c, &bv) ==0 ) {#ifdef CONFIG_CIFS_STATS2 atomic_set (&totBufAllocCount,0 );atomic_set (&totSmBufAllocCount,0 );@@ -451,15 +452,14 @@ static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - cifsFYI =0 ; -else if (c =='1' || c =='y' || c =='Y' ) - cifsFYI =1 ; +if (strtobool (&c, &bv) ==0 ) + cifsFYI = bv;else if ((c >'1' ) && (c <='9' )) cifsFYI = (int ) (c -'0' );/* see cifs_debug.h for meanings */ @@ -490,15 +490,18 @@ static ssize_t cifs_linux_ext_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - linuxExtEnabled =0 ; -else if (c =='1' || c =='y' || c =='Y' )fs/cifs/cifs_debug.c static ssize_t cifs_linux_ext_proc_write(struct file *file, · line 507
Quoted 10 lines
fs/cifs/cifs_debug.c +6
-1- linuxExtEnabled =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + linuxExtEnabled = bv;return count; }This changes the returned value of
cifs_linux_ext_proc_write()to-EINVALifstrtobool()was not able to find a boolean value. Previously setting anything non-bool wouldn't cause this side-effect.
Quoted 3 lines
Steve, is it OK to you? This is certainly a visible change in that writing to a proc entry will cause user-space error where it was ignored before.
Actually, good point. I have to mention this in the commit message.
Quoted 77 lines
Quoted 14 lines
fs/cifs/cifs_debug.c +1
-3@@ -527,15 +530,18 @@ static ssize_t cifs_lookup_cache_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - lookupCacheEnabled =0 ; -else if (c =='1' || c =='y' || c =='Y' )fs/cifs/cifs_debug.c static ssize_t cifs_lookup_cache_proc_write(struct file *file, · line 547
Quoted 10 lines
fs/cifs/cifs_debug.c +6
-1- lookupCacheEnabled =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + lookupCacheEnabled = bv;return count; }Same here.
Quoted 13 lines
fs/cifs/cifs_debug.c +1
-3@@ -564,15 +570,18 @@ static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - traceSMB =0 ; -else if (c =='1' || c =='y' || c =='Y' )fs/cifs/cifs_debug.c static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer, · line 587
Quoted 10 lines
fs/cifs/cifs_debug.c +6
-1- traceSMB =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + traceSMB = bv;return count; }same here.
Quoted 25 lines
fs/cifs/cifs_debug.c +3
-5@@ -630,6 +639,7 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,unsigned int flags;char flags_string[12 ];char c; +bool bv;if ((count <1 ) || (count >11 ))return -EINVAL ;@@ -642,11 +652,8 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,if (count <3 ) {/* single char or single char followed by null */ c = flags_string[0 ]; -if (c =='0' || c =='n' || c =='N' ) { - global_secflags =CIFSSEC_DEF ;/* default */ -return count; - }else if (c =='1' || c =='y' || c =='Y' ) { - global_secflags =CIFSSEC_MAX ; +if (strtobool (&c, &bv) ==0 ) { + global_secflags = bv ?CIFSSEC_MAX :CIFSSEC_DEF ;return count; }else if (!isdigit (c)) { cifs_dbg(VFS, "Invalid SecurityFlags: %s\n",Signature · 1 line
1.9.2
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 73 lines · On Mon, 12 May 2014 07:41:14 +0300 Alexander Bokovoy…
Quoted 58 lines · Andy Shevchenko
--- fs/cifs/cifs_debug.c | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-)fs/cifs/cifs_debug.c +6
-8@@ -274,6 +274,7 @@ static ssize_t cifs_stats_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc;struct list_head *tmp1, *tmp2, *tmp3;struct TCP_Server_Info *server;@@ -284,7 +285,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,if (rc)return rc; -if (c =='1' || c =='y' || c =='Y' || c =='0' ) { +if (strtobool (&c, &bv) ==0 ) {#ifdef CONFIG_CIFS_STATS2 atomic_set (&totBufAllocCount,0 );atomic_set (&totSmBufAllocCount,0 );@@ -451,15 +452,14 @@ static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - cifsFYI =0 ; -else if (c =='1' || c =='y' || c =='Y' ) - cifsFYI =1 ; +if (strtobool (&c, &bv) ==0 ) + cifsFYI = bv;else if ((c >'1' ) && (c <='9' )) cifsFYI = (int ) (c -'0' );/* see cifs_debug.h for meanings */ @@ -490,15 +490,18 @@ static ssize_t cifs_linux_ext_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - linuxExtEnabled =0 ; -else if (c =='1' || c =='y' || c =='Y' )fs/cifs/cifs_debug.c static ssize_t cifs_linux_ext_proc_write(struct file *file, · line 507
Quoted 10 lines
fs/cifs/cifs_debug.c +6
-1- linuxExtEnabled =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + linuxExtEnabled = bv;return count; }This changes the returned value of
cifs_linux_ext_proc_write()to-EINVALifstrtobool()was not able to find a boolean value. Previously setting anything non-bool wouldn't cause this side-effect.
Quoted 4 lines
Steve, is it OK to you? This is certainly a visible change in that writing to a proc entry will cause user-space error where it was ignored before.
I think returning an error there is the right thing to do. If someone is writing to this file, they likely mean for it to have some sort of an effect.
Honestly though, the *best* thing would be to (gradually) convert these procfile switches into module options. The way it stands now, it's really hard to set these at boot time. You have to:
# modprobe cifs
# echo N > /proc/fs/cifs/LinuxExtensionsEnabled
# mount -t cifs ...Making sure that gets done for anything in /etc/fstab is...tricky.
What would be best is to add module options that affect these variables that could be set via /etc/modprobe.d.
Then, either add a warning printk when someone writes to these files that they'll soon be deprecated (in 2-3 releases), or maybe turn them into symlinks that point to the files under /sys/module/cifs/parameters.
Quoted 76 lines
Quoted 13 lines
fs/cifs/cifs_debug.c +1
-3@@ -527,15 +530,18 @@ static ssize_t cifs_lookup_cache_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - lookupCacheEnabled =0 ; -else if (c =='1' || c =='y' || c =='Y' )fs/cifs/cifs_debug.c static ssize_t cifs_lookup_cache_proc_write(struct file *file, · line 547
Quoted 10 lines
fs/cifs/cifs_debug.c +6
-1- lookupCacheEnabled =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + lookupCacheEnabled = bv;return count; }Same here.
Quoted 13 lines
fs/cifs/cifs_debug.c +1
-3@@ -564,15 +570,18 @@ static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char c; +bool bv;int rc; rc =get_user (c, buffer);if (rc)return rc; -if (c =='0' || c =='n' || c =='N' ) - traceSMB =0 ; -else if (c =='1' || c =='y' || c =='Y' )fs/cifs/cifs_debug.c static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer, · line 587
Quoted 10 lines
fs/cifs/cifs_debug.c +6
-1- traceSMB =1 ; + + rc =strtobool (&c, &bv); +if (rc) +return rc; + + traceSMB = bv;return count; }same here.
Quoted 25 lines
fs/cifs/cifs_debug.c +3
-5@@ -630,6 +639,7 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,unsigned int flags;char flags_string[12 ];char c; +bool bv;if ((count <1 ) || (count >11 ))return -EINVAL ;@@ -642,11 +652,8 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,if (count <3 ) {/* single char or single char followed by null */ c = flags_string[0 ]; -if (c =='0' || c =='n' || c =='N' ) { - global_secflags =CIFSSEC_DEF ;/* default */ -return count; - }else if (c =='1' || c =='y' || c =='Y' ) { - global_secflags =CIFSSEC_MAX ; +if (strtobool (&c, &bv) ==0 ) { + global_secflags = bv ?CIFSSEC_MAX :CIFSSEC_DEF ;return count; }else if (!isdigit (c)) { cifs_dbg(VFS, "Invalid SecurityFlags: %s\n",Signature · 1 line
1.9.2
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20140512064100.5ba419a8-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Quoted 21 lines · Jeff Layton
Quoted 8 lines
This changes the returned value of
cifs_linux_ext_proc_write()to-EINVALifstrtobool()was not able to find a boolean value. Previously setting anything non-bool wouldn't cause this side-effect.Steve, is it OK to you? This is certainly a visible change in that writing to a proc entry will cause user-space error where it was ignored before.
I think returning an error there is the right thing to do. If someone is writing to this file, they likely mean for it to have some sort of an effect.
Honestly though, the *best* thing would be to (gradually) convert these procfile switches into module options. The way it stands now, it's really hard to set these at boot time. You have to:
# modprobe cifs # echo N > /proc/fs/cifs/LinuxExtensionsEnabled # mount -t cifs ...
Quoted 8 lines
Making sure that gets done for anything in
/etc/fstabis...tricky.What would be best is to add module options that affect these variables that could be set via
/etc/modprobe.d.Then, either add a warning printk when someone writes to these files that they'll soon be deprecated (in 2-3 releases), or maybe turn them into symlinks that point to the files under
/sys/module/cifs/parameters.
I agree.
I think strtobool() patches are fine (+ change to the commit message). The change to module options should certainly be done in a separate patchset.
Signature · 1 line
/ Alexander Bokovoy
A message that is not in the archive (sent off-list or not yet received): 20140512132203.GA31367-d+H2oAP8R5zifVmeSVo1ZkB+6BGkLq7r@public.gmane.org
Quoted 27 lines · Alexander Bokovoy
Quoted 26 lines · Jeff Layton
Quoted 8 lines
This changes the returned value of
cifs_linux_ext_proc_write()to-EINVALifstrtobool()was not able to find a boolean value. Previously setting anything non-bool wouldn't cause this side-effect.Steve, is it OK to you? This is certainly a visible change in that writing to a proc entry will cause user-space error where it was ignored before.
I think returning an error there is the right thing to do. If someone is writing to this file, they likely mean for it to have some sort of an effect.
Honestly though, the *best* thing would be to (gradually) convert these procfile switches into module options. The way it stands now, it's really hard to set these at boot time. You have to:
# modprobe cifs # echo N > /proc/fs/cifs/LinuxExtensionsEnabled # mount -t cifs ...Making sure that gets done for anything in
/etc/fstabis...tricky.What would be best is to add module options that affect these variables that could be set via
/etc/modprobe.d.
Quoted 6 lines
Quoted 3 lines
Then, either add a warning printk when someone writes to these files that they'll soon be deprecated (in 2-3 releases), or maybe turn them into symlinks that point to the files under
/sys/module/cifs/parameters.I agree.
I think
strtobool()patches are fine (+ change to the commit message).
I will resend v2 soon. Could I add your Acked-by or Reviewed-by?
Quoted 3 lines
The change to module options should certainly be done in a separate patchset.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
A message that is not in the archive (sent off-list or not yet received): 1399903195.3703.12.camel-XvqNBM/[email protected]
Quoted 28 lines · On Mon, 12 May 2014 16:59:55 +0300 Andy Shevchenko…
Quoted 27 lines · Alexander Bokovoy
Quoted 26 lines · Jeff Layton
Quoted 8 lines
This changes the returned value of
cifs_linux_ext_proc_write()to-EINVALifstrtobool()was not able to find a boolean value. Previously setting anything non-bool wouldn't cause this side-effect.Steve, is it OK to you? This is certainly a visible change in that writing to a proc entry will cause user-space error where it was ignored before.
I think returning an error there is the right thing to do. If someone is writing to this file, they likely mean for it to have some sort of an effect.
Honestly though, the *best* thing would be to (gradually) convert these procfile switches into module options. The way it stands now, it's really hard to set these at boot time. You have to:
# modprobe cifs # echo N > /proc/fs/cifs/LinuxExtensionsEnabled # mount -t cifs ...Making sure that gets done for anything in
/etc/fstabis...tricky.What would be best is to add module options that affect these variables that could be set via
/etc/modprobe.d.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Then, either add a warning printk when someone writes to these files that they'll soon be deprecated (in 2-3 releases), or maybe turn them into symlinks that point to the files under
/sys/module/cifs/parameters.I agree.
I think
strtobool()patches are fine (+ change to the commit message).I will resend v2 soon. Could I add your Acked-by or Reviewed-by?
Sure, you can add mine...
Quoted 5 lines
Quoted 3 lines
The change to module options should certainly be done in a separate patchset.
Agreed.
-- Jeff
Quoted 28 lines · Andy Shevchenko
Quoted 27 lines · Alexander Bokovoy
Quoted 26 lines · Jeff Layton
Quoted 8 lines
This changes the returned value of
cifs_linux_ext_proc_write()to-EINVALifstrtobool()was not able to find a boolean value. Previously setting anything non-bool wouldn't cause this side-effect.Steve, is it OK to you? This is certainly a visible change in that writing to a proc entry will cause user-space error where it was ignored before.
I think returning an error there is the right thing to do. If someone is writing to this file, they likely mean for it to have some sort of an effect.
Honestly though, the *best* thing would be to (gradually) convert these procfile switches into module options. The way it stands now, it's really hard to set these at boot time. You have to:
# modprobe cifs # echo N > /proc/fs/cifs/LinuxExtensionsEnabled # mount -t cifs ...Making sure that gets done for anything in
/etc/fstabis...tricky.What would be best is to add module options that affect these variables that could be set via
/etc/modprobe.d.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Then, either add a warning printk when someone writes to these files that they'll soon be deprecated (in 2-3 releases), or maybe turn them into symlinks that point to the files under
/sys/module/cifs/parameters.I agree.
I think
strtobool()patches are fine (+ change to the commit message).I will resend v2 soon. Could I add your Acked-by or Reviewed-by?
Sure, you can add mine.
Signature · 1 line
/ Alexander Bokovoy