int debug; /* -d flag */
-int Testing = 0; /* -n flag */
+extern int Testing; /* -n flag */
int ListInodeOption; /* -i flag */
int ShowRootFiles; /* -r flag */
int RebuildDirs; /* -sal flag */
return 0; /* otherwise may be transient, e.g. EMFILE */
}
-
#define MAX_ARGS 128
#ifdef AFS_NT40_ENV
char *save_args[MAX_ARGS];
int n_save_args = 0;
-pthread_t main_thread;
+extern pthread_t main_thread;
+childJob_t myjob = { SALVAGER_MAGIC, NOT_CHILD, "" };
#endif
-
/* Get the salvage lock if not already held. Hold until process exits. */
void
ObtainSalvageLock(void)
Abort("Can't open link table for volume %u (error = %d)\n",
isp->RWvolumeId, errno);
- if (FDH_TRUNC(fdP, 0) < 0)
+ if (FDH_TRUNC(fdP, sizeof(version) + sizeof(short)) < 0)
Abort("Can't truncate link table for volume %u (error = %d)\n",
isp->RWvolumeId, errno);
if (Testing) {
IH_INIT(VGLinkH, fileSysDevice, -1, -1);
} else {
+ int i, j;
+ struct ViceInodeInfo *ip;
CreateLinkTable(isp, ino);
+ fdP = IH_OPEN(VGLinkH);
+ /* Sync fake 1 link counts to the link table, now that it exists */
+ if (fdP) {
+ for (i = 0; i < nVols; i++) {
+ ip = allInodes + isp[i].index;
+ for (j = isp[i].nSpecialInodes; j < isp[i].nInodes; j++) {
+#ifdef AFS_NT40_ENV
+ nt_SetLinkCount(fdP, ip[j].inodeNumber, 1, 1);
+#else
+ namei_SetLinkCount(fdP, ip[j].inodeNumber, 1, 1);
+#endif
+ }
+ }
+ }
}
}
if (fdP)
struct VnodeDiskObject vnode;
struct VnodeClassInfo *vcp = &VnodeClassInfo[vLarge];
Inode oldinode, newinode;
- int code;
+ afs_sfsize_t code;
if (dir->copied || Testing)
return;
struct VnodeClassInfo *vcp = &VnodeClassInfo[vLarge];
Inode oldinode, newinode;
DirHandle newdir;
- register afs_int32 code;
+ afs_int32 code;
+ afs_sfsize_t lcode;
afs_int32 parentUnique = 1;
struct VnodeEssence *vnodeEssence;
if (Testing)
return;
Log("Salvaging directory %u...\n", dir->vnodeNumber);
- code =
+ lcode =
IH_IREAD(vnodeInfo[vLarge].handle,
vnodeIndexOffset(vcp, dir->vnodeNumber), (char *)&vnode,
sizeof(vnode));
- assert(code == sizeof(vnode));
+ assert(lcode == sizeof(vnode));
oldinode = VNDISK_GET_INO(&vnode);
/* Increment the version number by a whole lot to avoid problems with
* clients that were promised new version numbers--but the file server
if (code) {
/* didn't really build the new directory properly, let's just give up. */
code = IH_DEC(dir->ds_linkH, newinode, dir->rwVid);
- assert(code == 0);
Log("Directory salvage returned code %d, continuing.\n", code);
+ if (code) {
+ Log("also failed to decrement link count on new inode");
+ }
assert(1 == 2);
}
Log("Checking the results of the directory salvage...\n");
vnode.cloned = 0;
VNDISK_SET_INO(&vnode, newinode);
VNDISK_SET_LEN(&vnode, Length(&newdir));
- code =
+ lcode =
IH_IWRITE(vnodeInfo[vLarge].handle,
vnodeIndexOffset(vcp, dir->vnodeNumber), (char *)&vnode,
sizeof(vnode));
- assert(code == sizeof(vnode));
+ assert(lcode == sizeof(vnode));
#ifdef AFS_NT40_ENV
nt_sync(fileSysDevice);
#else
struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
char buf[SIZEOF_LARGEDISKVNODE];
struct VnodeDiskObject *vnode = (struct VnodeDiskObject *)buf;
- int size;
+ afs_sfsize_t size;
StreamHandle_t *file;
int vnodeIndex;
int nVnodes;
struct VnodeEssence *vep;
afs_int32 v, pv;
IHandle_t *h;
- int nBytes;
+ afs_sfsize_t nBytes;
ViceFid pa;
VnodeId LFVnode, ThisVnode;
Unique LFUnique, ThisUnique;
ClearROInUseBit(struct VolumeSummary *summary)
{
IHandle_t *h = summary->volumeInfoHandle;
- int nBytes;
+ afs_sfsize_t nBytes;
VolumeDiskData volHeader;
volHeader.inService = 1;
volHeader.dontSalvage = DONT_SALVAGE;
if (!Testing) {
- nBytes = IH_IREAD(h, 0, (char *)&volHeader, sizeof(volHeader));
+ nBytes = IH_IWRITE(h, 0, (char *)&volHeader, sizeof(volHeader));
assert(nBytes == sizeof(volHeader));
}
}