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