ReleaseReadLock(&afs_bufferLock);
}
-void
+int
DFlush(void)
{
/* Flush all the modified buffers. */
}
}
ReleaseReadLock(&afs_bufferLock);
+
+ return 0;
}
int
/*
* Add the new entry to the correct hash chain.
*/
- i = DirHash(name);
+ i = afs_dir_DirHash(name);
dirEntry->next = dirHeader->hashTable[i];
dirHeader->hashTable[i] = htons(curPage * EPP + curChunk);
extern void shutdown_xscache(void);
/* afs_buffer.c */
-struct DirBuffer;
-extern void DInit(int abuffers);
-extern int DRead(struct dcache * fid, int page, struct DirBuffer *);
-extern int DVOffset(struct DirBuffer *);
-extern void DZap(struct dcache * fid);
-extern void DFlush(void);
-extern void DFlushDCache(struct dcache *);
-extern int DNew(struct dcache * fid, int page, struct DirBuffer *);
extern void shutdown_bufferpackage(void);
/* afs_call.c */
#include <lock.h>
+#include "dir.h"
+
#ifdef AFS_64BIT_IOPS_ENV
-#define BUFFER_FID_SIZE (9 + 2*sizeof(char*)/sizeof(int))
+#define BUFFER_FID_SIZE (9*sizeof(int) + 2*sizeof(char*))
#else
-#define BUFFER_FID_SIZE (6 + 2*sizeof(char*)/sizeof(int))
+#define BUFFER_FID_SIZE (6*sizeof(int) + 2*sizeof(char*))
#endif
struct buffer {
/* fid is used for Unique cache key + i/o addressing.
* fid size is based on 4 + size of inode and size of pointer
*/
- afs_int32 fid[BUFFER_FID_SIZE];
+ char fid[BUFFER_FID_SIZE];
afs_int32 page;
afs_int32 accesstime;
struct buffer *hashNext;
struct Lock lock;
};
-#include "dir.h"
+static_inline dir_file_t
+bufferDir(struct buffer *b)
+{
+ return (dir_file_t) &b->fid;
+}
struct Lock afs_bufferLock;
* based on the volume id. This means this macro is dependent upon the
* layout of DirHandle in viced/viced.h, vol/salvage.h and volser/salvage.h.
*/
-#define pHash(fid) ((fid)[0] & (PHSIZE-1))
+#define pHash(fid) (((afs_int32 *)fid)[0] & (PHSIZE-1))
#define vHash(vid) (vid & (PHSIZE-1))
/* admittedly system dependent, this is the maximum signed 32-bit value */
int timecounter;
static int calls = 0, ios = 0;
-struct buffer *newslot(afs_int32 *afid, afs_int32 apage,
+struct buffer *newslot(dir_file_t dir, afs_int32 apage,
struct buffer *lp);
/* XXX - This sucks. The correct prototypes for these functions are ...
* extern int ReallyRead(DirHandle *a, int block, char *data);
*/
-extern void FidZero(afs_int32 *file);
-extern int FidEq(afs_int32 *a, afs_int32 *b);
-extern int ReallyRead(afs_int32 *file, int block, char *data);
-extern int ReallyWrite(afs_int32 *file, int block, char *data);
-extern void FidZap(afs_int32 *file);
-extern int FidVolEq(afs_int32 *file, afs_int32 vid);
-extern void FidCpy(afs_int32 *tofile, afs_int32 *fromfile);
+extern void FidZero(dir_file_t);
+extern int FidEq(dir_file_t, dir_file_t);
+extern int ReallyRead(dir_file_t, int block, char *data);
+extern int ReallyWrite(dir_file_t, int block, char *data);
+extern void FidZap(dir_file_t);
+extern int FidVolEq(dir_file_t, afs_int32 vid);
+extern void FidCpy(dir_file_t, dir_file_t fromfile);
+
extern void Die(char *msg);
int
* @return operation status
* @retval 0 success
*/
-int
+void
DInit(int abuffers)
{
/* Initialize the venus buffer system. */
tb = (struct buffer *)tp;
Buffers[i] = tb;
tp += tsize;
- FidZero(tb->fid);
+ FidZero(bufferDir(tb));
tb->accesstime = tb->lockers = 0;
tb->data = &BufferData[BUFFER_PAGE_SIZE * i];
tb->hashIndex = 0;
tb->dirty = 0;
Lock_Init(&tb->lock);
}
- return 0;
+ return;
}
/**
* @retval NULL read failed
*/
int
-DRead(afs_int32 *fid, int page, struct DirBuffer *entry)
+DRead(dir_file_t fid, int page, struct DirBuffer *entry)
{
/* Read a page from the disk. */
struct buffer *tb, *tb2, **bufhead;
ObtainWriteLock(&afs_bufferLock);
calls++;
-#define bufmatch(tb) (tb->page == page && FidEq(tb->fid, fid))
+#define bufmatch(tb,fid) (tb->page == page && FidEq(bufferDir(tb), fid))
#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
* probably obsolete.
*/
if ((tb = phTable[pHash(fid)])) { /* ASSMT HERE */
- if (bufmatch(tb)) {
+ if (bufmatch(tb, fid)) {
ObtainWriteLock(&tb->lock);
tb->lockers++;
ReleaseWriteLock(&afs_bufferLock);
} else {
bufhead = &(phTable[pHash(fid)]);
while ((tb2 = tb->hashNext)) {
- if (bufmatch(tb2)) {
+ if (bufmatch(tb2, fid)) {
buf_Front(bufhead, tb, tb2);
ObtainWriteLock(&tb2->lock);
tb2->lockers++;
return 0;
}
if ((tb = tb2->hashNext)) { /* ASSIGNMENT HERE! */
- if (bufmatch(tb)) {
+ if (bufmatch(tb, fid)) {
buf_Front(bufhead, tb2, tb);
ObtainWriteLock(&tb->lock);
tb->lockers++;
ObtainWriteLock(&tb->lock);
tb->lockers++;
ReleaseWriteLock(&afs_bufferLock);
- if (ReallyRead(tb->fid, tb->page, tb->data)) {
+ if (ReallyRead(bufferDir(tb), tb->page, tb->data)) {
tb->lockers--;
- FidZap(tb->fid); /* disaster */
+ FidZap(bufferDir(tb)); /* disaster */
ReleaseWriteLock(&tb->lock);
return EIO;
}
lp = &tp->hashNext;
}
/* now figure the new hash bucket */
- i = pHash(ap->fid);
+ i = pHash(ap);
ap->hashIndex = i; /* remember where we are for deletion */
ap->hashNext = phTable[i]; /* add us to the list */
phTable[i] = ap; /* at the front, since it's LRU */
}
struct buffer *
-newslot(afs_int32 *afid, afs_int32 apage, struct buffer *lp)
+newslot(dir_file_t dir, afs_int32 apage, struct buffer *lp)
{
/* Find a usable buffer slot */
afs_int32 i;
* and the afs_bufferLock prevents other threads from zapping this
* buffer while we are writing it out */
if (lp->dirty) {
- if (ReallyWrite(lp->fid, lp->page, lp->data))
+ if (ReallyWrite(bufferDir(lp), lp->page, lp->data))
Die("writing bogus buffer");
lp->dirty = 0;
}
/* Now fill in the header. */
- FidZap(lp->fid);
- FidCpy(lp->fid, afid); /* set this */
+ FidZap(bufferDir(lp));
+ FidCpy(bufferDir(lp), dir); /* set this */
lp->page = apage;
lp->accesstime = ++timecounter;
}
void
-DZap(afs_int32 *fid)
+DZap(dir_file_t dir)
{
/* Destroy all buffers pertaining to a particular fid. */
struct buffer *tb;
ObtainReadLock(&afs_bufferLock);
- for (tb = phTable[pHash(fid)]; tb; tb = tb->hashNext)
- if (FidEq(tb->fid, fid)) {
+ for (tb = phTable[pHash(dir)]; tb; tb = tb->hashNext)
+ if (FidEq(bufferDir(tb), dir)) {
ObtainWriteLock(&tb->lock);
- FidZap(tb->fid);
+ FidZap(bufferDir(tb));
tb->dirty = 0;
ReleaseWriteLock(&tb->lock);
}
int code, rcode = 0;
ObtainReadLock(&afs_bufferLock);
for (tb = phTable[vHash(vid)]; tb; tb = tb->hashNext)
- if (FidVolEq(tb->fid, vid)) {
+ if (FidVolEq(bufferDir(tb), vid)) {
ObtainWriteLock(&tb->lock);
if (tb->dirty) {
- code = ReallyWrite(tb->fid, tb->page, tb->data);
+ code = ReallyWrite(bufferDir(tb), tb->page, tb->data);
if (code && !rcode)
rcode = code;
tb->dirty = 0;
}
- FidZap(tb->fid);
+ FidZap(bufferDir(tb));
ReleaseWriteLock(&tb->lock);
}
ReleaseReadLock(&afs_bufferLock);
}
int
-DFlushEntry(afs_int32 *fid)
+DFlushEntry(dir_file_t fid)
{
/* Flush pages modified by one entry. */
struct buffer *tb;
ObtainReadLock(&afs_bufferLock);
for (tb = phTable[pHash(fid)]; tb; tb = tb->hashNext)
- if (FidEq(tb->fid, fid) && tb->dirty) {
+ if (FidEq(bufferDir(tb), fid) && tb->dirty) {
ObtainWriteLock(&tb->lock);
if (tb->dirty) {
- code = ReallyWrite(tb->fid, tb->page, tb->data);
+ code = ReallyWrite(bufferDir(tb), tb->page, tb->data);
if (code) {
ReleaseWriteLock(&tb->lock);
ReleaseReadLock(&afs_bufferLock);
(*tbp)->lockers++;
ReleaseReadLock(&afs_bufferLock);
if ((*tbp)->dirty) {
- code = ReallyWrite((*tbp)->fid, (*tbp)->page, (*tbp)->data);
+ code = ReallyWrite(bufferDir(*tbp), (*tbp)->page, (*tbp)->data);
if (!code)
(*tbp)->dirty = 0; /* Clear the dirty flag */
if (code && !rcode) {
* since it probably doesn't exist.
*/
int
-DNew(afs_int32 *fid, int page, struct DirBuffer *entry)
+DNew(dir_file_t dir, int page, struct DirBuffer *entry)
{
struct buffer *tb;
memset(entry,0, sizeof(struct DirBuffer));
ObtainWriteLock(&afs_bufferLock);
- if ((tb = newslot(fid, page, 0)) == 0) {
+ if ((tb = newslot(dir, page, 0)) == 0) {
ReleaseWriteLock(&afs_bufferLock);
return EIO;
}
# include "h/string.h"
# endif
-/* generic renaming */
-# define NameBlobs afs_dir_NameBlobs
-# define GetBlob afs_dir_GetBlob
-# define Create afs_dir_Create
-# define Length afs_dir_Length
-# define Delete afs_dir_Delete
-# define MakeDir afs_dir_MakeDir
-# define Lookup afs_dir_Lookup
-# define LookupOffset afs_dir_LookupOffset
-# define EnumerateDir afs_dir_EnumerateDir
-# define IsEmpty afs_dir_IsEmpty
-# define InverseLookup afs_dir_InverseLookup
-# define ChangeFid afs_dir_ChangeFid
-
#else /* KERNEL */
# include <roken.h>
afs_int32 DErrno;
/* Local static prototypes */
-static int FindItem(void *dir, char *ename, struct DirBuffer *,
+static int FindBlobs(dir_file_t, int);
+static void AddPage(dir_file_t, int);
+static void FreeBlobs(dir_file_t, int, int);
+static int FindItem(dir_file_t, char *, struct DirBuffer *,
struct DirBuffer *);
/* Find out how many entries are required to store a name. */
int
-NameBlobs(char *name)
+afs_dir_NameBlobs(char *name)
{
int i;
i = strlen(name) + 1;
/* 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_dir_Create(dir_file_t dir, char *entry, void *voidfid)
{
afs_int32 *vfid = (afs_int32 *) voidfid;
int blobs, firstelt;
return EEXIST;
}
- blobs = NameBlobs(entry); /* number of entries required */
+ blobs = afs_dir_NameBlobs(entry); /* number of entries required */
firstelt = FindBlobs(dir, blobs);
if (firstelt < 0)
return EFBIG; /* directory is full */
/* First, we fill in the directory entry. */
- if (GetBlob(dir, firstelt, &entrybuf) != 0)
+ if (afs_dir_GetBlob(dir, firstelt, &entrybuf) != 0)
return EIO;
ep = (struct DirEntry *)entrybuf.data;
}
dhp = (struct DirHeader *)headerbuf.data;
- i = DirHash(entry);
+ i = afs_dir_DirHash(entry);
ep->next = dhp->hashTable[i];
dhp->hashTable[i] = htons(firstelt);
DRelease(&headerbuf, 1);
}
int
-Length(void *dir)
+afs_dir_Length(dir_file_t dir)
{
int i, ctr;
struct DirBuffer headerbuf;
return ctr * AFS_PAGESIZE;
}
+/* Delete an entry from a directory, including update of all free entry
+ * descriptors. */
int
-Delete(void *dir, char *entry)
+afs_dir_Delete(dir_file_t dir, char *entry)
{
- /* Delete an entry from a directory, including update of all free entry
- * descriptors. */
+
int nitems, index;
struct DirBuffer entrybuf, prevbuf;
struct DirEntry *firstitem;
*previtem = firstitem->next;
DRelease(&prevbuf, 1);
index = DVOffset(&entrybuf) / 32;
- nitems = NameBlobs(firstitem->name);
+ nitems = afs_dir_NameBlobs(firstitem->name);
DRelease(&entrybuf, 0);
FreeBlobs(dir, index, nitems);
return 0;
}
-int
-FindBlobs(void *dir, int nblobs)
+/* Find a bunch of contiguous entries; at least nblobs in a row. */
+static int
+FindBlobs(dir_file_t dir, int nblobs)
{
- /* Find a bunch of contiguous entries; at least nblobs in a row. */
int i, j, k;
int failed = 0;
struct DirBuffer headerbuf, pagebuf;
return -1;
}
-void
-AddPage(void *dir, int pageno)
+static void
+AddPage(dir_file_t dir, int pageno)
{ /* Add a page to a directory. */
int i;
struct PageHeader *pp;
/* Free a whole bunch of directory entries. */
-void
-FreeBlobs(void *dir, int firstblob, int nblobs)
+static void
+FreeBlobs(dir_file_t dir, int firstblob, int nblobs)
{
int i;
int page;
* allocation map and 8 to the hash table.
*/
int
-MakeDir(void *dir, afs_int32 * me, afs_int32 * parent)
+afs_dir_MakeDir(dir_file_t dir, afs_int32 * me, afs_int32 * parent)
{
int i;
struct DirBuffer buffer;
for (i = 0; i < NHASHENT; i++)
dhp->hashTable[i] = 0;
DRelease(&buffer, 1);
- Create(dir, ".", me);
- Create(dir, "..", parent); /* Virtue is its own .. */
+ afs_dir_Create(dir, ".", me);
+ afs_dir_Create(dir, "..", parent); /* Virtue is its own .. */
return 0;
}
/* Look up a file name in directory. */
int
-Lookup(void *dir, char *entry, void *voidfid)
+afs_dir_Lookup(dir_file_t dir, char *entry, void *voidfid)
{
afs_int32 *fid = (afs_int32 *) voidfid;
struct DirBuffer firstbuf, prevbuf;
/* Look up a file name in directory. */
int
-LookupOffset(void *dir, char *entry, void *voidfid, long *offsetp)
+afs_dir_LookupOffset(dir_file_t dir, char *entry, void *voidfid,
+ long *offsetp)
{
afs_int32 *fid = (afs_int32 *) voidfid;
struct DirBuffer firstbuf, prevbuf;
*/
int
-EnumerateDir(void *dir, int (*hookproc) (void *dir, char *name,
- afs_int32 vnode, afs_int32 unique),
- void *hook)
+afs_dir_EnumerateDir(dir_file_t dir, int (*proc) (void *, char *name,
+ afs_int32 vnode,
+ afs_int32 unique),
+ void *hook)
{
int i;
int num;
while (num != 0) {
/* Walk down the hash table list. */
DErrno = 0;
- if (GetBlob(dir, num, &entrybuf) != 0) {
+ if (afs_dir_GetBlob(dir, num, &entrybuf) != 0) {
if (DErrno) {
/* we failed, return why */
DRelease(&headerbuf, 0);
ep = (struct DirEntry *)entrybuf.data;
num = ntohs(ep->next);
- code = (*hookproc) (hook, ep->name, ntohl(ep->fid.vnode),
- ntohl(ep->fid.vunique));
+ code = (*proc) (hook, ep->name, ntohl(ep->fid.vnode),
+ ntohl(ep->fid.vunique));
DRelease(&entrybuf, 0);
if (code)
break;
}
int
-IsEmpty(void *dir)
+afs_dir_IsEmpty(dir_file_t dir)
{
/* Enumerate the contents of a directory. */
int i;
num = ntohs(dhp->hashTable[i]);
while (num != 0) {
/* Walk down the hash table list. */
- if (GetBlob(dir, num, &entrybuf) != 0);
+ if (afs_dir_GetBlob(dir, num, &entrybuf) != 0);
break;
ep = (struct DirEntry *)entrybuf.data;
if (strcmp(ep->name, "..") && strcmp(ep->name, ".")) {
}
int
-GetBlob(void *dir, afs_int32 blobno, struct DirBuffer *buffer)
+afs_dir_GetBlob(dir_file_t dir, afs_int32 blobno, struct DirBuffer *buffer)
{
int code;
}
int
-DirHash(char *string)
+afs_dir_DirHash(char *string)
{
/* Hash a string to a number between 0 and NHASHENT. */
unsigned char tc;
* returned instead. */
static int
-FindItem(void *dir, char *ename, struct DirBuffer *prevbuf,
+FindItem(dir_file_t dir, char *ename, struct DirBuffer *prevbuf,
struct DirBuffer *itembuf )
{
int i, code;
return code;
dhp = (struct DirHeader *)prev.data;
- i = DirHash(ename);
+ i = afs_dir_DirHash(ename);
if (dhp->hashTable[i] == 0) {
/* no such entry */
DRelease(&prev, 0);
return ENOENT;
}
- code = GetBlob(dir, (u_short) ntohs(dhp->hashTable[i]), &curr);
+ code = afs_dir_GetBlob(dir, (u_short) ntohs(dhp->hashTable[i]),
+ &curr);
if (code) {
DRelease(&prev, 0);
return code;
prev = curr;
prev.data = &(tp->next);
- code = GetBlob(dir, (u_short) ntohs(tp->next), &curr);
+ code = afs_dir_GetBlob(dir, (u_short) ntohs(tp->next), &curr);
if (code) {
DRelease(&prev, 0);
return code;
for (i=0; i<NHASHENT; i++) {
if (dhp->hashTable[i] != 0) {
- code = GetBlob(dir, (u_short)ntohs(dhp->hashTable[i]),
- &curr);
+ code = afs_dir_GetBlob(dir, (u_short)ntohs(dhp->hashTable[i]),
+ &curr);
if (code) {
DRelease(&header, 0);
return code;
if (next == 0)
break;
- code = GetBlob(dir, (u_short)ntohs(next), &curr);
+ code = afs_dir_GetBlob(dir, (u_short)ntohs(next), &curr);
if (code) {
DRelease(&header, 0);
return code;
}
int
-InverseLookup (void *dir, afs_uint32 vnode, afs_uint32 unique, char *name,
- afs_uint32 length)
+afs_dir_InverseLookup(void *dir, afs_uint32 vnode, afs_uint32 unique,
+ char *name, afs_uint32 length)
{
/* Look for the name pointing to given vnode and unique in a directory */
struct DirBuffer entrybuf;
* It can be omitted if you don't need a safety check...
* \param new_fid The new find in MKFid format (host order).
*/
-int ChangeFid(void *dir,
- char *entry,
- afs_uint32 *old_fid,
- afs_uint32 *new_fid)
+int
+afs_dir_ChangeFid(dir_file_t dir, char *entry, afs_uint32 *old_fid,
+ afs_uint32 *new_fid)
{
struct DirBuffer prevbuf, entrybuf;
struct DirEntry *firstitem;
struct DirEntry entry[1];
};
-/*
- * Note that this declaration is seen in both the kernel code and the
- * user space code. One implementation is in afs/afs_buffer.c; the
- * other is in dir/buffer.c.
- */
-extern int DVOffset(struct DirBuffer *);
+/* Prototypes */
+#ifdef KERNEL
+struct dcache;
+typedef struct dcache * dir_file_t;
+#else
+struct DirHandle;
+typedef struct DirHandle * dir_file_t;
+#endif
+extern int afs_dir_NameBlobs(char *name);
+extern int afs_dir_Create(dir_file_t dir, char *entry, void *vfid);
+extern int afs_dir_Length(dir_file_t dir);
+extern int afs_dir_Delete(dir_file_t dir, char *entry);
+extern int afs_dir_MakeDir(dir_file_t dir, afs_int32 * me,
+ afs_int32 * parent);
+extern int afs_dir_Lookup(dir_file_t dir, char *entry, void *fid);
+extern int afs_dir_LookupOffset(dir_file_t dir, char *entry, void *fid,
+ long *offsetp);
+extern int afs_dir_EnumerateDir(dir_file_t dir,
+ int (*hookproc) (void *, char *name,
+ afs_int32 vnode,
+ afs_int32 unique),
+ void *hook);
+extern int afs_dir_IsEmpty(dir_file_t dir);
+extern int afs_dir_GetBlob(dir_file_t dir, afs_int32 blobno,
+ struct DirBuffer *);
+extern int afs_dir_DirHash(char *string);
-/* This is private to buffer.c */
-struct buffer;
+extern int afs_dir_InverseLookup (void *dir, afs_uint32 vnode,
+ afs_uint32 unique, char *name,
+ afs_uint32 length);
-/* Prototypes */
-extern int NameBlobs(char *name);
-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, 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 int GetBlob(void *dir, afs_int32 blobno, struct DirBuffer *);
-extern int DirHash(char *string);
+extern int afs_dir_ChangeFid(dir_file_t dir, char *entry,
+ afs_uint32 *old_fid, afs_uint32 *new_fid);
-extern int DStat(int *abuffers, int *acalls, int *aios);
-extern void DRelease(struct DirBuffer *loc, int flag);
-extern int DFlushVolume(afs_int32 vid);
-extern int DFlushEntry(afs_int32 *fid);
-extern int InverseLookup (void *dir, afs_uint32 vnode, afs_uint32 unique,
- char *name, afs_uint32 length);
+/* buffer operations */
-/* The kernel uses different versions of these, and prototypes them
- in afs_prototypes.h */
-#ifndef KERNEL
-extern int DInit(int abuffers);
-extern int DRead(afs_int32 *fid, int page, struct DirBuffer *);
+extern void DInit(int abuffers);
+extern int DRead(dir_file_t fid, int page, struct DirBuffer *);
extern int DFlush(void);
-extern int DNew(afs_int32 *fid, int page, struct DirBuffer *);
-extern void DZap(afs_int32 *fid);
+extern int DFlushVolume(afs_int32);
+extern int DNew(dir_file_t fid, int page, struct DirBuffer *);
+extern void DZap(dir_file_t fid);
+extern void DRelease(struct DirBuffer *loc, int flag);
+extern int DStat(int *abuffers, int *acalls, int *aios);
+extern int DFlushVolume(afs_int32 vid);
+extern int DFlushEntry(dir_file_t fid);
+extern int DVOffset(struct DirBuffer *);
/* salvage.c */
+#ifndef KERNEL
extern int DirOK(void *);
extern int DirSalvage(void *, void *, afs_int32, afs_int32,
afs_int32, afs_int32);
#endif
-#ifdef KERNEL
-extern int afs_dir_NameBlobs(char *name);
-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 int afs_dir_ChangeFid(void *dir, char *entry, afs_uint32 *old_fid,
- afs_uint32 *new_fid);
-extern int afs_dir_GetBlob(void *dir, afs_int32 blobno, struct DirBuffer *);
-#endif
-
#endif /* !defined(__AFS_DIR_H) */
/* Read the directory entry */
DErrno = 0;
- code = GetBlob(file, entry, &entrybuf);
+ code = afs_dir_GetBlob(file, entry, &entrybuf);
if (code) {
if (DErrno != 0) {
/* something went wrong reading the page, but it wasn't
/* The name used up k directory entries, set the bit in our in-memory
* freebitmap for each entry used by the name.
*/
- k = NameBlobs(ep->name);
+ k = afs_dir_NameBlobs(ep->name);
for (j = 0; j < k; j++) {
eaMap[(entry + j) >> 3] |= (1 << ((entry + j) & 7));
}
/* Hash the name and make sure it is in the correct name hash */
- if ((j = DirHash(ep->name)) != i) {
+ if ((j = afs_dir_DirHash(ep->name)) != i) {
printf("Dir entry %"AFS_PTR_FMT
" should be in hash bucket %d but IS in %d.\n",
ep, j, i);
dotdot[1] = pvn;
dotdot[2] = pvu;
- MakeDir(toFile, dot, dotdot); /* Returns no error code. */
+ afs_dir_MakeDir(toFile, dot, dotdot); /* Returns no error code. */
/* Find out how many pages are valid, using stupid heuristic since DRead
* never returns null.
}
DErrno = 0;
- code = GetBlob(fromFile, entry, &entrybuf);
+ code = afs_dir_GetBlob(fromFile, entry, &entrybuf);
if (code) {
if (DErrno) {
printf
if ((strcmp(tp, ".") != 0) && (strcmp(tp, "..") != 0)) {
lfid[1] = ntohl(ep->fid.vnode);
lfid[2] = ntohl(ep->fid.vunique);
- code = Create(toFile, tname, lfid);
+ code = afs_dir_Create(toFile, tname, lfid);
if (code) {
printf
("Create of %s returned code %d, skipping to next hash chain.\n",
long fidCounter = 0;
-typedef struct dirhandle {
+typedef struct DirHandle {
int fd;
int uniq;
} dirhandle;
int code;
OpenDir(dname, &dir);
- code = Lookup(&dir, ename, fid);
+ code = afs_dir_Lookup(&dir, ename, fid);
if (code)
printf("lookup code %d\n", code);
else {
fid[1] = fidCounter++;
fid[2] = 3;
OpenDir(dname, &dir);
- code = Create(&dir, ename, fid);
+ code = afs_dir_Create(&dir, ename, fid);
if (code)
printf("create code %d\n", code);
DFlush();
{
dirhandle dir;
OpenDir(name, &dir);
- EnumerateDir(&dir, ListEntry, 0);
+ afs_dir_EnumerateDir(&dir, ListEntry, 0);
}
static void
afs_int32 myFid[3], parentFid[3];
OpenDir(iname, &in);
- if (Lookup(&in, ".", myFid) || Lookup(&in, "..", parentFid)) {
+ if (afs_dir_Lookup(&in, ".", myFid) ||
+ afs_dir_Lookup(&in, "..", parentFid)) {
printf("Lookup of \".\" and/or \"..\" failed: ");
printf("%d %d %d %d\n", myFid[1], myFid[2], parentFid[1],
parentFid[2]);
int code;
OpenDir(dname, &dir);
- code = Delete(&dir, ename);
+ code = afs_dir_Delete(&dir, ename);
if (code)
printf("delete code is %d\n", code);
DFlush();
CreateDir(dname, &dir);
memset(fid, 0, sizeof(fid));
- MakeDir(&dir, fid, fid);
+ afs_dir_MakeDir(&dir, fid, fid);
for (i = 0; i < count; i++) {
sprintf(tbuffer, "%s%d", ename, i);
fid[1] = fidCounter++;
fid[2] = count;
- code = Create(&dir, tbuffer, &fid);
+ code = afs_dir_Create(&dir, tbuffer, &fid);
if (i % 100 == 0) {
printf("#");
fflush(stdout);
/* check that the file is in the directory */
SetDirHandle(dir, parentptr);
- if (Lookup(dir, Name, fileFid))
+ if (afs_dir_Lookup(dir, Name, fileFid))
return (ENOENT);
fileFid->Volume = V_id(volptr);
if (ChkForDir == MustBeDIR) {
SetDirHandle(&childdir, *targetptr);
- if (IsEmpty(&childdir) != 0)
+ if (afs_dir_IsEmpty(&childdir) != 0)
return (EEXIST);
- DZap((afs_int32 *) &childdir);
+ DZap(&childdir);
FidZap(&childdir);
(*targetptr)->delete = 1;
} else if ((--(*targetptr)->disk.linkCount) == 0)
(*targetptr)->changed_newTime = 1; /* Status change of deleted file/dir */
- code = Delete(dir, (char *)Name);
+ code = afs_dir_Delete(dir, Name);
if (code) {
ViceLog(0,
("Error %d deleting %s\n", code,
#endif /* FS_STATS_DETAILED */
parentptr->disk.dataVersion++;
- newlength = (afs_fsize_t) Length(dir);
+ newlength = (afs_fsize_t) afs_dir_Length(dir);
/*
* This is a called on both dir removals (i.e. remove, removedir, rename) but also in dir additions
* (create, symlink, link, makedir) so we need to check if we have enough space
/* add the name to the directory */
SetDirHandle(dir, parentptr);
- if ((errorCode = Create(dir, (char *)Name, OutFid))) {
+ if ((errorCode = afs_dir_Create(dir, Name, OutFid))) {
(*targetptr)->delete = 1;
VAdjustDiskUsage(&temp, volptr, -BlocksPreallocatedForVnode, 0);
IH_REALLYCLOSE((*targetptr)->handle);
SetDirHandle(&newdir, newvptr);
/* Lookup the file to delete its vnode */
- if (Lookup(&olddir, OldName, &fileFid)) {
+ if (afs_dir_Lookup(&olddir, OldName, &fileFid)) {
errorCode = ENOENT;
goto Bad_Rename;
}
}
/* Lookup the new file */
- if (!(Lookup(&newdir, NewName, &newFileFid))) {
+ if (!(afs_dir_Lookup(&newdir, NewName, &newFileFid))) {
if (readonlyServer) {
errorCode = VREADONLY;
goto Bad_Rename;
errorCode = EISDIR;
goto Bad_Rename;
}
- if ((IsEmpty(&newfiledir))) {
+ if ((afs_dir_IsEmpty(&newfiledir))) {
errorCode = EEXIST;
goto Bad_Rename;
}
} else {
struct AFSFid unused;
- code = Lookup(&filedir, "..", &unused);
+ code = afs_dir_Lookup(&filedir, "..", &unused);
if (code == ENOENT) {
/* only update .. if it doesn't already exist */
updatefile = 1;
doDelete = 0;
if (newfileptr) {
/* Delete NewName from its directory */
- code = Delete(&newdir, NewName);
+ code = afs_dir_Delete(&newdir, NewName);
osi_Assert(code == 0);
/* Drop the link count */
* highly unlikely that it would work since it would involve issuing
* another create.
*/
- if ((errorCode = Create(&newdir, (char *)NewName, &fileFid)))
+ if ((errorCode = afs_dir_Create(&newdir, NewName, &fileFid)))
goto Bad_Rename;
/* Delete the old name */
- osi_Assert(Delete(&olddir, (char *)OldName) == 0);
+ osi_Assert(afs_dir_Delete(&olddir, OldName) == 0);
/* if the directory length changes, reflect it in the statistics */
#if FS_STATS_DETAILED
fileptr->changed_newTime = 1; /* status change of moved file */
/* fix .. to point to the correct place */
- Delete(&filedir, ".."); /* No assert--some directories may be bad */
- osi_Assert(Create(&filedir, "..", NewDirFid) == 0);
+ afs_dir_Delete(&filedir, ".."); /* No assert--some directories may be bad */
+ osi_Assert(afs_dir_Create(&filedir, "..", NewDirFid) == 0);
fileptr->disk.dataVersion++;
/* if the parent directories are different the link counts have to be */
/* add the name to the directory */
SetDirHandle(&dir, parentptr);
- if ((errorCode = Create(&dir, (char *)Name, ExistingFid)))
+ if ((errorCode = afs_dir_Create(&dir, Name, ExistingFid)))
goto Bad_Link;
DFlush();
/* Actually create the New directory in the directory package */
SetDirHandle(&dir, targetptr);
- osi_Assert(!(MakeDir(&dir, (afs_int32 *)OutFid, (afs_int32 *)DirFid)));
+ osi_Assert(!(afs_dir_MakeDir(&dir, (afs_int32 *)OutFid, (afs_int32 *)DirFid)));
DFlush();
- VN_SET_LEN(targetptr, (afs_fsize_t) Length(&dir));
+ VN_SET_LEN(targetptr, (afs_fsize_t) afs_dir_Length(&dir));
/* set up return status */
GetStatus(targetptr, OutFidStatus, rights, anyrights, parentptr);
nice(-5); /* TODO: */
#endif
#endif
- osi_Assert(DInit(buffs) == 0);
+ DInit(buffs);
#ifdef AFS_DEMAND_ATTACH_FS
FS_STATE_INIT;
#endif
}
vnode.cloned = 0;
VNDISK_SET_INO(&vnode, newinode);
- length = Length(&newdir);
+ length = afs_dir_Length(&newdir);
VNDISK_SET_LEN(&vnode, length);
lcode =
IH_IWRITE(salvinfo->vnodeInfo[vLarge].handle,
}
if (!Testing) {
CopyOnWrite(salvinfo, dir);
- osi_Assert(Delete(&dir->dirHandle, name) == 0);
+ osi_Assert(afs_dir_Delete(&dir->dirHandle, name) == 0);
}
return 0;
}
if (!unique) {
if (!Testing) {
CopyOnWrite(salvinfo, dir);
- osi_Assert(Delete(&dir->dirHandle, name) == 0);
+ osi_Assert(afs_dir_Delete(&dir->dirHandle, name) == 0);
}
return 0;
}
fid.Vnode = vnodeNumber;
fid.Unique = vnodeEssence->unique;
CopyOnWrite(salvinfo, dir);
- osi_Assert(Delete(&dir->dirHandle, name) == 0);
+ osi_Assert(afs_dir_Delete(&dir->dirHandle, name) == 0);
if (!todelete)
- osi_Assert(Create(&dir->dirHandle, name, &fid) == 0);
+ osi_Assert(afs_dir_Create(&dir->dirHandle, name, &fid) == 0);
}
if (todelete)
return 0; /* no need to continue */
Log("directory vnode %u.%u: bad '.' entry (was %u.%u); fixed\n", dir->vnodeNumber, dir->unique, vnodeNumber, unique);
if (!Testing) {
CopyOnWrite(salvinfo, dir);
- osi_Assert(Delete(&dir->dirHandle, ".") == 0);
+ osi_Assert(afs_dir_Delete(&dir->dirHandle, ".") == 0);
fid.Vnode = dir->vnodeNumber;
fid.Unique = dir->unique;
- osi_Assert(Create(&dir->dirHandle, ".", &fid) == 0);
+ osi_Assert(afs_dir_Create(&dir->dirHandle, ".", &fid) == 0);
}
vnodeNumber = fid.Vnode; /* Get the new Essence */
Log("directory vnode %u.%u: bad '..' entry (was %u.%u); fixed\n", dir->vnodeNumber, dir->unique, vnodeNumber, unique);
if (!Testing) {
CopyOnWrite(salvinfo, dir);
- osi_Assert(Delete(&dir->dirHandle, "..") == 0);
- osi_Assert(Create(&dir->dirHandle, "..", &pa) == 0);
+ osi_Assert(afs_dir_Delete(&dir->dirHandle, "..") == 0);
+ osi_Assert(afs_dir_Create(&dir->dirHandle, "..", &pa) == 0);
}
vnodeNumber = pa.Vnode; /* Get the new Essence */
}
if (!Testing) {
CopyOnWrite(salvinfo, dir);
- osi_Assert(Delete(&dir->dirHandle, name) == 0);
+ osi_Assert(afs_dir_Delete(&dir->dirHandle, name) == 0);
}
vnodeEssence->claimed = 0; /* Not claimed: Orphaned */
vnodeEssence->todelete = 1; /* Will later delete vnode and decr inode */
}
if (!Testing) {
CopyOnWrite(salvinfo, dir);
- osi_Assert(Delete(&dir->dirHandle, name) == 0);
+ osi_Assert(afs_dir_Delete(&dir->dirHandle, name) == 0);
}
return 0;
}
judge_params.salvinfo = salvinfo;
judge_params.dir = &dir;
- osi_Assert(EnumerateDir(&dirHandle, JudgeEntry, &judge_params) == 0);
+ osi_Assert(afs_dir_EnumerateDir(&dirHandle, JudgeEntry,
+ &judge_params) == 0);
}
/* Delete the old directory if it was copied in order to salvage.
did.Volume = vid;
did.Vnode = 1;
did.Unique = 1;
- if (MakeDir(&rootdir->dirHandle, (afs_int32*)&did, (afs_int32*)&did)) {
+ if (afs_dir_MakeDir(&rootdir->dirHandle, (afs_int32*)&did, (afs_int32*)&did)) {
Log("CreateRootDir: MakeDir failed\n");
goto error;
}
- if (Create(&rootdir->dirHandle, "README.ROOTDIR", &readmeid)) {
+ if (afs_dir_Create(&rootdir->dirHandle, "README.ROOTDIR", &readmeid)) {
Log("CreateRootDir: Create failed\n");
goto error;
}
DFlush();
- length = Length(&rootdir->dirHandle);
- DZap((void *)&rootdir->dirHandle);
+ length = afs_dir_Length(&rootdir->dirHandle);
+ DZap(&rootdir->dirHandle);
/* create the new root dir vnode */
rootvnode = calloc(1, SIZEOF_LARGEDISKVNODE);
&salvinfo->VolumeChanged);
pa.Vnode = LFVnode;
pa.Unique = LFUnique;
- osi_Assert(Delete(&dh, "..") == 0);
- osi_Assert(Create(&dh, "..", &pa) == 0);
+ osi_Assert(afs_dir_Delete(&dh, "..") == 0);
+ osi_Assert(afs_dir_Create(&dh, "..", &pa) == 0);
/* The original parent's link count was decremented above.
* Here we increment the new parent's link count.
ThisVnode, ThisUnique);
CopyOnWrite(salvinfo, &rootdir);
- code = Create(&rootdir.dirHandle, npath, &pa);
+ code = afs_dir_Create(&rootdir.dirHandle, npath, &pa);
if (!code)
break;
ino = VNDISK_GET_INO(vd);
SetSalvageDirHandle(&dir, V_id(vol), V_device(vol), ino);
- code = InverseLookup(&dir, vN, un, name, length);
+ code = afs_dir_InverseLookup(&dir, vN, un, name, length);
FidZap(&dir);
return code;
}
ino = VNDISK_GET_INO(parent);
SetSalvageDirHandle(&dir, V_id(vol), V_device(vol), ino);
- code = Delete(&dir, name);
+ code = afs_dir_Delete(&dir, name);
if (code) {
Log("splitvolume: couldn't delete directory entry for %s in %u.%u.%u, code = %d\n",
name, V_id(vol), vN, parent->uniquifier, code);
return code;
}
- code = Create(&dir, name, &fid);
+ code = afs_dir_Create(&dir, name, &fid);
FidZap(&dir);
class = vLarge;
did.Vnode = (VnodeId) 1;
did.Unique = 1;
- osi_Assert(!(MakeDir(&dir, (afs_int32 *)&did, (afs_int32 *)&did)));
+ osi_Assert(!(afs_dir_MakeDir(&dir, (afs_int32 *)&did, (afs_int32 *)&did)));
DFlush(); /* flush all modified dir buffers out */
- DZap((afs_int32 *)&dir); /* Remove all buffers for this dir */
- length = Length(&dir); /* Remember size of this directory */
+ DZap(&dir); /* Remove all buffers for this dir */
+ length = afs_dir_Length(&dir); /* Remember size of this directory */
FidZap(&dir); /* Done with the dir handle obtained via SetSalvageDirHandle() */