From f841c189a53f3a6bcf5c25336e4e0ad5362036e2 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Tue, 31 Mar 2020 21:19:18 -0500 Subject: [PATCH] vos: Properly print volume transaction flags Currently, the code in 'vos status' treats the 'iflags' and 'vflags' of a transaction like an enumerated type; that is, we only check if 'iflags' is equal to ITOffline or ITBusy, etc. But both of these flags fields are bitfields; any combination of the relevant flags could theoretically be set. Practically speaking, we only ever set at most one of the flags in 'iflags', but if anything ever did set more than one flag, our output would look broken (we'd print "attachFlags:" without any flags). For 'vflags', multiple flags are often set at once: the most common combination is VTDeleteOnSalvage|VTOutOfService. So currently, we usually print "attachFlags:" without any actual flags, since the 'vflags' field isn't exactly equal to VTDeleteOnSalvage (instead it's set to VTDeleteOnSalvage|VTOutOfService). And if we ever did see just VTDeleteOnSalvage set by itself, the way the switch() cases fall through to each other, we'd print out that _all_ flags are set. To fix all of this, just test for the individual flag bits instead. Change-Id: Ib4d207bc713f0ef8eb51b9dbeaf2af50395536ee Reviewed-on: https://gerrit.openafs.org/14126 Tested-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Cheyenne Wills Reviewed-by: Benjamin Kaduk --- src/volser/vos.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/volser/vos.c b/src/volser/vos.c index 8e48bf1..be487b2 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -4095,33 +4095,32 @@ VolserStatus(struct cmd_syndesc *as, void *arock) } if (pntr->iflags) { fprintf(STDOUT, "attachFlags: "); - switch (pntr->iflags) { - case ITOffline: + if ((pntr->iflags & ITOffline) != 0) { fprintf(STDOUT, "offline "); - break; - case ITBusy: + } + if ((pntr->iflags & ITBusy) != 0) { fprintf(STDOUT, "busy "); - break; - case ITReadOnly: + } + if ((pntr->iflags & ITReadOnly) != 0) { fprintf(STDOUT, "readonly "); - break; - case ITCreate: + } + if ((pntr->iflags & ITCreate) != 0) { fprintf(STDOUT, "create "); - break; - case ITCreateVolID: + } + if ((pntr->iflags & ITCreateVolID) != 0) { fprintf(STDOUT, "create volid "); - break; } fprintf(STDOUT, "\n"); } if (pntr->vflags) { fprintf(STDOUT, "volumeStatus: "); - switch (pntr->vflags) { - case VTDeleteOnSalvage: + if ((pntr->vflags & VTDeleteOnSalvage) != 0) { fprintf(STDOUT, "deleteOnSalvage "); - case VTOutOfService: + } + if ((pntr->vflags & VTOutOfService) != 0) { fprintf(STDOUT, "outOfService "); - case VTDeleted: + } + if ((pntr->vflags & VTDeleted) != 0) { fprintf(STDOUT, "deleted "); } fprintf(STDOUT, "\n"); -- 1.9.4