21 static int set_option(
char const *name,
char const *value,
bool *var) {
23 fprintf(stderr,
"Option %s=%s contains a value when none was expected.\n",
32 static int set_option(
char const *name,
char const *value,
unsigned *var) {
35 const int rc = sscanf(value,
"%u%n", &v, &end);
36 if (rc != 1 || value[end] !=
'\0') {
37 fprintf(stderr,
"Invalid unsigned integer value for %s=%s\n", name, value);
45 static int set_option(
char const *name,
char const *value,
int *var) {
48 const int rc = sscanf(value,
"%d%n", &v, &end);
49 if (rc != 1 || value[end] !=
'\0') {
50 fprintf(stderr,
"Invalid integer value for %s=%s\n", name, value);
58 static int set_option(
char const *name,
char const *value,
string *var) {
64 #define CVMFS_OPT(var) \
65 if (strcmp(name, #var) == 0) \
66 return ::set_option(name, value, &var)
84 fprintf(stderr,
"Unknown repo option: %s\n", name);
89 if (mountpoint.empty() && !repo_name.empty()) {
90 mountpoint =
"/cvmfs/";
91 mountpoint += repo_name;
93 while (mountpoint.length() > 0
94 && mountpoint[mountpoint.length() - 1] ==
'/') {
95 mountpoint.resize(mountpoint.length() - 1);
104 , pubkey(
"/etc/cvmfs/keys/cern.ch.pub")
106 , allow_unsigned(false) { }
144 fprintf(stderr,
"Unknown global option: %s\n", name);
150 if ((nofiles >= 0) && (max_open_files != 0) && (nofiles != max_open_files))
153 max_open_files = nofiles;
161 if (log_syslog_level < 0)
162 log_syslog_level = 3;
164 if ((logfile !=
"") && (log_file !=
"") && (log_file != logfile))
169 if ((cachedir !=
"") && (cache_directory !=
"")
170 && (cache_directory != cachedir)) {
174 cache_directory = cachedir;
180 : change_to_cache_directory(false)
183 , log_syslog_level(-1)
188 , rebuild_cachedb(0) { }
216 template<
class DerivedT>
224 char const *next = options;
229 for (next = options; *next && *next !=
',' && *next !=
'='; next++) {
243 for (; *next && *next !=
','; next++) {
252 if (!name.empty() || !value.empty()) {
253 const int result =
set_option(name.c_str(), value.c_str());
264 return DerivedT::verify_sanity();
278 "CernVM-FS version %s\n"
279 "Copyright (c) 2009- CERN\n"
280 "All rights reserved\n\n"
281 "Please visit http://cernvm.cern.ch/project/info for license details "
282 "and author list.\n\n"
284 "libcvmfs options are expected in the form: option1,option2,option3,...\n"
285 "Within an option, the characters , and \\ must be preceded by \\.\n\n"
287 "There are two types of options (global and repository specifics)\n"
288 " cvmfs_init() expects global options\n"
289 " cvmfs_attach_repo() expects repository specific options\n"
291 "global options are:\n"
292 " cache_directory/cachedir=DIR Where to store disk cache\n"
293 " change_to_cache_directory Performs a cd to the cache directory "
294 "(performance tweak)\n"
295 " alien_cache Treat cache directory as alien cache\n"
296 " alien_cachedir=DIR Explicitly set an alien cache directory\n"
297 " lock_directory=DIR Directory for per instance lock files.\n"
298 " Needs to be on a file system with POSIX "
300 " Should be different from alien cache "
302 " \nDefaults to cache_directory.\n"
303 " (log_)syslog_level=LEVEL Sets the level used for syslog to "
304 "DEBUG (1), INFO (2), or NOTICE (3).\n"
305 " Default is NOTICE.\n"
306 " log_prefix String to use as a log prefix in syslog\n"
307 " log_file/logfile Logs all messages to FILE instead of "
308 "stderr and daemonizes.\n"
309 " Makes only sense for the debug version\n"
310 " nofiles/max_open_files Set the maximum number of open files "
311 "for CernVM-FS process (soft limit)\n\n"
313 "repository specific options are:"
314 " repo_name=REPO_NAME Unique name of the mounted repository, "
315 "e.g. atlas.cern.ch\n"
316 " url=REPOSITORY_URL The URL of the CernVM-FS server(s): "
318 " timeout=SECONDS Timeout for network operations (default is "
320 " timeout_direct=SECONDS Timeout for network operations without "
323 " proxies=HTTP_PROXIES Set the HTTP proxy list, such as "
324 "'proxy1|proxy2;DIRECT'\n"
325 " fallback_proxies=PROXIES Set the fallback proxy list, such as "
327 " tracefile=FILE Trace FUSE opaerations into FILE\n"
328 " pubkey=PEMFILE Public RSA key that is used to verify the "
329 "whitelist signature.\n"
330 " allow_unsigned Accept unsigned catalogs "
331 "(allows man-in-the-middle attacks)\n"
332 " deep_mount=PREFIX Path prefix if a repository is mounted on a "
334 " i.e. deep_mount=/software/15.0.1\n"
335 " mountpoint=PATH Path to root of repository, "
336 "e.g. /cvmfs/atlas.cern.ch\n"
337 " blacklist=FILE Local blacklist for invalid certificates. "
338 "Has precedence over the whitelist.\n",
347 const int unknown = -10;
397 const int parse_result = global_opts.
parse_options(legacy_options);
398 if (parse_result != 0) {
399 fprintf(stderr,
"Invalid CVMFS global options: %s.\n", legacy_options);
405 options_mgr->
SetValue(
"CVMFS_CACHE_DIR", global_opts.cache_directory);
406 if (!global_opts.lock_directory.empty()) {
407 options_mgr->
SetValue(
"CVMFS_WORKSPACE", global_opts.lock_directory);
409 if (global_opts.alien_cache) {
410 options_mgr->
SetValue(
"CVMFS_ALIEN_CACHE", global_opts.cache_directory);
412 if (!global_opts.alien_cachedir.empty()) {
413 options_mgr->
SetValue(
"CVMFS_ALIEN_CACHE", global_opts.alien_cachedir);
420 options_mgr->
SetValue(
"CVMFS_SYSLOG_LEVEL",
422 if (!global_opts.log_prefix.empty()) {
423 options_mgr->
SetValue(
"CVMFS_SYSLOG_PREFIX", global_opts.log_prefix);
425 if (!global_opts.log_file.empty()) {
426 options_mgr->
SetValue(
"CVMFS_DEBUGLOG", global_opts.log_file);
428 if (global_opts.max_open_files > 0) {
429 options_mgr->
SetValue(
"CVMFS_NFILES",
439 if (options_mgr == NULL) {
440 fprintf(stderr,
"Invalid CVMFS global options: %s.\n", options);
454 const char *legacy_options) {
457 const int parse_result = repo_opts.
parse_options(legacy_options);
458 if ((parse_result != 0) || repo_opts.url.empty()) {
465 options_mgr->
SetValue(
"CVMFS_FQRN", repo_opts.repo_name);
467 options_mgr->
SetValue(
"CVMFS_TIMEOUT_DIRECT",
469 options_mgr->
SetValue(
"CVMFS_SERVER_URL", repo_opts.url);
470 if (!repo_opts.external_url.empty()) {
471 options_mgr->
SetValue(
"CVMFS_EXTERNAL_URL", repo_opts.external_url);
473 if (repo_opts.proxies.empty()) {
474 if (!options_mgr->
IsDefined(
"CVMFS_HTTP_PROXY"))
475 options_mgr->
SetValue(
"CVMFS_HTTP_PROXY",
"DIRECT");
477 options_mgr->
SetValue(
"CVMFS_HTTP_PROXY", repo_opts.proxies);
479 options_mgr->
SetValue(
"CVMFS_FALLBACK_PROXY", repo_opts.fallback_proxies);
480 options_mgr->
SetValue(
"CVMFS_PUBLIC_KEY", repo_opts.pubkey);
481 if (!repo_opts.blacklist.empty()) {
482 options_mgr->
SetValue(
"CVMFS_BLACKLIST", repo_opts.blacklist);
484 if (!repo_opts.root_hash.empty()) {
485 options_mgr->
SetValue(
"CVMFS_ROOT_HASH", repo_opts.root_hash);
495 options_mgr_base, options);
497 if (options_mgr == NULL) {
498 fprintf(stderr,
"Invalid CVMFS options: %s.\n", options);
504 const bool retval = options_mgr->
GetValue(
"CVMFS_FQRN", &repo_name);
struct cvmcache_context * ctx
static LibContext * Create(const std::string &fqrn, OptionsManager *options_mgr)
#define LIBCVMFS_FAIL_MKCACHE
loader::Failures boot_status()
std::string cache_directory
cvmfs_context * cvmfs_attach_repo(char const *options)
cvmfs_option_map * cvmfs_options_clone(cvmfs_option_map *opts)
cvmfs_option_map * cvmfs_options_init()
assert((mem||(size==0))&&"Out Of Memory")
void set_options_mgr(OptionsManager *value)
cvmfs_options< cvmfs_global_options > global_options
std::string lock_directory
static void cvmfs_init(void *userdata, struct fuse_conn_info *conn)
void SwitchTemplateManager(OptionsTemplateManager *opt_templ_mgr_param)
#define LIBCVMFS_FAIL_NOFILES
void SetValue(const std::string &key, const std::string &value)
int set_option(char const *name, char const *value)
void cvmfs_options_fini(cvmfs_option_map *opts)
static loader::Failures Initialize(OptionsManager *options_mgr)
std::string alien_cachedir
int set_option(char const *name, char const *value)
int parse_options(char const *options)
#define LIBCVMFS_FAIL_BADOPT
string StringifyInt(const int64_t value)
cvmfs_option_map * cvmfs_options_init_legacy(const char *legacy_options)
#define LIBCVMFS_FAIL_INITCACHE
bool change_to_cache_directory
bool GetValue(const std::string &key, std::string *value) const
std::string fallback_proxies
static LibGlobals * GetInstance()
cvmfs_options< cvmfs_repo_options > repo_options
MountPoint * mount_point()
#define LIBCVMFS_FAIL_LOCKFILE
cvmfs_option_map * cvmfs_options_clone_legacy(cvmfs_option_map *opts, const char *legacy_options)
static int set_option(char const *name, char const *value, bool *var)
#define LIBCVMFS_FAIL_INITQUOTA
bool IsDefined(const std::string &key)
int set_option(char const *name, char const *value)
void set_options_mgr(OptionsManager *value)
static void CleanupInstance()
static int TranslateReturnValue(loader::Failures code)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)