]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
afs: improve -volume-ttl error messages
authorMichael Meffie <mmeffie@sinenomine.net>
Tue, 20 Feb 2018 16:51:01 +0000 (11:51 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Sat, 14 Apr 2018 02:34:51 +0000 (22:34 -0400)
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.

Reviewed-on: https://gerrit.openafs.org/12918
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 6d74e3d6a1becf86cec30efc2d01a5692167afe1)

Change-Id: I2cd86b6fbba31f74862bb902ac94b0874de8afac
Reviewed-on: https://gerrit.openafs.org/12936
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
src/afs/afs.h
src/afs/afs_call.c
src/afsd/afsd.c
src/config/afs_args.h

index d94f3282563d30f22e3df4768b530c3ecc80f215..bf2273dc91f78bab420821647562e2ad65752354 100644 (file)
@@ -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))
index bec71c4d15eebdcec7620098e0c94c919f5733a0..6eae4dab293d39196f1c83be2bc5655db4ed1b1d 100644 (file)
@@ -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;
index 46921728a1498f9e4b72512f73e10a116b08e90c..b3f2fc56b0ce4ba7d944ec49c0388e99f6c498f1 100644 (file)
@@ -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);
+       }
     }
 
     /*
index 4fa286ba34667b0bebed50943a425f57112aa717..2609bcef45064ca5d628d8b0a33f5ba05abba13e 100644 (file)
@@ -179,6 +179,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