Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / global / global_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) 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_GLOBAL_INIT_H
16 #define CEPH_COMMON_GLOBAL_INIT_H
17
18 #include <stdint.h>
19 #include <vector>
20 #include <boost/intrusive_ptr.hpp>
21 #include "include/assert.h"
22 #include "common/code_environment.h"
23 #include "common/common_init.h"
24
25 class CephContext;
26
27 /*
28  * global_init is the first initialization function that
29  * daemons and utility programs need to call. It takes care of a lot of
30  * initialization, including setting up g_ceph_context.
31  */
32 boost::intrusive_ptr<CephContext>
33      global_init(std::vector < const char * > *alt_def_args,
34                  std::vector < const char* >& args,
35                  uint32_t module_type,
36                  code_environment_t code_env,
37                  int flags,
38                  const char *data_dir_option = 0,
39                  bool run_pre_init = true);
40
41 void intrusive_ptr_add_ref(CephContext* cct);
42 void intrusive_ptr_release(CephContext* cct);
43
44 // just the first half; enough to get config parsed but doesn't start up the
45 // cct or log.
46 void global_pre_init(std::vector < const char * > *alt_def_args,
47                      std::vector < const char* >& args,
48                      uint32_t module_type, code_environment_t code_env,
49                      int flags,
50                      const char *data_dir_option = 0);
51
52 /*
53  * perform all of the steps that global_init_daemonize performs just prior
54  * to actually forking (via daemon(3)).  return 0 if we are going to proceed
55  * with the fork, or -1 otherwise.
56  */
57 int global_init_prefork(CephContext *cct);
58
59 /*
60  * perform all the steps that global_init_daemonize performs just after
61  * the fork, except closing stderr, which we'll do later on.
62  */
63 void global_init_postfork_start(CephContext *cct);
64
65 /*
66  * close stderr, thus completing the postfork.
67  */
68 void global_init_postfork_finish(CephContext *cct);
69
70
71 /*
72  * global_init_daemonize handles daemonizing a process. 
73  *
74  * If this is called, it *must* be called before common_init_finish.
75  * Note that this is equivalent to calling _prefork(), daemon(), and
76  * _postfork.
77  */
78 void global_init_daemonize(CephContext *cct);
79
80 /*
81  * global_init_chdir changes the process directory.
82  *
83  * If this is called, it *must* be called before common_init_finish
84  */
85 void global_init_chdir(const CephContext *cct);
86
87 /*
88  * Explicitly shut down stderr. Usually, you don't need to do
89  * this, because global_init_daemonize will do it for you. However, in some
90  * rare cases you need to call this explicitly.
91  *
92  * If this is called, it *must* be called before common_init_finish
93  */
94 int global_init_shutdown_stderr(CephContext *cct);
95
96 /*
97  * Preload the erasure coding libraries to detect early issues with
98  * configuration.
99  */
100 int global_init_preload_erasure_code(const CephContext *cct);
101
102 /**
103  * print daemon startup banner/warning
104  */
105 void global_print_banner(void);
106
107 #endif