[CRIU] [PATCH 2/3] ipcns: Split some routines

Pavel Emelyanov xemul at virtuozzo.com
Mon Apr 3 09:19:48 PDT 2017


Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>

---
 criu/ipc_ns.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/criu/ipc_ns.c b/criu/ipc_ns.c
index af1cb7c..0fcee68 100644
--- a/criu/ipc_ns.c
+++ b/criu/ipc_ns.c
@@ -777,18 +777,11 @@ err:
 	return ret;
 }
 
-static int prepare_ipc_shm_pages(struct cr_img *img, const IpcShmEntry *shm)
+static int restore_content(void *data, struct cr_img *img, const IpcShmEntry *shm)
 {
-	void *data;
 	int ifd;
 	ssize_t size, off;
 
-	data = shmat(shm->desc->id, NULL, 0);
-	if (data == (void *)-1) {
-		pr_perror("Failed to attach IPC shared memory");
-		return -errno;
-	}
-
 	ifd = img_raw_fd(img);
 	size = round_up(shm->size, sizeof(u32));
 	off = 0;
@@ -803,11 +796,28 @@ static int prepare_ipc_shm_pages(struct cr_img *img, const IpcShmEntry *shm)
 
 		off += ret;
 	} while (off < size);
+
+	return 0;
+}
+
+static int prepare_ipc_shm_pages(struct cr_img *img, const IpcShmEntry *shm)
+{
+	int ret;
+	void *data;
+
+	data = shmat(shm->desc->id, NULL, 0);
+	if (data == (void *)-1) {
+		pr_perror("Failed to attach IPC shared memory");
+		return -errno;
+	}
+
+	ret = restore_content(data, img, shm);
+
 	if (shmdt(data)) {
 		pr_perror("Failed to detach IPC shared memory");
 		return -errno;
 	}
-	return 0;
+	return ret;
 }
 
 static int prepare_ipc_shm_seg(struct cr_img *img, const IpcShmEntry *shm)
-- 
2.5.5



More information about the CRIU mailing list