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
966b9ecd
Unverified
Commit
966b9ecd
authored
Nov 15, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: rotate console log file
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
cf685555
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
2 deletions
+35
-2
commands.c
src/lxc/commands.c
+29
-0
confile.c
src/lxc/confile.c
+4
-1
console.c
src/lxc/console.c
+1
-1
console.h
src/lxc/console.h
+1
-0
No files found.
src/lxc/commands.c
View file @
966b9ecd
...
@@ -1064,6 +1064,10 @@ static int lxc_cmd_console_log_callback(int fd, struct lxc_cmd_req *req,
...
@@ -1064,6 +1064,10 @@ static int lxc_cmd_console_log_callback(int fd, struct lxc_cmd_req *req,
rsp
.
ret
=
0
;
rsp
.
ret
=
0
;
if
(
log
->
clear
)
{
if
(
log
->
clear
)
{
int
ret
;
size_t
len
;
char
*
tmp
;
/* clear the ringbuffer */
/* clear the ringbuffer */
lxc_ringbuf_clear
(
buf
);
lxc_ringbuf_clear
(
buf
);
...
@@ -1086,6 +1090,31 @@ static int lxc_cmd_console_log_callback(int fd, struct lxc_cmd_req *req,
...
@@ -1086,6 +1090,31 @@ static int lxc_cmd_console_log_callback(int fd, struct lxc_cmd_req *req,
goto
out
;
goto
out
;
}
}
}
}
/* rotate the console log file */
if
(
!
console
->
log_path
||
console
->
log_rotate
==
0
)
goto
out
;
/* be very certain things are kosher */
rsp
.
ret
=
-
EBADF
;
if
(
console
->
log_fd
<
0
)
goto
out
;
len
=
strlen
(
console
->
log_path
)
+
sizeof
(
".1"
);
tmp
=
alloca
(
len
);
rsp
.
ret
=
-
EFBIG
;
ret
=
snprintf
(
tmp
,
len
,
"%s.1"
,
console
->
log_path
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
len
)
goto
out
;
close
(
console
->
log_fd
);
console
->
log_fd
=
-
1
;
rsp
.
ret
=
lxc_unpriv
(
rename
(
console
->
log_path
,
tmp
));
if
(
rsp
.
ret
<
0
)
goto
out
;
rsp
.
ret
=
lxc_console_create_log_file
(
console
);
}
else
if
(
rsp
.
datalen
>
0
)
{
}
else
if
(
rsp
.
datalen
>
0
)
{
lxc_ringbuf_move_read_addr
(
buf
,
rsp
.
datalen
);
lxc_ringbuf_move_read_addr
(
buf
,
rsp
.
datalen
);
}
}
...
...
src/lxc/confile.c
View file @
966b9ecd
...
@@ -1803,8 +1803,11 @@ static int set_config_console_rotate(const char *key, const char *value,
...
@@ -1803,8 +1803,11 @@ static int set_config_console_rotate(const char *key, const char *value,
if
(
lxc_safe_uint
(
value
,
&
lxc_conf
->
console
.
log_rotate
)
<
0
)
if
(
lxc_safe_uint
(
value
,
&
lxc_conf
->
console
.
log_rotate
)
<
0
)
return
-
1
;
return
-
1
;
if
(
lxc_conf
->
console
.
log_rotate
>
1
)
if
(
lxc_conf
->
console
.
log_rotate
>
1
)
{
ERROR
(
"The
\"
lxc.console.rotate
\"
config key can only be set "
"to 0 or 1"
);
return
-
1
;
return
-
1
;
}
return
0
;
return
0
;
}
}
...
...
src/lxc/console.c
View file @
966b9ecd
...
@@ -674,7 +674,7 @@ static int lxc_console_create_ringbuf(struct lxc_console *console)
...
@@ -674,7 +674,7 @@ static int lxc_console_create_ringbuf(struct lxc_console *console)
* This is the console log file. Please note that the console log file is
* This is the console log file. Please note that the console log file is
* (implementation wise not content wise) independent of the console ringbuffer.
* (implementation wise not content wise) independent of the console ringbuffer.
*/
*/
static
int
lxc_console_create_log_file
(
struct
lxc_console
*
console
)
int
lxc_console_create_log_file
(
struct
lxc_console
*
console
)
{
{
if
(
!
console
->
log_path
)
if
(
!
console
->
log_path
)
return
0
;
return
0
;
...
...
src/lxc/console.h
View file @
966b9ecd
...
@@ -222,5 +222,6 @@ extern int lxc_console_cb_signal_fd(int fd, uint32_t events, void *cbdata,
...
@@ -222,5 +222,6 @@ extern int lxc_console_cb_signal_fd(int fd, uint32_t events, void *cbdata,
extern
void
lxc_console_signal_fini
(
struct
lxc_tty_state
*
ts
);
extern
void
lxc_console_signal_fini
(
struct
lxc_tty_state
*
ts
);
extern
int
lxc_console_write_ringbuffer
(
struct
lxc_console
*
console
);
extern
int
lxc_console_write_ringbuffer
(
struct
lxc_console
*
console
);
extern
int
lxc_console_create_log_file
(
struct
lxc_console
*
console
);
#endif
#endif
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