Skip to content

Commit

Permalink
log: get rid of LOG_DIR_FD_OFF and opening cwd in log_init()
Browse files Browse the repository at this point in the history
Signed-off-by: Ruslan Kuprieiev <[email protected]>
Signed-off-by: Pavel Emelyanov <[email protected]>
  • Loading branch information
efiop authored and xemul committed Nov 15, 2013
1 parent 127637b commit dc80d6f
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 28 deletions.
1 change: 0 additions & 1 deletion cr-restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,6 @@ static int restore_one_task(int pid, CoreEntry *core)
int ret;

/* No more fork()-s => no more per-pid logs */
log_closedir();

switch ((int)core->tc->task_state) {
case TASK_ALIVE:
Expand Down
2 changes: 0 additions & 2 deletions cr-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
if (open_image_dir(".") < 0)
return -1;

log_closedir();

/* initiate log file in imgs dir */
if (req->log_file)
opts.output = req->log_file;
Expand Down
1 change: 0 additions & 1 deletion include/servicefd.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ enum sfd_type {
SERVICE_FD_MIN,

LOG_FD_OFF,
LOG_DIR_FD_OFF,
IMG_FD_OFF,
PROC_FD_OFF, /* fd with /proc for all proc_ calls */
CTL_TTY_OFF,
Expand Down
26 changes: 2 additions & 24 deletions log.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,13 @@ int log_get_fd(void)

int log_init(const char *output)
{
int new_logfd, dfd, fd;
int new_logfd, fd;

gettimeofday(&start, NULL);
buf_off = TS_BUF_OFF;

dfd = get_service_fd(LOG_DIR_FD_OFF);
if (dfd < 0) {
int tmp;
tmp = open(".", O_RDONLY);
if (tmp == -1) {
pr_perror("Can't open a current directory");
return -1;
}

dfd = install_service_fd(LOG_DIR_FD_OFF, tmp);
close(tmp);
if (dfd < 0)
return -1;
}

if (output) {
new_logfd = openat(dfd, output,
O_CREAT | O_TRUNC | O_WRONLY | O_APPEND, 0600);
new_logfd = open(output, O_CREAT|O_TRUNC|O_WRONLY|O_APPEND, 0600);
if (new_logfd < 0) {
pr_perror("Can't create log file %s", output);
return -1;
Expand Down Expand Up @@ -137,12 +121,6 @@ int log_init_by_pid(void)
void log_fini(void)
{
close_service_fd(LOG_FD_OFF);
log_closedir();
}

void log_closedir(void)
{
close_service_fd(LOG_DIR_FD_OFF);
}

void log_set_loglevel(unsigned int level)
Expand Down

0 comments on commit dc80d6f

Please sign in to comment.