Commit 4727c739 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

restore: Simplify try_fixup_file_map

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
parent 69781946
...@@ -588,23 +588,26 @@ static int prepare_shmem(int pid) ...@@ -588,23 +588,26 @@ static int prepare_shmem(int pid)
return 0; return 0;
} }
static int try_fixup_file_map(int pid, struct vma_entry *vi, int fd) static int try_fixup_file_map(int pid, struct vma_entry *vma_entry, int fd)
{ {
struct fmap_fd *fmfd; struct fmap_fd *fmap_fd = pop_fmap_fd(pid, vma_entry->start);
fmfd = pop_fmap_fd(pid, vi->start); if (fmap_fd) {
if (fmfd != NULL) { pr_info("%d: Fixing %lx vma to %d fd\n",
pr_info("%d: Fixing %lx vma to %d fd\n", pid, vi->start, fmfd->fd); pid, vma_entry->start, fmap_fd->fd);
lseek(fd, -sizeof(*vi), SEEK_CUR);
vi->fd = fmfd->fd; lseek(fd, -sizeof(*vma_entry), SEEK_CUR);
if (write(fd, vi, sizeof(*vi)) != sizeof(*vi)) { vma_entry->fd = fmap_fd->fd;
perror("Can't write img");
return 1; write_ptr_safe(fd, &vma_entry, err);
}
free(fmfd); free(fmap_fd);
} }
return 0; return 0;
err:
pr_perror("%d: Can't fixup vma\n", pid);
return 1;
} }
static int try_fixup_shared_map(int pid, struct vma_entry *vi, int fd) static int try_fixup_shared_map(int pid, struct vma_entry *vi, int fd)
......
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