Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
d0e1b257
Unverified
Commit
d0e1b257
authored
Aug 18, 2018
by
2xsec
Committed by
Christian Brauner
Aug 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: lxc-console: add default log priority & cleanups
Signed-off-by:
2xsec
<
dh48.jeong@samsung.com
>
parent
83a5624a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
42 deletions
+43
-42
lxc_console.c
src/lxc/tools/lxc_console.c
+43
-42
No files found.
src/lxc/tools/lxc_console.c
View file @
d0e1b257
...
@@ -44,28 +44,8 @@
...
@@ -44,28 +44,8 @@
lxc_log_define
(
lxc_console
,
lxc
);
lxc_log_define
(
lxc_console
,
lxc
);
static
char
etoc
(
const
char
*
expr
)
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
);
{
static
char
etoc
(
const
char
*
expr
);
/* returns "control code" of given expression */
char
c
=
expr
[
0
]
==
'^'
?
expr
[
1
]
:
expr
[
0
];
return
1
+
((
c
>
'Z'
)
?
(
c
-
'a'
)
:
(
c
-
'Z'
));
}
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
{
switch
(
c
)
{
case
't'
:
if
(
lxc_safe_uint
(
arg
,
&
args
->
ttynum
)
<
0
)
return
-
1
;
break
;
case
'e'
:
args
->
escape
=
etoc
(
arg
);
break
;
}
return
0
;
}
static
const
struct
option
my_longopts
[]
=
{
static
const
struct
option
my_longopts
[]
=
{
{
"tty"
,
required_argument
,
0
,
't'
},
{
"tty"
,
required_argument
,
0
,
't'
},
...
@@ -74,8 +54,8 @@ static const struct option my_longopts[] = {
...
@@ -74,8 +54,8 @@ static const struct option my_longopts[] = {
};
};
static
struct
lxc_arguments
my_args
=
{
static
struct
lxc_arguments
my_args
=
{
.
progname
=
"lxc-console"
,
.
progname
=
"lxc-console"
,
.
help
=
"\
.
help
=
"\
--name=NAME [--tty NUMBER]
\n
\
--name=NAME [--tty NUMBER]
\n
\
\n
\
\n
\
lxc-console logs on the container with the identifier NAME
\n
\
lxc-console logs on the container with the identifier NAME
\n
\
...
@@ -85,35 +65,56 @@ Options :\n\
...
@@ -85,35 +65,56 @@ Options :\n\
-t, --tty=NUMBER console tty number
\n
\
-t, --tty=NUMBER console tty number
\n
\
-e, --escape=PREFIX prefix for escape command
\n
\
-e, --escape=PREFIX prefix for escape command
\n
\
--rcfile=FILE Load configuration file FILE
\n
"
,
--rcfile=FILE Load configuration file FILE
\n
"
,
.
options
=
my_longopts
,
.
options
=
my_longopts
,
.
parser
=
my_parser
,
.
parser
=
my_parser
,
.
checker
=
NULL
,
.
checker
=
NULL
,
.
ttynum
=
-
1
,
.
log_priority
=
"ERROR"
,
.
escape
=
1
,
.
log_file
=
"none"
,
.
ttynum
=
-
1
,
.
escape
=
1
,
};
};
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
{
switch
(
c
)
{
case
't'
:
if
(
lxc_safe_uint
(
arg
,
&
args
->
ttynum
)
<
0
)
return
-
1
;
break
;
case
'e'
:
args
->
escape
=
etoc
(
arg
);
break
;
}
return
0
;
}
static
char
etoc
(
const
char
*
expr
)
{
/* returns "control code" of given expression */
char
c
=
expr
[
0
]
==
'^'
?
expr
[
1
]
:
expr
[
0
];
return
1
+
((
c
>
'Z'
)
?
(
c
-
'a'
)
:
(
c
-
'Z'
));
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
ret
;
int
ret
;
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
struct
lxc_log
log
;
struct
lxc_log
log
;
ret
=
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
);
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
if
(
ret
)
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
/* Only create log if explicitly instructed */
log
.
name
=
my_args
.
name
;
if
(
my_args
.
log_file
||
my_args
.
log_priority
)
{
log
.
file
=
my_args
.
log_file
;
log
.
name
=
my_args
.
name
;
log
.
level
=
my_args
.
log_priority
;
log
.
file
=
my_args
.
log_file
;
log
.
prefix
=
my_args
.
progname
;
log
.
level
=
my_args
.
log_priority
;
log
.
quiet
=
my_args
.
quiet
;
log
.
prefix
=
my_args
.
progname
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
if
(
lxc_log_init
(
&
log
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment