[lxc-devel] [lxc/master] dlog: inherit dlog fds

2xsec on Github lxc-bot at linuxcontainers.org
Tue Oct 23 10:12:27 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 441 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181023/a2bbde2e/attachment.bin>
-------------- next part --------------
From 81b542493655eba8ed04aca7679854b0f438514a Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Tue, 23 Oct 2018 19:07:07 +0900
Subject: [PATCH] dlog: inherit dlog fds

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/lxc/start.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/src/lxc/start.c b/src/lxc/start.c
index 55c2e0e99..a7563bf78 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -204,6 +204,35 @@ static inline bool match_stdfds(int fd)
 	return (fd == STDIN_FILENO || fd == STDOUT_FILENO || fd == STDERR_FILENO);
 }
 
+#ifdef HAVE_DLOG
+static bool match_dlog_fds(struct dirent *direntp)
+{
+	char path[PATH_MAX] = {0};
+	char link[PATH_MAX] = {0};
+	ssize_t linklen;
+	int ret;
+
+	ret = snprintf(path, PATH_MAX, "/proc/self/fd/%s", direntp->d_name);
+	if (ret < 0 || ret >= PATH_MAX) {
+		ERROR("Failed to create file descriptor name");
+		return false;
+	}
+
+	linklen = readlink(path, link, PATH_MAX);
+	if (linklen < 0 || linklen >= PATH_MAX) {
+		SYSERROR("Failed to read link path - \"%s\"", path);
+		return false;
+	}
+
+	if (strcmp(link, "/dev/log_main") == 0 ||
+	    strcmp(link, "/dev/log_system") == 0 ||
+	    strcmp(link, "/dev/log_radio") == 0)
+		return true;
+
+	return false;
+}
+#endif
+
 int lxc_check_inherited(struct lxc_conf *conf, bool closeall,
 			int *fds_to_ignore, size_t len_fds)
 {
@@ -265,6 +294,11 @@ int lxc_check_inherited(struct lxc_conf *conf, bool closeall,
 		if (matched)
 			continue;
 
+#ifdef HAVE_DLOG
+		if (match_dlog_fds(direntp))
+			continue;
+
+#endif
 		if (current_config && fd == current_config->logfd)
 			continue;
 


More information about the lxc-devel mailing list