9 #define ENOATTR ENODATA
12 #include <sys/xattr.h>
23 #include <sys/errno.h>
25 #include <sys/mount.h>
26 #include <sys/resource.h>
29 #include <google/dense_hash_map>
31 #include <sys/statfs.h>
34 #include <sys/types.h>
100 assert(options_mgr != NULL);
101 assert(instance_ == NULL);
103 assert(instance_ != NULL);
109 fs_info.
name =
"libcvmfs";
115 return instance_->file_system_->boot_status();
119 if (options_mgr->
GetValue(
"CVMFS_NFILES", &arg)) {
122 PrintError(
"Failed to set maximum number of open files, "
123 "insufficient permissions");
133 if (instance_ != NULL) {
137 assert(instance_ == NULL);
157 assert(options_mgr != NULL);
210 if (*listlen + 1 >= *buflen) {
211 size_t newbuflen = (*listlen) * 2 + 5;
212 *buf =
reinterpret_cast<char **
>(realloc(*buf,
sizeof(
char *) * newbuflen));
215 assert(*listlen < *buflen);
218 (*buf)[(*listlen)] = strdup(str);
220 (*buf)[++(*listlen)] = NULL;
222 (*buf)[(*listlen)] = NULL;
231 if (*listlen + 1 >= *buflen) {
232 size_t newbuflen = (*listlen) * 2 + 5;
237 assert(*listlen < *buflen);
239 (*buf)[(*listlen)].info = st.
info;
240 (*buf)[(*listlen)++].name = st.
name;
250 p.
Assign(c_path, strlen(c_path));
286 p.
Assign(c_path, strlen(c_path));
335 p.
Assign(c_path, strlen(c_path));
361 bool self_reference) {
365 if (c_path[0] ==
'/' && c_path[1] ==
'\0') {
371 path.
Assign(c_path, strlen(c_path));
388 if (self_reference) {
404 for (
unsigned i = 0; i < listing_from_catalog.
size(); ++i) {
419 if (c_path[0] ==
'/' && c_path[1] ==
'\0') {
425 path.
Assign(c_path, strlen(c_path));
443 for (
unsigned i = 0; i < listing_from_catalog.
size(); ++i) {
445 st.
info = listing_from_catalog.
AtPtr(i)->info;
446 st.
name = strdup(listing_from_catalog.
AtPtr(i)->name.c_str());
459 p.
Assign(c_path, strlen(c_path));
472 std::string subcat_path;
476 p, &subcat_path, &tmp_hash)
487 nc_attr->
ctr_dir = counters[
"dir"];
506 if (c_path[0] ==
'/' && c_path[1] ==
'\0') {
512 path.
Assign(c_path, strlen(c_path));
514 std::vector<PathString> skein;
518 "cvmfs_list_nc failed to find skein of path: %s", c_path);
525 for (
unsigned i = 0; i < skein.size(); i++) {
540 path.
Assign(c_path, strlen(c_path));
550 "chunked file %s opened (download delayed to read() call)",
556 || chunks->IsEmpty()) {
558 "file %s is marked as "
559 "'chunked', but no chunks found.",
580 fd = this_fetcher->
Fetch(
589 "failed to open path: %s, CAS key %s, error code %d", c_path,
591 if (errno == EMFILE) {
605 const int chunk_handle = fd & ~kFdChunked;
611 if (chunk_list == NULL)
616 uint64_t overall_bytes_fetched = 0;
617 off_t offset_in_chunk = off - chunk_list->
AtPtr(chunk_idx)->
offset();
621 if ((chunk_fd->
fd == -1) || (chunk_fd->
chunk_idx != chunk_idx)) {
622 if (chunk_fd->
fd != -1)
639 if (chunk_fd->
fd < 0) {
648 const size_t bytes_to_read = size - overall_bytes_fetched;
649 const size_t remaining_bytes_in_chunk = chunk_list->
AtPtr(chunk_idx)
652 size_t bytes_to_read_in_chunk = std::min(bytes_to_read,
653 remaining_bytes_in_chunk);
656 reinterpret_cast<char *>(buf) + overall_bytes_fetched,
657 bytes_to_read_in_chunk,
660 if (bytes_fetched < 0) {
664 return -bytes_fetched;
666 overall_bytes_fetched += bytes_fetched;
671 }
while ((overall_bytes_fetched < size)
672 && (chunk_idx < chunk_list->
size()));
673 return overall_bytes_fetched;
683 const int chunk_handle = fd & ~kFdChunked;
711 "Remount requested to switch catalog but failed");
uint32_t linkcount() const
bool IsExternalFile() const
catalog::Counters LookupCounters(const PathString &path, std::string *subcatalog_path, shash::Any *hash)
struct cvmcache_context * ctx
static LibContext * Create(const std::string &fqrn, OptionsManager *options_mgr)
bool InsertNegative(const shash::Md5 &hash)
FileChunkReflist chunk_reflist
void EnableMultiThreaded()
uint64_t ctr_external_file_size
static const int kFdChunked
int GetNestedCatalogAttr(const char *c_path, struct cvmfs_nc_attr *nc_attr)
cvmfs::Fetcher * fetcher()
bool IsChunkedFile() const
SpecialDirents GetSpecial() const
std::string ToString(const bool with_suffix=false) const
void Assign(const char *chars, const unsigned length)
zlib::Algorithms compression_alg
bool Lookup(const shash::Md5 &hash, catalog::DirectoryEntry *dirent, bool update_lru=true)
CVMFS_EXPORT void CleanupLibcryptoMt()
const shash::Any & content_hash() const
bool ListingStat(const PathString &path, StatEntryList *listing)
assert((mem||(size==0))&&"Out Of Memory")
MountPoint * mount_point_
bool LookupPath(const PathString &path, const LookupOptions options, DirectoryEntry *entry)
int GetAttr(const char *c_path, struct stat *info)
int GetExtAttr(const char *c_path, struct cvmfs_attr *info)
lru::Md5PathCache * md5path_cache()
shash::Any checksum() const
OptionsManager * options_mgr_
unsigned int mode() const
const unsigned kLookupDefault
bool GetDirentForPath(const PathString &path, catalog::DirectoryEntry *dirent)
int SetLimitNoFile(unsigned limit_nofile)
static LibGlobals * instance_
#define LIBCVMFS_VERSION_MAJOR
std::map< std::string, FieldT > GetValues() const
BigVector< FileChunk > FileChunkList
catalog::ClientCatalogManager * catalog_mgr()
int64_t Pread(int fd, void *buf, uint64_t size, uint64_t off)
static loader::Failures Initialize(OptionsManager *options_mgr)
int ListNestedCatalogs(const char *path, char ***buf, size_t *buflen)
#define LIBCVMFS_REVISION
uint64_t size
unzipped size, if known
#define LIBCVMFS_VERSION_MINOR
int Fetch(const CacheManager::LabeledObject &object, const std::string &alt_url="")
MountPoint * mount_point_
FileSystem * file_system()
zlib::Algorithms compression_algorithm() const
CacheManager * cache_mgr()
uint64_t ctr_chunked_size
LoadReturn RemountDryrun()
unsigned FindChunkIdx(const uint64_t offset)
int cvm_is_hash_artificial
void AppendStatToList(const cvmfs_stat_t st, cvmfs_stat_t **buf, size_t *listlen, size_t *buflen)
LinkString symlink() const
IoErrorInfo * io_error_info()
download::DownloadManager * download_mgr()
int ListDirectoryStat(const char *c_path, cvmfs_stat_t **buf, size_t *listlen, size_t *buflen)
void Inc(class Counter *counter)
virtual int Close(int fd)=0
bool GetValue(const std::string &key, std::string *value) const
OptionsManager * options_mgr_
shash::Algorithms hash_algorithm() const
static LibGlobals * GetInstance()
bool ListCatalogSkein(const PathString &path, std::vector< PathString > *result_list)
cvmfs::Fetcher * external_fetcher()
int Add(FileChunkReflist chunks)
static FileSystem * Create(const FileSystemInfo &fs_info)
zlib::Algorithms zip_algorithm
int Open(const char *c_path)
std::string ToString() const
uint64_t GetRevision() const
int ListDirectory(const char *path, char ***buf, size_t *listlen, size_t *buflen, bool self_reference)
uint64_t String2Uint64(const string &value)
CVMFS_EXPORT void SetupLibcryptoMt()
bool ListFileChunks(const PathString &path, const shash::Algorithms interpret_hashes_as, FileChunkList *chunks)
shash::Any HashChunkList()
FileSystem * file_system_
void AppendStringToList(char const *str, char ***buf, size_t *listlen, size_t *buflen)
PathString GetParentPath(const PathString &path)
FileSystem * file_system_
int Readlink(const char *path, char *buf, size_t size)
SimpleChunkTables * simple_chunk_tables()
bool LookupXattrs(const PathString &path, XattrList *xattrs)
bool LookupNested(const PathString &path, PathString *mountpoint, shash::Any *hash, uint64_t *size)
InterruptCue default_interrupt_cue_
void CvmfsAttrFromDirent(const catalog::DirectoryEntry dirent, struct cvmfs_attr *attr)
OptionsManager * options_mgr_
inode_t GetRootInode() const
unsigned GetLength() const
static const int kLabelExternal
static const int kLabelChunked
void PrintError(const string &message)
const char * c_str() const
const char * GetChars() const
bool Insert(const shash::Md5 &hash, const catalog::DirectoryEntry &dirent)
virtual int64_t Pread(int fd, void *buf, uint64_t size, uint64_t offset)=0
static void CleanupInstance()
const Item * AtPtr(const size_t index) const
struct stat GetStatStructure() const
static MountPoint * Create(const std::string &fqrn, FileSystem *file_system, OptionsManager *options_mgr=NULL)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)
OptionsManager * options_mgr