From: Michael Meffie Date: Tue, 20 Feb 2018 16:51:01 +0000 (-0500) Subject: afs: improve -volume-ttl error messages X-Git-Tag: openafs-devel-1_9_0~611 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=6d74e3d6a1becf86cec30efc2d01a5692167afe1 afs: improve -volume-ttl error messages Change the afs call which sets the volume ttl value to return EFAULT instead of EINVAL when given an out of range value for the volume ttl parameter. This is more consistent with the other op codes, which return EFAULT when given an out of range parameter and allows the caller to distinguish between an invalid opcode and a bad parameter. Move the volume ttl range constants to afs_args.h, which is where constants related to the op codes are supposed to be defined. This makes the constants available to the caller in afsd.c as well as the implementation in afs_call.c. Update afsd to print a more sensible error message when the volume ttl set calls fails due to an out of range parameter. Change-Id: I6b3ab7d38a60464017daf06f70080a90d2a7a429 Reviewed-on: https://gerrit.openafs.org/12918 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- diff --git a/src/afs/afs.h b/src/afs/afs.h index d94f328..bf2273d 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -1398,10 +1398,6 @@ extern struct brequest afs_brs[NBRS]; /* request structures */ #define AFS_VOLCHECK_MTPTS 0x4 /* mount point invalidation also */ #define AFS_VOLCHECK_FORCE 0x8 /* do all forcibly */ -/* For volume ttl expiry checks. */ -#define AFS_MIN_VOLUME_TTL 600 -#define AFS_MAX_VOLUME_TTL MAX_AFS_INT32 - #endif /* KERNEL */ #define AFS_FSPORT ((unsigned short) htons(7000)) diff --git a/src/afs/afs_call.c b/src/afs/afs_call.c index bec71c4..6eae4da 100644 --- a/src/afs/afs_call.c +++ b/src/afs/afs_call.c @@ -1321,7 +1321,7 @@ afs_syscall_call(long parm, long parm2, long parm3, } } else if (parm == AFSOP_SET_VOLUME_TTL) { if ((parm2 < AFS_MIN_VOLUME_TTL) || (parm2 > AFS_MAX_VOLUME_TTL)) { - code = EINVAL; + code = EFAULT; } else { afs_volume_ttl = parm2; code = 0; diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index 4692172..b3f2fc5 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -2433,8 +2433,20 @@ afsd_run(void) if (afsd_verbose) printf("%s: Calling AFSOP_SET_VOLUME_TTL with '%d'\n", rn, volume_ttl); code = afsd_syscall(AFSOP_SET_VOLUME_TTL, volume_ttl); - if (code != 0) - printf("%s: Error setting volume ttl to %d seconds; code=%d.\n", rn, volume_ttl, code); + if (code == EFAULT) { + if (volume_ttl < AFS_MIN_VOLUME_TTL) + printf("%s: Failed to set volume ttl to %d seconds; " + "value is too low.\n", rn, volume_ttl); + else if (volume_ttl > AFS_MAX_VOLUME_TTL) + printf("%s: Failed to set volume ttl to %d seconds; " + "value is too high.\n", rn, volume_ttl); + else + printf("%s: Failed to set volume ttl to %d seconds; " + "value is out of range.\n", rn, volume_ttl); + } else if (code != 0) { + printf("%s: Failed to set volume ttl to %d seconds; " + "code=%d.\n", rn, volume_ttl, code); + } } /* diff --git a/src/config/afs_args.h b/src/config/afs_args.h index 5d508a3..dd90b80 100644 --- a/src/config/afs_args.h +++ b/src/config/afs_args.h @@ -174,6 +174,9 @@ enum { AFS_INUMCALC_MD5 = 1 }; +/* Supported volume ttl range. */ +#define AFS_MIN_VOLUME_TTL 600 +#define AFS_MAX_VOLUME_TTL MAX_AFS_INT32 /* * Note that the AFS_*ALLOCSIZ values should be multiples of sizeof(void*) to