]> git.proxmox.com Git - ceph.git/blob - ceph/src/common/common_init.h
update sources to v12.2.3
[ceph.git] / ceph / src / common / common_init.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2009-2011 New Dream Network
7 *
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.
12 *
13 */
14
15 #ifndef CEPH_COMMON_INIT_H
16 #define CEPH_COMMON_INIT_H
17
18 #include <deque>
19
20 #include "common/code_environment.h"
21
22 class CephContext;
23 class CephInitParameters;
24
25 enum common_init_flags_t {
26 // Set up defaults that make sense for an unprivileged deamon
27 CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS = 0x1,
28
29 // By default, don't read a configuration file
30 CINIT_FLAG_NO_DEFAULT_CONFIG_FILE = 0x2,
31
32 // Don't close stderr (in daemonize)
33 CINIT_FLAG_NO_CLOSE_STDERR = 0x4,
34
35 // don't do anything daemonish, like create /var/run/ceph, or print a banner
36 CINIT_FLAG_NO_DAEMON_ACTIONS = 0x8,
37
38 // don't drop privileges
39 CINIT_FLAG_DEFER_DROP_PRIVILEGES = 0x10,
40 };
41
42 /*
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.
45 *
46 * common_preinit creates the CephContext.
47 *
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
51 * the user asked for.
52 *
53 * This is usually done by something like this:
54 * cct->_conf->parse_env();
55 * cct->_conf->apply_changes();
56 *
57 * Your library may also supply functions to read a configuration file.
58 */
59 CephContext *common_preinit(const CephInitParameters &iparams,
60 enum code_environment_t code_env, int flags);
61
62 /* Print out some parse errors. */
63 void complain_about_parse_errors(CephContext *cct,
64 std::deque<std::string> *parse_errors);
65
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.
69 *
70 * This includes things like starting threads, initializing libraries that
71 * can't handle forking, and so forth.
72 *
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().
77 */
78 void common_init_finish(CephContext *cct);
79
80 #endif