8 #define _FILE_OFFSET_BITS 64
10 #ifndef __STDC_FORMAT_MACROS
11 #define __STDC_FORMAT_MACROS
14 #include "cvmfs_config.h"
42 attr =
reinterpret_cast<cvmfs_attr *
>(calloc(1,
sizeof(*attr)));
44 attr->
size =
sizeof(*attr);
69 attr =
reinterpret_cast<cvmfs_nc_attr *
>(calloc(1,
sizeof(*attr)));
93 string *expanded_path)
100 rc =
expand_path(depth, ctx, p_path.c_str(), expanded_path);
104 if (*expanded_path ==
"/") {
107 "libcvmfs cannot resolve symlinks to paths outside of the repo: "
113 if (*expanded_path ==
"") {
114 *expanded_path =
"/";
121 rc =
expand_path(depth, ctx, p_path.c_str(), &buf);
127 *expanded_path = buf;
132 if (buf.length() == 0 || buf[buf.length()-1] !=
'/') {
138 rc = ctx->
GetAttr(buf.c_str(), &st);
144 if (!S_ISLNK(st.st_mode)) {
145 *expanded_path = buf;
152 "libcvmfs hit its symlink recursion limit: %s", path);
159 char *ln_buf =
reinterpret_cast<char *
>(alloca(st.st_size+2));
164 rc = ctx->
Readlink(buf.c_str(), ln_buf, st.st_size + 2);
169 if (ln_buf[0] ==
'/') {
173 (ln_buf[len] ==
'/' || ln_buf[len] ==
'\0'))
176 if (ln_buf[len] ==
'\0') {
181 "libcvmfs can't resolve symlinks to paths outside of the repo: "
182 "%s --> %s (mountpoint=%s)",
197 return expand_path(depth + 1, ctx, buf.c_str(), expanded_path);
205 string *expanded_path)
211 *expanded_path = path;
215 int rc =
expand_path(0, ctx, p_path.c_str(), expanded_path);
220 (*expanded_path) +=
"/";
221 (*expanded_path) += fname;
234 path = lpath.c_str();
236 rc = ctx->
Open(path);
252 ssize_t nbytes = ctx->
Pread(fd, buf, size, off);
263 int rc = ctx->
Close(fd);
284 path = lpath.c_str();
286 rc = ctx->
Readlink(path, buf, size);
302 path = lpath.c_str();
320 path = lpath.c_str();
342 path = lpath.c_str();
365 path = lpath.c_str();
389 path = lpath.c_str();
412 path = lpath.c_str();
435 path = lpath.c_str();
458 path = lpath.c_str();
501 fqrn, (*ctx)->mount_point()->boot_error().c_str(), result);
553 if (log_fn == NULL) {
565 return strdup(stats.c_str());
int cvmfs_list_nc(LibContext *ctx, const char *path, char ***buf, size_t *buflen)
struct cvmcache_context * ctx
static LibContext * Create(const std::string &fqrn, OptionsManager *options_mgr)
void EnableMultiThreaded()
void cvmfs_detach_repo(LibContext *ctx)
NameString GetFileName(const PathString &path)
int GetNestedCatalogAttr(const char *c_path, struct cvmfs_nc_attr *nc_attr)
int cvmfs_listdir_contents(LibContext *ctx, const char *path, char ***buf, size_t *listlen, size_t *buflen)
perf::Statistics * statistics()
void cvmfs_attr_free(struct cvmfs_attr *attr)
struct cvmfs_nc_attr * cvmfs_nc_attr_init()
cvmfs_errors cvmfs_init_v2(SimpleOptionsParser *opts)
int cvmfs_stat_attr(LibContext *ctx, const char *path, struct cvmfs_attr *attr)
int cvmfs_stat_nc(LibContext *ctx, const char *path, struct cvmfs_nc_attr *nc_attr)
assert((mem||(size==0))&&"Out Of Memory")
static int expand_path(const int depth, LibContext *ctx, char const *path, string *expanded_path)
void SetAltLogFunc(void(*fn)(const LogSource source, const int mask, const char *msg))
int GetAttr(const char *c_path, struct stat *info)
void set_options_mgr(OptionsManager *value)
int GetExtAttr(const char *c_path, struct cvmfs_attr *info)
char * cvmfs_statistics_format(cvmfs_context *ctx)
uint64_t cvmfs_get_revision(LibContext *ctx)
void SwitchTemplateManager(OptionsTemplateManager *opt_templ_mgr_param)
void cvmfs_list_free(char **buf)
int cvmfs_listdir_stat(LibContext *ctx, const char *path, struct cvmfs_stat_t **buf, size_t *listlen, size_t *buflen)
void cvmfs_enable_threaded(LibContext *ctx)
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)
int cvmfs_stat(LibContext *ctx, const char *path, struct stat *st)
static void(* ext_log_fn)(const char *msg)
cvmfs_errors cvmfs_attach_repo_v2(const char *fqrn, SimpleOptionsParser *opts, LibContext **ctx)
static void cvmfs_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
int cvmfs_lstat(LibContext *ctx, const char *path, struct stat *st)
int cvmfs_listdir(LibContext *ctx, const char *path, char ***buf, size_t *buflen)
void cvmfs_nc_attr_free(struct cvmfs_nc_attr *nc_attr)
static void cvmfs_readlink(fuse_req_t req, fuse_ino_t ino)
int ListDirectoryStat(const char *c_path, cvmfs_stat_t **buf, size_t *listlen, size_t *buflen)
static LibGlobals * GetInstance()
int Open(const char *c_path)
MountPoint * mount_point()
int ListDirectory(const char *path, char ***buf, size_t *listlen, size_t *buflen, bool self_reference)
ssize_t cvmfs_pread(LibContext *ctx, int fd, void *buf, size_t size, off_t off)
std::string PrintList(const PrintOptions print_options)
PathString GetParentPath(const PathString &path)
int Readlink(const char *path, char *buf, size_t size)
int cvmfs_close(LibContext *ctx, int fd)
int cvmfs_remount(LibContext *ctx)
static int expand_ppath(LibContext *ctx, const char *path, string *expanded_path)
struct cvmfs_attr * cvmfs_attr_init()
static void CleanupInstance()
void cvmfs_set_log_fn(void(*log_fn)(const char *msg))
void cvmfs_adopt_options(cvmfs_context *ctx, SimpleOptionsParser *opts)
static void libcvmfs_log_fn(const LogSource, const int, const char *msg)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)