start: preserve_ns()

parent 0d98d367
...@@ -141,18 +141,10 @@ static void close_ns(int ns_fd[LXC_NS_MAX]) ...@@ -141,18 +141,10 @@ static void close_ns(int ns_fd[LXC_NS_MAX])
*/ */
static bool preserve_ns(int ns_fd[LXC_NS_MAX], int clone_flags, pid_t pid) static bool preserve_ns(int ns_fd[LXC_NS_MAX], int clone_flags, pid_t pid)
{ {
int i, ret; int i;
for (i = 0; i < LXC_NS_MAX; i++) for (i = 0; i < LXC_NS_MAX; i++)
ns_fd[i] = -1; ns_fd[i] = -EBADF;
ret = lxc_preserve_ns(pid, "");
if (ret < 0) {
SYSERROR("Kernel does not support attaching to namespaces.");
return false;
} else {
close(ret);
}
for (i = 0; i < LXC_NS_MAX; i++) { for (i = 0; i < LXC_NS_MAX; i++) {
if ((clone_flags & ns_info[i].clone_flag) == 0) if ((clone_flags & ns_info[i].clone_flag) == 0)
...@@ -166,9 +158,11 @@ static bool preserve_ns(int ns_fd[LXC_NS_MAX], int clone_flags, pid_t pid) ...@@ -166,9 +158,11 @@ static bool preserve_ns(int ns_fd[LXC_NS_MAX], int clone_flags, pid_t pid)
error: error:
if (errno == ENOENT) if (errno == ENOENT)
SYSERROR("Kernel does not support attaching to %s namespaces.", ns_info[i].proc_name); SYSERROR("Kernel does not support attaching to %s namespaces",
ns_info[i].proc_name);
else else
SYSERROR("Failed to open file descriptor for %s namespace: %s.", ns_info[i].proc_name, strerror(errno)); SYSERROR("Failed to open file descriptor for %s namespace",
ns_info[i].proc_name);
close_ns(ns_fd); close_ns(ns_fd);
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment