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

Andrey Vagin avagin at openvz.org
Wed Aug 13 00:51:34 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 a7624d2..1b253eb 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -228,6 +228,11 @@ static unsigned int get_ns_id(int pid, struct ns_desc *nd)
 	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;
 	}
@@ -235,6 +240,7 @@ static unsigned int get_ns_id(int pid, struct ns_desc *nd)
 	kid = parse_ns_link(ns_id, ret, nd);
 	BUG_ON(!kid);
 
+out:
 	return generate_ns_id(pid, kid, nd);
 }
 
-- 
1.9.3



More information about the CRIU mailing list