afs: improve -volume-ttl error messages 18/12918/3
authorMichael Meffie <mmeffie@sinenomine.net>
Tue, 20 Feb 2018 16:51:01 +0000 (11:51 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Wed, 28 Feb 2018 03:03:18 +0000 (22:03 -0500)
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 <buildbot@rampaginggeek.com>
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 d94f328..bf2273d 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 bec71c4..6eae4da 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 4692172..b3f2fc5 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 5d508a3..dd90b80 100644 (file)
@@ -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