OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/dir/dir.h
00001 /*
00002  * Copyright 2000, International Business Machines Corporation and others.
00003  * All Rights Reserved.
00004  *
00005  * This software has been released under the terms of the IBM Public
00006  * License.  For details, see the LICENSE file in the top-level source
00007  * directory or online at http://www.openafs.org/dl/license10.html
00008  */
00009 
00010 #if     !defined(__AFS_DIR_H)
00011 
00012 #define __AFS_DIR_H
00013 
00014 #define AFS_PAGESIZE 2048       /* bytes per page */
00015 #define NHASHENT 128            /* entries in the hash tbl */
00016 #define MAXPAGES 128            /* max pages in a dir */
00017 #define BIGMAXPAGES 1023        /* new big max pages */
00018 #define EPP 64                  /* dir entries per page */
00019 #define LEPP 6                  /* log above */
00020 /* When this next field changs, it is crucial to modify MakeDir, since the
00021  * latter is responsible for marking these entries as allocated.  Also
00022  * change the salvager. */
00023 #define DHE 12                  /* entries in a dir header above a pages header alone. */
00024 
00025 #define FFIRST 1
00026 #define FNEXT 2
00027 
00028 struct MKFid {                  /* A file identifier. */
00029     afs_int32 vnode;            /* file's vnode slot */
00030     afs_int32 vunique;          /* the slot incarnation number */
00031 };
00032 
00033 struct PageHeader {
00034     /* A page header entry. */
00035     unsigned short pgcount;     /* number of pages, or 0 if old-style */
00036     unsigned short tag;         /* 1234 in network byte order */
00037     char freecount;             /* unused, info in dirHeader structure */
00038     char freebitmap[EPP / 8];
00039     char padding[32 - (5 + EPP / 8)];
00040 };
00041 
00042 struct DirBuffer {
00043     void *buffer;
00044     void *data;
00045 };
00046 
00047 struct DirHeader {
00048     /* A directory header object. */
00049     struct PageHeader header;
00050     char alloMap[MAXPAGES];     /* one byte per 2K page */
00051     unsigned short hashTable[NHASHENT];
00052 };
00053 
00054 struct DirEntry {
00055     /* A directory entry */
00056     char flag;
00057     char length;                /* currently unused */
00058     unsigned short next;
00059     struct MKFid fid;
00060     char name[16];
00061 };
00062 
00063 struct DirXEntry {
00064     /* A directory extension entry. */
00065     char name[32];
00066 };
00067 
00068 struct DirPage0 {
00069     /* A page in a directory. */
00070     struct DirHeader header;
00071     struct DirEntry entry[1];
00072 };
00073 
00074 struct DirPage1 {
00075     /* A page in a directory. */
00076     struct PageHeader header;
00077     struct DirEntry entry[1];
00078 };
00079 
00080 /* Prototypes */
00081 #ifdef KERNEL
00082 struct dcache;
00083 typedef struct dcache * dir_file_t;
00084 #else
00085 struct DirHandle;
00086 typedef struct DirHandle * dir_file_t;
00087 extern void Die(const char *msg) AFS_NORETURN;
00088 #endif
00089 
00090 extern int afs_dir_NameBlobs(char *name);
00091 extern int afs_dir_Create(dir_file_t dir, char *entry, void *vfid);
00092 extern int afs_dir_Length(dir_file_t dir);
00093 extern int afs_dir_Delete(dir_file_t dir, char *entry);
00094 extern int afs_dir_MakeDir(dir_file_t dir, afs_int32 * me,
00095                            afs_int32 * parent);
00096 extern int afs_dir_Lookup(dir_file_t dir, char *entry, void *fid);
00097 extern int afs_dir_LookupOffset(dir_file_t dir, char *entry, void *fid,
00098                                 long *offsetp);
00099 extern int afs_dir_EnumerateDir(dir_file_t dir,
00100                                 int (*hookproc) (void *, char *name,
00101                                                  afs_int32 vnode, 
00102                                                  afs_int32 unique),
00103                                 void *hook);
00104 extern int afs_dir_IsEmpty(dir_file_t dir);
00105 extern int afs_dir_GetBlob(dir_file_t dir, afs_int32 blobno,
00106                            struct DirBuffer *);
00107 extern int afs_dir_GetVerifiedBlob(dir_file_t dir, afs_int32 blobno,
00108                                    struct DirBuffer *);
00109 extern int afs_dir_DirHash(char *string);
00110 
00111 extern int afs_dir_InverseLookup (void *dir, afs_uint32 vnode,
00112                                   afs_uint32 unique, char *name,
00113                                   afs_uint32 length);
00114 
00115 extern int afs_dir_ChangeFid(dir_file_t dir, char *entry,
00116                              afs_uint32 *old_fid, afs_uint32 *new_fid);
00117 
00118 /* buffer operations */
00119 
00120 extern void DInit(int abuffers);
00121 extern int DRead(dir_file_t fid, int page, struct DirBuffer *);
00122 extern int DFlush(void);
00123 extern int DFlushVolume(afs_int32);
00124 extern int DNew(dir_file_t fid, int page, struct DirBuffer *);
00125 extern void DZap(dir_file_t fid);
00126 extern void DRelease(struct DirBuffer *loc, int flag);
00127 extern int DStat(int *abuffers, int *acalls, int *aios);
00128 extern int DFlushVolume(afs_int32 vid);
00129 extern int DFlushEntry(dir_file_t fid);
00130 extern int DVOffset(struct DirBuffer *);
00131 
00132 /* salvage.c */
00133 
00134 #ifndef KERNEL
00135 extern int DirOK(void *);
00136 extern int DirSalvage(void *, void *, afs_int32, afs_int32,
00137                       afs_int32, afs_int32);
00138 
00139 #endif
00140 
00141 #endif /*       !defined(__AFS_DIR_H) */
 All Data Structures Files Functions Variables