提交 28e2aed2 编写于 作者: A Andy Shevchenko 提交者: Steve French

cifs: call strtobool instead of custom implementation

Meanwhile it cleans up the code, the behaviour is slightly changed. In case of
providing non-boolean value it will fails with corresponding error. In the
original code the attempt of an update was just ignored in such case.
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: NJeff Layton <jlayton@poochiereds.net>
Reviewed-by: NAlexander Bokovoy <ab@samba.org>
Signed-off-by: NSteve French <steve.french@primarydata.com>
上级 bb1d5dda
...@@ -274,6 +274,7 @@ static ssize_t cifs_stats_proc_write(struct file *file, ...@@ -274,6 +274,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
const char __user *buffer, size_t count, loff_t *ppos) const char __user *buffer, size_t count, loff_t *ppos)
{ {
char c; char c;
bool bv;
int rc; int rc;
struct list_head *tmp1, *tmp2, *tmp3; struct list_head *tmp1, *tmp2, *tmp3;
struct TCP_Server_Info *server; struct TCP_Server_Info *server;
...@@ -284,7 +285,7 @@ static ssize_t cifs_stats_proc_write(struct file *file, ...@@ -284,7 +285,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
if (rc) if (rc)
return rc; return rc;
if (c == '1' || c == 'y' || c == 'Y' || c == '0') { if (strtobool(&c, &bv) == 0) {
#ifdef CONFIG_CIFS_STATS2 #ifdef CONFIG_CIFS_STATS2
atomic_set(&totBufAllocCount, 0); atomic_set(&totBufAllocCount, 0);
atomic_set(&totSmBufAllocCount, 0); atomic_set(&totSmBufAllocCount, 0);
...@@ -451,15 +452,14 @@ static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer, ...@@ -451,15 +452,14 @@ static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
char c; char c;
bool bv;
int rc; int rc;
rc = get_user(c, buffer); rc = get_user(c, buffer);
if (rc) if (rc)
return rc; return rc;
if (c == '0' || c == 'n' || c == 'N') if (strtobool(&c, &bv) == 0)
cifsFYI = 0; cifsFYI = bv;
else if (c == '1' || c == 'y' || c == 'Y')
cifsFYI = 1;
else if ((c > '1') && (c <= '9')) else if ((c > '1') && (c <= '9'))
cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */ 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, ...@@ -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) const char __user *buffer, size_t count, loff_t *ppos)
{ {
char c; char c;
bool bv;
int rc; int rc;
rc = get_user(c, buffer); rc = get_user(c, buffer);
if (rc) if (rc)
return rc; return rc;
if (c == '0' || c == 'n' || c == 'N')
linuxExtEnabled = 0; rc = strtobool(&c, &bv);
else if (c == '1' || c == 'y' || c == 'Y') if (rc)
linuxExtEnabled = 1; return rc;
linuxExtEnabled = bv;
return count; return count;
} }
...@@ -527,15 +530,18 @@ static ssize_t cifs_lookup_cache_proc_write(struct file *file, ...@@ -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) const char __user *buffer, size_t count, loff_t *ppos)
{ {
char c; char c;
bool bv;
int rc; int rc;
rc = get_user(c, buffer); rc = get_user(c, buffer);
if (rc) if (rc)
return rc; return rc;
if (c == '0' || c == 'n' || c == 'N')
lookupCacheEnabled = 0; rc = strtobool(&c, &bv);
else if (c == '1' || c == 'y' || c == 'Y') if (rc)
lookupCacheEnabled = 1; return rc;
lookupCacheEnabled = bv;
return count; return count;
} }
...@@ -564,15 +570,18 @@ static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer, ...@@ -564,15 +570,18 @@ static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
char c; char c;
bool bv;
int rc; int rc;
rc = get_user(c, buffer); rc = get_user(c, buffer);
if (rc) if (rc)
return rc; return rc;
if (c == '0' || c == 'n' || c == 'N')
traceSMB = 0; rc = strtobool(&c, &bv);
else if (c == '1' || c == 'y' || c == 'Y') if (rc)
traceSMB = 1; return rc;
traceSMB = bv;
return count; return count;
} }
...@@ -630,6 +639,7 @@ static ssize_t cifs_security_flags_proc_write(struct file *file, ...@@ -630,6 +639,7 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,
unsigned int flags; unsigned int flags;
char flags_string[12]; char flags_string[12];
char c; char c;
bool bv;
if ((count < 1) || (count > 11)) if ((count < 1) || (count > 11))
return -EINVAL; return -EINVAL;
...@@ -642,11 +652,8 @@ static ssize_t cifs_security_flags_proc_write(struct file *file, ...@@ -642,11 +652,8 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,
if (count < 3) { if (count < 3) {
/* single char or single char followed by null */ /* single char or single char followed by null */
c = flags_string[0]; c = flags_string[0];
if (c == '0' || c == 'n' || c == 'N') { if (strtobool(&c, &bv) == 0) {
global_secflags = CIFSSEC_DEF; /* default */ global_secflags = bv ? CIFSSEC_MAX : CIFSSEC_DEF;
return count;
} else if (c == '1' || c == 'y' || c == 'Y') {
global_secflags = CIFSSEC_MAX;
return count; return count;
} else if (!isdigit(c)) { } else if (!isdigit(c)) {
cifs_dbg(VFS, "Invalid SecurityFlags: %s\n", cifs_dbg(VFS, "Invalid SecurityFlags: %s\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册