Commit 0ba02b2c authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

ipcns: Split some routines

Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 71d93a5a
...@@ -777,18 +777,11 @@ err: ...@@ -777,18 +777,11 @@ err:
return ret; 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; int ifd;
ssize_t size, off; 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); ifd = img_raw_fd(img);
size = round_up(shm->size, sizeof(u32)); size = round_up(shm->size, sizeof(u32));
off = 0; off = 0;
...@@ -803,11 +796,28 @@ static int prepare_ipc_shm_pages(struct cr_img *img, const IpcShmEntry *shm) ...@@ -803,11 +796,28 @@ static int prepare_ipc_shm_pages(struct cr_img *img, const IpcShmEntry *shm)
off += ret; off += ret;
} while (off < size); } 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)) { if (shmdt(data)) {
pr_perror("Failed to detach IPC shared memory"); pr_perror("Failed to detach IPC shared memory");
return -errno; return -errno;
} }
return 0; return ret;
} }
static int prepare_ipc_shm_seg(struct cr_img *img, const IpcShmEntry *shm) static int prepare_ipc_shm_seg(struct cr_img *img, const IpcShmEntry *shm)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment