* directory or online at http://www.openafs.org/dl/license10.html
*/
-#ifndef lint
-#endif
/*
* System: VICE-TWO
* Module: vol-salvage.c
/* Main program file. Define globals. */
#define MAIN 1
+#include <afsconfig.h>
#include <afs/param.h>
+
+RCSID("$Header$");
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#endif /* ITIMER_REAL */
#endif
-#if defined(AFS_AIX_ENV)
+#if defined(AFS_AIX_ENV) || defined(AFS_SUN4_ENV)
#define WCOREDUMP(x) (x & 0200)
#endif
#include <rx/xdr.h>
#ifdef AFS_SUN5_ENV
#include <sys/fs/ufs_inode.h>
#else
-#ifdef AFS_DARWIN_ENV
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
#else
#ifdef AFS_OSF_ENV
#include <ufs/inode.h>
#else /* AFS_OSF_ENV */
-#ifndef AFS_LINUX20_ENV
+#if !defined(AFS_LINUX20_ENV) && !defined(AFS_XBSD_ENV)
#include <sys/inode.h>
#endif
#endif
0 after scanning all directories */
unsigned salvaged:1;/* Set if this directory vnode has already been salvaged. */
unsigned todelete:1;/* Set if this vnode is to be deleted (should not be claimed) */
- afs_uint32 blockCount;
+ afs_offs_t blockCount;
/* Number of blocks (1K) used by this vnode,
approximately */
VnodeId parent; /* parent in vnode */
static int IsVnodeOrphaned(VnodeId vnode);
/* Uniquifier stored in the Inode */
-static Unique IUnique(u)
- Unique u;
+static Unique IUnique(Unique u)
{
#ifdef AFS_3DISPARES
return(u & 0x3fffff);
#endif
}
-static int BadError(aerror)
-register int aerror; {
+static int BadError(register int aerror)
+{
if (aerror == EPERM || aerror == ENXIO || aerror == ENOENT)
return 1;
return 0; /* otherwise may be transient, e.g. EMFILE */
char *tmpdir = 0;
-static handleit(as)
- struct cmd_syndesc *as;
+static int handleit(struct cmd_syndesc *as)
{
register struct cmd_item *ti;
char pname[100], *temp;
- afs_int32 seenpart = 0, seenvol = 0, vid = 0;
+ afs_int32 seenpart = 0, seenvol = 0, vid = 0, seenany = 0, i;
struct DiskPartition *partP;
#ifdef AFS_SGI_VNODE_GLUE
}
#endif
+#ifdef FAST_RESTART
+ for (i = 0; i < CMD_MAXPARMS; i++) {
+ if (as->parms[i].items) {
+ seenany = 1;
+ break;
+ }
+ }
+ if (!seenany) {
+ char *msg = "Exiting immediately without salvage. Look into the FileLog to find volumes which really need to be salvaged!";
+
+ if ( useSyslog )
+ Log(msg);
+ else
+ printf("%s\n", msg);
+
+ Exit(0);
+ }
+#endif /* FAST_RESTART */
if (ti = as->parms[0].items) { /* -partition */
seenpart = 1;
strncpy(pname, ti->data, 100);
dirp = opendir(tmpdir);
if (!dirp) {
printf("Can't open temporary placeholder dir %s; using current partition \n", tmpdir);
- tmpdir = (char *)0;
+ tmpdir = NULL;
} else
closedir(dirp);
}
#ifdef FAST_RESTART
if (ti = as->parms[18].items) { /* -DontSalvage */
- printf("Exiting immediately without salvage. Look into the FileLog");
- printf(" to find volumes which really need to be salvaged!\n");
+ char *msg = "Exiting immediately without salvage. Look into the FileLog to find volumes which really need to be salvaged!";
+
+ if ( useSyslog )
+ Log(msg);
+ else
+ printf("%s\n", msg);
Exit(0);
}
#endif /* FAST_RESTART */
pthread_t main_thread;
#endif
-main(argc,argv)
-char **argv;
+int main(int argc, char **argv)
{
struct cmd_syndesc *ts;
int err = 0;
#endif
/* Check if the given inode is the root of the filesystem. */
#ifndef AFS_SGI_XFS_IOPS_ENV
-int IsRootInode(status)
-struct stat *status;
+int IsRootInode(struct stat *status)
{
- /* The root inode is not a fixed value in XFS partitions. So we need to see if
- * the partition is in the list of mounted partitions. This only affects the
- * SalvageFileSys path, so we check there.
+ /*
+ * The root inode is not a fixed value in XFS partitions. So we need to
+ * see if the partition is in the list of mounted partitions. This only
+ * affects the SalvageFileSys path, so we check there.
*/
return (status->st_ino == ROOTINODE);
}
#endif
#ifdef AFS_AIX42_ENV
+#ifndef AFS_NAMEI_ENV
/* We don't want to salvage big files filesystems, since we can't put volumes on
* them.
*/
-int CheckIfBigFilesFS(mountPoint, devName)
- char *mountPoint;
- char *devName;
+int CheckIfBigFilesFS(char *mountPoint, char *devName)
{
struct superblock fs;
char name[128];
return 0;
}
#endif
+#endif
#ifdef AFS_NT40_ENV
#define HDSTR "\\Device\\Harddisk"
Log("Can't salvage '%s'. Not enough memory\n", partP->name);
return;
}
- bzero(thisjob, sizeof(struct job));
+ memset(thisjob, 0, sizeof(struct job));
thisjob->partP = partP;
thisjob->jobnumb = jobcount;
jobcount++;
Wait("SalvageFileSys");
}
-char *get_DevName(pbuffer, wpath)
-char *wpath, *pbuffer;
+char *get_DevName(char *pbuffer, char *wpath)
{
char pbuf[128], *ptr;
strcpy(pbuf, pbuffer);
*ptr = '\0';
strcpy(wpath, pbuf);
} else
- return (char *)0;
+ return NULL;
ptr = (char *)strrchr(pbuffer, '/');
if (ptr) {
strcpy(pbuffer, ptr+1);
return pbuffer;
} else
- return (char *)0;
+ return NULL;
}
void SalvageFileSys1(struct DiskPartition *partP, VolumeId singleVolumeNumber)
{
char *name, *tdir;
- char inodeListPath[50];
+ char inodeListPath[256];
static char tmpDevName[100];
static char wpath[100];
struct VolumeSummary *vsp, *esp;
tdir = (tmpdir ? tmpdir : fileSysPath);
#ifdef AFS_NT40_ENV
(void) _putenv("TMP="); /* If "TMP" is set, then that overrides tdir. */
- (void) strcpy(inodeListPath, _tempnam(tdir, "salvage.inodes."));
+ (void) strncpy(inodeListPath, _tempnam(tdir, "salvage.inodes."), 255);
#else
- sprintf(inodeListPath, "%s/salvage.inodes.%s.%d", tdir, name, getpid());
+ snprintf(inodeListPath, 255, "%s/salvage.inodes.%s.%d", tdir, name, getpid());
#endif
if (GetInodeSummary(inodeListPath, singleVolumeNumber) < 0) {
unlink(inodeListPath);
vsp->fileName = 0;
}
-CompareInodes(_p1,_p2)
- const void *_p1,*_p2;
+CompareInodes(const void *_p1, const void *_p2)
{
register const struct ViceInodeInfo *p1 = _p1;
register const struct ViceInodeInfo *p2 = _p2;
summary->maxUniquifier = maxunique;
}
-int OnlyOneVolume(inodeinfo, singleVolumeNumber)
- struct ViceInodeInfo *inodeinfo;
- VolumeId singleVolumeNumber;
+int OnlyOneVolume(struct ViceInodeInfo *inodeinfo, VolumeId singleVolumeNumber)
{
if (inodeinfo->u.vnode.vnodeNumber == INODESPECIAL)
return (inodeinfo->u.special.parentId == singleVolumeNumber);
*/
int GetInodeSummary(char *path, VolumeId singleVolumeNumber)
{
+#ifdef AFS_LARGEFILE_ENV
+ struct stat64 status;
+#else /* !AFS_LARGEFILE_ENV */
struct stat status;
- int summaryFd, forceSal, err;
+#endif /* !AFS_LARGEFILE_ENV */
+ int forceSal, err;
struct ViceInodeInfo *ip;
struct InodeSummary summary;
char summaryFileName[50];
ForceSalvage = 1;
}
inodeFd = open(path, O_RDWR);
- if (inodeFd == -1 || fstat(inodeFd, &status) == -1) {
+ if (inodeFd == -1 ||
+#ifdef AFS_LARGEFILE_ENV
+ fstat64(inodeFd, &status)
+#else /* !AFS_LARGEFILE_ENV */
+ fstat(inodeFd, &status)
+#endif /* !AFS_LARGEFILE_ENV */
+ == -1) {
unlink(path);
Abort("No inode description file for \"%s\"; not salvaged\n", dev);
}
Abort("Unable to read inode table; %s not salvaged\n", dev);
}
qsort(ip, nInodes, sizeof(struct ViceInodeInfo), CompareInodes);
- if (lseek(inodeFd, 0, SEEK_SET) == -1 ||
- write(inodeFd, ip, status.st_size) != status.st_size) {
+ if (
+#ifdef AFS_LARGEFILE_ENV
+ lseek64(inodeFd, (off64_t) 0, SEEK_SET) == -1
+#else /* !AFS_LARGEFILE_ENV */
+ lseek(inodeFd, (off_t) 0, SEEK_SET) == -1
+#endif /* !AFS_LARGEFILE_ENV */
+ || write(inodeFd, ip, status.st_size) != status.st_size) {
fclose(summaryFile); close(inodeFd);
unlink(path);
unlink(summaryFileName);
Exit(1); /* salvage of this partition aborted */
}
}
+#ifdef AFS_LARGEFILE_ENV
+ assert(fstat64(fileno(summaryFile), &status) != -1);
+#else /* !AFS_LARGEFILE_ENV */
assert(fstat(fileno(summaryFile), &status) != -1);
+#endif /* !AFS_LARGEFILE_ENV */
if ( status.st_size != 0 ) {
int ret;
inodeSummary = (struct InodeSummary *) malloc(status.st_size);
assert(inodeSummary != NULL);
/* For GNU we need to do lseek to get the file pointer moved. */
- assert(lseek(fileno(summaryFile), 0, SEEK_SET) == 0);
+#ifdef AFS_LARGEFILE_ENV
+ assert(lseek64(fileno(summaryFile), (off64_t) 0, SEEK_SET) == 0);
+#else /* !AFS_LARGEFILE_ENV */
+ assert(lseek(fileno(summaryFile), (off_t) 0, SEEK_SET) == 0);
+#endif /* !AFS_LARGEFILE_ENV */
ret = read(fileno(summaryFile), inodeSummary, status.st_size);
assert(ret == status.st_size);
}
/* Comparison routine for volume sort.
This is setup so that a read-write volume comes immediately before
any read-only clones of that volume */
-CompareVolumes(_p1,_p2)
- const void *_p1,*_p2;
+int CompareVolumes(const void *_p1, const void *_p2)
{
register const struct VolumeSummary *p1 = _p1;
register const struct VolumeSummary *p2 = _p2;
allInodes = inodes - isp->index; /* this would the base of all the inodes
for the partition, if all the inodes
had been read into memory */
- assert(lseek(inodeFd,isp->index*sizeof(struct ViceInodeInfo),SEEK_SET) != -1)
- assert(read(inodeFd,inodes,size) == size)
+#ifdef AFS_LARGEFILE_ENV
+ assert(lseek64(inodeFd,(off64_t)(isp->index*sizeof(struct ViceInodeInfo)),SEEK_SET) != -1);
+#else /* !AFS_LARGEFILE_ENV */
+ assert(lseek(inodeFd,(off_t)(isp->index*sizeof(struct ViceInodeInfo)),SEEK_SET) != -1);
+#endif /* !AFS_LARGEFILE_ENV */
+ assert(read(inodeFd,inodes,size) == size);
/* Don't try to salvage a read write volume if there isn't one on this
partition */
#endif
if (ip->linkCount != 0 && TraceBadLinkCounts) {
TraceBadLinkCounts--; /* Limit reports, per volume */
+#ifdef AFS_LARGEFILE_ENV
+ Log("#### DEBUG #### Link count incorrect by %d; inode %s, size (0X%x,0x%x), p=(%u,%u,%u,%u)\n",
+ ip->linkCount, PrintInode(NULL, ip->inodeNumber),
+ (unsigned) ((ip->byteCount) >> 32),
+ (unsigned) ((ip->byteCount) & 0xffffffff),
+ ip->u.param[0], ip->u.param[1],
+ ip->u.param[2], ip->u.param[3]);
+#else
Log("#### DEBUG #### Link count incorrect by %d; inode %s, size %u, p=(%u,%u,%u,%u)\n",
ip->linkCount, PrintInode(NULL, ip->inodeNumber),
ip->byteCount, ip->u.param[0], ip->u.param[1],
ip->u.param[2], ip->u.param[3]);
+#endif /* !AFS_LARGEFILE_ENV */
}
while (ip->linkCount > 0) {
/* below used to assert, not break */
if (deleteMe)
*deleteMe = 0;
- bzero(&tempHeader, sizeof(tempHeader));
+ memset(&tempHeader, 0, sizeof(tempHeader));
tempHeader.stamp.magic = VOLUMEHEADERMAGIC;
tempHeader.stamp.version = VOLUMEHEADERVERSION;
tempHeader.id = isp->volumeId;
isp->volumeId, (Testing?"it would have been ":""),
fileSysPathName, name);
headerFd = open(name, O_RDWR|O_CREAT|O_TRUNC, 0644);
- assert(headerFd != -1)
+ assert(headerFd != -1);
isp->volSummary = (struct VolumeSummary *)
malloc(sizeof(struct VolumeSummary));
isp->volSummary->fileName = ToString(name);
isp->volSummary->header.volumeAcl = 0;
isp->volSummary->header.volumeMountTable = 0;
- if (bcmp(&isp->volSummary->header, &tempHeader, sizeof(struct VolumeHeader))) {
+ if (memcmp(&isp->volSummary->header, &tempHeader, sizeof(struct VolumeHeader))) {
/* We often remove the name before calling us, so we make a fake one up */
if (isp->volSummary->fileName) {
strcpy(name, isp->volSummary->fileName);
return -1;
headerFd = open(name, O_RDWR|O_TRUNC, 0644);
- assert(headerFd != -1)
+ assert(headerFd != -1);
}
}
if (headerFd) {
- bcopy(&tempHeader,&isp->volSummary->header,sizeof(struct VolumeHeader));
+ memcpy(&isp->volSummary->header, &tempHeader, sizeof(struct VolumeHeader));
if (Testing) {
if (!Showmode) Log("It would have written a new header file for volume %u\n", isp->volumeId);
} else {
/* The following code should be moved into vutil.c */
if (sp->inodeType == VI_VOLINFO) {
struct timeval tp;
- bzero(&header.volumeInfo, sizeof (header.volumeInfo));
+ memset(&header.volumeInfo, 0, sizeof (header.volumeInfo));
header.volumeInfo.stamp = sp->stamp;
header.volumeInfo.id = isp->volumeId;
header.volumeInfo.parentId = isp->RWvolumeId;
int err = 0;
StreamHandle_t *file;
struct VnodeClassInfo *vcp;
- int size;
+ afs_size_t size, vnodeSize;
int vnodeIndex, nVnodes;
afs_ino_str_t stmp1, stmp2;
IHandle_t *handle;
fdP = IH_OPEN(handle);
assert(fdP != NULL);
file = FDH_FDOPEN(fdP, "r+");
- assert(file != NULL)
+ assert(file != NULL);
vcp = &VnodeClassInfo[class];
size = OS_SIZE(fdP->fd_fd);
assert(size != -1);
nVnodes = (size / vcp->diskSize) - 1;
if (nVnodes > 0) {
- assert((nVnodes+1) * vcp->diskSize == size)
- assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0)
+ assert((nVnodes+1) * vcp->diskSize == size);
+ assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0);
}
else {
nVnodes = 0;
if (VNDISK_GET_INO(vnode) == 0) {
if (RW) {
/* Log("### DEBUG ### Deleted Vnode with 0 inode (vnode %d)\n", vnodeNumber); */
- bzero(vnode, vcp->diskSize);
+ memset(vnode, 0, vcp->diskSize);
vnodeChanged = 1;
}
}
if (vcp->magic != vnode->vnodeMagic) {
/* bad magic #, probably partially created vnode */
Log("Partially allocated vnode %d deleted.\n", vnodeNumber);
- bzero(vnode, vcp->diskSize);
+ memset(vnode, 0, vcp->diskSize);
vnodeChanged = 1;
goto vnodeDone;
}
if (ip->inodeNumber != VNDISK_GET_INO(vnode)) {
if (check) {
if (!Showmode) {
+#ifdef AFS_LARGEFILE_ENV
+ Log("Vnode %d: inode number incorrect (is %s should be %s). FileSize=(0X%x,0X%x)\n",
+ vnodeNumber,
+ PrintInode(stmp1, VNDISK_GET_INO(vnode)),
+ PrintInode(stmp2, ip->inodeNumber),
+ (unsigned) (ip->byteCount >> 32),
+ (unsigned) (ip->byteCount & 0xffffffff));
+#else
Log("Vnode %d: inode number incorrect (is %s should be %s). FileSize=%d\n",
+ vnodeNumber,
PrintInode(stmp1, VNDISK_GET_INO(vnode)),
PrintInode(stmp2, ip->inodeNumber),
ip->byteCount);
+#endif /* !AFS_LARGEFILE_ENV */
}
VNDISK_SET_INO(vnode, ip->inodeNumber);
err = -1;
goto zooks;
}
if (!Showmode) {
+#ifdef AFS_LARGEFILE_ENV
+ Log("Vnode %d: inode number incorrect; changed from %s to %s. FileSize=(0X%x,0X%x)\n",
+ vnodeNumber,
+ PrintInode(stmp1, VNDISK_GET_INO(vnode)),
+ PrintInode(stmp2, ip->inodeNumber),
+ (unsigned) (ip->byteCount >> 32),
+ (unsigned) (ip->byteCount & 0xffffffff));
+#else
Log("Vnode %d: inode number incorrect; changed from %s to %s. FileSize=%d\n",
vnodeNumber,
PrintInode(stmp1, VNDISK_GET_INO(vnode)),
PrintInode(stmp2, ip->inodeNumber),
ip->byteCount);
+#endif /* !AFS_LARGEFILE_ENV */
}
VNDISK_SET_INO(vnode, ip->inodeNumber);
vnodeChanged = 1;
}
- if (ip->byteCount != vnode->length) {
+ VNDISK_GET_LEN(vnodeSize, vnode);
+ if (ip->byteCount != vnodeSize) {
if (check) {
- if (!Showmode) Log("Vnode %d: length incorrect; (is %d should be %d)\n",
- vnodeNumber, vnode->length, ip->byteCount);
+ if (!Showmode)
+#ifdef AFS_LARGEFILE_ENV
+ Log("Vnode %d: length incorrect; (is (0X%x,0X%x) should be (0X%x,0X%x))\n",
+ vnodeNumber,
+ (unsigned) (vnodeSize >> 32),
+ (unsigned) (vnodeSize & 0xffffffff),
+ (unsigned) (ip->byteCount >> 32),
+ (unsigned) (ip->byteCount & 0xffffffff));
+#else
+ Log("Vnode %d: length incorrect; (is %d should be %d)\n",
+ vnodeNumber, vnodeSize, ip->byteCount);
+#endif /* !AFS_LARGEFILE_ENV */
err = -1;
goto zooks;
}
- if (!Showmode) Log("Vnode %d: length incorrect; changed from %d to %d\n",
- vnodeNumber, vnode->length, ip->byteCount);
- vnode->length = ip->byteCount;
+ if (!Showmode)
+#ifdef AFS_LARGEFILE_ENV
+ Log("Vnode %d: length incorrect; changed from (0X%x,0X%x) to (0X%x,0X%x)\n",
+ vnodeNumber,
+ (unsigned) (vnodeSize >> 32),
+ (unsigned) (vnodeSize & 0xffffffff),
+ (unsigned) (ip->byteCount >> 32),
+ (unsigned) (ip->byteCount & 0xffffffff));
+#else
+ Log("Vnode %d: length incorrect; changed from %d to %d\n",
+ vnodeNumber, vnodeSize, ip->byteCount);
+#endif /* !AFS_LARGEFILE_ENV */
+ VNDISK_SET_LEN(vnode, ip->byteCount);
vnodeChanged = 1;
}
if (!check)
} else {
if (!Showmode) Log("Vnode %d (unique %d): bad directory vnode (no inode number listed); vnode deleted, vnode mod time=%s", vnodeNumber, vnode->uniquifier, ctime((time_t *)&(vnode->serverModifyTime)));
}
- bzero(vnode, vcp->diskSize);
+ memset(vnode, 0, vcp->diskSize);
vnodeChanged = 1;
} else {
/* Should not reach here becuase we checked for
return err;
}
-struct VnodeEssence *CheckVnodeNumber(vnodeNumber)
- VnodeId vnodeNumber;
+struct VnodeEssence *CheckVnodeNumber(VnodeId vnodeNumber)
{
VnodeClass class;
struct VnodeInfo *vip;
return (offset >= vip->nVnodes? NULL: &vip->vnodes[offset]);
}
-
void CopyOnWrite(register struct DirSummary *dir)
{
/* Copy the directory unconditionally if we are going to change it:
dir->copied = 1;
}
-/* This function should either successfully create a new dir, or give up and leave
- * things the way they were. In particular, if it fails to write the new dir properly,
- * it should return w/o changing the reference to the old dir.
+/*
+ * This function should either successfully create a new dir, or give up
+ * and leave things the way they were. In particular, if it fails to write
+ * the new dir properly, it should return w/o changing the reference to the
+ * old dir.
*/
void CopyAndSalvage(register struct DirSummary *dir)
{
}
vnode.cloned = 0;
VNDISK_SET_INO(&vnode, newinode);
- vnode.length = Length(&newdir);
+ VNDISK_SET_LEN(&vnode, (afs_size_t) Length(&newdir));
code = IH_IWRITE(vnodeInfo[vLarge].handle,
vnodeIndexOffset(vcp, dir->vnodeNumber),
(char*)&vnode, sizeof (vnode));
}
if (!Testing) {
CopyOnWrite(dir);
- assert(Delete(&dir->dirHandle, name) == 0)
+ assert(Delete(&dir->dirHandle, name) == 0);
}
return;
}
* so its unique matches the vnode unique. Delete if the unique is zero
* or if the directory is orphaned.
*/
- if (!IUnique(vnodeEssence->unique) ||
- (IUnique(vnodeEssence->unique) != IUnique(unique)) ) {
- if ( !IUnique(vnodeEssence->unique) &&
+ if (!vnodeEssence->unique ||
+ (vnodeEssence->unique) != unique) {
+ if (!vnodeEssence->unique &&
((strcmp(name,"..")==0) || (strcmp(name,".")==0)) ) {
/* This is an orphaned directory. Don't delete the . or ..
* entry. Otherwise, it will get created in the next
fid.Vnode = vnodeNumber;
fid.Unique = vnodeEssence->unique;
CopyOnWrite(dir);
- assert(Delete(&dir->dirHandle, name) == 0)
+ assert(Delete(&dir->dirHandle, name) == 0);
if (!todelete)
- assert(Create(&dir->dirHandle, name, &fid) == 0)
+ assert(Create(&dir->dirHandle, name, &fid) == 0);
}
if (todelete) return; /* no need to continue */
}
if (strcmp(name,".") == 0) {
- if (dir->vnodeNumber != vnodeNumber || (IUnique(dir->unique) != IUnique(unique))) {
+ if (dir->vnodeNumber != vnodeNumber || (dir->unique != unique)) {
ViceFid fid;
if (!Showmode) Log("directory vnode %d.%d: bad '.' entry (was %d.%d); fixed\n",
dir->vnodeNumber, dir->unique, vnodeNumber, unique);
if (!Testing) {
CopyOnWrite(dir);
- assert(Delete(&dir->dirHandle, ".") == 0)
+ assert(Delete(&dir->dirHandle, ".") == 0);
fid.Vnode = dir->vnodeNumber;
fid.Unique = dir->unique;
- assert(Create(&dir->dirHandle, ".", &fid) == 0)
+ assert(Create(&dir->dirHandle, ".", &fid) == 0);
}
vnodeNumber = fid.Vnode; /* Get the new Essence */
pa.Vnode = dir->vnodeNumber;
pa.Unique = dir->unique;
}
- if ((pa.Vnode != vnodeNumber) || (IUnique(pa.Unique) != IUnique(unique))) {
+ if ((pa.Vnode != vnodeNumber) || (pa.Unique != unique)) {
if (!Showmode) Log("directory vnode %d.%d: bad '..' entry (was %d.%d); fixed\n",
- dir->vnodeNumber, IUnique(dir->unique), vnodeNumber, IUnique(unique));
+ dir->vnodeNumber, dir->unique, vnodeNumber, unique);
if (!Testing) {
CopyOnWrite(dir);
assert(Delete(&dir->dirHandle, "..") == 0);
}
if (!Testing) {
CopyOnWrite(dir);
- assert(Delete(&dir->dirHandle, name) == 0)
+ assert(Delete(&dir->dirHandle, name) == 0);
}
vnodeEssence->claimed = 0; /* Not claimed: Orphaned */
vnodeEssence->todelete = 1; /* Will later delete vnode and decr inode */
else {
if (ShowSuid && (vnodeEssence->modeBits & 06000))
Log("FOUND suid/sgid file: %s/%s (%u.%u %05o) author %u (vnode %u dir %u)\n", dir->name?dir->name:"??", name,
- vnodeEssence->owner, vnodeEssence->group, vnodeEssence->modeBits, vnodeEssence->author,vnodeNumber, dir->vnodeNumber);
- if (ShowMounts && (vnodeEssence->type == vSymlink) && !(vnodeEssence->modeBits & 0111)) {
+ vnodeEssence->owner, vnodeEssence->group,
+ vnodeEssence->modeBits, vnodeEssence->author,vnodeNumber,
+ dir->vnodeNumber);
+ if (ShowMounts && (vnodeEssence->type == vSymlink) &&
+ !(vnodeEssence->modeBits & 0111)) {
int code, size;
char buf[1024];
IHandle_t *ihP;
assert(fdP != NULL);
size = FDH_SIZE(fdP);
assert(size != -1);
- bzero(buf, 1024);
+ memset(buf, 0, 1024);
if (size > 1024) size = 1024;
code = FDH_READ(fdP, buf, size);
assert(code == size);
}
if (ShowRootFiles && vnodeEssence->owner==0 && vnodeNumber != 1)
Log("FOUND root file: %s/%s (%u.%u %05o) author %u (vnode %u dir %u)\n", dir->name?dir->name:"??", name,
- vnodeEssence->owner, vnodeEssence->group, vnodeEssence->modeBits, vnodeEssence->author, vnodeNumber, dir->vnodeNumber);
- if (vnodeIdToClass(vnodeNumber) == vLarge && vnodeEssence->name == (char *)0) {
+ vnodeEssence->owner, vnodeEssence->group,
+ vnodeEssence->modeBits, vnodeEssence->author, vnodeNumber,
+ dir->vnodeNumber);
+ if (vnodeIdToClass(vnodeNumber) == vLarge &&
+ vnodeEssence->name == NULL) {
char *n;
if (n = (char*)malloc(strlen(name)+1))
strcpy(n, name);
struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
char buf[SIZEOF_LARGEDISKVNODE];
struct VnodeDiskObject *vnode = (struct VnodeDiskObject *) buf;
- int code;
int size;
StreamHandle_t *file;
int vnodeIndex;
IH_INIT(vip->handle, fileSysDevice, rwVId, ino);
fdP = IH_OPEN(vip->handle);
- assert(fdP != NULL)
+ assert(fdP != NULL);
file = FDH_FDOPEN(fdP, "r+");
assert(file != NULL);
size = OS_SIZE(fdP->fd_fd);
assert(size != -1);
vip->nVnodes = (size / vcp->diskSize) - 1;
if (vip->nVnodes > 0) {
- assert((vip->nVnodes+1)*vcp->diskSize == size)
- assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0)
+ assert((vip->nVnodes+1)*vcp->diskSize == size);
+ assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0);
assert((vip->vnodes = (struct VnodeEssence *)
- calloc(vip->nVnodes, sizeof(struct VnodeEssence))) != NULL)
+ calloc(vip->nVnodes, sizeof(struct VnodeEssence))) != NULL);
if (class == vLarge) {
assert((vip->inodes = (Inode *)
- calloc(vip->nVnodes, sizeof (Inode))) != NULL)
+ calloc(vip->nVnodes, sizeof (Inode))) != NULL);
}
else {
vip->inodes = NULL;
nVnodes--, vnodeIndex++) {
if (vnode->type != vNull) {
register struct VnodeEssence *vep = &vip->vnodes[vnodeIndex];
+ afs_size_t vnodeLength;
vip->nAllocatedVnodes++;
vep->count = vnode->linkCount;
- vep->blockCount = nBlocks(vnode->length);
+ VNDISK_GET_LEN(vnodeLength, vnode);
+ vep->blockCount = nBlocks(vnodeLength);
vip->volumeBlockCount += vep->blockCount;
vep->parent = vnode->parent;
vep->unique = vnode->uniquifier;
vep->owner = vnode->owner;
vep->group = vnode->group;
if (vnode->type == vDirectory) {
- assert(class == vLarge)
+ assert(class == vLarge);
vip->inodes[vnodeIndex] = VNDISK_GET_INO(vnode);
}
}
FDH_CLOSE(fdP);
}
-static char *GetDirName(vnode, vp, path)
- VnodeId vnode;
- struct VnodeEssence *vp;
- char *path;
+static char *GetDirName(VnodeId vnode, struct VnodeEssence *vp, char *path)
{
struct VnodeEssence *parentvp;
/* To determine if a vnode is orhpaned or not, the vnode and all its parent
* vnodes must be "claimed". The vep->claimed flag is set in JudgeEntry().
*/
-static int IsVnodeOrphaned(vnode)
- VnodeId vnode;
+static int IsVnodeOrphaned(VnodeId vnode)
{
struct VnodeEssence *vep;
/* Remember rootdir DirSummary _after_ it has been judged */
if (dir.vnodeNumber == 1 && dir.unique == 1) {
- bcopy(&dir, rootdir, sizeof(struct DirSummary));
+ memcpy(rootdir, &dir, sizeof(struct DirSummary));
*rootdirfound = 1;
}
*/
if (class == vLarge) { /* directory vnode */
pv = vnodeIdToBitNumber(vep->parent);
- if (IUnique(vnodeInfo[vLarge].vnodes[pv].unique) != 0)
+ if (vnodeInfo[vLarge].vnodes[pv].unique != 0)
vnodeInfo[vLarge].vnodes[pv].count++;
}
code = IH_DEC(alinkH, VNDISK_GET_INO(&vnode), vid);
assert(code == 0);
}
- bzero(&vnode, sizeof(vnode));
+ memset(&vnode, 0, sizeof(vnode));
}
} else if (vnp->count) {
if (!Showmode) {
nBytes = IH_IREAD(h, 0, (char*)&volHeader, sizeof(volHeader));
assert(nBytes == sizeof(volHeader));
- assert(volHeader.stamp.magic == VOLUMEINFOMAGIC)
+ assert(volHeader.stamp.magic == VOLUMEINFOMAGIC);
volHeader.inUse = 0;
volHeader.needsSalvaged = 0;
volHeader.inService = 1;
* deleteMe - Always do so, only a partial volume.
*/
void MaybeZapVolume(register struct InodeSummary *isp, char *message,
- int deleteMe,
- int check)
+ int deleteMe, int check)
{
if (readOnly(isp) || deleteMe) {
if (isp->volSummary && isp->volSummary->fileName) {
void AskOffline(VolumeId volumeId)
{
- if (FSYNC_askfs(volumeId, (char *)0, FSYNC_OFF, FSYNC_SALVAGE) == FSYNC_DENIED) {
+ if (FSYNC_askfs(volumeId, NULL, FSYNC_OFF, FSYNC_SALVAGE) == FSYNC_DENIED) {
Log("AskOffline: file server denied offline request; a general salvage is required.\n");
Abort("Salvage aborted\n");
}
char buf[4096];
IHandle_t *srcH, *destH;
FdHandle_t *srcFdP, *destFdP;
- register int n;
+ register int n = 0;
IH_INIT(srcH, device, rwvolume, inode1);
srcFdP = IH_OPEN(srcH);
{
register struct ViceInodeInfo *ip;
struct ViceInodeInfo *buf;
+#ifdef AFS_LARGEFILE_ENV
+ struct stat64 status;
+#else /* !AFS_LARGEFILE_ENV */
struct stat status;
+#endif /* !AFS_LARGEFILE_ENV */
register nInodes;
+#ifdef AFS_LARGEFILE_ENV
+ assert(fstat64(inodeFd, &status) == 0);
+#else /* !AFS_LARGEFILE_ENV */
assert(fstat(inodeFd, &status) == 0);
+#endif /* !AFS_LARGEFILE_ENV */
buf = (struct ViceInodeInfo *) malloc(status.st_size);
assert(buf != NULL);
nInodes = status.st_size / sizeof(struct ViceInodeInfo);
assert(read(inodeFd, buf, status.st_size) == status.st_size);
for(ip = buf; nInodes--; ip++) {
+#ifdef AFS_LARGEFILE_ENV
+ Log("Inode:%s, linkCount=%d, size=(0X%x,0X%x), p=(%u,%u,%u,%u)\n",
+ PrintInode(NULL, ip->inodeNumber), ip->linkCount,
+ (unsigned) (ip->byteCount >> 32),
+ (unsigned) (ip->byteCount & 0xffffffff),
+ ip->u.param[0], ip->u.param[1], ip->u.param[2], ip->u.param[3]);
+#else
Log("Inode:%s, linkCount=%d, size=%u, p=(%u,%u,%u,%u)\n",
PrintInode(NULL, ip->inodeNumber), ip->linkCount, ip->byteCount,
ip->u.param[0], ip->u.param[1], ip->u.param[2], ip->u.param[3]);
+#endif
}
free(buf);
}
assert(0); /* Fork is never executed in the NT code path */
#else
f = fork();
- assert(f >= 0)
+ assert(f >= 0);
#endif
return f;
}
int status;
int pid;
pid = wait(&status);
- assert(pid != -1)
+ assert(pid != -1);
if (WCOREDUMP(status))
Log("\"%s\" core dumped!\n", prog);
if (WIFSIGNALED(status) != 0 || WEXITSTATUS(status) != 0)
Exit(1);
}
-char * ToString(char *s)
+char *ToString(char *s)
{
register char *p;
p = (char *) malloc(strlen(s)+1);
- assert(p != NULL)
+ assert(p != NULL);
strcpy(p,s);
return p;