00001
00002
00003
00004
00005 #ifndef BUILTIN_CATALOG_H
00006 #define BUILTIN_CATALOG_H
00007
00008 #include <dmlite/cpp/catalog.h>
00009 #include <dmlite/cpp/inode.h>
00010 #include <dmlite/cpp/poolmanager.h>
00011 #include <dmlite/cpp/pooldriver.h>
00012
00013 namespace dmlite {
00014
00015 struct BuiltInDir: public Directory {
00016 virtual ~BuiltInDir() {};
00017 IDirectory* idir;
00018 ExtendedStat dir;
00019 };
00020
00021 class BuiltInCatalog: public Catalog {
00022 public:
00023 BuiltInCatalog(bool updateATime, unsigned symLinkLimit) throw (DmException);
00024 ~BuiltInCatalog();
00025
00026 std::string getImplId(void) const throw();
00027
00028 void setStackInstance(StackInstance* si) throw (DmException);
00029
00030 void setSecurityContext(const SecurityContext*) throw (DmException);
00031
00032 void changeDir (const std::string&) throw (DmException);
00033 std::string getWorkingDir (void) throw (DmException);
00034
00035 DmStatus extendedStat(ExtendedStat &xstat,
00036 const std::string& path,
00037 bool followSym) throw (DmException);
00038
00039 ExtendedStat extendedStat(const std::string& path,
00040 bool followSym = true) throw (DmException);
00041 ExtendedStat extendedStatByRFN(const std::string& rfn) throw (DmException);
00042
00043
00044
00045 bool access(const std::string& path, int mode) throw (DmException);
00046 bool accessReplica(const std::string& replica, int mode) throw (DmException);
00047
00048 void addReplica (const Replica& replica) throw (DmException);
00049 void deleteReplica(const Replica& replica) throw (DmException);
00050
00051 std::vector<Replica> getReplicas(const std::string& path) throw (DmException);
00052 Location get(const std::string& path) throw (DmException);
00053
00054 Location put(const std::string& path) throw (DmException);
00055 void putDone(const std::string& host, const std::string& rfn,
00056 const std::map<std::string, std::string>& params) throw (DmException);
00057
00058 void symlink(const std::string& oldpath,
00059 const std::string& newpath) throw (DmException);
00060 std::string readLink(const std::string& path) throw (DmException);
00061
00062 void unlink(const std::string& path) throw (DmException);
00063
00064 void create(const std::string& path, mode_t mode) throw (DmException);
00065
00066 void makeDir (const std::string& path, mode_t mode) throw (DmException);
00067 void removeDir(const std::string& path) throw (DmException);
00068
00069 void rename(const std::string& oldPath,
00070 const std::string& newPath) throw (DmException);
00071
00072 mode_t umask(mode_t mask) throw ();
00073
00074 void setMode (const std::string& path, mode_t mode) throw (DmException);
00075 void setOwner (const std::string& path, uid_t newUid, gid_t newGid,
00076 bool followSymLink = true) throw (DmException);
00077
00078 void setSize (const std::string& path, size_t newSize) throw (DmException);
00079
00080 void setAcl(const std::string& path, const Acl& acls) throw (DmException);
00081
00082 void utime(const std::string& path, const struct utimbuf* buf) throw (DmException);
00083
00084 std::string getComment(const std::string& path) throw (DmException);
00085 void setComment(const std::string& path,
00086 const std::string& comment) throw (DmException);
00087
00088 void setGuid(const std::string& path,
00089 const std::string &guid) throw (DmException);
00090
00091 void updateExtendedAttributes(const std::string& path,
00092 const Extensible& attr) throw (DmException);
00093
00094 Directory* openDir (const std::string& path) throw (DmException);
00095 void closeDir(Directory* dir) throw (DmException);
00096 struct dirent* readDir (Directory* dir) throw (DmException);
00097 ExtendedStat* readDirx(Directory* dir) throw (DmException);
00098
00099 Replica getReplicaByRFN(const std::string& rfn) throw (DmException);
00100 void updateReplica(const Replica& replica) throw (DmException);
00101
00102 protected:
00103
00104
00105
00106
00107
00108 ExtendedStat getParent(const std::string& path, std::string* parentPath,
00109 std::string* name) throw (DmException);
00110
00111
00112 void updateAccessTime(const ExtendedStat& meta) throw (DmException);
00113
00114
00115
00116
00117 void traverseBackwards(const ExtendedStat& meta) throw (DmException);
00118
00119
00120
00121
00122
00123
00124 void addFileSizeToParents(const std::string &fname, bool subtract) throw (DmException);
00125
00126
00127
00128
00129
00130
00131 void addFileSizeToParents(const ExtendedStat &statinfo, bool subtract) throw (DmException);
00132
00133 private:
00134 StackInstance* si_;
00135
00136 const SecurityContext* secCtx_;
00137
00138 std::string cwdPath_;
00139 ino_t cwd_;
00140
00141 mode_t umask_;
00142 bool updateATime_;
00143 unsigned symLinkLimit_;
00144 };
00145
00146
00147 class BuiltInCatalogFactory: public CatalogFactory {
00148 public:
00149 BuiltInCatalogFactory();
00150 ~BuiltInCatalogFactory();
00151
00152 void configure(const std::string&, const std::string&) throw (DmException);
00153
00154 Catalog* createCatalog(PluginManager*) throw (DmException);
00155
00156 private:
00157 bool updateATime_;
00158 unsigned symLinkLimit_;
00159 };
00160
00161 };
00162
00163 #endif // BUILTIN_CATALOG_H