volinfo: avoid exit on errors

Instead of exiting on errors, try to carry on.

Change-Id: Ia8da9403c57c19ac25a3ef4dac36c3e71bd1be25
Reviewed-on: http://gerrit.openafs.org/4736
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Michael Meffie 2011-05-26 21:58:11 -04:00 committed by Derrick Brashear
parent 277a8ad658
commit 59a1c40efb

View File

@ -297,7 +297,7 @@ handleit(struct cmd_syndesc *as, void *arock)
#ifndef AFS_NT40_ENV #ifndef AFS_NT40_ENV
if (geteuid() != 0) { if (geteuid() != 0) {
fprintf(stderr, "%s: Must be run as root; sorry\n", progname); fprintf(stderr, "%s: Must be run as root; sorry\n", progname);
exit(1); return 1;
} }
#endif #endif
@ -371,7 +371,7 @@ handleit(struct cmd_syndesc *as, void *arock)
fprintf(stderr, fprintf(stderr,
"%s: %s is not an AFS partition name on this server.\n", "%s: %s is not an AFS partition name on this server.\n",
progname, partName); progname, partName);
exit(1); return 1;
} }
} }
@ -390,7 +390,7 @@ handleit(struct cmd_syndesc *as, void *arock)
fprintf(stderr, fprintf(stderr,
"%s: Current partition is not a vice partition.\n", "%s: Current partition is not a vice partition.\n",
progname); progname);
exit(1); return 1;
} }
} }
snprintf(name1, sizeof name1, VFORMAT, snprintf(name1, sizeof name1, VFORMAT,
@ -432,7 +432,7 @@ FindCurrentPartition(void)
fprintf(stderr, "%s: Failed to get current working directory: ", fprintf(stderr, "%s: Failed to get current working directory: ",
progname); progname);
perror("pwd"); perror("pwd");
exit(1); return NULL;
} }
p = strchr(&partName[1], OS_DIRSEPC); p = strchr(&partName[1], OS_DIRSEPC);
if (p) { if (p) {
@ -444,7 +444,7 @@ FindCurrentPartition(void)
*p = tmp; *p = tmp;
fprintf(stderr, "%s: %s is not a valid vice partition.\n", progname, fprintf(stderr, "%s: %s is not a valid vice partition.\n", progname,
partName); partName);
exit(1); return NULL;
} }
return dp; return dp;
} }
@ -487,7 +487,7 @@ HandlePart(struct DiskPartition64 *partP)
if ((dirp = opendir(p)) == NULL) { if ((dirp = opendir(p)) == NULL) {
fprintf(stderr, "%s: Can't read directory %s; giving up\n", progname, fprintf(stderr, "%s: Can't read directory %s; giving up\n", progname,
p); p);
exit(1); return;
} }
while ((dp = readdir(dirp))) { while ((dp = readdir(dirp))) {
p = (char *)strrchr(dp->d_name, '.'); p = (char *)strrchr(dp->d_name, '.');
@ -772,15 +772,15 @@ NT_date(FILETIME * ft)
} }
#endif #endif
static void static int
GetFileInfo(FD_t fd, int *size, char **ctime, char **mtime, char **atime) GetFileInfo(FD_t fd, int *size, char **ctime, char **mtime, char **atime)
{ {
#ifdef AFS_NT40_ENV #ifdef AFS_NT40_ENV
BY_HANDLE_FILE_INFORMATION fi; BY_HANDLE_FILE_INFORMATION fi;
if (!GetFileInformationByHandle(fd, &fi)) { if (!GetFileInformationByHandle(fd, &fi)) {
fprintf(stderr, "%s: GetFileInformationByHandle failed, exiting\n", fprintf(stderr, "%s: GetFileInformationByHandle failed\n",
progname); progname);
exit(1); return -1;
} }
*size = (int)fi.nFileSizeLow; *size = (int)fi.nFileSizeLow;
*ctime = "N/A"; *ctime = "N/A";
@ -790,13 +790,14 @@ GetFileInfo(FD_t fd, int *size, char **ctime, char **mtime, char **atime)
struct afs_stat_st status; struct afs_stat_st status;
if (afs_fstat(fd, &status) == -1) { if (afs_fstat(fd, &status) == -1) {
fprintf(stderr, "%s: fstat failed %d\n", progname, errno); fprintf(stderr, "%s: fstat failed %d\n", progname, errno);
exit(1); return -1;
} }
*size = (int)status.st_size; *size = (int)status.st_size;
*ctime = date(status.st_ctime); *ctime = date(status.st_ctime);
*mtime = date(status.st_mtime); *mtime = date(status.st_mtime);
*atime = date(status.st_atime); *atime = date(status.st_atime);
#endif #endif
return 0;
} }
/** /**
@ -885,12 +886,12 @@ HandleVnodes(Volume * vp, VnodeClass class)
(class == vSmall ? SIZEOF_SMALLDISKVNODE : SIZEOF_LARGEDISKVNODE); (class == vSmall ? SIZEOF_SMALLDISKVNODE : SIZEOF_LARGEDISKVNODE);
char buf[SIZEOF_LARGEDISKVNODE]; char buf[SIZEOF_LARGEDISKVNODE];
struct VnodeDiskObject *vnode = (struct VnodeDiskObject *)buf; struct VnodeDiskObject *vnode = (struct VnodeDiskObject *)buf;
StreamHandle_t *file; StreamHandle_t *file = NULL;
int vnodeIndex, nVnodes; int vnodeIndex, nVnodes;
afs_foff_t offset = 0; afs_foff_t offset = 0;
Inode ino; Inode ino;
IHandle_t *ih = vp->vnodeIndex[class].handle; IHandle_t *ih = vp->vnodeIndex[class].handle;
FdHandle_t *fdP; FdHandle_t *fdP = NULL;
int size; int size;
char *ctime, *atime, *mtime; char *ctime, *atime, *mtime;
@ -915,16 +916,18 @@ HandleVnodes(Volume * vp, VnodeClass class)
fdP = IH_OPEN(ih); fdP = IH_OPEN(ih);
if (fdP == NULL) { if (fdP == NULL) {
fprintf(stderr, "%s: open failed: ", progname); fprintf(stderr, "%s: open failed: ", progname);
exit(1); goto error;
} }
file = FDH_FDOPEN(fdP, "r"); file = FDH_FDOPEN(fdP, "r");
if (!file) { if (!file) {
fprintf(stderr, "%s: fdopen failed\n", progname); fprintf(stderr, "%s: fdopen failed\n", progname);
exit(1); goto error;
} }
GetFileInfo(fdP->fd_fd, &size, &ctime, &atime, &mtime); if (GetFileInfo(fdP->fd_fd, &size, &ctime, &atime, &mtime) != 0) {
goto error;
}
if (InodeTimes) { if (InodeTimes) {
printf("ichanged : %s\nimodified: %s\niaccessed: %s\n\n", ctime, printf("ichanged : %s\nimodified: %s\niaccessed: %s\n\n", ctime,
mtime, atime); mtime, atime);
@ -958,8 +961,14 @@ HandleVnodes(Volume * vp, VnodeClass class)
bitNumberToVnodeNumber(vnodeIndex, class), ino, vp); bitNumberToVnodeNumber(vnodeIndex, class), ino, vp);
} }
} }
error:
if (file) {
STREAM_CLOSE(file); STREAM_CLOSE(file);
}
if (fdP) {
FDH_CLOSE(fdP); FDH_CLOSE(fdP);
}
} }
void void