[CRIU] [PATCH RESEND v1 17/55] pstree: Change arguments of read_pstree_ids()

Kirill Tkhai ktkhai at virtuozzo.com
Fri Mar 24 08:11:41 PDT 2017


Pass vpid instead of pstree_item as input argument,
and return ids to caller. No functional changes here.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/pstree.c |   39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/criu/pstree.c b/criu/pstree.c
index 46c2096b..15aacceb 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -481,48 +481,47 @@ struct pid *pstree_pid_by_virt(pid_t pid)
 	return NULL;
 }
 
-static int read_pstree_ids(struct pstree_item *pi)
+static int read_pstree_ids(pid_t pid, TaskKobjIdsEntry **ids)
 {
-	pid_t pid = vpid(pi);
-	int ret;
 	struct cr_img *img;
+	int ret;
 
-	img = open_image(CR_FD_IDS, O_RSTR, vpid(pi));
+	img = open_image(CR_FD_IDS, O_RSTR, pid);
 	if (!img)
 		return -1;
 
-	ret = pb_read_one_eof(img, &pi->ids, PB_IDS);
+	ret = pb_read_one_eof(img, ids, PB_IDS);
 	close_image(img);
 
 	if (ret <= 0)
 		return ret;
 
-	if (pi->ids->has_mnt_ns_id) {
-		if (rst_add_ns_id(pi->ids->mnt_ns_id, pid, &mnt_ns_desc))
+	if ((*ids)->has_mnt_ns_id) {
+		if (rst_add_ns_id((*ids)->mnt_ns_id, pid, &mnt_ns_desc))
 			return -1;
 	}
-	if (pi->ids->has_net_ns_id) {
-		if (rst_add_ns_id(pi->ids->net_ns_id, pid, &net_ns_desc))
+	if ((*ids)->has_net_ns_id) {
+		if (rst_add_ns_id((*ids)->net_ns_id, pid, &net_ns_desc))
 			return -1;
 	}
-	if (pi->ids->has_user_ns_id) {
-		if (rst_add_ns_id(pi->ids->user_ns_id, pid, &user_ns_desc))
+	if ((*ids)->has_user_ns_id) {
+		if (rst_add_ns_id((*ids)->user_ns_id, pid, &user_ns_desc))
 			return -1;
 	}
-	if (pi->ids->has_pid_ns_id) {
-		if (rst_add_ns_id(pi->ids->pid_ns_id, pid, &pid_ns_desc))
+	if ((*ids)->has_pid_ns_id) {
+		if (rst_add_ns_id((*ids)->pid_ns_id, pid, &pid_ns_desc))
 			return -1;
 	}
-	if (pi->ids->has_ipc_ns_id) {
-		if (rst_add_ns_id(pi->ids->ipc_ns_id, pid, &ipc_ns_desc))
+	if ((*ids)->has_ipc_ns_id) {
+		if (rst_add_ns_id((*ids)->ipc_ns_id, pid, &ipc_ns_desc))
 			return -1;
 	}
-	if (pi->ids->has_uts_ns_id) {
-		if (rst_add_ns_id(pi->ids->uts_ns_id, pid, &uts_ns_desc))
+	if ((*ids)->has_uts_ns_id) {
+		if (rst_add_ns_id((*ids)->uts_ns_id, pid, &uts_ns_desc))
 			return -1;
 	}
-	if (pi->ids->has_cgroup_ns_id) {
-		if (rst_add_ns_id(pi->ids->cgroup_ns_id, pid, &cgroup_ns_desc))
+	if ((*ids)->has_cgroup_ns_id) {
+		if (rst_add_ns_id((*ids)->cgroup_ns_id, pid, &cgroup_ns_desc))
 			return -1;
 	}
 
@@ -632,7 +631,7 @@ static int read_pstree_image(pid_t *pid_max)
 
 		pstree_entry__free_unpacked(e, NULL);
 
-		ret = read_pstree_ids(pi);
+		ret = read_pstree_ids(vpid(pi), &pi->ids);
 		if (ret < 0)
 			goto err;
 	}



More information about the CRIU mailing list