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  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  PathString p;
184  return GetDirentForPath(p, dirent);
185  }
186  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  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  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  ClientCtxGuard ctxg(geteuid(), getegid(), getpid(), &default_interrupt_cue_);
246 
247  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_getattr (stat) for path: %s", c_path);
248 
249  PathString p;
250  p.Assign(c_path, strlen(c_path));
251 
253  const bool found = GetDirentForPath(p, &dirent);
254 
255  if (!found) {
256  return -ENOENT;
257  }
258 
259  *info = dirent.GetStatStructure();
260  return 0;
261 }
262 
264  struct cvmfs_attr *attr) {
265  attr->st_ino = dirent.inode();
266  attr->st_mode = dirent.mode();
267  attr->st_nlink = dirent.linkcount();
268  attr->st_uid = dirent.uid();
269  attr->st_gid = dirent.gid();
270  attr->st_rdev = dirent.rdev();
271  attr->st_size = dirent.size();
272  attr->mtime = dirent.mtime();
273  attr->cvm_checksum = strdup(dirent.checksum().ToString().c_str());
274  attr->cvm_symlink = strdup(dirent.symlink().c_str());
275  attr->cvm_name = strdup(dirent.name().c_str());
276  attr->cvm_xattrs = NULL;
277 }
278 
279 
280 int LibContext::GetExtAttr(const char *c_path, struct cvmfs_attr *info) {
281  ClientCtxGuard ctxg(geteuid(), getegid(), getpid(), &default_interrupt_cue_);
282 
283  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_getattr (stat) for path: %s", c_path);
284 
285  PathString p;
286  p.Assign(c_path, strlen(c_path));
287 
289  const bool found = GetDirentForPath(p, &dirent);
290 
291  if (!found) {
292  return -ENOENT;
293  }
294 
295  CvmfsAttrFromDirent(dirent, info);
296  // Chunked files without bulk hash need to be treated specially
297  info->cvm_nchunks = 0;
298  info->cvm_is_hash_artificial = 0;
299  if (dirent.IsRegular()) {
300  info->cvm_nchunks = 1;
301  if (dirent.IsChunkedFile()) {
302  FileChunkList *chunks = new FileChunkList();
304  chunks);
305  assert(!chunks->IsEmpty());
306  info->cvm_nchunks = chunks->size();
307  if (dirent.checksum().IsNull()) {
308  info->cvm_is_hash_artificial = 1;
309  free(info->cvm_checksum);
310  FileChunkReflist chunks_reflist(
311  chunks, p, dirent.compression_algorithm(), dirent.IsExternalFile());
312  std::string hash_str = chunks_reflist.HashChunkList().ToString();
313  info->cvm_checksum = strdup(hash_str.c_str());
314  }
315  delete chunks;
316  }
317  }
318 
319  info->cvm_parent = strdup(GetParentPath(c_path).c_str());
320  if (dirent.HasXattrs()) {
321  XattrList *xattrs = new XattrList();
322  mount_point_->catalog_mgr()->LookupXattrs(p, xattrs);
323  info->cvm_xattrs = xattrs;
324  }
325  return 0;
326 }
327 
328 
329 int LibContext::Readlink(const char *c_path, char *buf, size_t size) {
330  perf::Inc(file_system()->n_fs_readlink());
331  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_readlink on path: %s", c_path);
332  ClientCtxGuard ctxg(geteuid(), getegid(), getpid(), &default_interrupt_cue_);
333 
334  PathString p;
335  p.Assign(c_path, strlen(c_path));
336 
338  const bool found = GetDirentForPath(p, &dirent);
339 
340  if (!found) {
341  return -ENOENT;
342  }
343 
344  if (!dirent.IsLink()) {
345  return -EINVAL;
346  }
347 
348  unsigned len = (dirent.symlink().GetLength() >= size)
349  ? size
350  : dirent.symlink().GetLength() + 1;
351  strncpy(buf, dirent.symlink().c_str(), len - 1);
352  buf[len - 1] = '\0';
353 
354  return 0;
355 }
356 
357 int LibContext::ListDirectory(const char *c_path,
358  char ***buf,
359  size_t *listlen,
360  size_t *buflen,
361  bool self_reference) {
362  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_listdir on path: %s", c_path);
363  ClientCtxGuard ctxg(geteuid(), getegid(), getpid(), &default_interrupt_cue_);
364 
365  if (c_path[0] == '/' && c_path[1] == '\0') {
366  // root path is expected to be "", not "/"
367  c_path = "";
368  }
369 
370  PathString path;
371  path.Assign(c_path, strlen(c_path));
372 
374  const bool found = GetDirentForPath(path, &d);
375 
376  if (!found) {
377  return -ENOENT;
378  }
379 
380  if (!d.IsDirectory()) {
381  return -ENOTDIR;
382  }
383 
384  AppendStringToList(NULL, buf, listlen, buflen);
385 
386  // Build listing
387 
388  if (self_reference) {
389  // Add current directory link
390  AppendStringToList(".", buf, listlen, buflen);
391 
392  // Add parent directory link
394  if (d.inode() != mount_point_->catalog_mgr()->GetRootInode()) {
395  AppendStringToList("..", buf, listlen, buflen);
396  }
397  }
398 
399  // Add all names
400  catalog::StatEntryList listing_from_catalog;
401  if (!mount_point_->catalog_mgr()->ListingStat(path, &listing_from_catalog)) {
402  return -EIO;
403  }
404  for (unsigned i = 0; i < listing_from_catalog.size(); ++i) {
405  AppendStringToList(listing_from_catalog.AtPtr(i)->name.c_str(), buf,
406  listlen, buflen);
407  }
408 
409  return 0;
410 }
411 
412 int LibContext::ListDirectoryStat(const char *c_path,
413  cvmfs_stat_t **buf,
414  size_t *listlen,
415  size_t *buflen) {
416  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_listdir_stat on path: %s", c_path);
417  ClientCtxGuard ctxg(geteuid(), getegid(), getpid(), &default_interrupt_cue_);
418 
419  if (c_path[0] == '/' && c_path[1] == '\0') {
420  // root path is expected to be "", not "/"
421  c_path = "";
422  }
423 
424  PathString path;
425  path.Assign(c_path, strlen(c_path));
426 
428  const bool found = GetDirentForPath(path, &d);
429 
430  if (!found) {
431  return -ENOENT;
432  }
433 
434  if (!d.IsDirectory()) {
435  return -ENOTDIR;
436  }
437 
438  // Build listing
439  catalog::StatEntryList listing_from_catalog;
440  if (!mount_point_->catalog_mgr()->ListingStat(path, &listing_from_catalog)) {
441  return -EIO;
442  }
443  for (unsigned i = 0; i < listing_from_catalog.size(); ++i) {
444  cvmfs_stat_t st;
445  st.info = listing_from_catalog.AtPtr(i)->info;
446  st.name = strdup(listing_from_catalog.AtPtr(i)->name.c_str());
447  AppendStatToList(st, buf, listlen, buflen);
448  }
449 
450  return 0;
451 }
452 
453 int LibContext::GetNestedCatalogAttr(const char *c_path,
454  struct cvmfs_nc_attr *nc_attr) {
455  ClientCtxGuard ctxg(geteuid(), getegid(), getpid(), &default_interrupt_cue_);
456  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_stat_nc (cvmfs_nc_attr) : %s", c_path);
457 
458  PathString p;
459  p.Assign(c_path, strlen(c_path));
460 
461  PathString mountpoint;
462  shash::Any hash;
463  uint64_t size;
464 
465  // Find the nested catalog from the root catalog
466  const bool found = mount_point_->catalog_mgr()->LookupNested(p, &mountpoint,
467  &hash, &size);
468  if (!found) {
469  return -ENOENT;
470  }
471 
472  std::string subcat_path;
473  shash::Any tmp_hash;
474  std::map<std::string, uint64_t> counters = mount_point_->catalog_mgr()
475  ->LookupCounters(
476  p, &subcat_path, &tmp_hash)
477  .GetValues();
478 
479  // Set values of the passed structure
480  nc_attr->mountpoint = strdup(mountpoint.ToString().c_str());
481  nc_attr->hash = strdup(hash.ToString().c_str());
482  nc_attr->size = size;
483 
484  nc_attr->ctr_regular = counters["regular"];
485  nc_attr->ctr_symlink = counters["symlink"];
486  nc_attr->ctr_special = counters["special"];
487  nc_attr->ctr_dir = counters["dir"];
488  nc_attr->ctr_nested = counters["nested"];
489  nc_attr->ctr_chunked = counters["chunked"];
490  nc_attr->ctr_chunks = counters["chunks"];
491  nc_attr->ctr_file_size = counters["file_size"];
492  nc_attr->ctr_chunked_size = counters["chunked_size"];
493  nc_attr->ctr_xattr = counters["xattr"];
494  nc_attr->ctr_external = counters["external"];
495  nc_attr->ctr_external_file_size = counters["external_file_size"];
496  return 0;
497 }
498 
499 
500 int LibContext::ListNestedCatalogs(const char *c_path,
501  char ***buf,
502  size_t *buflen) {
503  ClientCtxGuard ctxg(geteuid(), getegid(), getpid(), &default_interrupt_cue_);
504  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_list_nc on path: %s", c_path);
505 
506  if (c_path[0] == '/' && c_path[1] == '\0') {
507  // root path is expected to be "", not "/"
508  c_path = "";
509  }
510 
511  PathString path;
512  path.Assign(c_path, strlen(c_path));
513 
514  std::vector<PathString> skein;
515  bool retval = mount_point_->catalog_mgr()->ListCatalogSkein(path, &skein);
516  if (!retval) {
518  "cvmfs_list_nc failed to find skein of path: %s", c_path);
519  return 1;
520  }
521 
522  size_t listlen = 0;
523  AppendStringToList(NULL, buf, &listlen, buflen);
524 
525  for (unsigned i = 0; i < skein.size(); i++) {
526  AppendStringToList(skein.at(i).c_str(), buf, &listlen, buflen);
527  }
528 
529  return 0;
530 }
531 
532 
533 int LibContext::Open(const char *c_path) {
534  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_open on path: %s", c_path);
535  ClientCtxGuard ctxg(geteuid(), getegid(), getpid(), &default_interrupt_cue_);
536 
537  int fd = -1;
539  PathString path;
540  path.Assign(c_path, strlen(c_path));
541 
542  const bool found = GetDirentForPath(path, &dirent);
543 
544  if (!found) {
545  return -ENOENT;
546  }
547 
548  if (dirent.IsChunkedFile()) {
550  "chunked file %s opened (download delayed to read() call)",
551  path.c_str());
552 
553  FileChunkList *chunks = new FileChunkList();
555  path, dirent.hash_algorithm(), chunks)
556  || chunks->IsEmpty()) {
558  "file %s is marked as "
559  "'chunked', but no chunks found.",
560  path.c_str());
562  delete chunks;
563  return -EIO;
564  }
565 
567  chunks, path, dirent.compression_algorithm(), dirent.IsExternalFile()));
568  return fd | kFdChunked;
569  }
570 
571  cvmfs::Fetcher *this_fetcher = dirent.IsExternalFile()
573  : mount_point_->fetcher();
574  CacheManager::Label label;
575  label.path = std::string(path.GetChars(), path.GetLength());
576  label.size = dirent.size();
577  label.zip_algorithm = dirent.compression_algorithm();
578  if (dirent.IsExternalFile())
580  fd = this_fetcher->Fetch(
581  CacheManager::LabeledObject(dirent.checksum(), label));
582  perf::Inc(file_system()->n_fs_open());
583 
584  if (fd >= 0) {
585  LogCvmfs(kLogCvmfs, kLogDebug, "file %s opened (fd %d)", path.c_str(), fd);
586  return fd;
587  } else {
589  "failed to open path: %s, CAS key %s, error code %d", c_path,
590  dirent.checksum().ToString().c_str(), errno);
591  if (errno == EMFILE) {
592  return -EMFILE;
593  }
594  }
595 
597  return fd;
598 }
599 
600 
601 int64_t LibContext::Pread(int fd, void *buf, uint64_t size, uint64_t off) {
602  if (fd & kFdChunked) {
603  ClientCtxGuard ctxg(geteuid(), getegid(), getpid(),
605  const int chunk_handle = fd & ~kFdChunked;
607  open_chunks = mount_point_->simple_chunk_tables()->Get(chunk_handle);
608  FileChunkList *chunk_list = open_chunks.chunk_reflist.list;
609  zlib::Algorithms compression_alg = open_chunks.chunk_reflist
611  if (chunk_list == NULL)
612  return -EBADF;
613 
614  // Fetch all needed chunks and read the requested data
615  unsigned chunk_idx = open_chunks.chunk_reflist.FindChunkIdx(off);
616  uint64_t overall_bytes_fetched = 0;
617  off_t offset_in_chunk = off - chunk_list->AtPtr(chunk_idx)->offset();
618  do {
619  // Open file descriptor to chunk
620  ChunkFd *chunk_fd = open_chunks.chunk_fd;
621  if ((chunk_fd->fd == -1) || (chunk_fd->chunk_idx != chunk_idx)) {
622  if (chunk_fd->fd != -1)
623  file_system()->cache_mgr()->Close(chunk_fd->fd);
624  cvmfs::Fetcher *this_fetcher = open_chunks.chunk_reflist.external_data
626  : mount_point_->fetcher();
627  CacheManager::Label label;
628  label.path = std::string(open_chunks.chunk_reflist.path.GetChars(),
629  open_chunks.chunk_reflist.path.GetLength());
630  label.size = chunk_list->AtPtr(chunk_idx)->size();
631  label.zip_algorithm = compression_alg;
633  if (open_chunks.chunk_reflist.external_data) {
635  label.range_offset = chunk_list->AtPtr(chunk_idx)->offset();
636  }
637  chunk_fd->fd = this_fetcher->Fetch(CacheManager::LabeledObject(
638  chunk_list->AtPtr(chunk_idx)->content_hash(), label));
639  if (chunk_fd->fd < 0) {
640  chunk_fd->fd = -1;
641  return -EIO;
642  }
643  chunk_fd->chunk_idx = chunk_idx;
644  }
645 
646  LogCvmfs(kLogCvmfs, kLogDebug, "reading from chunk fd %d", chunk_fd->fd);
647  // Read data from chunk
648  const size_t bytes_to_read = size - overall_bytes_fetched;
649  const size_t remaining_bytes_in_chunk = chunk_list->AtPtr(chunk_idx)
650  ->size()
651  - offset_in_chunk;
652  size_t bytes_to_read_in_chunk = std::min(bytes_to_read,
653  remaining_bytes_in_chunk);
654  const int64_t bytes_fetched = file_system()->cache_mgr()->Pread(
655  chunk_fd->fd,
656  reinterpret_cast<char *>(buf) + overall_bytes_fetched,
657  bytes_to_read_in_chunk,
658  offset_in_chunk);
659 
660  if (bytes_fetched < 0) {
661  LogCvmfs(kLogCvmfs, kLogSyslogErr, "read err no %ld (%s)",
662  bytes_fetched,
663  open_chunks.chunk_reflist.path.ToString().c_str());
664  return -bytes_fetched;
665  }
666  overall_bytes_fetched += bytes_fetched;
667 
668  // Proceed to the next chunk to keep on reading data
669  ++chunk_idx;
670  offset_in_chunk = 0;
671  } while ((overall_bytes_fetched < size)
672  && (chunk_idx < chunk_list->size()));
673  return overall_bytes_fetched;
674  } else {
675  return file_system()->cache_mgr()->Pread(fd, buf, size, off);
676  }
677 }
678 
679 
680 int LibContext::Close(int fd) {
681  LogCvmfs(kLogCvmfs, kLogDebug, "cvmfs_close on file number: %d", fd);
682  if (fd & kFdChunked) {
683  const int chunk_handle = fd & ~kFdChunked;
685  open_chunks = mount_point_->simple_chunk_tables()->Get(chunk_handle);
686  if (open_chunks.chunk_reflist.list == NULL)
687  return -EBADF;
688  if (open_chunks.chunk_fd->fd != -1)
689  file_system()->cache_mgr()->Close(open_chunks.chunk_fd->fd);
690  mount_point_->simple_chunk_tables()->Release(chunk_handle);
691  } else {
692  file_system()->cache_mgr()->Close(fd);
693  }
694  return 0;
695 }
696 
698  LogCvmfs(kLogCvmfs, kLogDebug, "remounting root catalog");
700 
701  switch (retval) {
703  LogCvmfs(kLogCvmfs, kLogDebug, "catalog up to date");
704  return 0;
705 
706  case catalog::kLoadNew:
707  retval = mount_point_->catalog_mgr()->Remount();
708 
709  if (retval != catalog::kLoadUp2Date && retval != catalog::kLoadNew) {
711  "Remount requested to switch catalog but failed");
712  return -1;
713  }
714 
716  LogCvmfs(kLogCvmfs, kLogDebug, "switched to catalog revision %" PRIu64,
718  return 0;
719 
720  default:
721  return -1;
722  }
723 }
724 
725 
727  return mount_point_->catalog_mgr()->GetRevision();
728 }
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:1909
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:1455
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:368
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