21 const std::set<std::string> &protected_xattrs,
22 const std::set<gid_t> &priviledged_xattr_gids)
24 visibility_(visibility),
25 protected_xattrs_(protected_xattrs),
26 privileged_xattr_gids_(priviledged_xattr_gids),
87 std::map<std::string, BaseMagicXattr *>::iterator it =
xattr_list_.begin();
104 if (!dirent->
IsLink())
continue;
110 PANIC(
"unknown magic xattr flavor");
112 result += (*it).first;
113 result.push_back(
'\0');
130 result->
Lock(path, d);
141 "Magic extended attribute with name %s already registered",
168 std::set<std::string>::const_iterator iter;
169 std::vector<string> tmp;
173 tmp.push_back(*iter);
177 if (tmp.size() > 0) {
180 "Following CVMFS_XATTR_PROTECTED_XATTRS are "
181 "set but not recognized: %s", msg.c_str());
185 std::set<gid_t>::const_iterator iter_gid;
191 if (tmp.size() > 0) {
194 "Following CVMFS_XATTR_PRIVILEGED_GIDS are set: %s", msg.c_str());
199 return "# Access page at idx: " +
StringifyUint(requested_page) +
". " +
201 " (access other pages: xattr~<page_num>, starting " +
202 " with 0; number of pages available: xattr~?)\n";
207 assert(requested_page >= -1);
211 std::string res =
"";
213 if (requested_page >= static_cast<int32_t>(
result_pages_.size())) {
214 return std::pair<bool, std::string> (
false,
"");
216 if (requested_page == -1) {
217 return std::pair<bool, std::string> (
true,
221 if (requested_page >= static_cast<int32_t>(
result_pages_.size())) {
222 return std::pair<bool, std::string> (
true,
223 "Page requested does not exists. There are "
225 +
"Access them with xattr~<page_num> (machine-readable mode) "
226 +
"or xattr@<page_num> (human-readable mode).\n"
227 +
"Use xattr@? or xattr~? to get extra info about the attribute");
228 }
else if (requested_page == -1) {
229 return std::pair<bool, std::string> (
true,
230 "Access xattr with xattr~<page_num> (machine-readable mode) or "
231 + std::string(
" xattr@<page_num> (human-readable mode).\n")
238 "Unknown mode of magic xattr requested: %d", mode);
243 return std::pair<bool, std::string> (
true, res);
277 const std::string header =
"hash,offset,size\n";
278 std::string chunk_list_page_(header);
290 "'chunked', but no chunks found.",
path_.
c_str());
293 for (
size_t i = 0; i < chunks.
size(); ++i) {
300 chunk_list_page_ = header;
306 chunk_list_page_ +=
"0,";
311 if (chunk_list_page_.size() > header.size()) {
333 "'chunked', but no chunks found.",
path_.
c_str());
375 std::vector<string> host_chain;
376 std::vector<int> rtt;
377 unsigned current_host;
379 &host_chain, &rtt, ¤t_host);
380 if (host_chain.size()) {
381 result_pages_.push_back(std::string(host_chain[current_host]));
388 unsigned seconds, seconds_direct;
390 GetTimeout(&seconds, &seconds_direct);
407 std::vector<std::string> host_chain;
408 std::vector<int> rtt;
409 unsigned current_host;
411 GetHostInfo(&host_chain, &rtt, ¤t_host);
412 if (host_chain.size()) {
413 result_pages_.push_back(std::string(host_chain[current_host]));
421 std::vector<std::string> host_chain;
422 std::vector<int> rtt;
423 unsigned current_host;
425 GetHostInfo(&host_chain, &rtt, ¤t_host);
426 if (host_chain.size()) {
427 result = host_chain[current_host];
428 for (
unsigned i = 1; i < host_chain.size(); ++i) {
430 ";" + host_chain[(i+current_host) % host_chain.size()];
433 result =
"internal error: no hosts defined";
451 result =
"Not in cache";
460 result = hash.ToString();
472 for (std::vector<LogBufferEntry>::reverse_iterator itr = buffer.rbegin();
473 itr != buffer.rend(); ++itr)
477 itr->message +=
" <snip>";
479 result +=
"[" +
StringifyTime(itr->timestamp,
true ) +
" UTC] " +
491 const uint64_t period_s = 24 * 60 * 60;
508 file_system()->n_fs_dir_open()->ToString());
527 int64_t n_invocations =
530 if (n_invocations == 0) {
535 int64_t n_downloads =
537 float hitrate = 100. * (1. -
538 (
static_cast<float>(n_downloads) / static_cast<float>(n_invocations)));
543 vector< vector<download::DownloadManager::ProxyInfo> > proxy_chain;
544 unsigned current_group;
546 &proxy_chain, ¤t_group, NULL);
547 if (proxy_chain.size()) {
555 std::vector<std::string> *result_pages) {
556 vector< vector<download::DownloadManager::ProxyInfo> > proxy_chain;
557 unsigned current_group;
559 std::string buf =
"";
560 for (
unsigned int i = 0; i < proxy_chain.size(); i++) {
561 for (
unsigned int j = 0; j < proxy_chain[i].size(); j++) {
562 buf += proxy_chain[i][j].url;
567 result_pages->push_back(buf);
572 if (buf.size() > 0 || result_pages->size() == 0) {
573 result_pages->push_back(buf);
592 size_t full_size = 0;
594 for (
size_t i = 0; i <
pubkeys_.size(); i++) {
598 if (full_size == 0) {
602 size_t size_within_page = 0;
603 std::string res =
"";
605 for (
size_t i = 0; i <
pubkeys_.size(); i++) {
609 size_within_page = 0;
613 size_within_page +=
pubkeys_[i].size();
615 if (res.size() > 0) {
675 result_pages_.push_back(
"Failed to open: metadata file is too big");
681 ->
Pread(fd, buffer, actual_size, 0);
683 if (bytes_read < 0) {
687 result_pages_.push_back(
string(buffer, buffer + bytes_read));
710 int64_t rx = statistics->
Lookup(
"download.sz_transferred_bytes")->
Get();
716 int64_t rx = statistics->
Lookup(
"download.sz_transferred_bytes")->
Get();
717 int64_t time = statistics->
Lookup(
"download.sz_transfer_time")->
Get();
735 unsigned seconds, seconds_direct;
742 unsigned seconds, seconds_direct;
750 file_system()->io_error_info()->timestamp_last()));
755 no_open_files()->ToString());
760 no_open_dirs()->ToString());
765 + std::string(CVMFS_PATCH_LEVEL));
769 std::vector<std::string> host_chain;
770 std::vector<int> rtt;
771 unsigned current_host;
774 &host_chain, &rtt, ¤t_host);
775 if (host_chain.size()) {
776 result_pages_.push_back(std::string(host_chain[current_host])
std::vector< LogBufferEntry > GetLogBuffer()
const std::set< gid_t > privileged_xattr_gids_
int ChecksumFd(int fd, shash::Any *id)
bool IsExternalFile() const
const Counters & GetCounters() const
virtual void FinalizeValue()
virtual int64_t GetSize(int fd)=0
FileSystem * file_system()
Item At(const size_t index) const
virtual bool PrepareValueFenced()
static void ListProxy(download::DownloadManager *dm, std::vector< std::string > *result_pages)
bool PrepareValueFencedProtected(gid_t gid)
virtual void FinalizeValue()
virtual void FinalizeValue()
cvmfs::Fetcher * fetcher()
std::string subcatalog_path_
virtual void FinalizeValue()
virtual uint64_t GetCleanupRate(uint64_t period_s)=0
bool IsChunkedFile() const
virtual void FinalizeValue()
perf::Statistics * statistics()
void Register(const std::string &name, BaseMagicXattr *magic_xattr)
virtual bool PrepareValueFenced()
bool volatile_flag() const
static const int kLabelMetainfo
MountPoint * mount_point()
virtual void FinalizeValue()
virtual void FinalizeValue()
string JoinStrings(const vector< string > &strings, const string &joint)
std::string ToString(const bool with_suffix=false) const
virtual void FinalizeValue()
virtual void FinalizeValue()
catalog::Counters counters_
virtual void FinalizeValue()
BaseMagicXattr * GetLocked(const std::string &name, PathString path, catalog::DirectoryEntry *d)
virtual void FinalizeValue()
const std::set< std::string > protected_xattrs_
virtual void FinalizeValue()
virtual void FinalizeValue()
virtual bool PrepareValueFenced()
const shash::Any & content_hash() const
virtual bool PrepareValueFenced()
virtual void FinalizeValue()
std::string AlgorithmName(const zlib::Algorithms alg)
assert((mem||(size==0))&&"Out Of Memory")
MountPoint * mount_point_
virtual void FinalizeValue()
catalog::DirectoryEntry * dirent_
std::vector< std::string > chunk_list_
string StringifyTime(const time_t seconds, const bool utc)
string StringifyDouble(const double value)
virtual bool PrepareValueFenced()
std::string StringifyUint(const uint64_t value)
shash::Any checksum() const
bool IsPrivilegedGid(gid_t gid)
virtual bool PrepareValueFenced()
bool has_membership_req()
virtual void FinalizeValue()
MountPoint * mount_point_
virtual int Open(const LabeledObject &object)=0
perf::Counter * n_fs_open()
std::string membership_req()
virtual bool PrepareValueFenced()
MagicXattrManager * xattr_mgr_
std::string GetListString(catalog::DirectoryEntry *dirent)
static const uint32_t kMaxCharsPerPage
std::vector< std::string > GetActivePubkeysAsVector() const
Counter * Lookup(const std::string &name) const
virtual bool PrepareValueFenced()
virtual void FinalizeValue()
void GetProxyInfo(std::vector< std::vector< ProxyInfo > > *proxy_chain, unsigned *current_group, unsigned *fallback_group)
virtual void FinalizeValue()
virtual void FinalizeValue()
std::string repository_tag()
catalog::ClientCatalogManager * catalog_mgr()
std::string HeaderMultipageHuman(uint32_t requested_page)
virtual void FinalizeValue()
virtual void FinalizeValue()
virtual bool PrepareValueFenced()
int Fetch(const CacheManager::LabeledObject &object, const std::string &alt_url="")
virtual bool PrepareValueFenced()
virtual void FinalizeValue()
virtual void FinalizeValue()
zlib::Algorithms compression_algorithm() const
CacheManager * cache_mgr()
virtual void FinalizeValue()
virtual void FinalizeValue()
virtual void FinalizeValue()
virtual void FinalizeValue()
std::pair< bool, std::string > GetValue(int32_t requested_page, const MagicXattrMode mode)
LinkString symlink() const
virtual void FinalizeValue()
IoErrorInfo * io_error_info()
const unsigned int kMaxLogLine
download::DownloadManager * download_mgr()
virtual void FinalizeValue()
virtual void FinalizeValue()
virtual void FinalizeValue()
virtual void FinalizeValue()
string StringifyInt(const int64_t value)
virtual void FinalizeValue()
virtual int Close(int fd)=0
virtual void FinalizeValue()
shash::Algorithms hash_algorithm() const
virtual void FinalizeValue()
virtual void FinalizeValue()
static const int kLabelVolatile
CatalogT * GetRootCatalog() const
MagicXattrManager(MountPoint *mountpoint, EVisibility visibility, const std::set< std::string > &protected_xattrs, const std::set< gid_t > &privileged_xattr_gids)
virtual void FinalizeValue()
signature::SignatureManager * signature_mgr()
BackoffThrottle throttle_
std::string ToString() const
QuotaManager * quota_mgr()
uint64_t GetRevision() const
std::vector< std::string > pubkeys_
int GetNumCatalogs() const
bool ListFileChunks(const PathString &path, const shash::Algorithms interpret_hashes_as, FileChunkList *chunks)
virtual void FinalizeValue()
virtual bool PrepareValueFenced()
std::map< std::string, BaseMagicXattr * > xattr_list_
virtual bool PrepareValueFenced()
void GetTimeout(unsigned *seconds_proxy, unsigned *seconds_direct)
virtual void FinalizeValue()
virtual bool PrepareValueFenced()
catalog::Counters counters_
virtual void FinalizeValue()
virtual bool PrepareValueFenced()
virtual MagicXattrFlavor GetXattrFlavor()
manifest::Manifest * manifest() const
void Lock(PathString path, catalog::DirectoryEntry *dirent)
std::string GetCsvMap() const
const char * c_str() const
virtual bool PrepareValueFenced()
void GetHostInfo(std::vector< std::string > *host_chain, std::vector< int > *rtt, unsigned *current_host)
virtual void FinalizeValue()
virtual int64_t Pread(int fd, void *buf, uint64_t size, uint64_t offset)=0
virtual bool PrepareValueFenced()
std::vector< std::string > result_pages_
virtual bool PrepareValueFenced()
void SanityCheckProtectedXattrs()
shash::Any meta_info() const
virtual bool HasCapability(Capabilities capability)=0
download::DownloadManager * external_download_mgr()
virtual bool PrepareValueFenced()
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)