#endif
int online = 0;
int dheader = 0;
-int dsizeOnly = 0, totvolsize = 0, Vauxsize = 0, Vdiskused = 0, Vvnodesize =
- 0;
-int Vvnodesize_k = 0, Vauxsize_k = 0;
-int Totvolsize = 0, TVauxsize = 0, TVdiskused = 0, TVvnodesize = 0;
-int Stotvolsize = 0, SVauxsize = 0, SVdiskused = 0, SVvnodesize = 0;
+int dsizeOnly = 0;
int fixheader = 0, saveinodes = 0, orphaned = 0;
int VolumeChanged;
+/**
+ * Volume size running totals
+ */
+struct sizeTotals {
+ afs_uint64 diskused_k; /**< volume size from disk data file, in kilobytes */
+ afs_uint64 auxsize; /**< size of header files, in bytes */
+ afs_uint64 auxsize_k; /**< size of header files, in kilobytes */
+ afs_uint64 vnodesize; /**< size of the large and small vnodes, in bytes */
+ afs_uint64 vnodesize_k; /**< size of the large and small vnodes, in kilobytes */
+ afs_uint64 size_k; /**< size of headers and vnodes, in kilobytes */
+};
+
+static struct sizeTotals volumeTotals = { 0, 0, 0, 0, 0, 0 };
+static struct sizeTotals partitionTotals = { 0, 0, 0, 0, 0, 0 };
+static struct sizeTotals serverTotals = { 0, 0, 0, 0, 0, 0 };
+
/* Forward Declarations */
void PrintHeader(Volume * vp);
void HandleAllPart(void);
}
/**
+ * Accumulate totals.
+ *
+ * @return 0
+ */
+static void
+AddSizeTotals(struct sizeTotals *a, struct sizeTotals *b)
+{
+ a->diskused_k += b->diskused_k;
+ a->auxsize += b->auxsize;
+ a->auxsize_k += b->auxsize_k;
+ a->vnodesize += b->vnodesize;
+ a->vnodesize_k += b->vnodesize_k;
+ a->size_k += b->size_k;
+}
+
+/**
* Print the sizes for a volume.
*
* @return none
static void
PrintVolumeSizes(Volume * vp)
{
+ afs_int64 diff_k = volumeTotals.size_k - volumeTotals.diskused_k;
+
PrintVolumeSizeHeading();
- printf("%u\t%9d%9d%10d%10d%9d\t%24s\n", V_id(vp), Vdiskused,
- Vauxsize_k, Vvnodesize_k, totvolsize, totvolsize - Vdiskused,
- V_name(vp));
+ printf("%u\t%9llu%9llu%10llu%10llu%9lld\t%24s\n",
+ V_id(vp),
+ volumeTotals.diskused_k,
+ volumeTotals.auxsize_k, volumeTotals.vnodesize_k,
+ volumeTotals.size_k, diff_k, V_name(vp));
}
/**
* @return none
*/
static void
-PrintPartitionTotals(int nvols)
+PrintPartitionTotals(afs_uint64 nvols)
{
+ afs_int64 diff_k = partitionTotals.size_k - partitionTotals.diskused_k;
+
PrintVolumeSizeHeading();
- printf("\nPart Totals %12d%9d%10d%10d%9d (%d volumes)\n\n",
- TVdiskused, TVauxsize, TVvnodesize, Totvolsize,
- Totvolsize - TVdiskused, nvols);
+ printf("\nPart Totals %12llu%9llu%10llu%10llu%9lld (%llu volumes)\n\n",
+ partitionTotals.diskused_k, partitionTotals.auxsize,
+ partitionTotals.vnodesize, partitionTotals.size_k, diff_k, nvols);
PrintingVolumeSizes = 0;
}
static void
PrintServerTotals(void)
{
- printf("\nServer Totals%12d%9d%10d%10d%9d\n", SVdiskused, SVauxsize,
- SVvnodesize, Stotvolsize, Stotvolsize - SVdiskused);
+ afs_int64 diff_k = serverTotals.size_k - serverTotals.diskused_k;
+
+ printf("\nServer Totals%12lld%9lld%10lld%10lld%9lld\n",
+ serverTotals.diskused_k, serverTotals.auxsize,
+ serverTotals.vnodesize, serverTotals.size_k, diff_k);
}
int
for (partP = DiskPartitionList; partP; partP = partP->next) {
printf("Processing Partition %s:\n", partP->name);
HandlePart(partP);
- Stotvolsize += Totvolsize;
- SVauxsize += TVauxsize;
- SVvnodesize += TVvnodesize;
- SVdiskused += TVdiskused;
+ if (dsizeOnly) {
+ AddSizeTotals(&serverTotals, &partitionTotals);
+ }
}
if (dsizeOnly) {
void
HandlePart(struct DiskPartition64 *partP)
{
- int nvols = 0;
+ afs_int64 nvols = 0;
DIR *dirp;
struct dirent *dp;
#ifdef AFS_NT40_ENV
p = (char *)strrchr(dp->d_name, '.');
if (p != NULL && strcmp(p, VHDREXT) == 0) {
HandleVolume(partP, dp->d_name);
- Totvolsize += totvolsize;
- TVauxsize += Vauxsize;
- TVvnodesize += Vvnodesize;
- TVdiskused += Vdiskused;
- nvols++;
+ if (dsizeOnly) {
+ nvols++;
+ AddSizeTotals(&partitionTotals, &volumeTotals);
+ }
}
}
closedir(dirp);
if (!dsizeOnly && !saveinodes) {
printf("Total aux volume size = %lld\n\n", size);
}
- Vauxsize = size;
- Vauxsize_k = size / 1024;
+
+ if (dsizeOnly) {
+ volumeTotals.auxsize = size;
+ volumeTotals.auxsize_k = size / 1024;
+ }
}
void
PrintVnodes(vp, vSmall);
}
if (dsizeOnly) {
- totvolsize = Vauxsize_k + Vvnodesize_k;
+ volumeTotals.size_k =
+ volumeTotals.auxsize_k + volumeTotals.vnodesize_k;
PrintVolumeSizes(vp);
}
free(vp->header);
void
PrintHeader(Volume * vp)
{
- Vdiskused = V_diskused(vp);
+ volumeTotals.diskused_k = V_diskused(vp);
if (dsizeOnly || saveinodes)
return;
printf("Volume header for volume %u (%s)\n", V_id(vp), V_name(vp));
afs_fsize_t fileLength;
VNDISK_GET_LEN(fileLength, vnode);
- Vvnodesize += fileLength;
- Vvnodesize_k += fileLength / 1024;
+ if (fileLength > 0) {
+ volumeTotals.vnodesize += fileLength;
+ volumeTotals.vnodesize_k += fileLength / 1024;
+ }
} else if (class == vSmall) {
IHandle_t *ih1;
FdHandle_t *fdP1;
afs_fsize_t fileLength;
VNDISK_GET_LEN(fileLength, vnode);
- Vvnodesize += fileLength;
- Vvnodesize_k += fileLength / 1024;
+ if (fileLength > 0) {
+ volumeTotals.vnodesize += fileLength;
+ volumeTotals.vnodesize_k += fileLength / 1024;
+ }
if (dsizeOnly)
return;
if (orphaned && (fileLength == 0 || vnode->parent || !offset))