From: Phillip Moore Date: Tue, 19 Oct 2010 16:17:20 +0000 (-0400) Subject: Fix fs bypassthreshold to accept a size of -1 to disable X-Git-Tag: openafs-devel-1_7_1~1328 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=1fa575c09ea7aa66e657b226465cb90dbba4af70 Fix fs bypassthreshold to accept a size of -1 to disable The fs bypassthreshold command assumes a value of -1 means the feature is disabled, but the CLI refused to accept this argument, since it is not strictly a digit (according ti isdigit()). This patch accepts the string -1, and makes it possible to both enable AND disable this feature. Change-Id: I87720b2dcfc4e9ee9f322c4841836b74440ac442 Reviewed-on: http://gerrit.openafs.org/3009 Reviewed-by: Matt Benjamin Tested-by: BuildBot Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/venus/fs.c b/src/venus/fs.c index 7ce9fc4..a8c1712 100644 --- a/src/venus/fs.c +++ b/src/venus/fs.c @@ -1358,22 +1358,27 @@ BypassThresholdCmd(struct cmd_syndesc *as, void *arock) tp = as->parms[0].items->data; len = strlen(tp); - digit = 1; - for(ix = 0; ix < len; ++ix) { - if(!isdigit(tp[0])) { - digit = 0; - break; - } - } - if (digit == 0) { - fprintf(stderr, "fs bypassthreshold -size: %s must be an undecorated digit string.\n", tp); - return EINVAL; - } - threshold_i = atoi(tp); - if(ix > 9 && threshold_i < 2147483647) - threshold_i = 2147483647; - blob.in = (char *) &threshold_i; - blob.in_size = sizeof(threshold_i); + + if (!strcmp(tp,"-1")) { + threshold_i = -1; + } else { + digit = 1; + for(ix = 0; ix < len; ++ix) { + if(!isdigit(tp[0])) { + digit = 0; + break; + } + } + if (digit == 0) { + fprintf(stderr, "fs bypassthreshold -size: %s must be an integer between -1 and 2^31\n", tp); + return EINVAL; + } + threshold_i = atoi(tp); + if(ix > 9 && threshold_i < 2147483647) + threshold_i = 2147483647; + } + blob.in = (char *) &threshold_i; + blob.in_size = sizeof(threshold_i); } else { blob.in = NULL; blob.in_size = 0;