mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 15:30:14 +00:00
dir-char-to-void-20021014
Change a bunch of (char *) to (void *)
This commit is contained in:
parent
7aebf2b2ea
commit
a64d9d729d
161
src/dir/buffer.c
161
src/dir/buffer.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2000, International Business Machines Corporation and others.
|
* Copyright 2000, International Business Machines Corporation and others.
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This software has been released under the terms of the IBM Public
|
* This software has been released under the terms of the IBM Public
|
||||||
* License. For details, see the LICENSE file in the top-level source
|
* License. For details, see the LICENSE file in the top-level source
|
||||||
* directory or online at http://www.openafs.org/dl/license10.html
|
* directory or online at http://www.openafs.org/dl/license10.html
|
||||||
@ -53,14 +53,14 @@ struct buffer {
|
|||||||
afs_int32 page;
|
afs_int32 page;
|
||||||
afs_int32 accesstime;
|
afs_int32 accesstime;
|
||||||
struct buffer *hashNext;
|
struct buffer *hashNext;
|
||||||
char *data;
|
void *data;
|
||||||
char lockers;
|
char lockers;
|
||||||
char dirty;
|
char dirty;
|
||||||
char hashIndex;
|
char hashIndex;
|
||||||
struct Lock lock;
|
struct Lock lock;
|
||||||
} **Buffers;
|
} **Buffers;
|
||||||
|
|
||||||
char *BufferData;
|
void *BufferData;
|
||||||
|
|
||||||
static struct buffer *phTable[PHSIZE]; /* page hash table */
|
static struct buffer *phTable[PHSIZE]; /* page hash table */
|
||||||
static struct buffer *LastBuffer;
|
static struct buffer *LastBuffer;
|
||||||
@ -72,25 +72,27 @@ struct buffer *newslot();
|
|||||||
|
|
||||||
int DStat (abuffers, acalls, aios)
|
int DStat (abuffers, acalls, aios)
|
||||||
int *abuffers, *acalls, *aios;
|
int *abuffers, *acalls, *aios;
|
||||||
{*abuffers = nbuffers;
|
{
|
||||||
|
*abuffers = nbuffers;
|
||||||
*acalls = calls;
|
*acalls = calls;
|
||||||
*aios = ios;
|
*aios = ios;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DInit (abuffers)
|
int DInit (abuffers)
|
||||||
int abuffers;
|
int abuffers;
|
||||||
{/* Initialize the venus buffer system. */
|
{
|
||||||
|
/* Initialize the venus buffer system. */
|
||||||
register int i, tsize;
|
register int i, tsize;
|
||||||
register struct buffer *tb;
|
register struct buffer *tb;
|
||||||
register char *tp;
|
register void *tp;
|
||||||
|
|
||||||
Lock_Init(&afs_bufferLock);
|
Lock_Init(&afs_bufferLock);
|
||||||
/* Align each element of Buffers on a doubleword boundary */
|
/* Align each element of Buffers on a doubleword boundary */
|
||||||
tsize = (sizeof(struct buffer) + 7) & ~7;
|
tsize = (sizeof(struct buffer) + 7) & ~7;
|
||||||
tp = (char *) malloc(abuffers * tsize);
|
tp = (void *) malloc(abuffers * tsize);
|
||||||
Buffers = (struct buffer **) malloc(abuffers * sizeof(struct buffer *));
|
Buffers = (struct buffer **) malloc(abuffers * sizeof(struct buffer *));
|
||||||
BufferData = (char *) malloc(abuffers * BUFFER_PAGE_SIZE);
|
BufferData = (void *) malloc(abuffers * BUFFER_PAGE_SIZE);
|
||||||
timecounter = 0;
|
timecounter = 0;
|
||||||
LastBuffer = (struct buffer *)tp;
|
LastBuffer = (struct buffer *)tp;
|
||||||
nbuffers = abuffers;
|
nbuffers = abuffers;
|
||||||
@ -110,10 +112,11 @@ int DInit (abuffers)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *DRead(fid,page)
|
void *DRead(fid,page)
|
||||||
register afs_int32 *fid;
|
register afs_int32 *fid;
|
||||||
register int page;
|
register int page;
|
||||||
{ /* Read a page from the disk. */
|
{
|
||||||
|
/* Read a page from the disk. */
|
||||||
register struct buffer *tb, *tb2, **bufhead;
|
register struct buffer *tb, *tb2, **bufhead;
|
||||||
|
|
||||||
ObtainWriteLock(&afs_bufferLock);
|
ObtainWriteLock(&afs_bufferLock);
|
||||||
@ -123,13 +126,13 @@ char *DRead(fid,page)
|
|||||||
#define buf_Front(head,parent,p) {(parent)->hashNext = (p)->hashNext; (p)->hashNext= *(head);*(head)=(p);}
|
#define buf_Front(head,parent,p) {(parent)->hashNext = (p)->hashNext; (p)->hashNext= *(head);*(head)=(p);}
|
||||||
|
|
||||||
/* this apparently-complicated-looking code is simply an example of
|
/* this apparently-complicated-looking code is simply an example of
|
||||||
* a little bit of loop unrolling, and is a standard linked-list
|
* a little bit of loop unrolling, and is a standard linked-list
|
||||||
* traversal trick. It saves a few assignments at the the expense
|
* traversal trick. It saves a few assignments at the the expense
|
||||||
* of larger code size. This could be simplified by better use of
|
* of larger code size. This could be simplified by better use of
|
||||||
* macros. With the use of these LRU queues, the old one-cache is
|
* macros. With the use of these LRU queues, the old one-cache is
|
||||||
* probably obsolete.
|
* probably obsolete.
|
||||||
*/
|
*/
|
||||||
if ( tb = phTable[pHash(fid)] ) { /* ASSMT HERE */
|
if ( tb = phTable[pHash(fid)] ) { /* ASSMT HERE */
|
||||||
if (bufmatch(tb)) {
|
if (bufmatch(tb)) {
|
||||||
ObtainWriteLock(&tb->lock);
|
ObtainWriteLock(&tb->lock);
|
||||||
tb->lockers++;
|
tb->lockers++;
|
||||||
@ -139,37 +142,37 @@ char *DRead(fid,page)
|
|||||||
return tb->data;
|
return tb->data;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bufhead = &( phTable[pHash(fid)] );
|
bufhead = &( phTable[pHash(fid)] );
|
||||||
while (tb2 = tb->hashNext) {
|
while (tb2 = tb->hashNext) {
|
||||||
if (bufmatch(tb2)) {
|
if (bufmatch(tb2)) {
|
||||||
buf_Front(bufhead,tb,tb2);
|
buf_Front(bufhead,tb,tb2);
|
||||||
ObtainWriteLock(&tb2->lock);
|
ObtainWriteLock(&tb2->lock);
|
||||||
tb2->lockers++;
|
tb2->lockers++;
|
||||||
ReleaseWriteLock(&afs_bufferLock);
|
ReleaseWriteLock(&afs_bufferLock);
|
||||||
tb2->accesstime = ++timecounter;
|
tb2->accesstime = ++timecounter;
|
||||||
ReleaseWriteLock(&tb2->lock);
|
ReleaseWriteLock(&tb2->lock);
|
||||||
return tb2->data;
|
return tb2->data;
|
||||||
|
}
|
||||||
|
if (tb = tb2->hashNext) { /* ASSIGNMENT HERE! */
|
||||||
|
if (bufmatch(tb)) {
|
||||||
|
buf_Front(bufhead,tb2,tb);
|
||||||
|
ObtainWriteLock(&tb->lock);
|
||||||
|
tb->lockers++;
|
||||||
|
ReleaseWriteLock(&afs_bufferLock);
|
||||||
|
tb->accesstime = ++timecounter;
|
||||||
|
ReleaseWriteLock(&tb->lock);
|
||||||
|
return tb->data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else break;
|
||||||
}
|
}
|
||||||
if (tb = tb2->hashNext) { /* ASSIGNMENT HERE! */
|
|
||||||
if (bufmatch(tb)) {
|
|
||||||
buf_Front(bufhead,tb2,tb);
|
|
||||||
ObtainWriteLock(&tb->lock);
|
|
||||||
tb->lockers++;
|
|
||||||
ReleaseWriteLock(&afs_bufferLock);
|
|
||||||
tb->accesstime = ++timecounter;
|
|
||||||
ReleaseWriteLock(&tb->lock);
|
|
||||||
return tb->data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else tb2 = NULL;
|
else tb2 = NULL;
|
||||||
|
|
||||||
/* can't find it */
|
/* can't find it */
|
||||||
/* The last thing we looked at was either tb or tb2 (or nothing). That
|
/* The last thing we looked at was either tb or tb2 (or nothing). That
|
||||||
* is at least the oldest buffer on one particular hash chain, so it's
|
* is at least the oldest buffer on one particular hash chain, so it's
|
||||||
* a pretty good place to start looking for the truly oldest buffer.
|
* a pretty good place to start looking for the truly oldest buffer.
|
||||||
*/
|
*/
|
||||||
tb = newslot(fid, page, (tb ? tb : tb2));
|
tb = newslot(fid, page, (tb ? tb : tb2));
|
||||||
@ -192,7 +195,8 @@ char *DRead(fid,page)
|
|||||||
|
|
||||||
static FixupBucket(ap)
|
static FixupBucket(ap)
|
||||||
register struct buffer *ap;
|
register struct buffer *ap;
|
||||||
{register struct buffer **lp, *tp;
|
{
|
||||||
|
register struct buffer **lp, *tp;
|
||||||
register int i;
|
register int i;
|
||||||
/* first try to get it out of its current hash bucket, in which it might not be */
|
/* first try to get it out of its current hash bucket, in which it might not be */
|
||||||
i = ap->hashIndex;
|
i = ap->hashIndex;
|
||||||
@ -213,36 +217,37 @@ static FixupBucket(ap)
|
|||||||
|
|
||||||
struct buffer *newslot (afid, apage, lp)
|
struct buffer *newslot (afid, apage, lp)
|
||||||
afs_int32 *afid, apage;
|
afs_int32 *afid, apage;
|
||||||
register struct buffer *lp; /* pointer to a fairly-old buffer */
|
register struct buffer *lp; /* pointer to a fairly-old buffer */
|
||||||
{/* Find a usable buffer slot */
|
{
|
||||||
|
/* Find a usable buffer slot */
|
||||||
register afs_int32 i;
|
register afs_int32 i;
|
||||||
afs_int32 lt;
|
afs_int32 lt;
|
||||||
register struct buffer **tbp;
|
register struct buffer **tbp;
|
||||||
|
|
||||||
if (lp && (lp->lockers == 0)) {
|
if (lp && (lp->lockers == 0)) {
|
||||||
lt = lp->accesstime;
|
lt = lp->accesstime;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lp = 0;
|
lp = 0;
|
||||||
lt = BUFFER_LONG_MAX;
|
lt = BUFFER_LONG_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
tbp = Buffers;
|
tbp = Buffers;
|
||||||
for (i=0;i<nbuffers;i++,tbp++) {
|
for (i=0;i<nbuffers;i++,tbp++) {
|
||||||
if ((*tbp)->lockers == 0) {
|
if ((*tbp)->lockers == 0) {
|
||||||
if ((*tbp)->accesstime < lt) {
|
if ((*tbp)->accesstime < lt) {
|
||||||
lp = (*tbp);
|
lp = (*tbp);
|
||||||
lt = (*tbp)->accesstime;
|
lt = (*tbp)->accesstime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There are no unlocked buffers */
|
/* There are no unlocked buffers */
|
||||||
if (lp == 0) {
|
if (lp == 0) {
|
||||||
if (lt < 0)
|
if (lt < 0)
|
||||||
Die("accesstime counter wrapped");
|
Die("accesstime counter wrapped");
|
||||||
else
|
else
|
||||||
Die ("all buffers locked");
|
Die ("all buffers locked");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We do not need to lock the buffer here because it has no lockers
|
/* We do not need to lock the buffer here because it has no lockers
|
||||||
@ -251,7 +256,7 @@ struct buffer *newslot (afid, apage, lp)
|
|||||||
if (lp->dirty) {
|
if (lp->dirty) {
|
||||||
if (ReallyWrite(lp->fid,lp->page,lp->data)) Die("writing bogus buffer");
|
if (ReallyWrite(lp->fid,lp->page,lp->data)) Die("writing bogus buffer");
|
||||||
lp->dirty = 0;
|
lp->dirty = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now fill in the header. */
|
/* Now fill in the header. */
|
||||||
FidZap(lp->fid);
|
FidZap(lp->fid);
|
||||||
@ -262,39 +267,42 @@ struct buffer *newslot (afid, apage, lp)
|
|||||||
FixupBucket(lp); /* move to the right hash bucket */
|
FixupBucket(lp); /* move to the right hash bucket */
|
||||||
|
|
||||||
return lp;
|
return lp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DRelease (bp,flag)
|
DRelease (bp,flag)
|
||||||
register struct buffer *bp;
|
register struct buffer *bp;
|
||||||
int flag;
|
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;
|
register int index;
|
||||||
|
|
||||||
if (!bp) return;
|
if (!bp) return;
|
||||||
index = (((char *)bp)-((char *)BufferData))>>LOGPS;
|
index = (((void *)bp)-((void *)BufferData))>>LOGPS;
|
||||||
bp = Buffers[index];
|
bp = Buffers[index];
|
||||||
ObtainWriteLock(&bp->lock);
|
ObtainWriteLock(&bp->lock);
|
||||||
bp->lockers--;
|
bp->lockers--;
|
||||||
if (flag) bp->dirty=1;
|
if (flag) bp->dirty=1;
|
||||||
ReleaseWriteLock(&bp->lock);
|
ReleaseWriteLock(&bp->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
DVOffset (ap)
|
DVOffset (ap)
|
||||||
register void *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 struct buffer *bp;
|
||||||
register int index;
|
register int index;
|
||||||
bp=ap;
|
bp=ap;
|
||||||
index = (((char *)bp) - ((char *)BufferData)) >> LOGPS;
|
index = (((void *)bp) - ((void *)BufferData)) >> LOGPS;
|
||||||
if (index<0 || index >= nbuffers) return -1;
|
if (index<0 || index >= nbuffers) return -1;
|
||||||
bp = Buffers[index];
|
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)
|
DZap (fid)
|
||||||
register afs_int32 *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;
|
register struct buffer *tb;
|
||||||
ObtainReadLock(&afs_bufferLock);
|
ObtainReadLock(&afs_bufferLock);
|
||||||
for(tb=phTable[pHash(fid)]; tb; tb=tb->hashNext)
|
for(tb=phTable[pHash(fid)]; tb; tb=tb->hashNext)
|
||||||
@ -305,11 +313,12 @@ DZap (fid)
|
|||||||
ReleaseWriteLock(&tb->lock);
|
ReleaseWriteLock(&tb->lock);
|
||||||
}
|
}
|
||||||
ReleaseReadLock(&afs_bufferLock);
|
ReleaseReadLock(&afs_bufferLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
DFlushVolume (vid)
|
DFlushVolume (vid)
|
||||||
register afs_int32 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 struct buffer *tb;
|
||||||
register int code, rcode = 0;
|
register int code, rcode = 0;
|
||||||
ObtainReadLock(&afs_bufferLock);
|
ObtainReadLock(&afs_bufferLock);
|
||||||
@ -327,11 +336,12 @@ DFlushVolume (vid)
|
|||||||
}
|
}
|
||||||
ReleaseReadLock(&afs_bufferLock);
|
ReleaseReadLock(&afs_bufferLock);
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
DFlushEntry (fid)
|
DFlushEntry (fid)
|
||||||
register afs_int32 *fid;
|
register afs_int32 *fid;
|
||||||
{/* Flush pages modified by one entry. */
|
{
|
||||||
|
/* Flush pages modified by one entry. */
|
||||||
register struct buffer *tb;
|
register struct buffer *tb;
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
@ -355,7 +365,8 @@ register afs_int32 *fid;
|
|||||||
}
|
}
|
||||||
|
|
||||||
DFlush ()
|
DFlush ()
|
||||||
{/* Flush all the modified buffers. */
|
{
|
||||||
|
/* Flush all the modified buffers. */
|
||||||
register int i;
|
register int i;
|
||||||
register struct buffer **tbp;
|
register struct buffer **tbp;
|
||||||
afs_int32 code, rcode;
|
afs_int32 code, rcode;
|
||||||
@ -371,7 +382,7 @@ DFlush ()
|
|||||||
if ((*tbp)->dirty) {
|
if ((*tbp)->dirty) {
|
||||||
code = ReallyWrite((*tbp)->fid, (*tbp)->page, (*tbp)->data);
|
code = ReallyWrite((*tbp)->fid, (*tbp)->page, (*tbp)->data);
|
||||||
if (!code)
|
if (!code)
|
||||||
(*tbp)->dirty = 0; /* Clear the dirty flag */
|
(*tbp)->dirty = 0; /* Clear the dirty flag */
|
||||||
if (code && !rcode) {
|
if (code && !rcode) {
|
||||||
rcode = code;
|
rcode = code;
|
||||||
}
|
}
|
||||||
@ -385,9 +396,9 @@ DFlush ()
|
|||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *DNew (fid,page)
|
void *DNew (fid,page)
|
||||||
register int page;
|
register int page;
|
||||||
register afs_int32 *fid;
|
register afs_int32 *fid;
|
||||||
{
|
{
|
||||||
/* Same as read, only do *not* even try to read the page,
|
/* Same as read, only do *not* even try to read the page,
|
||||||
* since it probably doesn't exist.
|
* since it probably doesn't exist.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2000, International Business Machines Corporation and others.
|
* Copyright 2000, International Business Machines Corporation and others.
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This software has been released under the terms of the IBM Public
|
* This software has been released under the terms of the IBM Public
|
||||||
* License. For details, see the LICENSE file in the top-level source
|
* License. For details, see the LICENSE file in the top-level source
|
||||||
* directory or online at http://www.openafs.org/dl/license10.html
|
* directory or online at http://www.openafs.org/dl/license10.html
|
||||||
@ -108,7 +108,7 @@ RCSID("$Header$");
|
|||||||
# ifdef HAVE_UNISTD_H
|
# ifdef HAVE_UNISTD_H
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# endif
|
# endif
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# include <errno.h>
|
# include <errno.h>
|
||||||
# include "dir.h"
|
# include "dir.h"
|
||||||
#ifdef AFS_NT40_ENV
|
#ifdef AFS_NT40_ENV
|
||||||
@ -132,7 +132,7 @@ struct DirEntry *DRead();
|
|||||||
struct DirEntry *DNew();
|
struct DirEntry *DNew();
|
||||||
|
|
||||||
/* Local static prototypes */
|
/* Local static prototypes */
|
||||||
static struct DirEntry *FindItem (char *dir, char *ename,
|
static struct DirEntry *FindItem (void *dir, char *ename,
|
||||||
unsigned short **previtem);
|
unsigned short **previtem);
|
||||||
|
|
||||||
|
|
||||||
@ -143,9 +143,11 @@ int NameBlobs (char *name)
|
|||||||
return 1+((i+15)>>5);
|
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)
|
||||||
{
|
{
|
||||||
/* Create an entry in a file. Dir is a file representation, while entry is a string name. */
|
afs_int32 *vfid = (afs_int32 *) voidfid;
|
||||||
int blobs, firstelt;
|
int blobs, firstelt;
|
||||||
register int i;
|
register int i;
|
||||||
register struct DirEntry *ep;
|
register struct DirEntry *ep;
|
||||||
@ -155,22 +157,22 @@ int Create (char *dir, char *entry, afs_int32 *vfid)
|
|||||||
/* check name quality */
|
/* check name quality */
|
||||||
if (*entry == 0) return EINVAL;
|
if (*entry == 0) return EINVAL;
|
||||||
/* First check if file already exists. */
|
/* First check if file already exists. */
|
||||||
ep = FindItem(dir,entry,&pp);
|
ep = FindItem(dir, entry, &pp);
|
||||||
if (ep) {
|
if (ep) {
|
||||||
DRelease(ep, 0);
|
DRelease(ep, 0);
|
||||||
DRelease(pp, 0);
|
DRelease(pp, 0);
|
||||||
return EEXIST;
|
return EEXIST;
|
||||||
}
|
}
|
||||||
blobs = NameBlobs(entry); /* number of entries required */
|
blobs = NameBlobs(entry); /* number of entries required */
|
||||||
firstelt = FindBlobs(dir,blobs);
|
firstelt = FindBlobs(dir, blobs);
|
||||||
if (firstelt < 0) return EFBIG; /* directory is full */
|
if (firstelt < 0) return EFBIG; /* directory is full */
|
||||||
/* First, we fill in the directory entry. */
|
/* First, we fill in the directory entry. */
|
||||||
ep = GetBlob(dir,firstelt);
|
ep = GetBlob(dir, firstelt);
|
||||||
if (ep == 0) return EIO;
|
if (ep == 0) return EIO;
|
||||||
ep->flag = FFIRST;
|
ep->flag = FFIRST;
|
||||||
ep->fid.vnode = htonl(vfid[1]);
|
ep->fid.vnode = htonl(vfid[1]);
|
||||||
ep->fid.vunique = htonl(vfid[2]);
|
ep->fid.vunique = htonl(vfid[2]);
|
||||||
strcpy(ep->name,entry);
|
strcpy(ep->name, entry);
|
||||||
/* Now we just have to thread it on the hash table list. */
|
/* Now we just have to thread it on the hash table list. */
|
||||||
dhp = (struct DirHeader *) DRead(dir,0);
|
dhp = (struct DirHeader *) DRead(dir,0);
|
||||||
if (!dhp) {
|
if (!dhp) {
|
||||||
@ -185,7 +187,7 @@ int Create (char *dir, char *entry, afs_int32 *vfid)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Length (char *dir)
|
int Length (void *dir)
|
||||||
{
|
{
|
||||||
int i,ctr;
|
int i,ctr;
|
||||||
struct DirHeader *dhp;
|
struct DirHeader *dhp;
|
||||||
@ -202,7 +204,7 @@ int Length (char *dir)
|
|||||||
return ctr*AFS_PAGESIZE;
|
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. */
|
/* Delete an entry from a directory, including update of all free entry descriptors. */
|
||||||
int nitems, index;
|
int nitems, index;
|
||||||
@ -219,7 +221,7 @@ int Delete (char *dir, char *entry)
|
|||||||
return 0;
|
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. */
|
/* Find a bunch of contiguous entries; at least nblobs in a row. */
|
||||||
register int i, j, k;
|
register int i, j, k;
|
||||||
@ -286,7 +288,7 @@ int FindBlobs (char *dir, int nblobs)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddPage (char *dir, int pageno)
|
void AddPage (void *dir, int pageno)
|
||||||
{/* Add a page to a directory. */
|
{/* Add a page to a directory. */
|
||||||
register int i;
|
register int i;
|
||||||
register struct PageHeader *pp;
|
register struct PageHeader *pp;
|
||||||
@ -301,9 +303,10 @@ void AddPage (char *dir, int pageno)
|
|||||||
DRelease(pp,1);
|
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)
|
||||||
{
|
{
|
||||||
/* Free a whole bunch of directory entries. */
|
|
||||||
register int i;
|
register int i;
|
||||||
int page;
|
int page;
|
||||||
struct DirHeader *dhp;
|
struct DirHeader *dhp;
|
||||||
@ -318,12 +321,15 @@ void FreeBlobs(char *dir, register int firstblob, int nblobs)
|
|||||||
if (pp) for (i=0;i<nblobs;i++)
|
if (pp) for (i=0;i<nblobs;i++)
|
||||||
pp->freebitmap[(firstblob+i)>>3] &= ~(1<<((firstblob+i)&7));
|
pp->freebitmap[(firstblob+i)>>3] &= ~(1<<((firstblob+i)&7));
|
||||||
DRelease(pp,1);
|
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 int i;
|
||||||
register struct DirHeader *dhp;
|
register struct DirHeader *dhp;
|
||||||
dhp = (struct DirHeader *) DNew(dir,0);
|
dhp = (struct DirHeader *) DNew(dir,0);
|
||||||
@ -340,11 +346,13 @@ int MakeDir (char *dir, afs_int32 *me, afs_int32 *parent)
|
|||||||
Create(dir,".",me);
|
Create(dir,".",me);
|
||||||
Create(dir,"..",parent); /* Virtue is its own .. */
|
Create(dir,"..",parent); /* Virtue is its own .. */
|
||||||
return 0;
|
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)
|
||||||
{
|
{
|
||||||
/* Look up a file name in directory. */
|
afs_int32 *fid = (afs_int32 *) voidfid;
|
||||||
register struct DirEntry *firstitem;
|
register struct DirEntry *firstitem;
|
||||||
unsigned short *previtem;
|
unsigned short *previtem;
|
||||||
|
|
||||||
@ -357,24 +365,26 @@ int Lookup (char *dir, char *entry, register afs_int32 *fid)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LookupOffset (char *dir, char *entry, register afs_int32 *fid, long *offsetp)
|
/* Look up a file name in directory. */
|
||||||
{
|
|
||||||
/* Look up a file name in directory. */
|
|
||||||
register struct DirEntry *firstitem;
|
|
||||||
unsigned short *previtem;
|
|
||||||
|
|
||||||
firstitem = FindItem(dir,entry,&previtem);
|
int LookupOffset (void *dir, char *entry, void *voidfid, long *offsetp)
|
||||||
if (firstitem == 0) return ENOENT;
|
{
|
||||||
DRelease(previtem,0);
|
afs_int32 *fid = (afs_int32 *) voidfid;
|
||||||
fid[1] = ntohl(firstitem->fid.vnode);
|
register struct DirEntry *firstitem;
|
||||||
fid[2] = ntohl(firstitem->fid.vunique);
|
unsigned short *previtem;
|
||||||
if (offsetp)
|
|
||||||
*offsetp = DVOffset(firstitem);
|
firstitem = FindItem(dir,entry,&previtem);
|
||||||
DRelease(firstitem,0);
|
if (firstitem == 0) return ENOENT;
|
||||||
return 0;
|
DRelease(previtem,0);
|
||||||
|
fid[1] = ntohl(firstitem->fid.vnode);
|
||||||
|
fid[2] = ntohl(firstitem->fid.vunique);
|
||||||
|
if (offsetp)
|
||||||
|
*offsetp = DVOffset(firstitem);
|
||||||
|
DRelease(firstitem,0);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EnumerateDir (char *dir, int (*hookproc)(), void *hook)
|
int EnumerateDir (void *dir, int (*hookproc)(), void *hook)
|
||||||
{
|
{
|
||||||
/* Enumerate the contents of a directory. */
|
/* Enumerate the contents of a directory. */
|
||||||
register int i;
|
register int i;
|
||||||
@ -408,7 +418,7 @@ int EnumerateDir (char *dir, int (*hookproc)(), void *hook)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IsEmpty (char *dir)
|
int IsEmpty (void *dir)
|
||||||
{
|
{
|
||||||
/* Enumerate the contents of a directory. */
|
/* Enumerate the contents of a directory. */
|
||||||
register int i;
|
register int i;
|
||||||
@ -437,7 +447,7 @@ int IsEmpty (char *dir)
|
|||||||
return 0;
|
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. */
|
/* Return a pointer to an entry, given its number. */
|
||||||
struct DirEntry *ep;
|
struct DirEntry *ep;
|
||||||
@ -463,7 +473,7 @@ int DirHash (register char *string)
|
|||||||
return tval;
|
return tval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct DirEntry *FindItem (char *dir, char *ename,
|
static struct DirEntry *FindItem (void *dir, char *ename,
|
||||||
unsigned short **previtem)
|
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. */
|
/* 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. */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2000, International Business Machines Corporation and others.
|
* Copyright 2000, International Business Machines Corporation and others.
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This software has been released under the terms of the IBM Public
|
* This software has been released under the terms of the IBM Public
|
||||||
* License. For details, see the LICENSE file in the top-level source
|
* License. For details, see the LICENSE file in the top-level source
|
||||||
* directory or online at http://www.openafs.org/dl/license10.html
|
* directory or online at http://www.openafs.org/dl/license10.html
|
||||||
@ -24,52 +24,58 @@
|
|||||||
#define FNEXT 2
|
#define FNEXT 2
|
||||||
|
|
||||||
struct MKFid
|
struct MKFid
|
||||||
{/* A file identifier. */
|
{ /* A file identifier. */
|
||||||
afs_int32 vnode; /* file's vnode slot */
|
afs_int32 vnode; /* file's vnode slot */
|
||||||
afs_int32 vunique; /* the slot incarnation number */
|
afs_int32 vunique; /* the slot incarnation number */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PageHeader
|
struct PageHeader
|
||||||
{/* A page header entry. */
|
{
|
||||||
|
/* A page header entry. */
|
||||||
unsigned short pgcount; /* number of pages, or 0 if old-style */
|
unsigned short pgcount; /* number of pages, or 0 if old-style */
|
||||||
unsigned short tag; /* 1234 in network byte order */
|
unsigned short tag; /* 1234 in network byte order */
|
||||||
char freecount; /* unused, info in dirHeader structure */
|
char freecount; /* unused, info in dirHeader structure */
|
||||||
char freebitmap[EPP/8];
|
char freebitmap[EPP/8];
|
||||||
char padding[32-(5+EPP/8)];
|
char padding[32-(5+EPP/8)];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DirHeader
|
struct DirHeader
|
||||||
{/* A directory header object. */
|
{
|
||||||
|
/* A directory header object. */
|
||||||
struct PageHeader header;
|
struct PageHeader header;
|
||||||
char alloMap[MAXPAGES]; /* one byte per 2K page */
|
char alloMap[MAXPAGES]; /* one byte per 2K page */
|
||||||
unsigned short hashTable[NHASHENT];
|
unsigned short hashTable[NHASHENT];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DirEntry
|
struct DirEntry
|
||||||
{/* A directory entry */
|
{
|
||||||
|
/* A directory entry */
|
||||||
char flag;
|
char flag;
|
||||||
char length; /* currently unused */
|
char length; /* currently unused */
|
||||||
unsigned short next;
|
unsigned short next;
|
||||||
struct MKFid fid;
|
struct MKFid fid;
|
||||||
char name[16];
|
char name[16];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DirXEntry
|
struct DirXEntry
|
||||||
{/* A directory extension entry. */
|
{
|
||||||
|
/* A directory extension entry. */
|
||||||
char name[32];
|
char name[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DirPage0
|
struct DirPage0
|
||||||
{/* A page in a directory. */
|
{
|
||||||
|
/* A page in a directory. */
|
||||||
struct DirHeader header;
|
struct DirHeader header;
|
||||||
struct DirEntry entry[1];
|
struct DirEntry entry[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DirPage1
|
struct DirPage1
|
||||||
{/* A page in a directory. */
|
{
|
||||||
|
/* A page in a directory. */
|
||||||
struct PageHeader header;
|
struct PageHeader header;
|
||||||
struct DirEntry entry[1];
|
struct DirEntry entry[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note that this declaration is seen in both the kernel code and the
|
* Note that this declaration is seen in both the kernel code and the
|
||||||
@ -82,33 +88,31 @@ extern int DVOffset(void *ap);
|
|||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
extern int NameBlobs (char *name);
|
extern int NameBlobs (char *name);
|
||||||
extern int Create (char *dir, char *entry, afs_int32 *vfid);
|
extern int Create (void *dir, char *entry, void *vfid);
|
||||||
extern int Length (char *dir);
|
extern int Length (void *dir);
|
||||||
extern int Delete (char *dir, char *entry);
|
extern int Delete (void *dir, char *entry);
|
||||||
extern int FindBlobs (char *dir, int nblobs);
|
extern int FindBlobs (void *dir, int nblobs);
|
||||||
extern void AddPage (char *dir, int pageno);
|
extern void AddPage (void *dir, int pageno);
|
||||||
extern void FreeBlobs(char *dir, register int firstblob, int nblobs);
|
extern void FreeBlobs(void *dir, register int firstblob, int nblobs);
|
||||||
extern int MakeDir (char *dir, afs_int32 *me, afs_int32 *parent);
|
extern int MakeDir (void *dir, afs_int32 *me, afs_int32 *parent);
|
||||||
extern int Lookup (char *dir, char *entry, register afs_int32 *fid);
|
extern int Lookup (void *dir, char *entry, void *fid);
|
||||||
extern int LookupOffset (char *dir, char *entry, register afs_int32 *fid, long *offsetp);
|
extern int LookupOffset (void *dir, char *entry, void *fid, long *offsetp);
|
||||||
extern int EnumerateDir (char *dir, int (*hookproc)(void *dir, char *name, afs_int32 vnode, afs_int32 unique), void *hook);
|
extern int EnumerateDir (void *dir, int (*hookproc)(void *dir, char *name, afs_int32 vnode, afs_int32 unique), void *hook);
|
||||||
extern int IsEmpty (char *dir);
|
extern int IsEmpty (void *dir);
|
||||||
extern struct DirEntry *GetBlob (char *dir, afs_int32 blobno);
|
extern struct DirEntry *GetBlob (void *dir, afs_int32 blobno);
|
||||||
extern int DirHash (register char *string);
|
extern int DirHash (register char *string);
|
||||||
|
|
||||||
#ifdef KERNEL
|
#ifdef KERNEL
|
||||||
extern int afs_dir_NameBlobs (char *name);
|
extern int afs_dir_NameBlobs (char *name);
|
||||||
extern int afs_dir_Create (char *dir, char *entry, afs_int32 *vfid);
|
extern int afs_dir_Create (void *dir, char *entry, void *vfid);
|
||||||
extern int afs_dir_Length (char *dir);
|
extern int afs_dir_Length (void *dir);
|
||||||
extern int afs_dir_Delete (char *dir, char *entry);
|
extern int afs_dir_Delete (void *dir, char *entry);
|
||||||
extern int afs_dir_MakeDir (char *dir, afs_int32 *me, afs_int32 *parent);
|
extern int afs_dir_MakeDir (void *dir, afs_int32 *me, afs_int32 *parent);
|
||||||
extern int afs_dir_Lookup (char *dir, char *entry, register afs_int32 *fid);
|
extern int afs_dir_Lookup (void *dir, char *entry, void *fid);
|
||||||
extern int afs_dir_LookupOffset (char *dir, char *entry, register afs_int32 *fid, long *offsetp);
|
extern int afs_dir_LookupOffset (void *dir, char *entry, void *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_EnumerateDir (void *dir, int (*hookproc)(void *dir, char *name, afs_int32 vnode, afs_int32 unique), void *hook);
|
||||||
extern int afs_dir_IsEmpty (char *dir);
|
extern int afs_dir_IsEmpty (void *dir);
|
||||||
extern struct DirEntry *afs_dir_GetBlob (char *dir, afs_int32 blobno);
|
extern struct DirEntry *afs_dir_GetBlob (void *dir, afs_int32 blobno);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(__AFS_DIR_H) */
|
#endif /* !defined(__AFS_DIR_H) */
|
||||||
|
Loading…
Reference in New Issue
Block a user