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 "common/code_environment.h"
23 class CephInitParameters
;
25 enum common_init_flags_t
{
26 // Set up defaults that make sense for an unprivileged deamon
27 CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS
= 0x1,
29 // By default, don't read a configuration file
30 CINIT_FLAG_NO_DEFAULT_CONFIG_FILE
= 0x2,
32 // Don't close stderr (in daemonize)
33 CINIT_FLAG_NO_CLOSE_STDERR
= 0x4,
35 // don't do anything daemonish, like create /var/run/ceph, or print a banner
36 CINIT_FLAG_NO_DAEMON_ACTIONS
= 0x8,
38 // don't drop privileges
39 CINIT_FLAG_DEFER_DROP_PRIVILEGES
= 0x10,
43 * NOTE: If you are writing a Ceph daemon, ignore this function and call
44 * global_init instead. It will call common_preinit for you.
46 * common_preinit creates the CephContext.
48 * After this function gives you a CephContext, you need to set up the
49 * Ceph configuration, which lives inside the CephContext as md_config_t.
50 * The initial settings are not very useful because they do not reflect what
53 * This is usually done by something like this:
54 * cct->_conf->parse_env();
55 * cct->_conf->apply_changes();
57 * Your library may also supply functions to read a configuration file.
59 CephContext
*common_preinit(const CephInitParameters
&iparams
,
60 enum code_environment_t code_env
, int flags
);
62 /* Print out some parse errors. */
63 void complain_about_parse_errors(CephContext
*cct
,
64 std::deque
<std::string
> *parse_errors
);
66 /* This function is called after you have done your last
67 * fork. When you make this call, the system will initialize everything that
68 * cannot be initialized before a fork.
70 * This includes things like starting threads, initializing libraries that
71 * can't handle forking, and so forth.
73 * If you are writing a Ceph library, you can call this pretty much any time.
74 * We do not allow our library users to fork and continue using the Ceph
75 * libraries. The most obvious reason for this is that the threads started by
76 * the Ceph libraries would be destroyed by a fork().
78 void common_init_finish(CephContext
*cct
);