1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2009-2011 New Dream Network
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #ifndef CEPH_COMMON_INIT_H
16 #define CEPH_COMMON_INIT_H
20 #include "include/common_fwd.h"
21 #include "common/code_environment.h"
23 enum common_init_flags_t
{
24 // Set up defaults that make sense for an unprivileged daemon
25 CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS
= 0x1,
27 // By default, don't read a configuration file OR contact mons
28 CINIT_FLAG_NO_DEFAULT_CONFIG_FILE
= 0x2,
30 // Don't close stderr (in daemonize)
31 CINIT_FLAG_NO_CLOSE_STDERR
= 0x4,
33 // don't do anything daemonish, like create /var/run/ceph, or print a banner
34 CINIT_FLAG_NO_DAEMON_ACTIONS
= 0x8,
36 // don't drop privileges
37 CINIT_FLAG_DEFER_DROP_PRIVILEGES
= 0x10,
39 // don't contact mons for config
40 CINIT_FLAG_NO_MON_CONFIG
= 0x20,
42 // don't expose default cct perf counters
43 CINIT_FLAG_NO_CCT_PERF_COUNTERS
= 0x40,
47 class CephInitParameters
;
50 * NOTE: If you are writing a Ceph daemon, ignore this function and call
51 * global_init instead. It will call common_preinit for you.
53 * common_preinit creates the CephContext.
55 * After this function gives you a CephContext, you need to set up the
56 * Ceph configuration, which lives inside the CephContext as md_config_t.
57 * The initial settings are not very useful because they do not reflect what
60 * This is usually done by something like this:
61 * cct->_conf.parse_env();
62 * cct->_conf.apply_changes();
64 * Your library may also supply functions to read a configuration file.
66 CephContext
*common_preinit(const CephInitParameters
&iparams
,
67 enum code_environment_t code_env
, int flags
);
68 #endif // #ifndef WITH_SEASTAR
70 /* Print out some parse error. */
71 void complain_about_parse_error(CephContext
*cct
,
72 const std::string
& parse_error
);
74 /* This function is called after you have done your last
75 * fork. When you make this call, the system will initialize everything that
76 * cannot be initialized before a fork.
78 * This includes things like starting threads, initializing libraries that
79 * can't handle forking, and so forth.
81 * If you are writing a Ceph library, you can call this pretty much any time.
82 * We do not allow our library users to fork and continue using the Ceph
83 * libraries. The most obvious reason for this is that the threads started by
84 * the Ceph libraries would be destroyed by a fork().
86 void common_init_finish(CephContext
*cct
);