From b71f4ffa7c58ef7b27eb6e28d00892906aec49ec Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Wed, 11 Apr 2012 15:34:29 -0400 Subject: [PATCH] volinfo: show header filenames even if error When invoked with -header option, print the header inode number, and namei filename, even if the header file cannot be opened. Change-Id: Id2a2e63f07e12cd817718a9da63d24250718ae06 Reviewed-on: http://gerrit.openafs.org/7190 Tested-by: BuildBot Reviewed-by: Tom Keiser Reviewed-by: Derrick Brashear --- src/vol/vol-info.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/vol/vol-info.c b/src/vol/vol-info.c index 8682f1af57..d6c424de20 100644 --- a/src/vol/vol-info.c +++ b/src/vol/vol-info.c @@ -1172,7 +1172,7 @@ HandleSpecialFile(const char *name, struct DiskPartition64 *dp, struct VolumeHeader *header, Inode inode, afs_sfsize_t * psize) { - afs_sfsize_t size = 0; + afs_sfsize_t size = -1; IHandle_t *ih = NULL; FdHandle_t *fdP = NULL; #ifdef AFS_NAMEI_ENV @@ -1183,7 +1183,7 @@ HandleSpecialFile(const char *name, struct DiskPartition64 *dp, fdP = IH_OPEN(ih); if (fdP == NULL) { fprintf(stderr, - "%s: Error opening header file '%s' for volume %u", progname, + "%s: Error opening header file '%s' for volume %u\n", progname, name, header->id); perror("open"); goto error; @@ -1191,22 +1191,27 @@ HandleSpecialFile(const char *name, struct DiskPartition64 *dp, size = FDH_SIZE(fdP); if (size == -1) { fprintf(stderr, - "%s: Error getting size of header file '%s' for volume %u", + "%s: Error getting size of header file '%s' for volume %u\n", progname, name, header->id); perror("fstat"); goto error; } + *psize += size; + + error: if (DumpInfo) { - printf("\t%s inode\t= %s (size = %lld)\n", - name, PrintInode(NULL, inode), size); + printf("\t%s inode\t= %s (size = ", name, PrintInode(NULL, inode)); + if (size != -1) { + printf("%lld)\n", size); + } else { + printf("unknown)\n"); + } #ifdef AFS_NAMEI_ENV namei_HandleToName(&filename, ih); printf("\t%s namei\t= %s\n", name, filename.n_path); #endif /* AFS_NAMEI_ENV */ } - *psize += size; - error: if (fdP != NULL) { FDH_REALLYCLOSE(fdP); }