aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifs_debug.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2014-08-27 09:49:42 -0400
committerSteve French <steve.french@primarydata.com>2014-12-07 23:47:58 -0500
commit28e2aed244b1b81e45b105d90ffb82384665dfb7 (patch)
tree5319be196b8d4cf920048f1734cb7bcc79004a58 /fs/cifs/cifs_debug.c
parentbb1d5ddaf962921a5c3ad4166e3c1b7b70ba5778 (diff)
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Jeff Layton <jlayton@poochiereds.net> Reviewed-by: Alexander Bokovoy <ab@samba.org> Signed-off-by: Steve French <steve.french@primarydata.com>
Diffstat (limited to 'fs/cifs/cifs_debug.c')
-rw-r--r--fs/cifs/cifs_debug.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 44ec72684df5..7c50bfa9c438 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -274,6 +274,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
274 const char __user *buffer, size_t count, loff_t *ppos) 274 const char __user *buffer, size_t count, loff_t *ppos)
275{ 275{
276 char c; 276 char c;
277 bool bv;
277 int rc; 278 int rc;
278 struct list_head *tmp1, *tmp2, *tmp3; 279 struct list_head *tmp1, *tmp2, *tmp3;
279 struct TCP_Server_Info *server; 280 struct TCP_Server_Info *server;
@@ -284,7 +285,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
284 if (rc) 285 if (rc)
285 return rc; 286 return rc;
286 287
287 if (c == '1' || c == 'y' || c == 'Y' || c == '0') { 288 if (strtobool(&c, &bv) == 0) {
288#ifdef CONFIG_CIFS_STATS2 289#ifdef CONFIG_CIFS_STATS2
289 atomic_set(&totBufAllocCount, 0); 290 atomic_set(&totBufAllocCount, 0);
290 atomic_set(&totSmBufAllocCount, 0); 291 atomic_set(&totSmBufAllocCount, 0);
@@ -451,15 +452,14 @@ static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer,
451 size_t count, loff_t *ppos) 452 size_t count, loff_t *ppos)
452{ 453{
453 char c; 454 char c;
455 bool bv;
454 int rc; 456 int rc;
455 457
456 rc = get_user(c, buffer); 458 rc = get_user(c, buffer);
457 if (rc) 459 if (rc)
458 return rc; 460 return rc;
459 if (c == '0' || c == 'n' || c == 'N') 461 if (strtobool(&c, &bv) == 0)
460 cifsFYI = 0; 462 cifsFYI = bv;
461 else if (c == '1' || c == 'y' || c == 'Y')
462 cifsFYI = 1;
463 else if ((c > '1') && (c <= '9')) 463 else if ((c > '1') && (c <= '9'))
464 cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */ 464 cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */
465 465
@@ -490,15 +490,18 @@ static ssize_t cifs_linux_ext_proc_write(struct file *file,
490 const char __user *buffer, size_t count, loff_t *ppos) 490 const char __user *buffer, size_t count, loff_t *ppos)
491{ 491{
492 char c; 492 char c;
493 bool bv;
493 int rc; 494 int rc;
494 495
495 rc = get_user(c, buffer); 496 rc = get_user(c, buffer);
496 if (rc) 497 if (rc)
497 return rc; 498 return rc;
498 if (c == '0' || c == 'n' || c == 'N') 499
499 linuxExtEnabled = 0; 500 rc = strtobool(&c, &bv);
500 else if (c == '1' || c == 'y' || c == 'Y') 501 if (rc)
501 linuxExtEnabled = 1; 502 return rc;
503
504 linuxExtEnabled = bv;
502 505
503 return count; 506 return count;
504} 507}
@@ -527,15 +530,18 @@ static ssize_t cifs_lookup_cache_proc_write(struct file *file,
527 const char __user *buffer, size_t count, loff_t *ppos) 530 const char __user *buffer, size_t count, loff_t *ppos)
528{ 531{
529 char c; 532 char c;
533 bool bv;
530 int rc; 534 int rc;
531 535
532 rc = get_user(c, buffer); 536 rc = get_user(c, buffer);
533 if (rc) 537 if (rc)
534 return rc; 538 return rc;
535 if (c == '0' || c == 'n' || c == 'N') 539
536 lookupCacheEnabled = 0; 540 rc = strtobool(&c, &bv);
537 else if (c == '1' || c == 'y' || c == 'Y') 541 if (rc)
538 lookupCacheEnabled = 1; 542 return rc;
543
544 lookupCacheEnabled = bv;
539 545
540 return count; 546 return count;
541} 547}
@@ -564,15 +570,18 @@ static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer,
564 size_t count, loff_t *ppos) 570 size_t count, loff_t *ppos)
565{ 571{
566 char c; 572 char c;
573 bool bv;
567 int rc; 574 int rc;
568 575
569 rc = get_user(c, buffer); 576 rc = get_user(c, buffer);
570 if (rc) 577 if (rc)
571 return rc; 578 return rc;
572 if (c == '0' || c == 'n' || c == 'N') 579
573 traceSMB = 0; 580 rc = strtobool(&c, &bv);
574 else if (c == '1' || c == 'y' || c == 'Y') 581 if (rc)
575 traceSMB = 1; 582 return rc;
583
584 traceSMB = bv;
576 585
577 return count; 586 return count;
578} 587}
@@ -630,6 +639,7 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,
630 unsigned int flags; 639 unsigned int flags;
631 char flags_string[12]; 640 char flags_string[12];
632 char c; 641 char c;
642 bool bv;
633 643
634 if ((count < 1) || (count > 11)) 644 if ((count < 1) || (count > 11))
635 return -EINVAL; 645 return -EINVAL;
@@ -642,11 +652,8 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,
642 if (count < 3) { 652 if (count < 3) {
643 /* single char or single char followed by null */ 653 /* single char or single char followed by null */
644 c = flags_string[0]; 654 c = flags_string[0];
645 if (c == '0' || c == 'n' || c == 'N') { 655 if (strtobool(&c, &bv) == 0) {
646 global_secflags = CIFSSEC_DEF; /* default */ 656 global_secflags = bv ? CIFSSEC_MAX : CIFSSEC_DEF;
647 return count;
648 } else if (c == '1' || c == 'y' || c == 'Y') {
649 global_secflags = CIFSSEC_MAX;
650 return count; 657 return count;
651 } else if (!isdigit(c)) { 658 } else if (!isdigit(c)) {
652 cifs_dbg(VFS, "Invalid SecurityFlags: %s\n", 659 cifs_dbg(VFS, "Invalid SecurityFlags: %s\n",