Closes #1993.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
struct stat ns_st1, ns_st2;
ns_fd1 = lxc_preserve_ns(pid1, ns);
- if (ns_fd1 < 0)
+ if (ns_fd1 < 0) {
+ /* The kernel does not support this namespace. This is not an
+ * error.
+ */
+ if (errno == ENOENT)
+ return -EINVAL;
+
goto out;
+ }
ns_fd2 = lxc_preserve_ns(pid2, ns);
if (ns_fd2 < 0)
ret = snprintf(path, __NS_PATH_LEN, "/proc/%d/ns%s%s", pid,
!ns || strcmp(ns, "") == 0 ? "" : "/",
!ns || strcmp(ns, "") == 0 ? "" : ns);
+ errno = EFBIG;
if (ret < 0 || (size_t)ret >= __NS_PATH_LEN)
- return -1;
+ return -EFBIG;
return open(path, O_RDONLY | O_CLOEXEC);
}