File: | cli/src/cli.c |
Location: | line 232, column 9 |
Description: | Value stored to 'ret' is never read |
1 | /* |
2 | Copyright (c) 2010-2012 Red Hat, Inc. <http://www.redhat.com> |
3 | This file is part of GlusterFS. |
4 | |
5 | This file is licensed to you under your choice of the GNU Lesser |
6 | General Public License, version 3 or any later version (LGPLv3 or |
7 | later), or the GNU General Public License, version 2 (GPLv2), in all |
8 | cases as published by the Free Software Foundation. |
9 | */ |
10 | #include <stdio.h> |
11 | #include <string.h> |
12 | #include <stdlib.h> |
13 | #include <netinet/in.h> |
14 | #include <sys/socket.h> |
15 | #include <sys/types.h> |
16 | #include <sys/resource.h> |
17 | #include <sys/file.h> |
18 | #include <netdb.h> |
19 | #include <signal.h> |
20 | #include <libgen.h> |
21 | |
22 | #include <sys/utsname.h> |
23 | |
24 | #include <stdint.h> |
25 | #include <pthread.h> |
26 | #include <sys/stat.h> |
27 | #include <fcntl.h> |
28 | #include <time.h> |
29 | #include <semaphore.h> |
30 | #include <errno(*__errno_location ()).h> |
31 | |
32 | #ifndef _CONFIG_H |
33 | #define _CONFIG_H |
34 | #include "config.h" |
35 | #endif |
36 | |
37 | #ifdef HAVE_MALLOC_H1 |
38 | #include <malloc.h> |
39 | #endif |
40 | |
41 | #ifdef HAVE_MALLOC_STATS1 |
42 | #ifdef DEBUG |
43 | #include <mcheck.h> |
44 | #endif |
45 | #endif |
46 | |
47 | #include "cli.h" |
48 | #include "cli-cmd.h" |
49 | #include "cli-mem-types.h" |
50 | |
51 | #include "xlator.h" |
52 | #include "glusterfs.h" |
53 | #include "compat.h" |
54 | #include "logging.h" |
55 | #include "dict.h" |
56 | #include "list.h" |
57 | #include "timer.h" |
58 | #include "stack.h" |
59 | #include "revision.h" |
60 | #include "common-utils.h" |
61 | #include "event.h" |
62 | #include "globals.h" |
63 | #include "syscall.h" |
64 | #include "call-stub.h" |
65 | #include <fnmatch.h> |
66 | |
67 | #include "xdr-generic.h" |
68 | |
69 | extern int connected; |
70 | /* using argp for command line parsing */ |
71 | |
72 | const char *argp_program_version = "" \ |
73 | PACKAGE_NAME"glusterfs"" "PACKAGE_VERSION"3git"" built on "__DATE__"May 5 2013"" "__TIME__"11:39:38" \ |
74 | "\nRepository revision: " GLUSTERFS_REPOSITORY_REVISION"git://git.gluster.com/glusterfs.git" "\n" \ |
75 | "Copyright (c) 2006-2011 Gluster Inc. " \ |
76 | "<http://www.gluster.com>\n" \ |
77 | "GlusterFS comes with ABSOLUTELY NO WARRANTY.\n" \ |
78 | "You may redistribute copies of GlusterFS under the terms of "\ |
79 | "the GNU General Public License."; |
80 | |
81 | const char *argp_program_bug_address = "<" PACKAGE_BUGREPORT"gluster-users@gluster.org" ">"; |
82 | |
83 | |
84 | |
85 | struct rpc_clnt *global_rpc; |
86 | |
87 | rpc_clnt_prog_t *cli_rpc_prog; |
88 | |
89 | |
90 | extern struct rpc_clnt_program cli_prog; |
91 | |
92 | static int |
93 | glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx) |
94 | { |
95 | cmd_args_t *cmd_args = NULL((void*)0); |
96 | struct rlimit lim = {0, }; |
97 | call_pool_t *pool = NULL((void*)0); |
98 | |
99 | xlator_mem_acct_init (THIS(*__glusterfs_this_location()), cli_mt_end); |
100 | |
101 | ctx->process_uuid = generate_glusterfs_ctx_id (); |
102 | if (!ctx->process_uuid) |
103 | return -1; |
104 | |
105 | ctx->page_size = 128 * GF_UNIT_KB1024ULL; |
106 | |
107 | ctx->iobuf_pool = iobuf_pool_new (); |
108 | if (!ctx->iobuf_pool) |
109 | return -1; |
110 | |
111 | ctx->event_pool = event_pool_new (DEFAULT_EVENT_POOL_SIZE16384); |
112 | if (!ctx->event_pool) |
113 | return -1; |
114 | |
115 | pool = GF_CALLOC (1, sizeof (call_pool_t),__gf_calloc (1, sizeof (call_pool_t), cli_mt_call_pool_t) |
116 | cli_mt_call_pool_t)__gf_calloc (1, sizeof (call_pool_t), cli_mt_call_pool_t); |
117 | if (!pool) |
118 | return -1; |
119 | |
120 | /* frame_mem_pool size 112 * 64 */ |
121 | pool->frame_mem_pool = mem_pool_new (call_frame_t, 32)mem_pool_new_fn (sizeof(call_frame_t), 32, "call_frame_t"); |
122 | if (!pool->frame_mem_pool) |
123 | return -1; |
124 | |
125 | /* stack_mem_pool size 256 * 128 */ |
126 | pool->stack_mem_pool = mem_pool_new (call_stack_t, 16)mem_pool_new_fn (sizeof(call_stack_t), 16, "call_stack_t"); |
127 | |
128 | if (!pool->stack_mem_pool) |
129 | return -1; |
130 | |
131 | ctx->stub_mem_pool = mem_pool_new (call_stub_t, 16)mem_pool_new_fn (sizeof(call_stub_t), 16, "call_stub_t"); |
132 | if (!ctx->stub_mem_pool) |
133 | return -1; |
134 | |
135 | ctx->dict_pool = mem_pool_new (dict_t, 32)mem_pool_new_fn (sizeof(dict_t), 32, "dict_t"); |
136 | if (!ctx->dict_pool) |
137 | return -1; |
138 | |
139 | ctx->dict_pair_pool = mem_pool_new (data_pair_t, 512)mem_pool_new_fn (sizeof(data_pair_t), 512, "data_pair_t"); |
140 | if (!ctx->dict_pair_pool) |
141 | return -1; |
142 | |
143 | ctx->dict_data_pool = mem_pool_new (data_t, 512)mem_pool_new_fn (sizeof(data_t), 512, "data_t"); |
144 | if (!ctx->dict_data_pool) |
145 | return -1; |
146 | |
147 | INIT_LIST_HEAD (&pool->all_frames)do { (&pool->all_frames)->next = (&pool->all_frames )->prev = &pool->all_frames; } while (0); |
148 | LOCK_INIT (&pool->lock)pthread_spin_init (&pool->lock, 0); |
149 | ctx->pool = pool; |
150 | |
151 | pthread_mutex_init (&(ctx->lock), NULL((void*)0)); |
152 | |
153 | cmd_args = &ctx->cmd_args; |
154 | |
155 | INIT_LIST_HEAD (&cmd_args->xlator_options)do { (&cmd_args->xlator_options)->next = (&cmd_args ->xlator_options)->prev = &cmd_args->xlator_options ; } while (0); |
156 | |
157 | lim.rlim_cur = RLIM_INFINITY0xffffffffffffffffuLL; |
158 | lim.rlim_max = RLIM_INFINITY0xffffffffffffffffuLL; |
159 | setrlimit (RLIMIT_CORERLIMIT_CORE, &lim); |
160 | |
161 | return 0; |
162 | } |
163 | |
164 | |
165 | static int |
166 | logging_init (glusterfs_ctx_t *ctx, struct cli_state *state) |
167 | { |
168 | char *log_file = state->log_file ? state->log_file : |
169 | DEFAULT_CLI_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs" "/cli.log"; |
170 | |
171 | if (gf_log_init (ctx, log_file) == -1) { |
172 | fprintf (stderrstderr, "ERROR: failed to open logfile %s\n", |
173 | log_file); |
174 | return -1; |
175 | } |
176 | |
177 | /* CLI should not have something to DEBUG after the release, |
178 | hence defaulting to INFO loglevel */ |
179 | gf_log_set_loglevel ((state->log_level == -1) ? GF_LOG_INFO : |
180 | state->log_level); |
181 | |
182 | return 0; |
183 | } |
184 | |
185 | int |
186 | cli_submit_request (void *req, call_frame_t *frame, |
187 | rpc_clnt_prog_t *prog, |
188 | int procnum, struct iobref *iobref, |
189 | xlator_t *this, fop_cbk_fn_t cbkfn, xdrproc_t xdrproc) |
190 | { |
191 | int ret = -1; |
192 | int count = 0; |
193 | struct iovec iov = {0, }; |
194 | struct iobuf *iobuf = NULL((void*)0); |
195 | char new_iobref = 0; |
196 | ssize_t xdr_size = 0; |
197 | |
198 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "cli.c", __FUNCTION__ , 198, GF_LOG_ERROR, "Assertion failed: " "this"); } while (0 ); } } while (0); |
199 | |
200 | if (req) { |
201 | xdr_size = xdr_sizeof (xdrproc, req); |
202 | iobuf = iobuf_get2 (this->ctx->iobuf_pool, xdr_size); |
203 | if (!iobuf) { |
204 | goto out; |
205 | }; |
206 | |
207 | if (!iobref) { |
208 | iobref = iobref_new (); |
209 | if (!iobref) { |
210 | goto out; |
211 | } |
212 | |
213 | new_iobref = 1; |
214 | } |
215 | |
216 | iobref_add (iobref, iobuf); |
217 | |
218 | iov.iov_base = iobuf->ptr; |
219 | iov.iov_len = iobuf_size (iobuf); |
220 | |
221 | |
222 | /* Create the xdr payload */ |
223 | ret = xdr_serialize_generic (iov, req, xdrproc); |
224 | if (ret == -1) { |
225 | goto out; |
226 | } |
227 | iov.iov_len = ret; |
228 | count = 1; |
229 | } |
230 | |
231 | /* Send the msg */ |
232 | ret = rpc_clnt_submit (global_rpc, prog, procnum, cbkfn, |
Value stored to 'ret' is never read | |
233 | &iov, count, |
234 | NULL((void*)0), 0, iobref, frame, NULL((void*)0), 0, NULL((void*)0), 0, NULL((void*)0)); |
235 | ret = 0; |
236 | |
237 | out: |
238 | if (new_iobref) |
239 | iobref_unref (iobref); |
240 | if (iobuf) |
241 | iobuf_unref (iobuf); |
242 | return ret; |
243 | } |
244 | |
245 | int |
246 | cli_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, |
247 | void *data) |
248 | { |
249 | xlator_t *this = NULL((void*)0); |
250 | int ret = 0; |
251 | |
252 | this = mydata; |
253 | |
254 | switch (event) { |
255 | case RPC_CLNT_CONNECT: |
256 | { |
257 | |
258 | cli_cmd_broadcast_connected (); |
259 | gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_CONNECT")do { do { if (0) printf ("got RPC_CLNT_CONNECT"); } while (0) ; _gf_log (this->name, "cli.c", __FUNCTION__, 259, GF_LOG_TRACE , "got RPC_CLNT_CONNECT"); } while (0); |
260 | break; |
261 | } |
262 | |
263 | case RPC_CLNT_DISCONNECT: |
264 | { |
265 | gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_DISCONNECT")do { do { if (0) printf ("got RPC_CLNT_DISCONNECT"); } while ( 0); _gf_log (this->name, "cli.c", __FUNCTION__, 265, GF_LOG_TRACE , "got RPC_CLNT_DISCONNECT"); } while (0); |
266 | connected = 0; |
267 | if (!global_state->prompt && global_state->await_connected) { |
268 | ret = 1; |
269 | cli_out ("Connection failed. Please check if gluster "do { do { if (0) printf ("Connection failed. Please check if gluster " "daemon is operational."); } while (0); _cli_out("Connection failed. Please check if gluster " "daemon is operational."); } while (0) |
270 | "daemon is operational.")do { do { if (0) printf ("Connection failed. Please check if gluster " "daemon is operational."); } while (0); _cli_out("Connection failed. Please check if gluster " "daemon is operational."); } while (0); |
271 | exit (ret); |
272 | } |
273 | break; |
274 | } |
275 | |
276 | default: |
277 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("got some other RPC event %d", event ); } while (0); _gf_log (this->name, "cli.c", __FUNCTION__ , 278, GF_LOG_TRACE, "got some other RPC event %d", event); } while (0) |
278 | "got some other RPC event %d", event)do { do { if (0) printf ("got some other RPC event %d", event ); } while (0); _gf_log (this->name, "cli.c", __FUNCTION__ , 278, GF_LOG_TRACE, "got some other RPC event %d", event); } while (0); |
279 | ret = 0; |
280 | break; |
281 | } |
282 | |
283 | return ret; |
284 | } |
285 | |
286 | |
287 | /* |
288 | * ret: 0: option successfully processed |
289 | * 1: signalling end of option list |
290 | * -1: unknown option or other issue |
291 | */ |
292 | int |
293 | cli_opt_parse (char *opt, struct cli_state *state) |
294 | { |
295 | char *oarg; |
296 | |
297 | if (strcmp (opt, "") == 0) |
298 | return 1; |
299 | |
300 | if (strcmp (opt, "version") == 0) { |
301 | cli_out ("%s", argp_program_version)do { do { if (0) printf ("%s", argp_program_version); } while (0); _cli_out("%s", argp_program_version); } while (0); |
302 | exit (0); |
303 | } |
304 | |
305 | if (strcmp (opt, "print-logdir") == 0) { |
306 | cli_out ("%s", DEFAULT_LOG_FILE_DIRECTORY)do { do { if (0) printf ("%s", "/usr/local/var" "/log/glusterfs" ); } while (0); _cli_out("%s", "/usr/local/var" "/log/glusterfs" ); } while (0); |
307 | exit (0); |
308 | } |
309 | |
310 | if (strcmp (opt, "print-statedumpdir") == 0) { |
311 | cli_out ("%s", DEFAULT_VAR_RUN_DIRECTORY)do { do { if (0) printf ("%s", "/usr/local/var" "/run/gluster" ); } while (0); _cli_out("%s", "/usr/local/var" "/run/gluster" ); } while (0); |
312 | exit (0); |
313 | } |
314 | |
315 | if (strcmp (opt, "xml") == 0) { |
316 | #if (HAVE_LIB_XML1) |
317 | state->mode |= GLUSTER_MODE_XML(1 << 2); |
318 | #else |
319 | cli_err ("XML output not supported. Ignoring '--xml' option")do { do { if (0) printf ("XML output not supported. Ignoring '--xml' option" ); } while (0); _cli_err("XML output not supported. Ignoring '--xml' option" ); } while (0); |
320 | #endif |
321 | return 0; |
322 | } |
323 | |
324 | oarg = strtail (opt, "mode="); |
325 | if (oarg) { |
326 | if (strcmp (oarg, "script") == 0) { |
327 | state->mode |= GLUSTER_MODE_SCRIPT(1 << 0); |
328 | return 0; |
329 | } |
330 | if (strcmp (oarg, "interactive") == 0) |
331 | return 0; |
332 | return -1; |
333 | } |
334 | |
335 | oarg = strtail (opt, "remote-host="); |
336 | if (oarg) { |
337 | state->remote_host = oarg; |
338 | return 0; |
339 | } |
340 | |
341 | oarg = strtail (opt, "log-file="); |
342 | if (oarg) { |
343 | state->log_file = oarg; |
344 | return 0; |
345 | } |
346 | |
347 | oarg = strtail (opt, "log-level="); |
348 | if (oarg) { |
349 | state->log_level = glusterd_check_log_level(oarg); |
350 | if (state->log_level == -1) |
351 | return -1; |
352 | return 0; |
353 | } |
354 | |
355 | return -1; |
356 | } |
357 | |
358 | int |
359 | parse_cmdline (int argc, char *argv[], struct cli_state *state) |
360 | { |
361 | int ret = 0; |
362 | int i = 0; |
363 | int j = 0; |
364 | char *opt = NULL((void*)0); |
365 | |
366 | state->argc=argc-1; |
367 | state->argv=&argv[1]; |
368 | |
369 | for (i = 0; i < state->argc; i++) { |
370 | opt = strtail (state->argv[i], "--"); |
371 | if (opt) { |
372 | ret = cli_opt_parse (opt, state); |
373 | if (ret == -1) { |
374 | cli_out ("unrecognized option --%s", opt)do { do { if (0) printf ("unrecognized option --%s", opt); } while (0); _cli_out("unrecognized option --%s", opt); } while (0); |
375 | return ret; |
376 | } |
377 | for (j = i; j < state->argc - 1; j++) |
378 | state->argv[j] = state->argv[j + 1]; |
379 | state->argc--; |
380 | /* argv shifted, next check should be at i again */ |
381 | i--; |
382 | if (ret == 1) { |
383 | /* end of cli options */ |
384 | ret = 0; |
385 | break; |
386 | } |
387 | } |
388 | } |
389 | |
390 | state->argv[state->argc] = NULL((void*)0); |
391 | |
392 | return ret; |
393 | } |
394 | |
395 | |
396 | int |
397 | cli_cmd_tree_init (struct cli_cmd_tree *tree) |
398 | { |
399 | struct cli_cmd_word *root = NULL((void*)0); |
400 | int ret = 0; |
401 | |
402 | root = &tree->root; |
403 | root->tree = tree; |
404 | |
405 | return ret; |
406 | } |
407 | |
408 | |
409 | int |
410 | cli_state_init (struct cli_state *state) |
411 | { |
412 | struct cli_cmd_tree *tree = NULL((void*)0); |
413 | int ret = 0; |
414 | |
415 | |
416 | state->remote_host = "localhost"; |
417 | state->log_level = -1; |
418 | |
419 | tree = &state->tree; |
420 | tree->state = state; |
421 | |
422 | ret = cli_cmd_tree_init (tree); |
423 | |
424 | return ret; |
425 | } |
426 | |
427 | int |
428 | cli_usage_out (const char *usage) |
429 | { |
430 | GF_ASSERT (usage)do { if (!(usage)) { do { do { if (0) printf ("Assertion failed: " "usage"); } while (0); _gf_log_callingfn ("", "cli.c", __FUNCTION__ , 430, GF_LOG_ERROR, "Assertion failed: " "usage"); } while ( 0); } } while (0); |
431 | GF_ASSERT (usage[0] != '\0')do { if (!(usage[0] != '\0')) { do { do { if (0) printf ("Assertion failed: " "usage[0] != '\\0'"); } while (0); _gf_log_callingfn ("", "cli.c" , __FUNCTION__, 431, GF_LOG_ERROR, "Assertion failed: " "usage[0] != '\\0'" ); } while (0); } } while (0); |
432 | |
433 | if (!usage || usage[0] == '\0') |
434 | return -1; |
435 | |
436 | cli_err ("Usage: %s", usage)do { do { if (0) printf ("Usage: %s", usage); } while (0); _cli_err ("Usage: %s", usage); } while (0); |
437 | return 0; |
438 | } |
439 | |
440 | int |
441 | _cli_err (const char *fmt, ...) |
442 | { |
443 | struct cli_state *state = NULL((void*)0); |
444 | va_list ap; |
445 | int ret = 0; |
446 | |
447 | state = global_state; |
448 | |
449 | va_start (ap, fmt)__builtin_va_start(ap, fmt); |
450 | |
451 | #ifdef HAVE_READLINE1 |
452 | if (state->rl_enabled && !state->rl_processing) |
453 | return cli_rl_err(state, fmt, ap); |
454 | #endif |
455 | |
456 | ret = vfprintf (stderrstderr, fmt, ap); |
457 | fprintf (stderrstderr, "\n"); |
458 | va_end (ap)__builtin_va_end(ap); |
459 | |
460 | return ret; |
461 | } |
462 | |
463 | |
464 | int |
465 | _cli_out (const char *fmt, ...) |
466 | { |
467 | struct cli_state *state = NULL((void*)0); |
468 | va_list ap; |
469 | int ret = 0; |
470 | |
471 | state = global_state; |
472 | |
473 | va_start (ap, fmt)__builtin_va_start(ap, fmt); |
474 | |
475 | #ifdef HAVE_READLINE1 |
476 | if (state->rl_enabled && !state->rl_processing) |
477 | return cli_rl_out(state, fmt, ap); |
478 | #endif |
479 | |
480 | ret = vprintf (fmt, ap); |
481 | printf ("\n"); |
482 | va_end (ap)__builtin_va_end(ap); |
483 | |
484 | return ret; |
485 | } |
486 | |
487 | struct rpc_clnt * |
488 | cli_rpc_init (struct cli_state *state) |
489 | { |
490 | struct rpc_clnt *rpc = NULL((void*)0); |
491 | dict_t *options = NULL((void*)0); |
492 | int ret = -1; |
493 | int port = CLI_GLUSTERD_PORT24007; |
494 | xlator_t *this = NULL((void*)0); |
495 | |
496 | |
497 | this = THIS(*__glusterfs_this_location()); |
498 | cli_rpc_prog = &cli_prog; |
499 | options = dict_new (); |
500 | if (!options) |
501 | goto out; |
502 | |
503 | ret = dict_set_str (options, "remote-host", state->remote_host); |
504 | if (ret) |
505 | goto out; |
506 | |
507 | if (state->remote_port) |
508 | port = state->remote_port; |
509 | |
510 | ret = dict_set_int32 (options, "remote-port", port); |
511 | if (ret) |
512 | goto out; |
513 | |
514 | ret = dict_set_str (options, "transport.address-family", "inet"); |
515 | if (ret) |
516 | goto out; |
517 | |
518 | rpc = rpc_clnt_new (options, this->ctx, this->name, 16); |
519 | |
520 | if (!rpc) |
521 | goto out; |
522 | |
523 | ret = rpc_clnt_register_notify (rpc, cli_rpc_notify, this); |
524 | if (ret) { |
525 | gf_log ("cli", GF_LOG_ERROR, "failed to register notify")do { do { if (0) printf ("failed to register notify"); } while (0); _gf_log ("cli", "cli.c", __FUNCTION__, 525, GF_LOG_ERROR , "failed to register notify"); } while (0); |
526 | goto out; |
527 | } |
528 | |
529 | rpc_clnt_start (rpc); |
530 | out: |
531 | if (ret) { |
532 | if (rpc) |
533 | rpc_clnt_unref (rpc); |
534 | rpc = NULL((void*)0); |
535 | } |
536 | return rpc; |
537 | } |
538 | |
539 | cli_local_t * |
540 | cli_local_get () |
541 | { |
542 | cli_local_t *local = NULL((void*)0); |
543 | |
544 | local = GF_CALLOC (1, sizeof (*local), cli_mt_cli_local_t)__gf_calloc (1, sizeof (*local), cli_mt_cli_local_t); |
545 | |
546 | return local; |
547 | } |
548 | |
549 | void |
550 | cli_local_wipe (cli_local_t *local) |
551 | { |
552 | if (local) { |
553 | GF_FREE (local->get_vol.volname)__gf_free (local->get_vol.volname); |
554 | if (local->dict) |
555 | dict_unref (local->dict); |
556 | GF_FREE (local)__gf_free (local); |
557 | } |
558 | |
559 | return; |
560 | } |
561 | |
562 | struct cli_state *global_state; |
563 | |
564 | int |
565 | main (int argc, char *argv[]) |
566 | { |
567 | struct cli_state state = {0, }; |
568 | int ret = -1; |
569 | glusterfs_ctx_t *ctx = NULL((void*)0); |
570 | |
571 | ctx = glusterfs_ctx_new (); |
572 | if (!ctx) |
573 | return ENOMEM12; |
574 | |
575 | #ifdef DEBUG |
576 | gf_mem_acct_enable_set (ctx); |
577 | #endif |
578 | |
579 | ret = glusterfs_globals_init (ctx); |
580 | if (ret) |
581 | return ret; |
582 | |
583 | THIS(*__glusterfs_this_location())->ctx = ctx; |
584 | |
585 | ret = glusterfs_ctx_defaults_init (ctx); |
586 | if (ret) |
587 | goto out; |
588 | |
589 | ret = cli_state_init (&state); |
590 | if (ret) |
591 | goto out; |
592 | |
593 | state.ctx = ctx; |
594 | global_state = &state; |
595 | |
596 | ret = parse_cmdline (argc, argv, &state); |
597 | if (ret) |
598 | goto out; |
599 | |
600 | ret = logging_init (ctx, &state); |
601 | if (ret) |
602 | goto out; |
603 | |
604 | global_rpc = cli_rpc_init (&state); |
605 | if (!global_rpc) |
606 | goto out; |
607 | |
608 | ret = cli_cmds_register (&state); |
609 | if (ret) |
610 | goto out; |
611 | |
612 | ret = cli_cmd_cond_init (); |
613 | if (ret) |
614 | goto out; |
615 | |
616 | ret = cli_input_init (&state); |
617 | if (ret) |
618 | goto out; |
619 | |
620 | ret = event_dispatch (ctx->event_pool); |
621 | |
622 | out: |
623 | // glusterfs_ctx_destroy (ctx); |
624 | |
625 | return ret; |
626 | } |
627 | |
628 | void |
629 | cli_print_line (int len) |
630 | { |
631 | GF_ASSERT (len > 0)do { if (!(len > 0)) { do { do { if (0) printf ("Assertion failed: " "len > 0"); } while (0); _gf_log_callingfn ("", "cli.c", __FUNCTION__ , 631, GF_LOG_ERROR, "Assertion failed: " "len > 0"); } while (0); } } while (0); |
632 | |
633 | while (len--) |
634 | printf ("-"); |
635 | |
636 | printf ("\n"); |
637 | } |