23 const shash::Md5 Catalog::kMd5PathEmpty(
"", 0);
29 Catalog* Catalog::AttachFreely(
const string &imaginary_mountpoint,
33 const bool is_nested) {
36 imaginary_mountpoint.length()),
41 if (!successful_init) {
52 const bool is_nested) :
53 catalog_hash_(catalog_hash),
55 is_regular_mountpoint_(
mountpoint_ == root_prefix_),
56 volatile_flag_(false),
57 is_root_(parent == NULL && !is_nested),
58 managed_database_(false),
60 nested_catalog_cache_dirty_(true),
61 voms_authz_status_(kVomsUnknown),
66 lock_ =
reinterpret_cast<pthread_mutex_t *
>(smalloc(
sizeof(pthread_mutex_t)));
67 int retval = pthread_mutex_init(
lock_, NULL);
85 pthread_mutex_destroy(
lock_);
137 bool statistics_loaded;
143 }
else if (
database().schema_revision() < 2) {
146 }
else if (
database().schema_revision() < 3) {
149 }
else if (
database().schema_revision() < 5) {
155 return statistics_loaded;
174 "SELECT count(*) FROM sqlite_master "
175 "WHERE type='table' AND name='nested_catalogs' AND sql LIKE '%sha1%';");
176 bool retval = sql_has_nested_sha1.
FetchRow();
179 if (!has_nested_sha1) {
195 "Cannot retrieve maximal row id for database file %s "
196 "(SqliteErrorcode: %d)",
208 "found root prefix %s in root catalog file %s",
213 "no root prefix for root catalog file %s", db_path.c_str());
223 "failed to load statistics counters for catalog %s (file %s)",
255 reinterpret_cast<const unsigned char *>(path.
GetChars()) +
260 return result.CastToMd5();
311 if (found && (dirent != NULL)) {
354 if (found && (xattrs != NULL)) {
404 const bool expand_symlink)
const
414 listing->push_back(dirent);
471 while (list_content_hashes.
FetchRow()) {
516 if (
database().HasProperty(
"voms_authz")) {
534 const std::string prop_name =
"last_modified";
535 return (
database().HasProperty(prop_name))
547 const string sql =
"SELECT count(*) FROM catalog;";
557 const std::string hash_string =
559 return (!hash_string.empty())
594 const uint64_t hardlink_group)
const {
605 if (hardlink_group > 0) {
606 HardlinkGroupMap::const_iterator inode_iter =
613 inode = inode_iter->second;
666 result.push_back(nested);
697 if (found && (hash != NULL)) {
721 uid_map_ = (uid_map && uid_map->HasEffect()) ? uid_map : NULL;
722 gid_map_ = (gid_map && gid_map->HasEffect()) ? gid_map : NULL;
756 for (NestedCatalogMap::const_iterator i =
children_.begin(),
759 result.push_back(i->second);
786 path_prefix.
Append(
"/", 1);
787 const char *c = remaining.
GetChars() + 1;
788 for (
unsigned i = 1; i < remaining.
GetLength(); ++i, ++c) {
809 NestedCatalogMap::const_iterator nested_iter;
812 nested_iter =
children_.find(mountpoint);
814 (nested_iter ==
children_.end()) ? NULL : nested_iter->second;
PathString GetPath() const
bool BindSearchPath(const PathString &path)
InodeRange inode_range() const
PathString PlantPath(const PathString &path) const
shash::Any GetHash() const
SqlAllChunks * sql_all_chunks_
NestedCatalogMap children_
bool AllChunksNext(shash::Any *hash, zlib::Algorithms *compression_alg)
HardlinkGroupMap hardlink_groups_
struct cvmcache_context * ctx
void EnforceSchema(float version, unsigned revision)
int page_cache_used
Bytes used for caching pages.
void set_inode(const inode_t inode)
PathString GetPath() const
CatalogDatabase * database_
NestedCatalogList nested_catalog_cache_
ShortString Suffix(const unsigned start_at) const
bool BindPathHash(const shash::Md5 &hash)
bool LookupXattrsMd5Path(const shash::Md5 &md5path, XattrList *xattrs) const
const OwnerMap * gid_map_
bool OpenDatabase(const std::string &db_path)
const OwnerMap * uid_map_
shash::Any GetContentHash() const
void Assign(const char *chars, const unsigned length)
SqlOwnNestedCatalogListing * sql_own_list_nested_
PathString NormalizePath2(const PathString &path) const
bool LookupPath(const PathString &path, DirectoryEntry *dirent) const
static const shash::Md5 kMd5PathEmpty
DirectoryEntry GetDirent(const Catalog *catalog, const bool expand_symlink=true) const
Catalog * FindSubtree(const PathString &path) const
virtual void InitPreparedStatements()
shash::Any GetPreviousRevision() const
assert((mem||(size==0))&&"Out Of Memory")
float schema_version() const
shash::Any GetContentHash() const
CatalogList GetChildren() const
bool InitStandalone(const std::string &database_file)
int stmt_used
Bytes used for prepared statmements (lookaside + heap)
std::string PrintMemStatistics() const
bool ListMd5PathChunks(const shash::Md5 &md5path, const shash::Algorithms interpret_hashes_as, FileChunkList *chunks) const
Catalog * FindChild(const PathString &mountpoint) const
void SetInodeAnnotation(InodeAnnotation *new_annotation)
const NestedCatalogList & ListNestedCatalogs() const
SqlLookupXattrs * sql_lookup_xattrs_
bool ListingMd5Path(const shash::Md5 &md5path, DirectoryEntryList *listing, const bool expand_symlink=true) const
bool LookupEntry(const shash::Md5 &md5path, const bool expand_symlink, DirectoryEntry *dirent) const
static DerivedT * Open(const std::string &filename, const OpenMode open_mode)
IntegerMap< uint64_t > OwnerMap
void FinalizePreparedStatements()
T GetProperty(const std::string &key) const
SqlListing * sql_listing_
void Init(ContextPtr context)
T GetPropertyDefault(const std::string &key, const T default_value) const
InodeAnnotation * inode_annotation_
bool GetVOMSAuthz(std::string *authz) const
std::vector< shash::Any > HashVector
bool IsNestedCatalogRoot() const
uint64_t GetNumEntries() const
uint64_t GetRevision() const
std::vector< DirectoryEntry > DirectoryEntryList
uint64_t GetLastModified() const
bool HasExplicitTTL() const
virtual CatalogDatabase::OpenMode DatabaseOpenMode() const
void set_parent(Catalog *catalog)
bool Next(shash::Any *hash, zlib::Algorithms *compression_alg)
SqlNestedCatalogListing * sql_list_nested_
static const float kSchemaEpsilon
const HashVector & GetReferencedObjects() const
bool LookupMd5Path(const shash::Md5 &md5path, DirectoryEntry *dirent) const
void AddChild(Catalog *child)
shash::Md5 NormalizePath(const PathString &path) const
const char kSuffixCatalog
void FixTransitionPoint(const shash::Md5 &md5path, DirectoryEntry *dirent) const
void ResetNestedCatalogCacheUnprotected()
sqlite3_int64 RetrieveInt64(const int idx_column) const
LinkString symlink() const
bool ListingMd5PathStat(const shash::Md5 &md5path, StatEntryList *listing) const
PathString mountpoint() const
void Final(ContextPtr context, Any *any_digest)
bool BindPathHash(const shash::Md5 &hash)
bool BindPathHash(const struct shash::Md5 &hash)
static const inode_t kInvalidInode
void Append(const char *chars, const unsigned length)
void TakeDatabaseFileOwnership()
string StringifyInt(const int64_t value)
SqlLookupPathHash * sql_lookup_md5path_
bool ReadFromDatabase(const CatalogDatabase &database, const LegacyMode::Type legacy=LegacyMode::kNoLegacy)
void RemoveChild(Catalog *child)
bool BindPathHash(const struct shash::Md5 &hash)
PathString root_prefix() const
std::vector< Catalog * > CatalogList
bool is_regular_mountpoint_
bool HasProperty(const std::string &key) const
bool IsInitialized() const
void PushBack(const Item &item)
void set_inode_range(const InodeRange value)
bool IsEqualSchema(const float value, const float compare) const
inode_t GetMangledInode(const uint64_t row_id, const uint64_t hardlink_group) const
std::vector< NestedCatalog > NestedCatalogList
void Update(const unsigned char *buffer, const unsigned buffer_length, ContextPtr context)
const NestedCatalogList ListOwnNestedCatalogs() const
SqlChunksListing * sql_chunks_listing_
shash::Any GetContentHash() const
FileChunk GetFileChunk(const shash::Algorithms interpret_hash_as) const
virtual inode_t Annotate(const inode_t raw_inode)=0
ShortString< kDefaultMaxPath, 0 > PathString
int schema_used
Bytes used to store db schema.
uint64_t GetNumChunks() const
void SetOwnerMaps(const OwnerMap *uid_map, const OwnerMap *gid_map)
HashVector referenced_hashes_
const CatalogDatabase & database() const
FieldT Get(const std::string &key) const
bool FindNested(const PathString &mountpoint, shash::Any *hash, uint64_t *size) const
Any MkFromHexPtr(const HexPtr hex, const char suffix)
bool LookupRawSymlink(const PathString &path, LinkString *raw_symlink) const
bool StartsWith(const ShortString &other) const
bool ReadCatalogCounters()
void DropDatabaseFileOwnership()
static const float kLatestSupportedSchema
void GetMemStatistics(MemStatistics *stats) const
unsigned GetLength() const
const char * c_str() const
const char * GetChars() const
bool nested_catalog_cache_dirty_
SqlNestedCatalogLookup * sql_lookup_nested_
VomsAuthzStatus voms_authz_status_
static const uint64_t kDefaultTTL
struct stat GetStatStructure() const
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)