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;
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);
}
/* 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];
Wait("SalvageFileSys");
}
-char *get_DevName(pbuffer, wpath)
-char *wpath, *pbuffer;
+char *get_DevName(char *pbuffer, char *wpath)
{
char pbuf[128], *ptr;
strcpy(pbuf, pbuffer);
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);
/* 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;
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)
{
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;
}
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 == NULL) {
+ 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);
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;
* 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) {
Exit(1);
}
-char * ToString(char *s)
+char *ToString(char *s)
{
register char *p;
p = (char *) malloc(strlen(s)+1);
normally goes online at this time. An offline volume
must be reattached to make it go online */
Volume *
-VAttachVolumeByName(ec, partition, name, mode)
- Error *ec;
- char *partition;
- char *name;
- int mode;
+VAttachVolumeByName(Error *ec, char *partition, char *name, int mode)
{
Volume *retVal;
VATTACH_LOCK
}
Volume *
-VAttachVolumeByName_r(ec, partition, name, mode)
- Error *ec;
- char *partition;
- char *name;
- int mode;
+VAttachVolumeByName_r(Error *ec, char *partition, char *name, int mode)
{
register Volume *vp;
int fd,n;
return vp;
}
-private Volume *attach2(ec, path, header, partp, isbusy)
- Error *ec;
- char *path;
- register struct VolumeHeader *header;
- struct DiskPartition *partp;
- int isbusy;
+private Volume *attach2(Error *ec, char *path, register struct VolumeHeader
+ *header, struct DiskPartition *partp, int isbusy)
{
register Volume *vp;
if (!*ec) {
struct IndexFileHeader iHead;
-#if TRANSARC_VOL_STATS
+#if OPENAFS_VOL_STATS
/*
* We just read in the diskstuff part of the header. If the detailed
* volume stats area has not yet been initialized, we should bzero the
memset((char *)(V_stat_area(vp)), 0, VOL_STATS_BYTES);
V_stat_initialized(vp) = 1;
}
-#endif /* TRANSARC_VOL_STATS */
+#endif /* OPENAFS_VOL_STATS */
VOL_UNLOCK
(void) ReadHeader(ec, vp->vnodeIndex[vSmall].handle,
(char *)&iHead, sizeof(iHead),
*/
Volume *
-VAttachVolume(ec,volumeId, mode)
- Error *ec;
- VolumeId volumeId;
- int mode;
+VAttachVolume(Error *ec, VolumeId volumeId, int mode)
{
Volume *retVal;
VATTACH_LOCK
}
Volume *
-VAttachVolume_r(ec,volumeId, mode)
- Error *ec;
- VolumeId volumeId;
- int mode;
+VAttachVolume_r(Error *ec, VolumeId volumeId, int mode)
{
char *part, *name;
GetVolumePath(ec,volumeId, &part, &name);
/* Get a pointer to an attached volume. The pointer is returned regardless
of whether or not the volume is in service or on/off line. An error
code, however, is returned with an indication of the volume's status */
-Volume *VGetVolume(ec,volumeId)
- Error *ec;
- VolId volumeId;
+Volume *VGetVolume(Error *ec, VolId volumeId)
{
Volume *retVal;
VOL_LOCK
return retVal;
}
-Volume *VGetVolume_r(ec,volumeId)
- Error *ec;
- VolId volumeId;
+Volume *VGetVolume_r(Error *ec, VolId volumeId)
{
Volume *vp;
unsigned short V0=0, V1=0, V2=0, V3=0, V4=0, V5=0, V6=0, V7=0, V8=0, V9=0;
/* Will be detached sometime in the future--this is OK since volume is offline */
if (programType == volumeUtility && notifyServer) {
- /* Note: The server is not notified in the case of a bogus volume explicitly to
- make it possible to create a volume, do a partial restore, then abort the
- operation without ever putting the volume online. This is essential in the
- case of a volume move operation between two partitions on the same server. In
- that case, there would be two instances of the same volume, one of them bogus,
- which the file server would attempt to put on line */
+ /*
+ * Note: The server is not notified in the case of a bogus volume
+ * explicitly to make it possible to create a volume, do a partial
+ * restore, then abort the operation without ever putting the volume
+ * online. This is essential in the case of a volume move operation
+ * between two partitions on the same server. In that case, there
+ * would be two instances of the same volume, one of them bogus,
+ * which the file server would attempt to put on line
+ */
if (useDone)
- FSYNC_askfs(volume, tpartp->name, FSYNC_DONE, 0); /* don't put online */
+ /* don't put online */
+ FSYNC_askfs(volume, tpartp->name, FSYNC_DONE, 0);
else {
- FSYNC_askfs(volume, tpartp->name, FSYNC_ON, 0); /* fs can use it again */
+ /* fs can use it again */
+ FSYNC_askfs(volume, tpartp->name, FSYNC_ON, 0);
/* Dettaching it so break all callbacks on it*/
if (V_BreakVolumeCallbacks) {
Log("volume %u detached; breaking all call backs\n", volume);
}
-int VAllocBitmapEntry_r(ec,vp,index)
- Error *ec;
- Volume *vp;
- register struct vnodeIndex *index;
+int VAllocBitmapEntry_r(Error *ec, Volume *vp, register struct vnodeIndex
+ *index)
{
register byte *bp,*ep;
*ec = 0;
return index->bitmapOffset*8;
}
-int VAllocBitmapEntry(ec,vp,index)
- Error *ec;
- Volume *vp;
- register struct vnodeIndex *index;
+int VAllocBitmapEntry(Error *ec, Volume *vp, register struct vnodeIndex *index)
{
int retVal;
VOL_LOCK
VOL_UNLOCK
}
-static void FreeVolume(vp)
- Volume *vp;
+static void FreeVolume(Volume *vp)
{
int i;
if (!vp)
}
}
-VolumeNumber(name)
- char *name;
+int VolumeNumber(char *name)
{
if (*name == '/')
name++;
return atoi(name+1);
}
-char *VolumeExternalName(volumeId)
- VolumeId volumeId;
+char *VolumeExternalName(VolumeId volumeId)
{
static char name[15];
sprintf(name,VFORMAT,volumeId);
return name;
}
-#if TRANSARC_VOL_STATS
+#if OPENAFS_VOL_STATS
#define OneDay (86400) /* 24 hours' worth of seconds */
#else
#define OneDay (24*60*60) /* 24 hours */
-#endif /* TRANSARC_VOL_STATS */
+#endif /* OPENAFS_VOL_STATS */
#define Midnight(date) ((date-TimeZoneCorrection)/OneDay*OneDay+TimeZoneCorrection)
* As described.
*------------------------------------------------------------------------*/
-VAdjustVolumeStatistics_r(vp)
- register Volume *vp;
-
-{ /*VAdjustVolumeStatistics*/
-
+int VAdjustVolumeStatistics_r(register Volume *vp)
+{
unsigned int now = FT_ApproxTime();
if (now - V_dayUseDate(vp) > OneDay) {
V_dayUse(vp) = 0;
V_dayUseDate(vp) = Midnight(now);
-#if TRANSARC_VOL_STATS
+#if OPENAFS_VOL_STATS
/*
* All we need to do is bzero the entire VOL_STATS_BYTES of
* the detailed volume statistics area.
*/
memset((char *)(V_stat_area(vp)), 0, VOL_STATS_BYTES);
-#endif /* TRANSARC_VOL_STATS */
+#endif /* OPENAFS_VOL_STATS */
} /*It's been more than a day of collection*/
-#if TRANSARC_VOL_STATS
/*
* Always return happily.
*/
return(0);
-#endif /* TRANSARC_VOL_STATS */
-
} /*VAdjustVolumeStatistics*/
-VAdjustVolumeStatistics(vp)
- register Volume *vp;
+int VAdjustVolumeStatistics(register Volume *vp)
{
int retVal;
VOL_LOCK
- VAdjustVolumeStatistics_r(vp);
+ retVal = VAdjustVolumeStatistics_r(vp);
VOL_UNLOCK
return retVal;
}
static struct volHeader *volumeLRU;
/* Allocate a bunch of headers; string them together */
-static void InitLRU(howMany)
-int howMany;
+static void InitLRU(int howMany)
{
register struct volHeader *hp;
if (programType != fileServer)
/* Get a volume header from the LRU list; update the old one if necessary */
/* Returns 1 if there was already a header, which is removed from the LRU list */
-static int GetVolumeHeader(vp)
-register Volume *vp;
+static int GetVolumeHeader(register Volume *vp)
{
Error error;
register struct volHeader *hd;
}
else {
if (volumeLRU)
- hd = volumeLRU->prev; /* not currently in use and least recently used */
+ /* not currently in use and least recently used */
+ hd = volumeLRU->prev;
else {
hd = (struct volHeader *) calloc(1, sizeof(*vp->header));
- hd->prev = hd->next = hd; /* make it look like single elt LRU */
+ /* make it look like single elt LRU */
+ hd->prev = hd->next = hd;
if (!everLogged) {
Log("****Allocated more volume headers, probably leak****\n");
everLogged=1;
}
/* Put it at the top of the LRU chain */
-static void ReleaseVolumeHeader(hd)
- register struct volHeader *hd;
+static void ReleaseVolumeHeader(register struct volHeader *hd)
{
if (programType != fileServer)
return;
volumeLRU = hd;
}
-static void FreeVolumeHeader(vp)
-register Volume *vp;
+static void FreeVolumeHeader(register Volume *vp)
{
register struct volHeader *hd = vp->header;
if (!hd)
/* Routines to add volume to hash chain, delete it */
/***************************************************/
-static void AddVolumeToHashTable(vp, hashid)
-register Volume *vp;
+static void AddVolumeToHashTable(register Volume *vp, int hashid)
{
int hash = VOLUME_HASH(hashid);
vp->hashid = hashid;
vp->vnodeHashOffset = VolumeHashOffset_r();
}
-static void DeleteVolumeFromHashTable(vp)
-register Volume *vp;
+static void DeleteVolumeFromHashTable(register Volume *vp)
{
int hash = VOLUME_HASH(vp->hashid);
if (VolumeHashTable[hash] == vp)
/*
* Define whether we are keeping detailed statistics on volume dealings.
*/
-#define TRANSARC_VOL_STATS 1
+#define OPENAFS_VOL_STATS 1
-#if TRANSARC_VOL_STATS
+#if OPENAFS_VOL_STATS
/*
* Define various indices and counts used in keeping volume-level statistics.
*/
#define VOL_STATS_TIME_IDX_3 3 /*1 hr to 24 hrs*/
#define VOL_STATS_TIME_IDX_4 4 /*1 day to 7 days*/
#define VOL_STATS_TIME_IDX_5 5 /*Greater than 1 week*/
-#endif /* TRANSARC_VOL_STATS */
+#endif /* OPENAFS_VOL_STATS */
/* Volume header. This is the contents of the named file representing
* the volume. Read-only by the file server!
set when the copy is created */
Date copyDate;
-#if TRANSARC_VOL_STATS
+#if OPENAFS_VOL_STATS
bit32 stat_initialized; /*Are the stat fields below set up?*/
bit32 reserved4[7];
#else
bit32 reserved4[8];
-#endif /* TRANSARC_VOL_STATS */
+#endif /* OPENAFS_VOL_STATS */
/* messages */
#define VMSGSIZE 128
char offlineMessage[VMSGSIZE]; /* Why the volume is offline */
-#if TRANSARC_VOL_STATS
+#if OPENAFS_VOL_STATS
#define VOL_STATS_BYTES 128
/*
* Keep per-volume aggregate statistics on type and distance of access,
bit32 stat_dirDiffAuthor[VOL_STATS_NUM_TIME_FIELDS];
#else
char motd[VMSGSIZE]; /* Volume "message of the day" */
-#endif /* TRANSARC_VOL_STATS */
+#endif /* OPENAFS_VOL_STATS */
} VolumeDiskData;
#define V_offlineMessage(vp) ((vp)->header->diskstuff.offlineMessage)
#define V_disk(vp) ((vp)->header->diskstuff)
#define V_motd(vp) ((vp)->header->diskstuff.motd)
-#if TRANSARC_VOL_STATS
+#if OPENAFS_VOL_STATS
#define V_stat_initialized(vp) ((vp)->header->diskstuff.stat_initialized)
#define V_stat_area(vp) (((vp)->header->diskstuff.stat_reads))
#define V_stat_reads(vp, idx) (((vp)->header->diskstuff.stat_reads)[idx])
#define V_stat_fileDiffAuthor(vp, idx) (((vp)->header->diskstuff.stat_fileDiffAuthor)[idx])
#define V_stat_dirSameAuthor(vp, idx) (((vp)->header->diskstuff.stat_dirSameAuthor)[idx])
#define V_stat_dirDiffAuthor(vp, idx) (((vp)->header->diskstuff.stat_dirDiffAuthor)[idx])
-#endif /* TRANSARC_VOL_STATS */
+#endif /* OPENAFS_VOL_STATS */
/* File offset computations. The offset values in the volume header are
computed with these macros -- when the file is written only!! */