Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

VDirChangeable.H

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 //
00020 // VDirChangeable.H
00021 //
00022 // Derived class for in-memory representation of Vesta directories
00023 // that can change, including appendable and mutable.  The
00024 // representation is also adequate for immutable directories, though
00025 // it wastes a little space in that case.
00026 //
00027 // The purpose of this class is to provide methods that operate on the
00028 // special packed representation.  Most of the directories that exist
00029 // at any moment will not have objects of this class corresponding to
00030 // them; they will exist only in the packed representation.
00031 //
00032 
00033 #ifndef _VDIRCH
00034 #define _VDIRCH 1
00035 
00036 #include "VestaSource.H"
00037 #include "VDirVolatileRoot.H"
00038 #include "VMemPool.H"
00039 #include "AccessControl.H"
00040 #include "ShortIdRefCount.H"
00041 #include <assert.h>
00042 
00043 // Below we describe the packed representation of a VDirChangeable
00044 // using a pseudo-C++ notation.  Differences from real C++ are:
00045 // (1) The keyword "packed" indicates the struct contains no compiler-
00046 // inserted padding; its fields may be arbitrarily aligned.  (2)
00047 // "@" in place of "*" indicates a 32-bit pointer.  On the Alpha this
00048 // is an offset within a 2^32 byte range of the address space within
00049 // which directories are constrained to lie.  (3) An array size can be
00050 // a field of the struct or empty, rather than a constant.  (4) Bit
00051 // fields are always packed into bytes in little-endian order.
00052 //
00053 // packed struct VDirChangeableRep {
00054 //     Bit8 hasName: 1;        // bool, used by GC
00055 //     Bit8 visited: 1;        // bool, used by GC
00056 //     Bit8 isMoreOrBase: 2;
00057 //     Bit8 typecode: 4;       // If immutable,  VMemPool::vDirImmutable;
00058 //                             // if appendable, VMemPool::vDirAppendable;
00059 //                             // else           VMemPool::vDirChangeable.
00060 //     union {
00061 //         Bit32 null = 0;              // if isMoreOrBase = isNeither
00062 //         VDirChangeableRep@ more;     // if isMoreOrBase = isMore
00063 //         VDirChangeableRep@ base;     // if isMoreOrBase = isBase 
00064 //     } moreOrBase;
00065 //     Bit32 timestamp;                 // modified time (32-bit time_t)
00066 //     union {
00067 //         Bit32 pseudoInode;           // mutable or volatile directory
00068 //         ShortId sid;                 // immutable directory
00069 //         Bit32 null = 0;              // others
00070 //     };
00071 //     union {
00072 //         VDirChangeableRep@ snapshot; // mutable directory (padded)
00073 //         FP::Tag fptag;               // immutable directory
00074 //         FP::Tag unusedTag;           // others
00075 //     };
00076 //     packed struct {
00077 //         Bit8 master: 1;     // bool
00078 //         Bit8 inUse: 1;      // bool, used by GC
00079 //         Bit8 hasEFPTag: 1;  // efptag field present
00080 //         Bit8 sameAsBase: 1; // bool: map the LongId of this name in
00081 //                             //  the base to this entry.
00082 //         Bit8 type: 4;       // VestaSource::typeTag
00083 //         union {
00084 //             Bit32 null = 0;            // ghost, stub
00085 //             ShortId sid;               // immutableFile, mutableFile
00086 //             VForward@ fwd;             // deleted
00087 //             VDirChangeableRep@ cdir;   // directory
00088 //             Bit32 gapsize;             // gap (=number of unused indices)
00089 //         } value;
00090 //         AttributesRep@ attrib;
00091 //         packed union {
00092 //             FP::Tag efptag; // if hasEFPTag == 1
00093 //             /*empty*/;      // if hasEFPTag == 0 (occupies no space)
00094 //         };
00095 //         Bit8 arcLen;
00096 //         char arc[arcLen];   // NUL-padded but not terminated
00097 //     } entries[];
00098 //     Bit8 endMark;  // Must be 0xff; identifies end of entries.
00099 //                    //  This bit pattern can't begin an entry because
00100 //                    //  0xf is not a valid type tag.
00101 //     Bit32 freeLen;
00102 //     Bit8 free[freeLen];  // free space for expansion
00103 // };
00104 
00105 // Some numbers derived from above
00106 #define VDIRCH_FLAGS 0
00107 #define VDIRCH_MOREORBASE 1
00108 #define VDIRCH_TIMESTAMP 5
00109 #define VDIRCH_ID 9
00110 #define VDIRCH_FPTAG 13
00111 #define VDIRCH_ENTRIES 29
00112 #define VDIRCH_ENDMARK 29 // if no entries
00113 #define VDIRCH_FREELEN 30 // if no entries
00114 #define VDIRCH_MINSIZE 34 // if no entries
00115 #define VDIRCH_EFLAGS 0
00116 #define VDIRCH_EVALUE 1
00117 #define VDIRCH_EATTRIB 5
00118 // if efptag omitted:
00119 #define VDIRCH_E1ARCLEN 9
00120 #define VDIRCH_E1ARC 10
00121 #define VDIRCH_E1MINSIZE 10 // if arcLen=0
00122 // if efptag present:
00123 #define VDIRCH_EFPTAG 9
00124 #define VDIRCH_E2ARCLEN 25
00125 #define VDIRCH_E2ARC 26
00126 #define VDIRCH_E2MINSIZE 26 // if arcLen=0
00127 
00128 class VDirChangeable : public VestaSource {
00129   public:
00130     // Our versions of virtual methods from base class.
00131     void resync(AccessControl::Identity who =NULL) throw ();
00132     ShortId shortId() throw ();
00133     VestaSource::errorCode
00134       setTimestamp(time_t ts, AccessControl::Identity who =NULL) throw ();
00135     VestaSource::errorCode lookup(Arc arc, VestaSource*& result,
00136                  AccessControl::Identity who =NULL,
00137                  unsigned int indexOffset =0) throw();
00138     VestaSource::errorCode 
00139       reallyDelete(Arc arc, AccessControl::Identity who =NULL,
00140                  bool existCheck =true, time_t timestamp =0) throw();
00141     VestaSource::errorCode
00142       insertFile(Arc arc, ShortId sid, bool mast,
00143                  AccessControl::Identity who =NULL,
00144                  VestaSource::dupeCheck chk =VestaSource::dontReplace,
00145                  VestaSource** newvs =NULL, time_t timestamp =0,
00146                  FP::Tag* fptag =NULL) throw();
00147     VestaSource::errorCode
00148       insertMutableFile(Arc arc, ShortId sid, bool mast,
00149                  AccessControl::Identity who =NULL,
00150                  VestaSource::dupeCheck chk =VestaSource::dontReplace,
00151                  VestaSource** newvs =NULL, time_t timestamp =0) throw();
00152     VestaSource::errorCode
00153       insertImmutableDirectory(Arc arc, VestaSource* dir, bool mast,
00154                  AccessControl::Identity who =NULL,
00155                  VestaSource::dupeCheck chk =VestaSource::dontReplace,
00156                  VestaSource** newvs =NULL, time_t timestamp =0,
00157                  FP::Tag* fptag =NULL) throw();
00158     VestaSource::errorCode
00159       insertAppendableDirectory(Arc arc, bool mast, 
00160                  AccessControl::Identity who =NULL,
00161                  VestaSource::dupeCheck chk =VestaSource::dontReplace,
00162                  VestaSource** newvs =NULL, time_t timestamp =0) throw();
00163     VestaSource::errorCode
00164       insertMutableDirectory(Arc arc, VestaSource* dir, bool mast, 
00165                  AccessControl::Identity who =NULL,
00166                  VestaSource::dupeCheck chk =VestaSource::dontReplace,
00167                  VestaSource** newvs =NULL, time_t timestamp =0) throw();
00168     VestaSource::errorCode
00169       insertGhost(Arc arc, bool mast, 
00170                  AccessControl::Identity who =NULL,
00171                  VestaSource::dupeCheck chk =VestaSource::dontReplace,
00172                  VestaSource** newvs =NULL, time_t timestamp =0) throw();
00173     VestaSource::errorCode
00174       insertStub(Arc arc, bool mast, 
00175                  AccessControl::Identity who =NULL,
00176                  VestaSource::dupeCheck chk =VestaSource::dontReplace,
00177                  VestaSource** newvs =NULL, time_t timestamp =0) throw();
00178     VestaSource::errorCode
00179       renameTo(Arc arc, VestaSource* fromDir, Arc fromArc,
00180                  AccessControl::Identity who =NULL,
00181                  VestaSource::dupeCheck chk =VestaSource::dontReplace,
00182                  time_t timestamp =0) throw();
00183     VestaSource::errorCode
00184       getBase(VestaSource*& result, AccessControl::Identity who =NULL) throw();
00185     VestaSource::errorCode
00186       list(unsigned int firstIndex,
00187                  VestaSource::listCallback callback, void* closure,
00188                  AccessControl::Identity who =NULL,
00189                  bool deltaOnly =false, unsigned int indexOffset =0) throw();
00190 
00191     VestaSource::errorCode
00192       lookupIndex(unsigned int index, VestaSource*& result,
00193                   char* arcbuf =NULL) throw();
00194 
00195     // This method provides support for makeMutable.  The directory
00196     // must already be mutable (or volatile).  Kludge warning: The
00197     // method assumes that this->longid and index have been obtained
00198     // by splitting the longid obtained as the result of a lookup done
00199     // atomically with the current call under VRLock.  (In the
00200     // implementation, the method fails if index names a forwarding
00201     // pointer).
00202     VestaSource::errorCode
00203       makeIndexMutable(unsigned int index, VestaSource*& result,
00204                        ShortId sid =NullShortId,
00205                        Basics::uint64 copyMax = (Basics::uint64) -1,
00206                        AccessControl::Identity who =NULL) throw();
00207 
00208     // This method provides support for makeFilesImmutable.  The
00209     // index must belong directly to a mutable file (not to a
00210     // forwarding pointer, not to an immutable file that has been
00211     // copied to a mutable file, etc.).  The file type is changed to
00212     // immutable, the fingerprint is changed if fptag is non-NULL,
00213     // and the shortid is changed if newsid is not NullShortId.
00214     // The caller is responsible for chmod-ing the shortid file to
00215     // remove write permission.
00216     void makeIndexImmutable(unsigned int index,
00217                             const FP::Tag* fptag =NULL,
00218                             ShortId newsid =NullShortId) throw();
00219 
00220     // This method is also here to help makeFilesImmutable.  When
00221     // making a mutable file into an immutable file, it's necessary to
00222     // know whether there are multiple references to it.  It's
00223     // incorrect to unlink or chmod read-only a shortid which still
00224     // has another mutable reference.
00225     inline int getRefCount(ShortId sid, int default_count = 0)
00226       { return (sidref
00227                 ? sidref->GetCount(sid, default_count)
00228                 : default_count); }
00229 
00230     // This method provides support for copyToMutable.  The directory
00231     // must already be mutable.  Essentially a limited version of
00232     // makeIndexMutable that copies the directory entry to a
00233     // sameAsBase entry in the mutable directory without actually
00234     // making it mutable.  (As with makeIndexMutable, it's assumed
00235     // that this->longid and index have been obtained by splitting the
00236     // longid obtained as the result of a lookup done atomically with
00237     // the current call while holding a lock on the directory
00238     // structure.)
00239     VestaSource::errorCode
00240       copyIndexToMutable(unsigned int index, VestaSource*& result,
00241                          AccessControl::Identity who =NULL) throw();
00242 
00243     // Turn the master flag on or off.  Use with care to preserve the
00244     // replication invariants!
00245     errorCode setIndexMaster(unsigned int index, bool state,
00246                              AccessControl::Identity who =NULL) throw();
00247 
00248     // Garbage collection support.  The closure argument to the
00249     // sweepCallback should be an ostream* representing an open
00250     // ShortIdsFile.  All reachable ShortIds found in the sweep are
00251     // appended to this file.
00252     void mark(bool byName =true, ArcTable* hidden =NULL) throw();
00253     static void markCallback(void* closure, VMemPool::typeCode type) throw();
00254     static bool sweepCallback(void* closure, VMemPool::typeCode type,
00255                               void* addr, Bit32& size) throw();
00256     static void rebuildCallback(void* closure, VMemPool::typeCode type,
00257                                 void* addr, Bit32& size) throw();
00258     
00259     // Checkpointing
00260     Bit32 checkpoint(Bit32& nextSP, std::fstream& ckpt) throw();
00261 
00262     // Explicit free support
00263     void freeTree() throw();
00264 
00265     errorCode
00266       measureDirectory(/*OUT*/directoryStats &result,
00267                        AccessControl::Identity who =NULL)
00268       throw (SRPC::failure);
00269 
00270     errorCode
00271       collapseBase(AccessControl::Identity who =NULL)
00272       throw (SRPC::failure);
00273 
00274     // Constructors
00275     enum { defaultRepSize = 512 }; // must hold >=1 max sized entry
00276     VDirChangeable(VestaSource::typeTag type,
00277                    int size =defaultRepSize, // size= initial size in bytes
00278                    ShortIdRefCount* sidref =NULL)
00279       throw();
00280 
00281     VDirChangeable(VestaSource::typeTag type, Bit8* existingRep,
00282                    ShortIdRefCount* sidref =NULL) throw();
00283 
00284     // Build the ShortIdRefCount for this mtuable directory.  Only
00285     // valid on the mutable root.
00286     void buildMutableSidref() throw();
00287 
00288     // Re-build the ShortIdRefCount for this mtuable directory and see
00289     // if thr counts match.  Only valid on the mutable root.  If
00290     // "correct" is true, then any inconsistency will simply result in
00291     // a message and the reference count will be corrected.  If
00292     // "correct" is false, exit with abort.
00293     void checkMutableSidref(bool correct = false) throw();
00294     
00295     // Print memory usage stats using dprintf
00296     static void printStats() throw ();
00297 
00298     virtual VestaSource *copy() throw();
00299 
00300   private:
00301     // Cached values are valid iff repEndCache != NULL
00302     Bit8* repEndCache;              // Cached pointer to endMark of rep
00303     unsigned int nextRawIndexCache; // Number of entries + 1
00304     Bit8* baseCache;                // Pointer to rep of base, if any
00305     Bit8* lastRepBlockCache;        // Last block of rep
00306     int totalRepSizeCache;          // Total non-free bytes of rep,
00307                                     // not counting outdated entries.
00308 
00309     // Accessors for the packed representation.  Those for entries
00310     // take a "Bit8* entry" argument, which is simply a pointer within
00311     // the representation.  Those that may access another block of
00312     // representation at the end of a more pointer take the (current
00313     // block of) rep as an argument.
00314   public:
00315     inline bool hasName() throw() { return (bool) (rep[VDIRCH_FLAGS] & 1); };
00316     inline void setHasName(bool newval) throw()
00317       { rep[VDIRCH_FLAGS] = (rep[VDIRCH_FLAGS] & 0xfe) | (int) newval; };
00318     inline bool visited() throw()
00319       { return (bool) ((rep[VDIRCH_FLAGS] & 2) != 0); };
00320     inline void setVisited(bool newval) throw()
00321       { rep[VDIRCH_FLAGS] =
00322           (rep[VDIRCH_FLAGS] & 0xfd) | ((int)newval << 1); };
00323   private:
00324     inline bool hasName(Bit8* repb) throw()
00325       { return (bool) (repb[VDIRCH_FLAGS] & 1); };
00326     inline void setHasName(Bit8* repb, bool newval) throw()
00327       { repb[VDIRCH_FLAGS] = (repb[VDIRCH_FLAGS] & 0xfe) | (int) newval; };
00328     inline bool visited(Bit8* repb) throw()
00329       { return (bool) ((repb[VDIRCH_FLAGS] & 2) != 0); };
00330     inline void setVisited(Bit8* repb, bool newval) throw()
00331       { repb[VDIRCH_FLAGS] =
00332           (repb[VDIRCH_FLAGS] & 0xfd) | ((int)newval << 1); };
00333 
00334     enum { isNeither = 0, isMore = 1, isBase = 2 };
00335     static inline int isMoreOrBase(Bit8 *repb) throw()
00336       { return (repb[VDIRCH_FLAGS] >> 2) & 3; };
00337     static inline void setIsMoreOrBase(Bit8* repb, int newval) throw()
00338       { repb[VDIRCH_FLAGS] = (repb[VDIRCH_FLAGS] & 0xf3) | (newval << 2); };
00339     static inline Bit32 moreOrBase(Bit8 *repb) throw()
00340       { Bit32 val; memcpy(&val, &repb[VDIRCH_MOREORBASE], 4); return val; };
00341     static inline void setMoreOrBase(Bit8 *repb, Bit32 newval) throw()
00342       { memcpy(&repb[VDIRCH_MOREORBASE], &newval, 4); };
00343   public:
00344     inline time_t timestamp() throw()
00345       { Bit32 val; memcpy(&val, &rep[VDIRCH_TIMESTAMP], 4);
00346         return (time_t) val; };
00347   private:
00348     inline void setTimestampField(Bit32 newval) throw()
00349       { memcpy(&rep[VDIRCH_TIMESTAMP], &newval, 4); };
00350     // Get/set pseudoInode or sid, depending on type
00351     inline Bit32 getID() throw()
00352       { Bit32 val; memcpy(&val, &rep[VDIRCH_ID], 4); return val; };
00353     inline void setID(Bit32 newval) throw()
00354       { memcpy(&rep[VDIRCH_ID], &newval, 4); };
00355 
00356     // Get/set fptag or snapshot, depending on type
00357     inline FP::Tag fptag() throw()
00358       { FP::Tag ret;
00359         memcpy(ret.Words(), &rep[VDIRCH_FPTAG], FP::ByteCnt); return ret; };
00360     inline void setFPTag(const FP::Tag& newfptag) throw()
00361       { memcpy(&rep[VDIRCH_FPTAG], ((FP::Tag&)newfptag).Words(),
00362                FP::ByteCnt); };
00363     inline Bit32 snapshot() throw()
00364       { Bit32 val; memcpy(&val, &rep[VDIRCH_FPTAG], 4); return val; };
00365     inline void setSnapshot(Bit32 newval) throw()
00366       { memcpy(&rep[VDIRCH_FPTAG], &newval, 4); };
00367 
00368     inline Bit8* firstEntry(Bit8 *repb) throw()
00369       { return &repb[VDIRCH_ENTRIES]; };
00370     static inline Bit8* nextEntry(Bit8* entry) throw() {
00371         if (hasEFPTag(entry))
00372           return entry + entry[VDIRCH_E2ARCLEN] + VDIRCH_E2MINSIZE;
00373         else
00374           return entry + entry[VDIRCH_E1ARCLEN] + VDIRCH_E1MINSIZE;
00375     };
00376 
00377     static inline bool isEndMark(Bit8* entry) throw()
00378       { return (bool) (entry[VDIRCH_EFLAGS] == 0xff); };
00379     static inline bool masterFlag(Bit8* entry) throw()
00380       { return (bool) (entry[VDIRCH_EFLAGS] & 1); };
00381     static inline void setMasterFlag(Bit8* entry, bool newval) throw()
00382       { entry[VDIRCH_EFLAGS] = (entry[VDIRCH_EFLAGS] & 0xfe) | (int) newval; };
00383     static inline bool inUse(Bit8* entry) throw()
00384       { return (bool) ((entry[VDIRCH_EFLAGS] & 2) != 0); };
00385     static inline void setInUse(Bit8* entry, bool newval) throw()
00386       { entry[VDIRCH_EFLAGS] =
00387           (entry[VDIRCH_EFLAGS] & 0xfd) | ((int) newval << 1); };
00388     static inline bool hasEFPTag(Bit8* entry) throw()
00389       { return (bool) ((entry[VDIRCH_EFLAGS] & 4) != 0); };
00390     static inline void setHasEFPTag(Bit8* entry, bool newval) throw()
00391       { entry[VDIRCH_EFLAGS] =
00392           (entry[VDIRCH_EFLAGS] & 0xfb) | ((int) newval << 2); };
00393     static inline bool sameAsBase(Bit8* entry) throw()
00394       { return (bool) ((entry[VDIRCH_EFLAGS] & 8) != 0); };
00395     static inline void setSameAsBase(Bit8* entry, bool newval) throw()
00396       { entry[VDIRCH_EFLAGS] =
00397           (entry[VDIRCH_EFLAGS] & 0xf7) | ((int) newval << 3); };
00398     static inline VestaSource::typeTag type(Bit8* entry) throw()
00399       { return (VestaSource::typeTag) ((entry[VDIRCH_EFLAGS] >> 4) & 0xf); };
00400     static inline void setType(Bit8* entry, VestaSource::typeTag type) throw()
00401       { entry[VDIRCH_EFLAGS] =
00402           (entry[VDIRCH_EFLAGS] & 0x0f) | (((int) type) << 4); };
00403     static inline Bit32 value(Bit8* entry) throw()
00404       { Bit32 val; memcpy(&val, &entry[VDIRCH_EVALUE], 4); return val; };
00405     static inline void setValue(Bit8* entry, Bit32 value) throw()
00406       { memcpy(&entry[VDIRCH_EVALUE], &value, 4); };
00407     static inline Bit32 attrib(Bit8* entry) throw()
00408       { Bit32 val; memcpy(&val, &entry[VDIRCH_EATTRIB], 4); return val; };
00409     static inline void setAttrib(Bit8* entry, Bit32 attrib) throw()
00410       { memcpy(&entry[VDIRCH_EATTRIB], &attrib, 4); };
00411     inline Bit8* attribAddr(Bit8* entry) throw()
00412       { if (VestaSource::type == VestaSource::appendableDirectory ||
00413             VestaSource::type == VestaSource::mutableDirectory)
00414           return entry + VDIRCH_EATTRIB; else return NULL; };
00415     static inline FP::Tag efptag(Bit8* entry) throw()
00416       { FP::Tag ret; assert(hasEFPTag(entry));
00417         memcpy(ret.Words(), &entry[VDIRCH_EFPTAG], FP::ByteCnt); return ret; };
00418     static inline void setEFPTag(Bit8* entry, const FP::Tag& newfptag) throw()
00419       { assert(hasEFPTag(entry));
00420         memcpy(&entry[VDIRCH_EFPTAG], ((FP::Tag&)newfptag).Words(),
00421                FP::ByteCnt); };
00422     static inline int arcLen(Bit8* entry) throw()
00423       { return (int) entry[hasEFPTag(entry) ?
00424                            VDIRCH_E2ARCLEN : VDIRCH_E1ARCLEN]; };
00425     static inline char* arc(Bit8* entry) throw()
00426       { return (char*) &entry[hasEFPTag(entry) ?
00427                               VDIRCH_E2ARC : VDIRCH_E1ARC]; };
00428 
00429     void fillCaches() throw();  // fills all xxxCache members
00430     inline Bit8* repEnd() throw()
00431       { if (!repEndCache) fillCaches(); return repEndCache; };
00432     inline unsigned int nextRawIndex() throw()
00433       { if (!repEndCache) fillCaches(); return nextRawIndexCache; };
00434     inline Bit8* base() throw()
00435       { if (!repEndCache) fillCaches(); return baseCache; };
00436     inline Bit8* lastRepBlock() throw()
00437       { if (!repEndCache) fillCaches(); return lastRepBlockCache; };
00438     inline int totalRepSize() throw() // not counting outdated entries (?!!)
00439       { if (!repEndCache) fillCaches(); return totalRepSizeCache; };
00440     inline Bit32 freeLen() throw()
00441       { Bit32 val; memcpy(&val, repEnd() + 1, 4); return val; };
00442     inline void setFreeLen(Bit32 newval) throw()
00443       { memcpy(repEnd() + 1, &newval, 4); };
00444 
00445     // Locate an existing entry with the given arc name; return NULL
00446     // if there is none.  Also supply the raw index of the entry
00447     // found, that is, its actual 1-origin position within the rep.
00448     // Does not follow the base pointer.  A deleted entry is not
00449     // returned unless includeDeleted is true.  A deleted entry that
00450     // has been outdated by a later entry (by a replaceDiff insertion)
00451     // is not returned unless includeOutdated is true.
00452     Bit8* findArc(const char* arc, unsigned int& rawIndex,
00453                   bool includeDeleted =false,
00454                   bool includeOutdated =false) throw();
00455 
00456     // Locate an existing entry with the given raw index; NULL if none.
00457     // Does not follow the base pointer.  Also return a pointer to
00458     // the start of the rep block the index was found in.
00459     Bit8* findRawIndex(unsigned int rawIndex, Bit8*& repBlock) throw(); 
00460 
00461     // Append a new entry.  Don't check for duplicate names, etc.
00462     // arc need not be null-terminated.  arcLen must be <= MAX_ARC_LEN.
00463     // A pointer to the new entry is returned.  If fptag==NULL, no 
00464     // space is reserved in the entry for an fptag.
00465     Bit8* appendEntry(bool mast, bool sameAsBase,
00466                       VestaSource::typeTag type, Bit32 value,
00467                       Bit32 attrib, const FP::Tag* efptag,
00468                       const char* arc, int arcLen) throw();
00469 
00470     // Change attributes and value of an existing entry.  If the
00471     // entry had no fptag field when first created, then fptag must be
00472     // NULL; otherwise it can either be NULL or have a value.
00473     static void setEntry(Bit8* entry, bool mast, bool sameAsBase,
00474                          VestaSource::typeTag type, Bit32 value,
00475                          Bit32 attrib, const FP::Tag* efptag) throw();
00476 
00477     // Common code for all insertXXX methods.  When replacing a stub
00478     // with anything or anything with a stub or ghost, the atttributes
00479     // of the old object are optionally returned in the "attribs"
00480     // parameter.
00481     VestaSource::errorCode insertCommon(Arc arc, bool mast,
00482                       VestaSource::typeTag newtype,
00483                       AccessControl::Identity who,
00484                       VestaSource::dupeCheck chk,
00485                       const char** setOwner, ShortId* delsid,
00486                       Bit32* attribs = NULL) throw();
00487 
00488     // Support code for insertImmutableDirectory.  WARNING: returned
00489     // value does not have a valid LongId field.
00490     VDirChangeable* copyMutableToImmutable(const FP::Tag& fptag) throw();
00491 
00492     VDirChangeable* collapse(unsigned int newSize = defaultRepSize) throw();
00493 
00494     // Support for reference counting the new shortids in a volatile
00495     // directory tree.  NULL in anything other than a volatile directory.
00496     ShortIdRefCount* sidref;
00497 
00498     // Rebuild a ShortIdRefCount for this directory.  Only valid on
00499     // the mutable root.
00500     ShortIdRefCount *rebuildMutableSidref() throw();
00501 
00502     // Miscellaneous friends that use internal methods (ugh).
00503     friend bool filterListCallback(void* closure, typeTag type, 
00504                                    Arc arc, unsigned int index,
00505                                    unsigned int pseudoInode,
00506                                    bool mast) throw();
00507     friend VestaSource::errorCode
00508       VDirVolatileRoot::createVolatileDirectory(char* hostname, char* port,
00509                                                 Bit64 handle,
00510                                                 VestaSource*& result,
00511                                                 time_t timestamp,
00512                                                 LongId::lockKindTag lockKind,
00513                                                 ReadersWritersLock** lock,
00514                                                 bool readOnlyExisting)
00515         throw();
00516     friend VestaSource::errorCode
00517       VDirVolatileRoot::lookupIndexAndLock(unsigned int index,
00518                                          VestaSource*& result,
00519                                          LongId::lockKindTag lockKind,
00520                                            ReadersWritersLock** lock)
00521       throw();
00522     friend VestaSource*
00523       VDCLookupResult(VDirChangeable* dir, Bit8* entry, unsigned int index);
00524 
00525     friend VestaSource*
00526       LongId::lookup(LongId::lockKindTag lockKind, ReadersWritersLock** lock)
00527         throw (SRPC::failure);
00528 
00529     friend FP::Tag DirFP(Bit8* rep);
00530     friend ShortId DirId(Bit8* rep);
00531     friend void InitFPShortId();
00532 };
00533 
00534 
00535 #endif //_VDIRCH

Generated on Mon May 8 00:48:48 2006 for Vesta by  doxygen 1.4.2