![]() |
CernVM-FS
2.13.0
|
#include <stdint.h>
#include <sys/stat.h>
#include <unistd.h>
Go to the source code of this file.
Classes | |
struct | cvmfs_nc_attr |
struct | cvmfs_attr |
struct | cvmfs_stat_t |
Macros | |
#define | LIBCVMFS_VERSION 2 |
#define | LIBCVMFS_VERSION_MAJOR LIBCVMFS_VERSION |
#define | LIBCVMFS_VERSION_MINOR 13 |
#define | LIBCVMFS_REVISION 31 |
#define | LIBCVMFS_FAIL_OK 0 |
#define | LIBCVMFS_FAIL_NOFILES -1 |
#define | LIBCVMFS_FAIL_MKCACHE -2 |
#define | LIBCVMFS_FAIL_OPENCACHE -3 |
#define | LIBCVMFS_FAIL_LOCKFILE -4 |
#define | LIBCVMFS_FAIL_INITCACHE -5 |
#define | LIBCVMFS_FAIL_INITQUOTA -6 |
#define | LIBCVMFS_FAIL_BADOPT -7 |
Typedefs | |
typedef struct LibContext | cvmfs_context |
typedef struct OptionsManager | cvmfs_option_map |
#define LIBCVMFS_FAIL_BADOPT -7 |
Definition at line 61 of file libcvmfs.h.
Referenced by cvmfs_init(), cvmfs_global_options::set_option(), TranslateReturnValue(), and cvmfs_global_options::verify_sanity().
#define LIBCVMFS_FAIL_INITCACHE -5 |
Definition at line 59 of file libcvmfs.h.
Referenced by TranslateReturnValue().
#define LIBCVMFS_FAIL_INITQUOTA -6 |
Definition at line 60 of file libcvmfs.h.
Referenced by TranslateReturnValue().
#define LIBCVMFS_FAIL_LOCKFILE -4 |
Definition at line 58 of file libcvmfs.h.
Referenced by TranslateReturnValue().
#define LIBCVMFS_FAIL_MKCACHE -2 |
Definition at line 56 of file libcvmfs.h.
Referenced by TranslateReturnValue().
#define LIBCVMFS_FAIL_NOFILES -1 |
Definition at line 55 of file libcvmfs.h.
Referenced by TranslateReturnValue().
#define LIBCVMFS_FAIL_OK 0 |
Definition at line 54 of file libcvmfs.h.
Referenced by TranslateReturnValue(), cvmfs_repo_options::verify_sanity(), and cvmfs_global_options::verify_sanity().
#define LIBCVMFS_FAIL_OPENCACHE -3 |
Definition at line 57 of file libcvmfs.h.
#define LIBCVMFS_REVISION 31 |
Definition at line 47 of file libcvmfs.h.
Referenced by LibGlobals::Initialize(), and libcvmfs_initialize().
#define LIBCVMFS_VERSION 2 |
This file is part of the CernVM File System.
NOTE: when adding or removing public symbols, you must also update the list in libcvmfs_public_syms.txt.
Not supported in the library:
Definition at line 18 of file libcvmfs.h.
#define LIBCVMFS_VERSION_MAJOR LIBCVMFS_VERSION |
Definition at line 19 of file libcvmfs.h.
Referenced by LibGlobals::Initialize(), and libcvmfs_initialize().
#define LIBCVMFS_VERSION_MINOR 13 |
Definition at line 20 of file libcvmfs.h.
Referenced by LibGlobals::Initialize(), and libcvmfs_initialize().
typedef struct LibContext cvmfs_context |
Definition at line 70 of file libcvmfs.h.
typedef struct OptionsManager cvmfs_option_map |
Definition at line 71 of file libcvmfs.h.
enum cvmfs_errors |
Error codes for cvmfs_init_v2() and cvmfs_attach_repo_v2(). Mirrors the failure codes in loader.h
Definition at line 78 of file libcvmfs.h.
void cvmfs_adopt_options | ( | cvmfs_context * | ctx, |
cvmfs_option_map * | opts | ||
) |
Transfer ownership of opts to the context ctx. The option map is automatically freed by cvmfs_detach_repo.
cvmfs_context* cvmfs_attach_repo | ( | char const * | options | ) |
Initialize a CVMFS remote repository. Legacy. Use cvmfs_attach_repo_v2().
[in] | options,option1,option2,... |
Definition at line 490 of file libcvmfs_legacy.cc.
cvmfs_errors cvmfs_attach_repo_v2 | ( | const char * | fqrn, |
cvmfs_option_map * | opts, | ||
cvmfs_context ** | ctx | ||
) |
Creates a new repository context. On successful return, *ctx is not NULL and must be freed by a call to cvmfs_detach_repo(). Otherwise *ctx is NULL.
The cvmfs_option_map can be the global cvmfs_option_map pointer or a new pointer retrieved from cvmfs_options_clone(). If it is a new pointer, ownership can be transferred to the context by a call to cvmfs_adopt_options() so that the options map is free by cvmfs_detach_repo().
void cvmfs_attr_free | ( | struct cvmfs_attr * | attr | ) |
Destroy the cvmfs_attr struct and frees the checksum, symlink, parent, name, and xattrs.
attr,pointer | to a cvmfs_attr struct to be deleted. |
Destroy the cvmfs_attr struct and frees the checksum, symlink, name, and xattrs.
Definition at line 53 of file libcvmfs.cc.
Referenced by libcvmfs_has_file(), shrinkwrap::Sync(), and shrinkwrap::updateStat().
struct cvmfs_attr* cvmfs_attr_init | ( | ) |
Create the cvmfs_attr struct which contains the same information as a stat, but also has pointers to the hash, symlink, and name. pointer to a cvmfs_attr struct
Create the cvmfs_attr struct which contains the same information as a stat, but also has pointers to the hash, symlink, and name.
Definition at line 39 of file libcvmfs.cc.
Referenced by libcvmfs_has_file(), shrinkwrap::Sync(), and shrinkwrap::updateStat().
int cvmfs_close | ( | cvmfs_context * | ctx, |
int | fd | ||
) |
Close a file previously opened with cvmfs_open().
[in] | fd,file | descriptor to close |
Definition at line 261 of file libcvmfs.cc.
Referenced by libcvmfs_do_fclose().
void cvmfs_detach_repo | ( | cvmfs_context * | ctx | ) |
Uninitialize a cvmfs remote repository and release all resources for it. Works with both cvmfs_attach_repo() and cvmfs_attach_repo_v2().
Definition at line 514 of file libcvmfs.cc.
Referenced by libcvmfs_finalize().
void cvmfs_enable_threaded | ( | cvmfs_context * | ctx | ) |
Definition at line 483 of file libcvmfs.cc.
Referenced by libcvmfs_initialize().
void cvmfs_fini | ( | ) |
Shut down the CVMFS library and release all resources. The cvmfs_option_map object passed to cvmfs_init_v2 must be deleted afterwards by a call to cvmfs_options_fini().
Definition at line 531 of file libcvmfs.cc.
Referenced by libcvmfs_finalize().
uint64_t cvmfs_get_revision | ( | cvmfs_context * | ctx | ) |
Return the root file catalog revision
Definition at line 575 of file libcvmfs.cc.
int cvmfs_init | ( | char const * | options | ) |
Initialize global CVMFS library structures. Legacy. Use cvmfs_init_v2(). Note: this must be called before any of the following functions.
[in] | options,option1,option2,... |
Definition at line 433 of file libcvmfs_legacy.cc.
cvmfs_errors cvmfs_init_v2 | ( | cvmfs_option_map * | opts | ) |
Initializes the global cvmfs state based on a cvmfs_options_map. The cvmfs_fini() function works for both cvmfs_init() and cvmfs_init_v2()
void cvmfs_list_free | ( | char ** | buf | ) |
Free the items contained in list and then the list.
[in] | buf,pointer | to the list that was allocated. |
Definition at line 469 of file libcvmfs.cc.
Referenced by shrinkwrap::Sync().
int cvmfs_list_nc | ( | cvmfs_context * | ctx, |
const char * | path, | ||
char *** | buf, | ||
size_t * | buflen | ||
) |
Get list of nested catalog at path. The list contents includes the empty string for the base and each nested catalog needed to reach this location. It also contains the list of nested catalogs reachable directly from the nested catalog serving this location. If this is a transition point, the nested catalog at this location is used.
On return, the array will contain a NULL-terminated list of strings. The caller must free the strings and the array containing them. The array (*buf) may be NULL when this function is called.
[in] | path,path | of nested catalog (e.g. /dir, not /cvmfs/repo/dir) |
[out] | buf,pointer | to dynamically allocated NULL-terminated array of strings |
[in] | buflen,pointer | to variable containing size of array |
Definition at line 446 of file libcvmfs.cc.
int cvmfs_listdir | ( | cvmfs_context * | ctx, |
const char * | path, | ||
char *** | buf, | ||
size_t * | buflen | ||
) |
Get list of directory contents. The directory contents includes "." and "..".
On return, the array will contain a NULL-terminated list of strings. The caller must free the strings and the array containing them. The array (*buf) may be NULL when this function is called.
[in] | path,path | of directory (e.g. /dir, not /cvmfs/repo/dir) |
[out] | buf,pointer | to dynamically allocated NULL-terminated array of strings |
[in] | buflen,pointer | to variable containing size of array |
Definition at line 353 of file libcvmfs.cc.
int cvmfs_listdir_contents | ( | cvmfs_context * | ctx, |
const char * | path, | ||
char *** | buf, | ||
size_t * | listlen, | ||
size_t * | buflen | ||
) |
Get list of directory contents. The list does not include "." or "..".
On return, the array will contain a NULL-terminated list of strings. The caller must free the strings and the array containing them. The array (*buf) may be NULL when this function is called.
[in] | path,path | of directory (e.g. /dir, not /cvmfs/repo/dir) |
[out] | buf,pointer | to dynamically allocated NULL-terminated array of strings |
[in] | buflen,pointer | to variable containing size of array |
Definition at line 376 of file libcvmfs.cc.
Referenced by libcvmfs_list_dir().
int cvmfs_listdir_stat | ( | cvmfs_context * | ctx, |
const char * | path, | ||
struct cvmfs_stat_t ** | buf, | ||
size_t * | listlen, | ||
size_t * | buflen | ||
) |
Get list of directory contents' stat info. The list does not include "." or "..".
On return,
buf | will contain list of cvmfs_stat_t objects. The caller must free the cvmfs_stat_t::name and the array containing cvmfs_stat_t objects (*buf). The array (*buf) may be NULL when this function is called. | |
[in] | path,path | of directory (e.g. /dir, not /cvmfs/repo/dir) |
[out] | buf,pointer | to dynamically allocated array of cvmfs_stat_t |
[in] | buflen,pointer | to variable containing size of |
buf | ||
in/out] | listlen, pointer to number of entries in | |
buf. | Set | |
listlen | to 0 before to fill | |
buf | from index 0. |
Definition at line 399 of file libcvmfs.cc.
int cvmfs_lstat | ( | cvmfs_context * | ctx, |
const char * | path, | ||
struct stat * | st | ||
) |
Get information about a file. If the file is a symlink, return info about the link, not the file it points to.
[in] | path,path | of file (e.g. /dir/file, not /cvmfs/repo/dir/file) |
[out] | st,stat | buffer in which to write the result |
Definition at line 313 of file libcvmfs.cc.
void cvmfs_nc_attr_free | ( | struct cvmfs_nc_attr * | nc_attr | ) |
Frees the cvmfs_nc_attr struct passed, including freeing the mountpoint and hash.
[in] | nc_attr,pointer | the cvmfs_nc_attr to be destroyed |
Definition at line 73 of file libcvmfs.cc.
Referenced by libcvmfs_list_dir().
struct cvmfs_nc_attr* cvmfs_nc_attr_init | ( | ) |
Creates an empty cvmfs_nc_attr struct and returns the pointer to the user.
Definition at line 66 of file libcvmfs.cc.
Referenced by libcvmfs_list_dir().
int cvmfs_open | ( | cvmfs_context * | ctx, |
const char * | path | ||
) |
Open a file in the cvmfs cache.
[in] | path,path | to open (e.g. /dir/file, not /cvmfs/repo/dir/file) |
Definition at line 227 of file libcvmfs.cc.
cvmfs_option_map* cvmfs_options_clone | ( | cvmfs_option_map * | opts | ) |
Creates a new option map based on an existing one. Should be used to add repository specific options passed to cvmfs_attach_repo_v2() based on the global options that were passed to cvmfs_init_v2().
Referenced by cvmfs_options_clone_legacy().
cvmfs_option_map* cvmfs_options_clone_legacy | ( | cvmfs_option_map * | opts, |
const char * | legacy_options | ||
) |
Derives an option map based on the legacy option string that would be passed to the legacy function cvmfs_attach_repo(). Returns NULL if legacy_options is invalid. On success, the repository name is in the CVMFS_FQRN key in the options manager.
Referenced by cvmfs_attach_repo().
char* cvmfs_options_dump | ( | cvmfs_option_map * | opts | ) |
Prints the key-value pairs of cvmfs_option_map line-by-line. The resulting string needs to be freed by a call to cvmfs_options_free().
void cvmfs_options_fini | ( | cvmfs_option_map * | opts | ) |
Frees the resources of a cvmfs_options_map, which was created either by a call to cvmfs_options_init() or by a call to cvmfs_options_clone().
Referenced by cvmfs_attach_repo().
void cvmfs_options_free | ( | char * | value | ) |
Frees a string returned from cvmfs_options_get() or cvmfs_options_dump().
Definition at line 32 of file libcvmfs_options.cc.
char* cvmfs_options_get | ( | cvmfs_option_map * | opts, |
const char * | key | ||
) |
Retrieves the value for a given key or NULL of the key does not exist. If the result is not NULL, it must be freed by a call to cvmfs_options_free().
Referenced by libcvmfs_initialize().
cvmfs_option_map* cvmfs_options_init | ( | ) |
An option map must be created an populated before calling cvmfs_init_v2().
Definition at line 55 of file libcvmfs_options.cc.
Referenced by cvmfs_attach_repo(), and cvmfs_options_init_legacy().
cvmfs_option_map* cvmfs_options_init_legacy | ( | const char * | legacy_options | ) |
Creates a new option map based on the legacy option string that would be passed to the legacy function cvmfs_init(). Returns NULL if legacy_options is invalid.
Definition at line 391 of file libcvmfs_legacy.cc.
Referenced by cvmfs_init().
cvmfs_option_map* cvmfs_options_init_v2 | ( | int | taint_environ | ) |
Like cvmfs_options_init but let decide whether or not cvmfs options make it to the process environment. Relevant for resolving symbolic links.
Definition at line 60 of file libcvmfs_options.cc.
Referenced by cvmfs_options_init(), and libcvmfs_initialize().
int cvmfs_options_parse | ( | cvmfs_option_map * | opts, |
const char * | path | ||
) |
Sets options from a file with linewise KEY=VALUE pairs. Returns 0 on success and -1 otherwise.
Referenced by libcvmfs_initialize().
void cvmfs_options_parse_default | ( | cvmfs_option_map * | opts, |
const char * | fqrn | ||
) |
Sets default options from repository defaults in /etc/cvmfs. Returns 0 on success and -1 otherwise.
void cvmfs_options_set | ( | cvmfs_option_map * | opts, |
const char * | key, | ||
const char * | value | ||
) |
Fills a cvmfs_options_map. Use the same key/value pairs as the configuration parameters used by the fuse module in /etc/cvmfs/...
Referenced by libcvmfs_initialize().
void cvmfs_options_unset | ( | cvmfs_option_map * | opts, |
const char * | key | ||
) |
Removes a key-value pair from a cvmfs_options_map. The key may or may not exist before the call.
ssize_t cvmfs_pread | ( | cvmfs_context * | ctx, |
int | fd, | ||
void * | buf, | ||
size_t | size, | ||
off_t | off | ||
) |
Read from a file descriptor returned by cvmfs_open(). File descriptors that have bit 30 set indicate chunked files.
Definition at line 245 of file libcvmfs.cc.
Referenced by libcvmfs_do_fread().
int cvmfs_readlink | ( | cvmfs_context * | ctx, |
const char * | path, | ||
char * | buf, | ||
size_t | size | ||
) |
Read a symlink from the catalog. Environment variables in the symlink that are of the form are expanded according to the process' environment variables. If the provided buffer is not long enough for the null-terminated value of the symlink, -1 is returned and errno is set to ERANGE.
[in] | path,path | of symlink (e.g. /dir/file, not /cvmfs/repo/dir/file) |
[out] | buf,buffer | in which to write the null-terminated value of the symlink |
[in] | size,size | of buffer |
Definition at line 272 of file libcvmfs.cc.
int cvmfs_remount | ( | cvmfs_context * | ctx | ) |
Load a new catalog if there is one.
Definition at line 569 of file libcvmfs.cc.
void cvmfs_set_log_fn | ( | void(*)(const char *msg) | log_fn | ) |
Send syslog and debug messages to log_fn instead. This may (and probably should) be called before any other routine. Setting this to NULL restores the default logging behavior.
Definition at line 550 of file libcvmfs.cc.
Referenced by libcvmfs_initialize().
int cvmfs_stat | ( | cvmfs_context * | ctx, |
const char * | path, | ||
struct stat * | st | ||
) |
Get information about a file. If the file is a symlink, return info about the file it points to, not the symlink itself.
[in] | path,path | of file (e.g. /dir/file, not /cvmfs/repo/dir/file) |
[out] | st,stat | buffer in which to write the result |
Definition at line 295 of file libcvmfs.cc.
int cvmfs_stat_attr | ( | cvmfs_context * | ctx, |
const char * | path, | ||
struct cvmfs_attr * | attr | ||
) |
Get the extended CVMFS information about a file. If the file is a symlink, return info about the link, not the file it points to.
[in] | path,path | of file (e.g. /dir/file, not /cvmfs/repo/dir/file) |
[out] | attr,cvmfs_attr | struct in which to write the result |
Definition at line 331 of file libcvmfs.cc.
Referenced by libcvmfs_get_stat(), and libcvmfs_has_file().
int cvmfs_stat_nc | ( | cvmfs_context * | ctx, |
const char * | path, | ||
struct cvmfs_nc_attr * | ncst | ||
) |
Get the CVMFS information about a nested catalog. The information returned pertains to the catalog that serves this path, if this path is a transition point, then the information is about this transition point.
[in] | path,path | of nested catalog (e.g. /dir, not /cvmfs/repo/dir) |
[out] | ncst,cvmfs_nc_attr | buffer in which to write the result |
Definition at line 424 of file libcvmfs.cc.
Referenced by libcvmfs_list_dir().
char* cvmfs_statistics_format | ( | cvmfs_context * | ctx | ) |
Get runtime statistics formatted as a string. The raw counters are also available via cvmfs_talk
when using the FUSE module. cvmfs_statistics()
allocates a new string, which the caller must free. Returns NULL if insufficient memory was available.
Definition at line 561 of file libcvmfs.cc.