[CRIU] [PATCH 3/N] log: get rid of LOG_DIR_FD_OFF and of opening directory at log_init()

Ruslan Kuprieiev kupruser at gmail.com
Thu Nov 14 17:33:51 PST 2013


We don't need this, since we are using work_dir.

Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 cr-restore.c        |  1 -
 cr-service.c        |  2 --
 include/servicefd.h |  2 +-
 log.c               | 26 ++------------------------
 4 files changed, 3 insertions(+), 28 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 3fa55dc..27169e7 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -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:
diff --git a/cr-service.c b/cr-service.c
index d2724e5..a10d07f 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -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;
diff --git a/include/servicefd.h b/include/servicefd.h
index 85526b0..3c8664c 100644
--- a/include/servicefd.h
+++ b/include/servicefd.h
@@ -7,7 +7,7 @@ enum sfd_type {
 	SERVICE_FD_MIN,
 
 	LOG_FD_OFF,
-	LOG_DIR_FD_OFF,
+	LOG_DIR_FD_OFF, /* unused */
 	IMG_FD_OFF,
 	PROC_FD_OFF,	/* fd with /proc for all proc_ calls */
 	CTL_TTY_OFF,
diff --git a/log.c b/log.c
index a3b1472..6f0f2b6 100644
--- a/log.c
+++ b/log.c
@@ -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;
@@ -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)
-- 
1.8.1.2



More information about the CRIU mailing list