Motr  M0
m0mkfs.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2014-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #include <stdio.h> /* fprintf */
24 #include <unistd.h> /* pause */
25 #include <signal.h> /* sigaction */
26 #include <sys/time.h>
27 #include <sys/resource.h>
28 
29 #include "lib/errno.h"
30 #include "lib/memory.h"
31 #include "lib/misc.h" /* M0_SET0 */
32 #include "lib/uuid.h" /* m0_node_uuid_string_set */
33 
34 #include "motr/setup.h"
35 #include "motr/init.h"
36 #include "motr/version.h"
37 #include "module/instance.h" /* m0 */
38 #include "net/lnet/lnet.h"
39 #include "reqh/reqh_service.h"
40 
95 M0_INTERNAL int main(int argc, char **argv)
96 {
97  int rc;
98  int i;
99  struct m0_motr motr_ctx;
100  static struct m0 instance;
101  struct rlimit rlim = {10240, 10240};
102  char *uuid = NULL;
103 
104  if (argc > 1 &&
105  (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0)) {
107  exit(EXIT_SUCCESS);
108  }
109 
110  rc = setrlimit(RLIMIT_NOFILE, &rlim);
111  if (rc != 0) {
112  fprintf(stderr, "\n Failed to setrlimit\n");
113  goto out;
114  }
115 
116  for (i = 0; i < argc; ++i)
117  if (m0_streq("-u", argv[i])) {
118  uuid = argv[i + 1];
119  break;
120  }
122 
123  errno = 0;
124  M0_SET0(&motr_ctx);
125  rc = m0_init(&instance);
126  if (rc != 0) {
127  fprintf(stderr, "\n Failed to initialise Motr \n");
128  goto out;
129  }
130 
132  stderr, true);
133  if (rc != 0) {
134  fprintf(stderr, "\n Failed to initialise Motr \n");
135  goto cleanup;
136  }
137 
138  rc = m0_cs_setup_env(&motr_ctx, argc, argv);
139  m0_cs_fini(&motr_ctx);
140 cleanup:
141  m0_fini();
142 out:
143  errno = rc < 0 ? -rc : rc;
144  return errno;
145 }
146 
149 /*
150  * Local variables:
151  * c-indentation-style: "K&R"
152  * c-basic-offset: 8
153  * tab-width: 8
154  * fill-column: 80
155  * scroll-step: 1
156  * End:
157  */
struct m0_uint128 uuid[1000]
Definition: uuid.c:73
#define NULL
Definition: misc.h:38
void m0_fini(void)
Definition: init.c:318
int m0_cs_setup_env(struct m0_motr *cctx, int argc, char **argv)
Definition: setup.c:2972
void m0_cs_fini(struct m0_motr *cctx)
Definition: setup.c:3029
int m0_init(struct m0 *instance)
Definition: init.c:310
#define M0_SET0(obj)
Definition: misc.h:64
int i
Definition: dir.c:1033
void m0_build_info_print(void)
Definition: version.c:66
void m0_node_uuid_string_set(const char *uuid)
Definition: uuuid.c:64
#define m0_streq(a, b)
Definition: string.h:34
int m0_net_xprt_nr(void)
Definition: net.c:168
Definition: instance.h:80
int m0_cs_init(struct m0_motr *cctx, struct m0_net_xprt **xprts, size_t xprts_nr, FILE *out, bool mkfs)
Definition: setup.c:2999
Definition: setup.h:354
struct m0_net_xprt ** m0_net_all_xprt_get(void)
Definition: net.c:161
static struct m0 instance
Definition: main.c:78
M0_INTERNAL int main(int argc, char **argv)
Definition: m0mkfs.c:95
#define out(...)
Definition: gen.c:41
int32_t rc
Definition: trigger_fop.h:47