From: Tom Keiser Date: Sun, 3 Apr 2005 21:23:00 +0000 (+0000) Subject: STABLE14-vos-partinfo-summary-portability-20050403 X-Git-Tag: openafs-devel-1_3_81~10 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=68ee51c84a8f7c7dc87c73c3bda01f3e2d0f4cf0;p=packages%2Fo%2Fopenafs.git STABLE14-vos-partinfo-summary-portability-20050403 make this work on systems with non-native 64 bit int (cherry picked from commit 2a3d2ad3af1a0443fe59d48b2889f2508ec5fe5f) --- diff --git a/src/volser/vos.c b/src/volser/vos.c index a069025aa..2cb1ef896 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -4945,6 +4945,34 @@ UnlockVLDB(as) return 0; } +static char * +PrintInt64Size(afs_uint64 in) +{ + register afs_uint32 hi, lo; + register char * units; + static char output[16]; + + SplitInt64(in,hi,lo); + + if (hi == 0) { + units = "KB"; + } else if (!(hi & 0xFFFFFC00)) { + units = "MB"; + lo = (hi << 22) | (lo >> 10); + } else if (!(hi & 0xFFF00000)) { + units = "GB"; + lo = (hi << 12) | (lo >> 20); + } else if (!(hi & 0xC0000000)) { + units = "TB"; + lo = (hi << 2) | (lo >> 30); + } else { + units = "PB"; + lo = (hi >> 8); + } + sprintf(output,"%u %s", lo, units); + return output; +} + static PartitionInfo(as) register struct cmd_syndesc *as; @@ -4956,8 +4984,10 @@ PartitionInfo(as) struct partList dummyPartList; int i, cnt; int printSummary=0, sumPartitions=0; - long long sumFree=0, sumStorage=0; + afs_uint64 sumFree, sumStorage, tmp; + ZeroInt64(sumFree); + ZeroInt64(sumStorage); apart = -1; aserver = GetServer(as->parms[0].items->data); if (aserver == 0) { @@ -5010,14 +5040,20 @@ PartitionInfo(as) "Free space on partition %s: %d K blocks out of total %d\n", pname, partition.free, partition.minFree); sumPartitions++; - sumFree += partition.free; - sumStorage += partition.minFree; + FillInt64(tmp,0,partition.free); + AddUInt64(sumFree,tmp,&sumFree); + FillInt64(tmp,0,partition.minFree); + AddUInt64(sumStorage,tmp,&sumStorage); } } if (printSummary) { fprintf(STDOUT, - "Summary: %lld K blocks free out of %lld K blocks on %d partitions\n", - sumFree, sumStorage, sumPartitions); + "Summary: %s free out of ", + PrintInt64Size(sumFree)); + fprintf(STDOUT, + "%s on %d partitions\n", + PrintInt64Size(sumStorage), + sumPartitions); } return 0; }