[CRIU] [PATCH v2 26/36] ns: Add ns_owner
Kirill Tkhai
ktkhai at virtuozzo.com
Fri Feb 3 08:15:26 PST 2017
Add a struct ns_id member to store information,
where the ns copy may be obtained.
It's "/proc/[pid]/fd/[fd]", or "/proc/[pid]/ns/[ns]"
in dependence of ns_owner::fd value.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/include/namespaces.h | 8 ++++++++
criu/namespaces.c | 2 ++
2 files changed, 10 insertions(+)
diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h
index 21dc8beb7..546de7c5d 100644
--- a/criu/include/namespaces.h
+++ b/criu/include/namespaces.h
@@ -81,6 +81,13 @@ enum ns_type {
NS_OTHER,
};
+struct ns_owner {
+ struct {
+ pid_t pid; /* Owner pid */
+ int fd; /* Owner fd, or -1 if it's /proc/[pid]/ns/[ns] file */
+ };
+};
+
struct ns_id {
unsigned int kid;
unsigned int id;
@@ -90,6 +97,7 @@ struct ns_id {
struct list_head children;
struct list_head siblings;
struct ns_id *user_ns;
+ struct ns_owner owner;
struct ns_id *next;
enum ns_type type;
diff --git a/criu/namespaces.c b/criu/namespaces.c
index 538074ab9..6151219d8 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -302,6 +302,8 @@ struct ns_id *rst_new_ns_id(unsigned int id, pid_t pid,
nsid->type = type;
nsid_add(nsid, nd, id, pid);
nsid->ns_populated = false;
+ nsid->owner.pid = -1;
+ nsid->owner.fd = -1;
INIT_LIST_HEAD(&nsid->children);
INIT_LIST_HEAD(&nsid->siblings);
}
More information about the CRIU
mailing list