[CRIU] [PATCH 01/14] namespace: don't fail if a namespace isn't supported by kernel

Andrey Vagin avagin at openvz.org
Tue Oct 14 04:38:15 PDT 2014


CRIU reads /proc/pid/ns/[NS] and fails of a link is not exist.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 namespaces.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/namespaces.c b/namespaces.c
index 1feb165..bd7d86e 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -230,6 +230,11 @@ static unsigned int __get_ns_id(int pid, struct ns_desc *nd, struct ns_id **ns)
 	sprintf(ns_path, "ns/%s", nd->str);
 	ret = readlinkat(proc_dir, ns_path, ns_id, sizeof(ns_id));
 	if (ret < 0) {
+		if (errno == ENOENT) {
+			/* The namespace is unsupported */
+			kid = 0;
+			goto out;
+		}
 		pr_perror("Can't readlink ns link");
 		return 0;
 	}
@@ -237,6 +242,7 @@ static unsigned int __get_ns_id(int pid, struct ns_desc *nd, struct ns_id **ns)
 	kid = parse_ns_link(ns_id, ret, nd);
 	BUG_ON(!kid);
 
+out:
 	return generate_ns_id(pid, kid, nd, ns);
 }
 
-- 
1.9.3



More information about the CRIU mailing list