22 static int set_option(
char const *name,
char const *value,
bool *var) {
24 fprintf(stderr,
"Option %s=%s contains a value when none was expected.\n",
33 static int set_option(
char const *name,
char const *value,
unsigned *var) {
36 int rc = sscanf(value,
"%u%n", &v, &end);
37 if (rc != 1 || value[end] !=
'\0') {
38 fprintf(stderr,
"Invalid unsigned integer value for %s=%s\n", name, value);
46 static int set_option(
char const *name,
char const *value,
int *var) {
49 int rc = sscanf(value,
"%d%n", &v, &end);
50 if (rc != 1 || value[end] !=
'\0') {
51 fprintf(stderr,
"Invalid integer value for %s=%s\n", name, value);
59 static int set_option(
char const *name,
char const *value,
string *var) {
65 #define CVMFS_OPT(var) 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 && 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;
162 if (log_syslog_level < 0)
163 log_syslog_level = 3;
165 if ((logfile !=
"") && (log_file !=
"") && (log_file != logfile))
170 if ((cachedir !=
"") && (cache_directory !=
"") &&
171 (cache_directory != cachedir))
176 cache_directory = cachedir;
182 : change_to_cache_directory(false)
185 , log_syslog_level(-1)
219 template <
class DerivedT>
228 char const *next = options;
233 for (next=options; *next && *next !=
',' && *next !=
'='; next++) {
236 if (*next ==
'\0')
break;
246 for (; *next && *next !=
','; next++) {
249 if (*next ==
'\0')
break;
254 if (!name.empty() || !value.empty()) {
255 int result =
set_option(name.c_str(), value.c_str());
261 if (*next ==
',') next++;
265 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 locks.\n"
299 " Should be different from alien cache directory."
300 " \nDefaults to cache_directory.\n"
301 " (log_)syslog_level=LEVEL Sets the level used for syslog to "
302 "DEBUG (1), INFO (2), or NOTICE (3).\n"
303 " Default is NOTICE.\n"
304 " log_prefix String to use as a log prefix in syslog\n"
305 " log_file/logfile Logs all messages to FILE instead of "
306 "stderr and daemonizes.\n"
307 " Makes only sense for the debug version\n"
308 " nofiles/max_open_files Set the maximum number of open files "
309 "for CernVM-FS process (soft limit)\n\n"
311 "repository specific options are:"
312 " repo_name=REPO_NAME Unique name of the mounted repository, "
313 "e.g. atlas.cern.ch\n"
314 " url=REPOSITORY_URL The URL of the CernVM-FS server(s): "
316 " timeout=SECONDS Timeout for network operations (default is %d)\n"
317 " timeout_direct=SECONDS Timeout for network operations without proxy "
319 " proxies=HTTP_PROXIES Set the HTTP proxy list, such as "
320 "'proxy1|proxy2;DIRECT'\n"
321 " fallback_proxies=PROXIES Set the fallback proxy list, such as "
323 " tracefile=FILE Trace FUSE opaerations into FILE\n"
324 " pubkey=PEMFILE Public RSA key that is used to verify the "
325 "whitelist signature.\n"
326 " allow_unsigned Accept unsigned catalogs "
327 "(allows man-in-the-middle attacks)\n"
328 " deep_mount=PREFIX Path prefix if a repository is mounted on a "
330 " i.e. deep_mount=/software/15.0.1\n"
331 " mountpoint=PATH Path to root of repository, "
332 "e.g. /cvmfs/atlas.cern.ch\n"
333 " blacklist=FILE Local blacklist for invalid certificates. "
334 "Has precedence over the whitelist.\n",
343 const int unknown = -10;
393 int parse_result = global_opts.
parse_options(legacy_options);
394 if (parse_result != 0) {
395 fprintf(stderr,
"Invalid CVMFS global options: %s.\n", legacy_options);
401 options_mgr->
SetValue(
"CVMFS_CACHE_DIR", global_opts.cache_directory);
402 if (!global_opts.lock_directory.empty()) {
403 options_mgr->
SetValue(
"CVMFS_WORKSPACE", global_opts.lock_directory);
405 if (global_opts.alien_cache) {
406 options_mgr->
SetValue(
"CVMFS_ALIEN_CACHE", global_opts.cache_directory);
408 if (!global_opts.alien_cachedir.empty()) {
409 options_mgr->
SetValue(
"CVMFS_ALIEN_CACHE", global_opts.alien_cachedir);
416 options_mgr->
SetValue(
"CVMFS_SYSLOG_LEVEL",
418 if (!global_opts.log_prefix.empty()) {
419 options_mgr->
SetValue(
"CVMFS_SYSLOG_PREFIX", global_opts.log_prefix);
421 if (!global_opts.log_file.empty()) {
422 options_mgr->
SetValue(
"CVMFS_DEBUGLOG", global_opts.log_file);
424 if (global_opts.max_open_files > 0) {
425 options_mgr->
SetValue(
"CVMFS_NFILES",
435 if (options_mgr == NULL) {
436 fprintf(stderr,
"Invalid CVMFS global options: %s.\n", options);
451 const char *legacy_options)
456 if ((parse_result != 0) || repo_opts.url.empty()) {
463 options_mgr->
SetValue(
"CVMFS_FQRN", repo_opts.repo_name);
465 options_mgr->
SetValue(
"CVMFS_TIMEOUT_DIRECT",
467 options_mgr->
SetValue(
"CVMFS_SERVER_URL", repo_opts.url);
468 if (!repo_opts.external_url.empty()) {
469 options_mgr->
SetValue(
"CVMFS_EXTERNAL_URL", repo_opts.external_url);
471 if (repo_opts.proxies.empty()) {
472 if (!options_mgr->
IsDefined(
"CVMFS_HTTP_PROXY"))
473 options_mgr->
SetValue(
"CVMFS_HTTP_PROXY",
"DIRECT");
475 options_mgr->
SetValue(
"CVMFS_HTTP_PROXY", repo_opts.proxies);
477 options_mgr->
SetValue(
"CVMFS_FALLBACK_PROXY", repo_opts.fallback_proxies);
478 options_mgr->
SetValue(
"CVMFS_PUBLIC_KEY", repo_opts.pubkey);
479 if (!repo_opts.blacklist.empty()) {
480 options_mgr->
SetValue(
"CVMFS_BLACKLIST", repo_opts.blacklist);
482 if (!repo_opts.root_hash.empty()) {
483 options_mgr->
SetValue(
"CVMFS_ROOT_HASH", repo_opts.root_hash);
496 if (options_mgr == NULL) {
497 fprintf(stderr,
"Invalid CVMFS options: %s.\n", options);
503 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,...)