9 #define ENOATTR ENODATA
11 #include <sys/xattr.h>
18 #include <google/dense_hash_map>
22 #include <sys/errno.h>
24 #include <sys/mount.h>
25 #include <sys/resource.h>
28 #include <sys/statfs.h>
31 #include <sys/types.h>
98 assert(options_mgr != NULL);
101 assert(instance_ != NULL);
107 fs_info.
name =
"libcvmfs";
113 return instance_->file_system_->boot_status();
117 if (options_mgr->
GetValue(
"CVMFS_NFILES", &arg)) {
120 PrintError(
"Failed to set maximum number of open files, "
121 "insufficient permissions");
131 if (instance_ != NULL) {
135 assert(instance_ == NULL);
160 assert(options_mgr != NULL);
219 if (*listlen + 1 >= *buflen) {
220 size_t newbuflen = (*listlen)*2 + 5;
221 *buf =
reinterpret_cast<char **
>(
222 realloc(*buf,
sizeof(
char *) * newbuflen));
225 assert(*listlen < *buflen);
228 (*buf)[(*listlen)] = strdup(str);
230 (*buf)[++(*listlen)] = NULL;
232 (*buf)[(*listlen)] = NULL;
242 if (*listlen + 1 >= *buflen) {
243 size_t newbuflen = (*listlen)*2 + 5;
248 assert(*listlen < *buflen);
250 (*buf)[(*listlen)].info = st.
info;
251 (*buf)[(*listlen)++].name = st.
name;
261 p.
Assign(c_path, strlen(c_path));
299 p.
Assign(c_path, strlen(c_path));
348 p.
Assign(c_path, strlen(c_path));
379 if (c_path[0] ==
'/' && c_path[1] ==
'\0') {
385 path.
Assign(c_path, strlen(c_path));
402 if (self_reference) {
418 for (
unsigned i = 0; i < listing_from_catalog.
size(); ++i) {
420 buf, listlen, buflen);
434 if (c_path[0] ==
'/' && c_path[1] ==
'\0') {
440 path.
Assign(c_path, strlen(c_path));
458 for (
unsigned i = 0; i < listing_from_catalog.
size(); ++i) {
460 st.
info = listing_from_catalog.
AtPtr(i)->info;
461 st.
name = strdup(listing_from_catalog.
AtPtr(i)->name.c_str());
474 "cvmfs_stat_nc (cvmfs_nc_attr) : %s", c_path);
477 p.
Assign(c_path, strlen(c_path));
490 std::string subcat_path;
492 std::map<std::string, uint64_t> counters =
494 LookupCounters(p, &subcat_path, &tmp_hash).GetValues();
504 nc_attr->
ctr_dir = counters[
"dir"];
524 "cvmfs_list_nc on path: %s", c_path);
526 if (c_path[0] ==
'/' && c_path[1] ==
'\0') {
532 path.
Assign(c_path, strlen(c_path));
534 std::vector<PathString> skein;
538 "cvmfs_list_nc failed to find skein of path: %s", c_path);
545 for (
unsigned i = 0; i < skein.size(); i++) {
560 path.
Assign(c_path, strlen(c_path));
570 "chunked file %s opened (download delayed to read() call)",
579 "'chunked', but no chunks found.", path.
c_str());
610 "failed to open path: %s, CAS key %s, error code %d",
612 if (errno == EMFILE) {
631 const int chunk_handle = fd & ~kFdChunked;
637 if (chunk_list == NULL)
642 uint64_t overall_bytes_fetched = 0;
643 off_t offset_in_chunk = off - chunk_list->
AtPtr(chunk_idx)->
offset();
647 if ((chunk_fd->
fd == -1) || (chunk_fd->
chunk_idx != chunk_idx)) {
664 if (chunk_fd->
fd < 0) {
674 const size_t bytes_to_read = size - overall_bytes_fetched;
675 const size_t remaining_bytes_in_chunk =
676 chunk_list->
AtPtr(chunk_idx)->
size() - offset_in_chunk;
677 size_t bytes_to_read_in_chunk =
678 std::min(bytes_to_read, remaining_bytes_in_chunk);
681 reinterpret_cast<char *>(buf) + overall_bytes_fetched,
682 bytes_to_read_in_chunk,
685 if (bytes_fetched < 0) {
689 return -bytes_fetched;
691 overall_bytes_fetched += bytes_fetched;
696 }
while ((overall_bytes_fetched < size) &&
697 (chunk_idx < chunk_list->
size()));
698 return overall_bytes_fetched;
708 const int chunk_handle = fd & ~kFdChunked;
736 "Remount requested to switch catalog but failed");
uint32_t linkcount() const
bool IsExternalFile() const
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
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