Commit 138eda99 by 2xsec

tools: lxc-console: share internal API symbols

Signed-off-by: 's avatar2xsec <dh48.jeong@samsung.com>
parent b27cdf66
...@@ -269,7 +269,7 @@ lxc_attach_SOURCES = tools/lxc_attach.c tools/arguments.c ...@@ -269,7 +269,7 @@ lxc_attach_SOURCES = tools/lxc_attach.c tools/arguments.c
lxc_autostart_SOURCES = tools/lxc_autostart.c tools/arguments.c lxc_autostart_SOURCES = tools/lxc_autostart.c tools/arguments.c
lxc_cgroup_SOURCES = tools/lxc_cgroup.c tools/arguments.c lxc_cgroup_SOURCES = tools/lxc_cgroup.c tools/arguments.c
lxc_config_SOURCES = tools/lxc_config.c tools/arguments.c lxc_config_SOURCES = tools/lxc_config.c tools/arguments.c
lxc_console_SOURCES = tools/lxc_console.c tools/arguments.c tools/tool_utils.c lxc_console_SOURCES = tools/lxc_console.c tools/arguments.c
lxc_destroy_SOURCES = tools/lxc_destroy.c tools/arguments.c tools/tool_utils.c lxc_destroy_SOURCES = tools/lxc_destroy.c tools/arguments.c tools/tool_utils.c
lxc_device_SOURCES = tools/lxc_device.c tools/arguments.c tools/tool_utils.c lxc_device_SOURCES = tools/lxc_device.c tools/arguments.c tools/tool_utils.c
lxc_execute_SOURCES = tools/lxc_execute.c tools/arguments.c tools/tool_utils.c lxc_execute_SOURCES = tools/lxc_execute.c tools/arguments.c tools/tool_utils.c
......
...@@ -39,16 +39,20 @@ ...@@ -39,16 +39,20 @@
#include <lxc/lxccontainer.h> #include <lxc/lxccontainer.h>
#include "arguments.h" #include "arguments.h"
#include "tool_utils.h" #include "log.h"
#include "utils.h"
lxc_log_define(lxc_console, lxc);
static char etoc(const char *expr) static char etoc(const char *expr)
{ {
/* returns "control code" of given expression */ /* returns "control code" of given expression */
char c = expr[0] == '^' ? expr[1] : expr[0]; char c = expr[0] == '^' ? expr[1] : expr[0];
return 1 + ((c > 'Z') ? (c - 'a') : (c - 'Z')); return 1 + ((c > 'Z') ? (c - 'a') : (c - 'Z'));
} }
static int my_parser(struct lxc_arguments* args, int c, char* arg) static int my_parser(struct lxc_arguments *args, int c, char *arg)
{ {
switch (c) { switch (c) {
case 't': case 't':
...@@ -59,6 +63,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg) ...@@ -59,6 +63,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
args->escape = etoc(arg); args->escape = etoc(arg);
break; break;
} }
return 0; return 0;
} }
...@@ -95,7 +100,7 @@ int main(int argc, char *argv[]) ...@@ -95,7 +100,7 @@ int main(int argc, char *argv[])
ret = lxc_arguments_parse(&my_args, argc, argv); ret = lxc_arguments_parse(&my_args, argc, argv);
if (ret) if (ret)
return EXIT_FAILURE; exit(EXIT_FAILURE);
/* Only create log if explicitly instructed */ /* Only create log if explicitly instructed */
if (my_args.log_file || my_args.log_priority) { if (my_args.log_file || my_args.log_priority) {
...@@ -112,33 +117,35 @@ int main(int argc, char *argv[]) ...@@ -112,33 +117,35 @@ int main(int argc, char *argv[])
c = lxc_container_new(my_args.name, my_args.lxcpath[0]); c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
if (!c) { if (!c) {
fprintf(stderr, "System error loading container\n"); ERROR("System error loading container");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (my_args.rcfile) { if (my_args.rcfile) {
c->clear_config(c); c->clear_config(c);
if (!c->load_config(c, my_args.rcfile)) { if (!c->load_config(c, my_args.rcfile)) {
fprintf(stderr, "Failed to load rcfile\n"); ERROR("Failed to load rcfile");
lxc_container_put(c); lxc_container_put(c);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
c->configfile = strdup(my_args.rcfile); c->configfile = strdup(my_args.rcfile);
if (!c->configfile) { if (!c->configfile) {
fprintf(stderr, "Out of memory setting new config filename\n"); ERROR("Out of memory setting new config filename");
lxc_container_put(c); lxc_container_put(c);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
if (!c->may_control(c)) { if (!c->may_control(c)) {
fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name); ERROR("Insufficent privileges to control %s", my_args.name);
lxc_container_put(c); lxc_container_put(c);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (!c->is_running(c)) { if (!c->is_running(c)) {
fprintf(stderr, "%s is not running\n", my_args.name); ERROR("%s is not running", my_args.name);
lxc_container_put(c); lxc_container_put(c);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -148,6 +155,7 @@ int main(int argc, char *argv[]) ...@@ -148,6 +155,7 @@ int main(int argc, char *argv[])
lxc_container_put(c); lxc_container_put(c);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
lxc_container_put(c); lxc_container_put(c);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment