CernVM-FS  2.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
libcvmfs_int.cc
Go to the documentation of this file.
1 
9 #define ENOATTR ENODATA
11 // clang-format off
12 #include <sys/xattr.h>
13 // clang-format on
14 
15 #include "libcvmfs_int.h"
16 
17 #include <dirent.h>
18 #include <errno.h>
19 #include <fcntl.h>
20 #include <pthread.h>
21 #include <stddef.h>
22 #include <stdint.h>
23 #include <sys/errno.h>
24 #include <sys/file.h>
25 #include <sys/mount.h>
26 #include <sys/resource.h>
27 #include <sys/stat.h>
28 
29 #include <google/dense_hash_map>
30 #ifndef __APPLE__
31 #include <sys/statfs.h>
32 #endif
33 #include <sys/time.h>
34 #include <sys/types.h>
35 #include <sys/wait.h>
36 #include <unistd.h>
37 
38 #include <algorithm>
39 #include <cassert>
40 #include <csignal>
41 #include <cstdio>
42 #include <cstdlib>
43 #include <cstring>
44 #include <ctime>
45 #include <functional>
46 #include <map>
47 #include <string>
48 #include <vector>
49 
50 #include "cache_posix.h"
51 #include "catalog.h"
52 #include "catalog_mgr_client.h"
53 #include "clientctx.h"
55 #include "crypto/crypto_util.h"
56 #include "crypto/hash.h"
57 #include "crypto/signature.h"
58 #include "directory_entry.h"
59 #include "duplex_sqlite3.h"
60 #include "fetch.h"
61 #include "globals.h"
62 #include "interrupt.h"
63 #include "libcvmfs.h"
64 #include "lru_md.h"
65 #include "network/download.h"
66 #include "quota.h"
67 #include "shortstring.h"
68 #include "sqlitemem.h"
69 #include "sqlitevfs.h"
70 #include "util/atomic.h"
71 #include "util/logging.h"
72 #include "util/murmur.hxx"
73 #include "util/posix.h"
74 #include "util/smalloc.h"
75 #include "util/string.h"
76 #include "xattr.h"
77 
78 using namespace std; // NOLINT
79 
80 // TODO(jblomer): remove. Only needed to satisfy monitor.cc
81 namespace cvmfs {
82 pid_t pid_ = 0;
83 }
84 
85 
89  return LibGlobals::instance_;
90 }
91 
92 
97  LogCvmfs(kLogCvmfs, kLogStdout, "LibCvmfs version %d.%d, revision %d",
99 
100  assert(options_mgr != NULL);
101  assert(instance_ == NULL);
102  instance_ = new LibGlobals();
103  assert(instance_ != NULL);
104 
105  // Multi-threaded libcrypto (otherwise done by the loader)
107 
109  fs_info.name = "libcvmfs";
110  fs_info.type = FileSystem::kFsLibrary;
111  fs_info.options_mgr = options_mgr;
112  instance_->file_system_ = FileSystem::Create(fs_info);
113 
114  if (instance_->file_system_->boot_status() != loader::kFailOk)
115  return instance_->file_system_->boot_status();
116 
117  // Maximum number of open files, handled otherwise as root by the fuse loader
118  string arg;
119  if (options_mgr->GetValue("CVMFS_NFILES", &arg)) {
120  const int retval = SetLimitNoFile(String2Uint64(arg));
121  if (retval != 0) {
122  PrintError("Failed to set maximum number of open files, "
123  "insufficient permissions");
125  }
126  }
127 
128  return loader::kFailOk;
129 }
130 
131 
133  if (instance_ != NULL) {
134  delete instance_;
135  instance_ = NULL;
136  }
137  assert(instance_ == NULL);
138 }
139 
140 
142 
143 
145  delete file_system_;
146  delete options_mgr_;
147 
149 }
150 
151 
152 //------------------------------------------------------------------------------
153 
154 
155 LibContext *LibContext::Create(const string &fqrn,
156  OptionsManager *options_mgr) {
157  assert(options_mgr != NULL);
158  LibContext *ctx = new LibContext();
159  assert(ctx != NULL);
160 
162  fqrn, LibGlobals::GetInstance()->file_system(), options_mgr);
163  return ctx;
164 }
165 
166 
168 
169 
171  delete mount_point_;
172  delete options_mgr_;
173 }
174 
177 }
178 
180  catalog::DirectoryEntry *dirent) {
181  if (path.GetLength() == 1 && path.GetChars()[0] == '/') {
182  // root path is expected to be "", not "/"
183  const PathString p;
184  return GetDirentForPath(p, dirent);
185  }
186  const shash::Md5 md5path(path.GetChars(), path.GetLength());
187  if (mount_point_->md5path_cache()->Lookup(md5path, dirent))
188  return dirent->GetSpecial() != catalog::kDirentNegative;
189 
190  // TODO(jblomer): not twice md5 calculation
192  dirent)) {
193  mount_point_->md5path_cache()->Insert(md5path, *dirent);
194  return true;
195  }
196 
197  LogCvmfs(kLogCvmfs, kLogDebug, "GetDirentForPath, no entry");
198  // Only cache real ENOENT errors, not catalog load errors
199  if (dirent->GetSpecial() == catalog::kDirentNegative)
201 
202  return false;
203 }
204 
205 
206 void LibContext::AppendStringToList(char const *str,
207  char ***buf,
208  size_t *listlen,
209  size_t *buflen) {
210  if (*listlen + 1 >= *buflen) {
211  const size_t newbuflen = (*listlen) * 2 + 5;
212  *buf = reinterpret_cast<char **>(realloc(*buf, sizeof(char *) * newbuflen));
213  assert(*buf);
214  *buflen = newbuflen;
215  assert(*listlen < *buflen);
216  }
217  if (str) {
218  (*buf)[(*listlen)] = strdup(str);
219  // null-terminate the list
220  (*buf)[++(*listlen)] = NULL;
221  } else {
222  (*buf)[(*listlen)] = NULL;
223  }
224 }
225 
226 
228  cvmfs_stat_t **buf,
229  size_t *listlen,
230  size_t *buflen) {
231  if (*listlen + 1 >= *buflen) {
232  const size_t newbuflen = (*listlen) * 2 + 5;
233  *buf = reinterpret_cast<cvmfs_stat_t *>(
234  realloc(*buf, sizeof(cvmfs_stat_t) * newbuflen));
235  assert(*buf);
236  *buflen = newbuflen;
237  assert(*listlen < *buflen);
238  }
239  (*buf)[(*listlen)].info = st.info;
240  (*buf)[(*listlen)++].name = st.name;
241 }
242 
243 int LibContext::GetAttr(const char *c_path, struct stat *info) {
244  perf::Inc(file_system()->n_fs_stat());
245  const ClientCtxGuard ctxg(geteuid(), getegid(), getpid(),
247 
248  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_getattr (stat) for path: %s", c_path);
249 
250  PathString p;
251  p.Assign(c_path, strlen(c_path));
252 
254  const bool found = GetDirentForPath(p, &dirent);
255 
256  if (!found) {
257  return -ENOENT;
258  }
259 
260  *info = dirent.GetStatStructure();
261  return 0;
262 }
263 
265  struct cvmfs_attr *attr) {
266  attr->st_ino = dirent.inode();
267  attr->st_mode = dirent.mode();
268  attr->st_nlink = dirent.linkcount();
269  attr->st_uid = dirent.uid();
270  attr->st_gid = dirent.gid();
271  attr->st_rdev = dirent.rdev();
272  attr->st_size = dirent.size();
273  attr->mtime = dirent.mtime();
274  attr->cvm_checksum = strdup(dirent.checksum().ToString().c_str());
275  attr->cvm_symlink = strdup(dirent.symlink().c_str());
276  attr->cvm_name = strdup(dirent.name().c_str());
277  attr->cvm_xattrs = NULL;
278 }
279 
280 
281 int LibContext::GetExtAttr(const char *c_path, struct cvmfs_attr *info) {
282  const ClientCtxGuard ctxg(geteuid(), getegid(), getpid(),
284 
285  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_getattr (stat) for path: %s", c_path);
286 
287  PathString p;
288  p.Assign(c_path, strlen(c_path));
289 
291  const bool found = GetDirentForPath(p, &dirent);
292 
293  if (!found) {
294  return -ENOENT;
295  }
296 
297  CvmfsAttrFromDirent(dirent, info);
298  // Chunked files without bulk hash need to be treated specially
299  info->cvm_nchunks = 0;
300  info->cvm_is_hash_artificial = 0;
301  if (dirent.IsRegular()) {
302  info->cvm_nchunks = 1;
303  if (dirent.IsChunkedFile()) {
304  FileChunkList *chunks = new FileChunkList();
306  chunks);
307  assert(!chunks->IsEmpty());
308  info->cvm_nchunks = chunks->size();
309  if (dirent.checksum().IsNull()) {
310  info->cvm_is_hash_artificial = 1;
311  free(info->cvm_checksum);
312  FileChunkReflist chunks_reflist(
313  chunks, p, dirent.compression_algorithm(), dirent.IsExternalFile());
314  const std::string hash_str = chunks_reflist.HashChunkList().ToString();
315  info->cvm_checksum = strdup(hash_str.c_str());
316  }
317  delete chunks;
318  }
319  }
320 
321  info->cvm_parent = strdup(GetParentPath(c_path).c_str());
322  if (dirent.HasXattrs()) {
323  XattrList *xattrs = new XattrList();
324  mount_point_->catalog_mgr()->LookupXattrs(p, xattrs);
325  info->cvm_xattrs = xattrs;
326  }
327  return 0;
328 }
329 
330 
331 int LibContext::Readlink(const char *c_path, char *buf, size_t size) {
332  perf::Inc(file_system()->n_fs_readlink());
333  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_readlink on path: %s", c_path);
334  const ClientCtxGuard ctxg(geteuid(), getegid(), getpid(),
336 
337  PathString p;
338  p.Assign(c_path, strlen(c_path));
339 
341  const bool found = GetDirentForPath(p, &dirent);
342 
343  if (!found) {
344  return -ENOENT;
345  }
346 
347  if (!dirent.IsLink()) {
348  return -EINVAL;
349  }
350 
351  const unsigned len = (dirent.symlink().GetLength() >= size)
352  ? size
353  : dirent.symlink().GetLength() + 1;
354  strncpy(buf, dirent.symlink().c_str(), len - 1);
355  buf[len - 1] = '\0';
356 
357  return 0;
358 }
359 
360 int LibContext::ListDirectory(const char *c_path,
361  char ***buf,
362  size_t *listlen,
363  size_t *buflen,
364  bool self_reference) {
365  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_listdir on path: %s", c_path);
366  const ClientCtxGuard ctxg(geteuid(), getegid(), getpid(),
368 
369  if (c_path[0] == '/' && c_path[1] == '\0') {
370  // root path is expected to be "", not "/"
371  c_path = "";
372  }
373 
374  PathString path;
375  path.Assign(c_path, strlen(c_path));
376 
378  const bool found = GetDirentForPath(path, &d);
379 
380  if (!found) {
381  return -ENOENT;
382  }
383 
384  if (!d.IsDirectory()) {
385  return -ENOTDIR;
386  }
387 
388  AppendStringToList(NULL, buf, listlen, buflen);
389 
390  // Build listing
391 
392  if (self_reference) {
393  // Add current directory link
394  AppendStringToList(".", buf, listlen, buflen);
395 
396  // Add parent directory link
397  const catalog::DirectoryEntry p;
398  if (d.inode() != mount_point_->catalog_mgr()->GetRootInode()) {
399  AppendStringToList("..", buf, listlen, buflen);
400  }
401  }
402 
403  // Add all names
404  catalog::StatEntryList listing_from_catalog;
405  if (!mount_point_->catalog_mgr()->ListingStat(path, &listing_from_catalog)) {
406  return -EIO;
407  }
408  for (unsigned i = 0; i < listing_from_catalog.size(); ++i) {
409  AppendStringToList(listing_from_catalog.AtPtr(i)->name.c_str(), buf,
410  listlen, buflen);
411  }
412 
413  return 0;
414 }
415 
416 int LibContext::ListDirectoryStat(const char *c_path,
417  cvmfs_stat_t **buf,
418  size_t *listlen,
419  size_t *buflen) {
420  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_listdir_stat on path: %s", c_path);
421  const ClientCtxGuard ctxg(geteuid(), getegid(), getpid(),
423 
424  if (c_path[0] == '/' && c_path[1] == '\0') {
425  // root path is expected to be "", not "/"
426  c_path = "";
427  }
428 
429  PathString path;
430  path.Assign(c_path, strlen(c_path));
431 
433  const bool found = GetDirentForPath(path, &d);
434 
435  if (!found) {
436  return -ENOENT;
437  }
438 
439  if (!d.IsDirectory()) {
440  return -ENOTDIR;
441  }
442 
443  // Build listing
444  catalog::StatEntryList listing_from_catalog;
445  if (!mount_point_->catalog_mgr()->ListingStat(path, &listing_from_catalog)) {
446  return -EIO;
447  }
448  for (unsigned i = 0; i < listing_from_catalog.size(); ++i) {
449  cvmfs_stat_t st;
450  st.info = listing_from_catalog.AtPtr(i)->info;
451  st.name = strdup(listing_from_catalog.AtPtr(i)->name.c_str());
452  AppendStatToList(st, buf, listlen, buflen);
453  }
454 
455  return 0;
456 }
457 
458 int LibContext::GetNestedCatalogAttr(const char *c_path,
459  struct cvmfs_nc_attr *nc_attr) {
460  const ClientCtxGuard ctxg(geteuid(), getegid(), getpid(),
462  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_stat_nc (cvmfs_nc_attr) : %s", c_path);
463 
464  PathString p;
465  p.Assign(c_path, strlen(c_path));
466 
467  PathString mountpoint;
468  shash::Any hash;
469  uint64_t size;
470 
471  // Find the nested catalog from the root catalog
472  const bool found = mount_point_->catalog_mgr()->LookupNested(p, &mountpoint,
473  &hash, &size);
474  if (!found) {
475  return -ENOENT;
476  }
477 
478  std::string subcat_path;
479  shash::Any tmp_hash;
480  std::map<std::string, uint64_t> counters = mount_point_->catalog_mgr()
481  ->LookupCounters(
482  p, &subcat_path, &tmp_hash)
483  .GetValues();
484 
485  // Set values of the passed structure
486  nc_attr->mountpoint = strdup(mountpoint.ToString().c_str());
487  nc_attr->hash = strdup(hash.ToString().c_str());
488  nc_attr->size = size;
489 
490  nc_attr->ctr_regular = counters["regular"];
491  nc_attr->ctr_symlink = counters["symlink"];
492  nc_attr->ctr_special = counters["special"];
493  nc_attr->ctr_dir = counters["dir"];
494  nc_attr->ctr_nested = counters["nested"];
495  nc_attr->ctr_chunked = counters["chunked"];
496  nc_attr->ctr_chunks = counters["chunks"];
497  nc_attr->ctr_file_size = counters["file_size"];
498  nc_attr->ctr_chunked_size = counters["chunked_size"];
499  nc_attr->ctr_xattr = counters["xattr"];
500  nc_attr->ctr_external = counters["external"];
501  nc_attr->ctr_external_file_size = counters["external_file_size"];
502  return 0;
503 }
504 
505 
506 int LibContext::ListNestedCatalogs(const char *c_path,
507  char ***buf,
508  size_t *buflen) {
509  const ClientCtxGuard ctxg(geteuid(), getegid(), getpid(),
511  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_list_nc on path: %s", c_path);
512 
513  if (c_path[0] == '/' && c_path[1] == '\0') {
514  // root path is expected to be "", not "/"
515  c_path = "";
516  }
517 
518  PathString path;
519  path.Assign(c_path, strlen(c_path));
520 
521  std::vector<PathString> skein;
522  const bool retval =
523  mount_point_->catalog_mgr()->ListCatalogSkein(path, &skein);
524  if (!retval) {
526  "cvmfs_list_nc failed to find skein of path: %s", c_path);
527  return 1;
528  }
529 
530  size_t listlen = 0;
531  AppendStringToList(NULL, buf, &listlen, buflen);
532 
533  for (unsigned i = 0; i < skein.size(); i++) {
534  AppendStringToList(skein.at(i).c_str(), buf, &listlen, buflen);
535  }
536 
537  return 0;
538 }
539 
540 
541 int LibContext::Open(const char *c_path) {
542  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_open on path: %s", c_path);
543  const ClientCtxGuard ctxg(geteuid(), getegid(), getpid(),
545 
546  int fd = -1;
548  PathString path;
549  path.Assign(c_path, strlen(c_path));
550 
551  const bool found = GetDirentForPath(path, &dirent);
552 
553  if (!found) {
554  return -ENOENT;
555  }
556 
557  if (dirent.IsChunkedFile()) {
559  "chunked file %s opened (download delayed to read() call)",
560  path.c_str());
561 
562  FileChunkList *chunks = new FileChunkList();
564  path, dirent.hash_algorithm(), chunks)
565  || chunks->IsEmpty()) {
567  "file %s is marked as "
568  "'chunked', but no chunks found.",
569  path.c_str());
571  delete chunks;
572  return -EIO;
573  }
574 
576  chunks, path, dirent.compression_algorithm(), dirent.IsExternalFile()));
577  return fd | kFdChunked;
578  }
579 
580  cvmfs::Fetcher *this_fetcher = dirent.IsExternalFile()
582  : mount_point_->fetcher();
583  CacheManager::Label label;
584  label.path = std::string(path.GetChars(), path.GetLength());
585  label.size = dirent.size();
586  label.zip_algorithm = dirent.compression_algorithm();
587  if (dirent.IsExternalFile())
589  fd = this_fetcher->Fetch(
590  CacheManager::LabeledObject(dirent.checksum(), label));
591  perf::Inc(file_system()->n_fs_open());
592 
593  if (fd >= 0) {
594  LogCvmfs(kLogCvmfs, kLogDebug, "file %s opened (fd %d)", path.c_str(), fd);
595  return fd;
596  } else {
598  "failed to open path: %s, CAS key %s, error code %d", c_path,
599  dirent.checksum().ToString().c_str(), errno);
600  if (errno == EMFILE) {
601  return -EMFILE;
602  }
603  }
604 
606  return fd;
607 }
608 
609 
610 int64_t LibContext::Pread(int fd, void *buf, uint64_t size, uint64_t off) {
611  if (fd & kFdChunked) {
612  const ClientCtxGuard ctxg(geteuid(), getegid(), getpid(),
614  const int chunk_handle = fd & ~kFdChunked;
616  open_chunks = mount_point_->simple_chunk_tables()->Get(chunk_handle);
617  FileChunkList *chunk_list = open_chunks.chunk_reflist.list;
618  const zlib::Algorithms compression_alg =
619  open_chunks.chunk_reflist.compression_alg;
620  if (chunk_list == NULL)
621  return -EBADF;
622 
623  // Fetch all needed chunks and read the requested data
624  unsigned chunk_idx = open_chunks.chunk_reflist.FindChunkIdx(off);
625  uint64_t overall_bytes_fetched = 0;
626  off_t offset_in_chunk = off - chunk_list->AtPtr(chunk_idx)->offset();
627  do {
628  // Open file descriptor to chunk
629  ChunkFd *chunk_fd = open_chunks.chunk_fd;
630  if ((chunk_fd->fd == -1) || (chunk_fd->chunk_idx != chunk_idx)) {
631  if (chunk_fd->fd != -1)
632  file_system()->cache_mgr()->Close(chunk_fd->fd);
633  cvmfs::Fetcher *this_fetcher = open_chunks.chunk_reflist.external_data
635  : mount_point_->fetcher();
636  CacheManager::Label label;
637  label.path = std::string(open_chunks.chunk_reflist.path.GetChars(),
638  open_chunks.chunk_reflist.path.GetLength());
639  label.size = chunk_list->AtPtr(chunk_idx)->size();
640  label.zip_algorithm = compression_alg;
642  if (open_chunks.chunk_reflist.external_data) {
644  label.range_offset = chunk_list->AtPtr(chunk_idx)->offset();
645  }
646  chunk_fd->fd = this_fetcher->Fetch(CacheManager::LabeledObject(
647  chunk_list->AtPtr(chunk_idx)->content_hash(), label));
648  if (chunk_fd->fd < 0) {
649  chunk_fd->fd = -1;
650  return -EIO;
651  }
652  chunk_fd->chunk_idx = chunk_idx;
653  }
654 
655  LogCvmfs(kLogCvmfs, kLogDebug, "reading from chunk fd %d", chunk_fd->fd);
656  // Read data from chunk
657  const size_t bytes_to_read = size - overall_bytes_fetched;
658  const size_t remaining_bytes_in_chunk = chunk_list->AtPtr(chunk_idx)
659  ->size()
660  - offset_in_chunk;
661  const size_t bytes_to_read_in_chunk =
662  std::min(bytes_to_read, remaining_bytes_in_chunk);
663  const int64_t bytes_fetched = file_system()->cache_mgr()->Pread(
664  chunk_fd->fd,
665  reinterpret_cast<char *>(buf) + overall_bytes_fetched,
666  bytes_to_read_in_chunk,
667  offset_in_chunk);
668 
669  if (bytes_fetched < 0) {
670  LogCvmfs(kLogCvmfs, kLogSyslogErr, "read err no %ld (%s)",
671  bytes_fetched,
672  open_chunks.chunk_reflist.path.ToString().c_str());
673  return -bytes_fetched;
674  }
675  overall_bytes_fetched += bytes_fetched;
676 
677  // Proceed to the next chunk to keep on reading data
678  ++chunk_idx;
679  offset_in_chunk = 0;
680  } while ((overall_bytes_fetched < size)
681  && (chunk_idx < chunk_list->size()));
682  return overall_bytes_fetched;
683  } else {
684  return file_system()->cache_mgr()->Pread(fd, buf, size, off);
685  }
686 }
687 
688 
689 int LibContext::Close(int fd) {
690  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_close on file number: %d", fd);
691  if (fd & kFdChunked) {
692  const int chunk_handle = fd & ~kFdChunked;
693  const SimpleChunkTables::OpenChunks open_chunks =
694  mount_point_->simple_chunk_tables()->Get(chunk_handle);
695  if (open_chunks.chunk_reflist.list == NULL)
696  return -EBADF;
697  if (open_chunks.chunk_fd->fd != -1)
698  file_system()->cache_mgr()->Close(open_chunks.chunk_fd->fd);
699  mount_point_->simple_chunk_tables()->Release(chunk_handle);
700  } else {
701  file_system()->cache_mgr()->Close(fd);
702  }
703  return 0;
704 }
705 
707  LogCvmfs(kLogCvmfs, kLogDebug, "remounting root catalog");
709 
710  switch (retval) {
712  LogCvmfs(kLogCvmfs, kLogDebug, "catalog up to date");
713  return 0;
714 
715  case catalog::kLoadNew:
716  retval = mount_point_->catalog_mgr()->Remount();
717 
718  if (retval != catalog::kLoadUp2Date && retval != catalog::kLoadNew) {
720  "Remount requested to switch catalog but failed");
721  return -1;
722  }
723 
725  LogCvmfs(kLogCvmfs, kLogDebug, "switched to catalog revision %" PRIu64,
727  return 0;
728 
729  default:
730  return -1;
731  }
732 }
733 
734 
736  return mount_point_->catalog_mgr()->GetRevision();
737 }
uint32_t linkcount() const
nlink_t st_nlink
Definition: libcvmfs.h:159
char * cvm_symlink
Definition: libcvmfs.h:172
bool IsExternalFile() const
uint64_t GetRevision()
catalog::Counters LookupCounters(const PathString &path, std::string *subcatalog_path, shash::Any *hash)
bool IsNull() const
Definition: hash.h:371
struct cvmcache_context * ctx
static LibContext * Create(const std::string &fqrn, OptionsManager *options_mgr)
bool InsertNegative(const shash::Md5 &hash)
Definition: lru_md.h:118
FileChunkReflist chunk_reflist
Definition: file_chunk.h:140
void EnableMultiThreaded()
time_t mtime() const
bool IsDirectory() const
uint64_t ctr_external_file_size
Definition: libcvmfs.h:133
off_t range_offset
Definition: cache.h:127
char * cvm_name
Definition: libcvmfs.h:174
char * mountpoint
Definition: libcvmfs.h:117
static const int kFdChunked
Definition: libcvmfs_int.h:126
int GetNestedCatalogAttr(const char *c_path, struct cvmfs_nc_attr *nc_attr)
cvmfs::Fetcher * fetcher()
Definition: mountpoint.h:516
bool IsChunkedFile() const
SpecialDirents GetSpecial() const
uint64_t size() const
std::string ToString(const bool with_suffix=false) const
Definition: hash.h:241
void Assign(const char *chars, const unsigned length)
Definition: shortstring.h:61
zlib::Algorithms compression_alg
Definition: file_chunk.h:65
OpenChunks Get(int fd)
Definition: file_chunk.cc:187
int Close(int fd)
bool Lookup(const shash::Md5 &hash, catalog::DirectoryEntry *dirent, bool update_lru=true)
Definition: lru_md.h:125
CVMFS_EXPORT void CleanupLibcryptoMt()
Definition: crypto_util.cc:66
uint64_t ctr_external
Definition: libcvmfs.h:132
const shash::Any & content_hash() const
Definition: file_chunk.h:37
inode_t inode() const
bool ListingStat(const PathString &path, StatEntryList *listing)
assert((mem||(size==0))&&"Out Of Memory")
MountPoint * mount_point_
Definition: cvmfs.cc:131
char * cvm_parent
Definition: libcvmfs.h:173
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)
int fd
Definition: file_chunk.h:76
lru::Md5PathCache * md5path_cache()
Definition: mountpoint.h:531
shash::Any checksum() const
void ReEvaluateAuthz()
Definition: mountpoint.cc:1912
OptionsManager * options_mgr_
Definition: libcvmfs_int.h:150
unsigned int mode() const
const unsigned kLookupDefault
Definition: catalog_mgr.h:43
uint64_t ctr_xattr
Definition: libcvmfs.h:131
bool GetDirentForPath(const PathString &path, catalog::DirectoryEntry *dirent)
int SetLimitNoFile(unsigned limit_nofile)
Definition: posix.cc:1456
char * cvm_checksum
Definition: libcvmfs.h:171
static LibGlobals * instance_
Definition: libcvmfs_int.h:73
#define LIBCVMFS_VERSION_MAJOR
Definition: libcvmfs.h:19
char * hash
Definition: libcvmfs.h:118
pid_t pid_
Definition: cvmfs.cc:156
uint64_t ctr_regular
Definition: libcvmfs.h:122
PathString path
Definition: file_chunk.h:64
std::map< std::string, FieldT > GetValues() const
NameString name() const
bool IsLink() const
Algorithms
Definition: compression.h:44
BigVector< FileChunk > FileChunkList
Definition: file_chunk.h:47
bool HasXattrs() const
catalog::ClientCatalogManager * catalog_mgr()
Definition: mountpoint.h:507
void * cvm_xattrs
Definition: libcvmfs.h:175
int64_t Pread(int fd, void *buf, uint64_t size, uint64_t off)
static loader::Failures Initialize(OptionsManager *options_mgr)
Definition: libcvmfs_int.cc:96
int ListNestedCatalogs(const char *path, char ***buf, size_t *buflen)
#define LIBCVMFS_REVISION
Definition: libcvmfs.h:47
bool IsRegular() const
uint64_t size
unzipped size, if known
Definition: cache.h:125
#define LIBCVMFS_VERSION_MINOR
Definition: libcvmfs.h:20
int Fetch(const CacheManager::LabeledObject &object, const std::string &alt_url="")
Definition: fetch.cc:82
MountPoint * mount_point_
Definition: libcvmfs_int.h:151
time_t mtime
Definition: libcvmfs.h:164
FileSystem * file_system()
Definition: libcvmfs_int.h:131
gid_t st_gid
Definition: libcvmfs.h:161
off_t offset() const
Definition: file_chunk.h:38
zlib::Algorithms compression_algorithm() const
CacheManager * cache_mgr()
Definition: mountpoint.h:205
unsigned chunk_idx
Definition: file_chunk.h:77
uint64_t ctr_chunked_size
Definition: libcvmfs.h:130
off_t st_size
Definition: libcvmfs.h:163
unsigned FindChunkIdx(const uint64_t offset)
Definition: file_chunk.cc:23
int cvm_is_hash_artificial
Definition: libcvmfs.h:168
void AppendStatToList(const cvmfs_stat_t st, cvmfs_stat_t **buf, size_t *listlen, size_t *buflen)
LinkString symlink() const
IoErrorInfo * io_error_info()
Definition: mountpoint.h:233
download::DownloadManager * download_mgr()
Definition: mountpoint.h:509
char * name
Definition: libcvmfs.h:184
Failures
Definition: loader.h:27
int ListDirectoryStat(const char *c_path, cvmfs_stat_t **buf, size_t *listlen, size_t *buflen)
void Inc(class Counter *counter)
Definition: statistics.h:50
virtual int Close(int fd)=0
bool GetValue(const std::string &key, std::string *value) const
Definition: options.cc:369
OptionsManager * options_mgr_
Definition: cvmfs.cc:155
shash::Algorithms hash_algorithm() const
static LibGlobals * GetInstance()
Definition: libcvmfs_int.cc:87
bool ListCatalogSkein(const PathString &path, std::vector< PathString > *result_list)
cvmfs::Fetcher * external_fetcher()
Definition: mountpoint.h:520
int Add(FileChunkReflist chunks)
Definition: file_chunk.cc:167
static FileSystem * Create(const FileSystemInfo &fs_info)
Definition: mountpoint.cc:164
bool IsEmpty() const
Definition: bigvector.h:70
uint64_t ctr_chunked
Definition: libcvmfs.h:127
zlib::Algorithms zip_algorithm
Definition: cache.h:126
int Open(const char *c_path)
std::string ToString() const
Definition: shortstring.h:139
int ListDirectory(const char *path, char ***buf, size_t *listlen, size_t *buflen, bool self_reference)
uint64_t String2Uint64(const string &value)
Definition: string.cc:240
CVMFS_EXPORT void SetupLibcryptoMt()
Definition: crypto_util.cc:48
bool ListFileChunks(const PathString &path, const shash::Algorithms interpret_hashes_as, FileChunkList *chunks)
ino_t st_ino
Definition: libcvmfs.h:157
uint64_t ctr_symlink
Definition: libcvmfs.h:123
uint64_t size
Definition: libcvmfs.h:119
shash::Any HashChunkList()
Definition: file_chunk.cc:49
size_t size() const
Definition: file_chunk.h:39
FileSystem * file_system_
Definition: libcvmfs_int.h:80
void AppendStringToList(char const *str, char ***buf, size_t *listlen, size_t *buflen)
uint64_t ctr_chunks
Definition: libcvmfs.h:128
PathString GetParentPath(const PathString &path)
Definition: shortstring.cc:14
uint64_t ctr_file_size
Definition: libcvmfs.h:129
FileSystem * file_system_
Definition: cvmfs.cc:130
int Readlink(const char *path, char *buf, size_t size)
SimpleChunkTables * simple_chunk_tables()
Definition: mountpoint.h:537
bool LookupXattrs(const PathString &path, XattrList *xattrs)
bool LookupNested(const PathString &path, PathString *mountpoint, shash::Any *hash, uint64_t *size)
InterruptCue default_interrupt_cue_
Definition: libcvmfs_int.h:157
uid_t st_uid
Definition: libcvmfs.h:160
uint64_t ctr_dir
Definition: libcvmfs.h:125
void Release(int fd)
Definition: file_chunk.cc:201
struct stat info
Definition: libcvmfs.h:185
std::string path
Definition: cache.h:133
uid_t uid() const
dev_t st_rdev
Definition: libcvmfs.h:162
void CvmfsAttrFromDirent(const catalog::DirectoryEntry dirent, struct cvmfs_attr *attr)
gid_t gid() const
OptionsManager * options_mgr_
Definition: libcvmfs_int.h:79
unsigned GetLength() const
Definition: shortstring.h:131
int cvm_nchunks
Definition: libcvmfs.h:167
uint64_t ctr_special
Definition: libcvmfs.h:124
static const int kLabelExternal
Definition: cache.h:83
static const int kLabelChunked
Definition: cache.h:84
void PrintError(const string &message)
Definition: logging.cc:556
const char * c_str() const
Definition: shortstring.h:143
const char * GetChars() const
Definition: shortstring.h:123
bool Insert(const shash::Md5 &hash, const catalog::DirectoryEntry &dirent)
Definition: lru_md.h:110
static void size_t size
Definition: smalloc.h:54
virtual int64_t Pread(int fd, void *buf, uint64_t size, uint64_t offset)=0
static void CleanupInstance()
FileChunkList * list
Definition: file_chunk.h:63
const Item * AtPtr(const size_t index) const
Definition: bigvector.h:53
struct stat GetStatStructure() const
dev_t rdev() const
size_t size() const
Definition: bigvector.h:117
mode_t st_mode
Definition: libcvmfs.h:158
static MountPoint * Create(const std::string &fqrn, FileSystem *file_system, OptionsManager *options_mgr=NULL)
Definition: mountpoint.cc:1243
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)
Definition: logging.cc:545
uint64_t ctr_nested
Definition: libcvmfs.h:126
OptionsManager * options_mgr
Definition: mountpoint.h:139