dir-char-to-void-20021014

Change a bunch of (char *) to (void *)
This commit is contained in:
Jim Rees 2002-10-14 15:41:16 +00:00
parent 7aebf2b2ea
commit a64d9d729d
3 changed files with 183 additions and 158 deletions

View File

@ -53,14 +53,14 @@ struct buffer {
afs_int32 page;
afs_int32 accesstime;
struct buffer *hashNext;
char *data;
void *data;
char lockers;
char dirty;
char hashIndex;
struct Lock lock;
} **Buffers;
char *BufferData;
void *BufferData;
static struct buffer *phTable[PHSIZE]; /* page hash table */
static struct buffer *LastBuffer;
@ -72,7 +72,8 @@ struct buffer *newslot();
int DStat (abuffers, acalls, aios)
int *abuffers, *acalls, *aios;
{*abuffers = nbuffers;
{
*abuffers = nbuffers;
*acalls = calls;
*aios = ios;
return 0;
@ -80,17 +81,18 @@ int DStat (abuffers, acalls, aios)
int DInit (abuffers)
int abuffers;
{/* Initialize the venus buffer system. */
{
/* Initialize the venus buffer system. */
register int i, tsize;
register struct buffer *tb;
register char *tp;
register void *tp;
Lock_Init(&afs_bufferLock);
/* Align each element of Buffers on a doubleword boundary */
tsize = (sizeof(struct buffer) + 7) & ~7;
tp = (char *) malloc(abuffers * tsize);
tp = (void *) malloc(abuffers * tsize);
Buffers = (struct buffer **) malloc(abuffers * sizeof(struct buffer *));
BufferData = (char *) malloc(abuffers * BUFFER_PAGE_SIZE);
BufferData = (void *) malloc(abuffers * BUFFER_PAGE_SIZE);
timecounter = 0;
LastBuffer = (struct buffer *)tp;
nbuffers = abuffers;
@ -110,10 +112,11 @@ int DInit (abuffers)
return 0;
}
char *DRead(fid,page)
void *DRead(fid,page)
register afs_int32 *fid;
register int page;
{ /* Read a page from the disk. */
{
/* Read a page from the disk. */
register struct buffer *tb, *tb2, **bufhead;
ObtainWriteLock(&afs_bufferLock);
@ -192,7 +195,8 @@ char *DRead(fid,page)
static FixupBucket(ap)
register struct buffer *ap;
{register struct buffer **lp, *tp;
{
register struct buffer **lp, *tp;
register int i;
/* first try to get it out of its current hash bucket, in which it might not be */
i = ap->hashIndex;
@ -214,7 +218,8 @@ static FixupBucket(ap)
struct buffer *newslot (afid, apage, lp)
afs_int32 *afid, apage;
register struct buffer *lp; /* pointer to a fairly-old buffer */
{/* Find a usable buffer slot */
{
/* Find a usable buffer slot */
register afs_int32 i;
afs_int32 lt;
register struct buffer **tbp;
@ -268,11 +273,12 @@ void
DRelease (bp,flag)
register struct buffer *bp;
int flag;
{/* Release a buffer, specifying whether or not the buffer has been modified by the locker. */
{
/* Release a buffer, specifying whether or not the buffer has been modified by the locker. */
register int index;
if (!bp) return;
index = (((char *)bp)-((char *)BufferData))>>LOGPS;
index = (((void *)bp)-((void *)BufferData))>>LOGPS;
bp = Buffers[index];
ObtainWriteLock(&bp->lock);
bp->lockers--;
@ -282,19 +288,21 @@ DRelease (bp,flag)
DVOffset (ap)
register void *ap;
{/* Return the byte within a file represented by a buffer pointer. */
{
/* Return the byte within a file represented by a buffer pointer. */
register struct buffer *bp;
register int index;
bp=ap;
index = (((char *)bp) - ((char *)BufferData)) >> LOGPS;
index = (((void *)bp) - ((void *)BufferData)) >> LOGPS;
if (index<0 || index >= nbuffers) return -1;
bp = Buffers[index];
return BUFFER_PAGE_SIZE*bp->page+((char *)ap)-bp->data;
return BUFFER_PAGE_SIZE*bp->page+((void *)ap)-bp->data;
}
DZap (fid)
register afs_int32 *fid;
{/* Destroy all buffers pertaining to a particular fid. */
{
/* Destroy all buffers pertaining to a particular fid. */
register struct buffer *tb;
ObtainReadLock(&afs_bufferLock);
for(tb=phTable[pHash(fid)]; tb; tb=tb->hashNext)
@ -309,7 +317,8 @@ DZap (fid)
DFlushVolume (vid)
register afs_int32 vid;
{/* Flush all data and release all inode handles for a particular volume */
{
/* Flush all data and release all inode handles for a particular volume */
register struct buffer *tb;
register int code, rcode = 0;
ObtainReadLock(&afs_bufferLock);
@ -331,7 +340,8 @@ DFlushVolume (vid)
DFlushEntry (fid)
register afs_int32 *fid;
{/* Flush pages modified by one entry. */
{
/* Flush pages modified by one entry. */
register struct buffer *tb;
int code;
@ -355,7 +365,8 @@ register afs_int32 *fid;
}
DFlush ()
{/* Flush all the modified buffers. */
{
/* Flush all the modified buffers. */
register int i;
register struct buffer **tbp;
afs_int32 code, rcode;
@ -385,7 +396,7 @@ DFlush ()
return rcode;
}
char *DNew (fid,page)
void *DNew (fid,page)
register int page;
register afs_int32 *fid;
{

View File

@ -132,7 +132,7 @@ struct DirEntry *DRead();
struct DirEntry *DNew();
/* Local static prototypes */
static struct DirEntry *FindItem (char *dir, char *ename,
static struct DirEntry *FindItem (void *dir, char *ename,
unsigned short **previtem);
@ -143,9 +143,11 @@ int NameBlobs (char *name)
return 1+((i+15)>>5);
}
int Create (char *dir, char *entry, afs_int32 *vfid)
{
/* Create an entry in a file. Dir is a file representation, while entry is a string name. */
int Create (void *dir, char *entry, void *voidfid)
{
afs_int32 *vfid = (afs_int32 *) voidfid;
int blobs, firstelt;
register int i;
register struct DirEntry *ep;
@ -185,7 +187,7 @@ int Create (char *dir, char *entry, afs_int32 *vfid)
return 0;
}
int Length (char *dir)
int Length (void *dir)
{
int i,ctr;
struct DirHeader *dhp;
@ -202,7 +204,7 @@ int Length (char *dir)
return ctr*AFS_PAGESIZE;
}
int Delete (char *dir, char *entry)
int Delete (void *dir, char *entry)
{
/* Delete an entry from a directory, including update of all free entry descriptors. */
int nitems, index;
@ -219,7 +221,7 @@ int Delete (char *dir, char *entry)
return 0;
}
int FindBlobs (char *dir, int nblobs)
int FindBlobs (void *dir, int nblobs)
{
/* Find a bunch of contiguous entries; at least nblobs in a row. */
register int i, j, k;
@ -286,7 +288,7 @@ int FindBlobs (char *dir, int nblobs)
return -1;
}
void AddPage (char *dir, int pageno)
void AddPage (void *dir, int pageno)
{/* Add a page to a directory. */
register int i;
register struct PageHeader *pp;
@ -301,9 +303,10 @@ void AddPage (char *dir, int pageno)
DRelease(pp,1);
}
void FreeBlobs(char *dir, register int firstblob, int nblobs)
{
/* Free a whole bunch of directory entries. */
void FreeBlobs(void *dir, register int firstblob, int nblobs)
{
register int i;
int page;
struct DirHeader *dhp;
@ -320,10 +323,13 @@ void FreeBlobs(char *dir, register int firstblob, int nblobs)
DRelease(pp,1);
}
int MakeDir (char *dir, afs_int32 *me, afs_int32 *parent)
/*
* Format an empty directory properly. Note that the first 13 entries in a
* directory header page are allocated, 1 to the page header, 4 to the
* allocation map and 8 to the hash table.
*/
int MakeDir (void *dir, afs_int32 *me, afs_int32 *parent)
{
/* Format an empty directory properly. Note that the first 13 entries in a directory header
page are allocated, 1 to the page header, 4 to the allocation map and 8 to the hash table. */
register int i;
register struct DirHeader *dhp;
dhp = (struct DirHeader *) DNew(dir,0);
@ -342,9 +348,11 @@ int MakeDir (char *dir, afs_int32 *me, afs_int32 *parent)
return 0;
}
int Lookup (char *dir, char *entry, register afs_int32 *fid)
{
/* Look up a file name in directory. */
int Lookup (void *dir, char *entry, void *voidfid)
{
afs_int32 *fid = (afs_int32 *) voidfid;
register struct DirEntry *firstitem;
unsigned short *previtem;
@ -357,9 +365,11 @@ int Lookup (char *dir, char *entry, register afs_int32 *fid)
return 0;
}
int LookupOffset (char *dir, char *entry, register afs_int32 *fid, long *offsetp)
{
/* Look up a file name in directory. */
int LookupOffset (void *dir, char *entry, void *voidfid, long *offsetp)
{
afs_int32 *fid = (afs_int32 *) voidfid;
register struct DirEntry *firstitem;
unsigned short *previtem;
@ -374,7 +384,7 @@ int LookupOffset (char *dir, char *entry, register afs_int32 *fid, long *offsetp
return 0;
}
int EnumerateDir (char *dir, int (*hookproc)(), void *hook)
int EnumerateDir (void *dir, int (*hookproc)(), void *hook)
{
/* Enumerate the contents of a directory. */
register int i;
@ -408,7 +418,7 @@ int EnumerateDir (char *dir, int (*hookproc)(), void *hook)
return 0;
}
int IsEmpty (char *dir)
int IsEmpty (void *dir)
{
/* Enumerate the contents of a directory. */
register int i;
@ -437,7 +447,7 @@ int IsEmpty (char *dir)
return 0;
}
struct DirEntry *GetBlob (char *dir, afs_int32 blobno)
struct DirEntry *GetBlob (void *dir, afs_int32 blobno)
{
/* Return a pointer to an entry, given its number. */
struct DirEntry *ep;
@ -463,7 +473,7 @@ int DirHash (register char *string)
return tval;
}
static struct DirEntry *FindItem (char *dir, char *ename,
static struct DirEntry *FindItem (void *dir, char *ename,
unsigned short **previtem)
{
/* Find a directory entry, given its name. This entry returns a pointer to a locked buffer, and a pointer to a locked buffer (in previtem) referencing the found item (to aid the delete code). If no entry is found, however, no items are left locked, and a null pointer is returned instead. */

View File

@ -30,7 +30,8 @@ struct MKFid
};
struct PageHeader
{/* A page header entry. */
{
/* A page header entry. */
unsigned short pgcount; /* number of pages, or 0 if old-style */
unsigned short tag; /* 1234 in network byte order */
char freecount; /* unused, info in dirHeader structure */
@ -39,14 +40,16 @@ struct PageHeader
};
struct DirHeader
{/* A directory header object. */
{
/* A directory header object. */
struct PageHeader header;
char alloMap[MAXPAGES]; /* one byte per 2K page */
unsigned short hashTable[NHASHENT];
};
struct DirEntry
{/* A directory entry */
{
/* A directory entry */
char flag;
char length; /* currently unused */
unsigned short next;
@ -55,18 +58,21 @@ struct DirEntry
};
struct DirXEntry
{/* A directory extension entry. */
{
/* A directory extension entry. */
char name[32];
};
struct DirPage0
{/* A page in a directory. */
{
/* A page in a directory. */
struct DirHeader header;
struct DirEntry entry[1];
};
struct DirPage1
{/* A page in a directory. */
{
/* A page in a directory. */
struct PageHeader header;
struct DirEntry entry[1];
};
@ -82,33 +88,31 @@ extern int DVOffset(void *ap);
/* Prototypes */
extern int NameBlobs (char *name);
extern int Create (char *dir, char *entry, afs_int32 *vfid);
extern int Length (char *dir);
extern int Delete (char *dir, char *entry);
extern int FindBlobs (char *dir, int nblobs);
extern void AddPage (char *dir, int pageno);
extern void FreeBlobs(char *dir, register int firstblob, int nblobs);
extern int MakeDir (char *dir, afs_int32 *me, afs_int32 *parent);
extern int Lookup (char *dir, char *entry, register afs_int32 *fid);
extern int LookupOffset (char *dir, char *entry, register afs_int32 *fid, long *offsetp);
extern int EnumerateDir (char *dir, int (*hookproc)(void *dir, char *name, afs_int32 vnode, afs_int32 unique), void *hook);
extern int IsEmpty (char *dir);
extern struct DirEntry *GetBlob (char *dir, afs_int32 blobno);
extern int Create (void *dir, char *entry, void *vfid);
extern int Length (void *dir);
extern int Delete (void *dir, char *entry);
extern int FindBlobs (void *dir, int nblobs);
extern void AddPage (void *dir, int pageno);
extern void FreeBlobs(void *dir, register int firstblob, int nblobs);
extern int MakeDir (void *dir, afs_int32 *me, afs_int32 *parent);
extern int Lookup (void *dir, char *entry, void *fid);
extern int LookupOffset (void *dir, char *entry, void *fid, long *offsetp);
extern int EnumerateDir (void *dir, int (*hookproc)(void *dir, char *name, afs_int32 vnode, afs_int32 unique), void *hook);
extern int IsEmpty (void *dir);
extern struct DirEntry *GetBlob (void *dir, afs_int32 blobno);
extern int DirHash (register char *string);
#ifdef KERNEL
extern int afs_dir_NameBlobs (char *name);
extern int afs_dir_Create (char *dir, char *entry, afs_int32 *vfid);
extern int afs_dir_Length (char *dir);
extern int afs_dir_Delete (char *dir, char *entry);
extern int afs_dir_MakeDir (char *dir, afs_int32 *me, afs_int32 *parent);
extern int afs_dir_Lookup (char *dir, char *entry, register afs_int32 *fid);
extern int afs_dir_LookupOffset (char *dir, char *entry, register afs_int32 *fid, long *offsetp);
extern int afs_dir_EnumerateDir (char *dir, int (*hookproc)(void *dir, char *name, afs_int32 vnode, afs_int32 unique), void *hook);
extern int afs_dir_IsEmpty (char *dir);
extern struct DirEntry *afs_dir_GetBlob (char *dir, afs_int32 blobno);
extern int afs_dir_Create (void *dir, char *entry, void *vfid);
extern int afs_dir_Length (void *dir);
extern int afs_dir_Delete (void *dir, char *entry);
extern int afs_dir_MakeDir (void *dir, afs_int32 *me, afs_int32 *parent);
extern int afs_dir_Lookup (void *dir, char *entry, void *fid);
extern int afs_dir_LookupOffset (void *dir, char *entry, void *fid, long *offsetp);
extern int afs_dir_EnumerateDir (void *dir, int (*hookproc)(void *dir, char *name, afs_int32 vnode, afs_int32 unique), void *hook);
extern int afs_dir_IsEmpty (void *dir);
extern struct DirEntry *afs_dir_GetBlob (void *dir, afs_int32 blobno);
#endif
#endif /* !defined(__AFS_DIR_H) */