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