Commit 7b8dee72 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

restore: Use pr_perror instead of plain perror

This prints line number as well.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
parent ad93e59d
...@@ -175,7 +175,7 @@ static int shmem_wait_and_open(struct shmem_info *si) ...@@ -175,7 +175,7 @@ static int shmem_wait_and_open(struct shmem_info *si)
return ret; return ret;
if (ret < 0 && errno != ENOENT) { if (ret < 0 && errno != ENOENT) {
perror(" Can't stat shmem"); pr_perror(" Can't stat shmem");
return -1; return -1;
} }
...@@ -299,13 +299,13 @@ static int prepare_shmem_pid(int pid) ...@@ -299,13 +299,13 @@ static int prepare_shmem_pid(int pid)
sh_fd = open_fmt_ro(FMT_FNAME_SHMEM, pid); sh_fd = open_fmt_ro(FMT_FNAME_SHMEM, pid);
if (sh_fd < 0) { if (sh_fd < 0) {
perror("Can't open shmem info"); pr_perror("Can't open shmem info");
return 1; return 1;
} }
read(sh_fd, &type, sizeof(type)); read(sh_fd, &type, sizeof(type));
if (type != SHMEM_MAGIC) { if (type != SHMEM_MAGIC) {
perror("Bad shmem magic"); pr_perror("Bad shmem magic");
return 1; return 1;
} }
...@@ -318,7 +318,7 @@ static int prepare_shmem_pid(int pid) ...@@ -318,7 +318,7 @@ static int prepare_shmem_pid(int pid)
break; break;
if (ret != sizeof(e)) { if (ret != sizeof(e)) {
perror("Can't read shmem entry"); pr_perror("Can't read shmem entry");
return 1; return 1;
} }
...@@ -337,13 +337,13 @@ static int prepare_pipes_pid(int pid) ...@@ -337,13 +337,13 @@ static int prepare_pipes_pid(int pid)
p_fd = open_fmt_ro(FMT_FNAME_PIPES, pid); p_fd = open_fmt_ro(FMT_FNAME_PIPES, pid);
if (p_fd < 0) { if (p_fd < 0) {
perror("Can't open pipes image"); pr_perror("Can't open pipes image");
return 1; return 1;
} }
read(p_fd, &type, sizeof(type)); read(p_fd, &type, sizeof(type));
if (type != PIPES_MAGIC) { if (type != PIPES_MAGIC) {
perror("Bad pipes magin"); pr_perror("Bad pipes magin");
return 1; return 1;
} }
...@@ -378,13 +378,13 @@ static int prepare_shared(int ps_fd) ...@@ -378,13 +378,13 @@ static int prepare_shared(int ps_fd)
nr_shmems = 0; nr_shmems = 0;
shmems = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, 0, 0); shmems = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, 0, 0);
if (shmems == MAP_FAILED) { if (shmems == MAP_FAILED) {
perror("Can't map shmems"); pr_perror("Can't map shmems");
return 1; return 1;
} }
pipes = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, 0, 0); pipes = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, 0, 0);
if (pipes == MAP_FAILED) { if (pipes == MAP_FAILED) {
perror("Can't map pipes"); pr_perror("Can't map pipes");
return 1; return 1;
} }
...@@ -397,7 +397,7 @@ static int prepare_shared(int ps_fd) ...@@ -397,7 +397,7 @@ static int prepare_shared(int ps_fd)
break; break;
if (ret != sizeof(e)) { if (ret != sizeof(e)) {
perror("Can't read pstree_entry"); pr_perror("Can't read pstree_entry");
return 1; return 1;
} }
...@@ -469,7 +469,7 @@ static int open_fd(int pid, struct fdinfo_entry *fe, int *cfd) ...@@ -469,7 +469,7 @@ static int open_fd(int pid, struct fdinfo_entry *fe, int *cfd)
if (*cfd == (int)fe->addr) { if (*cfd == (int)fe->addr) {
tmp = dup(*cfd); tmp = dup(*cfd);
if (tmp < 0) { if (tmp < 0) {
perror("Can't dup file"); pr_perror("Can't dup file");
return 1; return 1;
} }
...@@ -597,13 +597,13 @@ static int prepare_shmem(int pid) ...@@ -597,13 +597,13 @@ static int prepare_shmem(int pid)
sh_fd = open_fmt_ro(FMT_FNAME_SHMEM, pid); sh_fd = open_fmt_ro(FMT_FNAME_SHMEM, pid);
if (sh_fd < 0) { if (sh_fd < 0) {
perror("Can't open shmem info"); pr_perror("Can't open shmem info");
return 1; return 1;
} }
read(sh_fd, &type, sizeof(type)); read(sh_fd, &type, sizeof(type));
if (type != SHMEM_MAGIC) { if (type != SHMEM_MAGIC) {
perror("Bad shmem magic"); pr_perror("Bad shmem magic");
return 1; return 1;
} }
...@@ -615,7 +615,7 @@ static int prepare_shmem(int pid) ...@@ -615,7 +615,7 @@ static int prepare_shmem(int pid)
if (ret == 0) if (ret == 0)
break; break;
if (ret != sizeof(e)) { if (ret != sizeof(e)) {
perror("Can't read shmem entry"); pr_perror("Can't read shmem entry");
return 1; return 1;
} }
...@@ -672,7 +672,7 @@ static int try_fixup_shared_map(int pid, struct vma_entry *vi, int fd) ...@@ -672,7 +672,7 @@ static int try_fixup_shared_map(int pid, struct vma_entry *vi, int fd)
pr_info("%d: Fixing %lx vma to %lx/%d shmem -> %d\n", pr_info("%d: Fixing %lx vma to %lx/%d shmem -> %d\n",
pid, vi->start, si->shmid, si->pid, sh_fd); pid, vi->start, si->shmid, si->pid, sh_fd);
if (sh_fd < 0) { if (sh_fd < 0) {
perror("Can't open shmem"); pr_perror("Can't open shmem");
return 1; return 1;
} }
...@@ -681,7 +681,7 @@ static int try_fixup_shared_map(int pid, struct vma_entry *vi, int fd) ...@@ -681,7 +681,7 @@ static int try_fixup_shared_map(int pid, struct vma_entry *vi, int fd)
pr_info("%d: Fixed %lx vma %lx/%d shmem -> %d\n", pr_info("%d: Fixed %lx vma %lx/%d shmem -> %d\n",
pid, vi->start, si->shmid, si->pid, sh_fd); pid, vi->start, si->shmid, si->pid, sh_fd);
if (write(fd, vi, sizeof(*vi)) != sizeof(*vi)) { if (write(fd, vi, sizeof(*vi)) != sizeof(*vi)) {
perror("Can't write img"); pr_perror("Can't write img");
return 1; return 1;
} }
} }
...@@ -699,7 +699,7 @@ static int fixup_vma_fds(int pid, int fd) ...@@ -699,7 +699,7 @@ static int fixup_vma_fds(int pid, int fd)
struct vma_entry vi; struct vma_entry vi;
if (read(fd, &vi, sizeof(vi)) != sizeof(vi)) { if (read(fd, &vi, sizeof(vi)) != sizeof(vi)) {
perror("Can't read"); pr_perror("Can't read");
return 1; return 1;
} }
...@@ -835,12 +835,11 @@ static int prepare_and_sigreturn(int pid) ...@@ -835,12 +835,11 @@ static int prepare_and_sigreturn(int pid)
fd = open_fmt_ro(FMT_FNAME_CORE, pid); fd = open_fmt_ro(FMT_FNAME_CORE, pid);
if (fd < 0) { if (fd < 0) {
perror("Can't open exec image"); pr_perror("Can't open exec image");
return 1; return 1;
} }
if (fstat(fd, &buf)) { if (fstat(fd, &buf)) {
perror("Can't stat"); pr_perror("Can't stat");
return 1; return 1;
} }
...@@ -849,7 +848,7 @@ static int prepare_and_sigreturn(int pid) ...@@ -849,7 +848,7 @@ static int prepare_and_sigreturn(int pid)
fd_new = open(path, O_RDWR | O_CREAT | O_EXCL, 0700); fd_new = open(path, O_RDWR | O_CREAT | O_EXCL, 0700);
if (fd_new < 0) { if (fd_new < 0) {
perror("Can't open new image"); pr_perror("Can't open new image");
return 1; return 1;
} }
...@@ -861,12 +860,12 @@ static int prepare_and_sigreturn(int pid) ...@@ -861,12 +860,12 @@ static int prepare_and_sigreturn(int pid)
close(fd); close(fd);
if (fchmod(fd_new, 0700)) { if (fchmod(fd_new, 0700)) {
perror("Can't prepare exec image"); pr_perror("Can't prepare exec image");
return 1; return 1;
} }
if (fstat(fd_new, &buf)) { if (fstat(fd_new, &buf)) {
perror("Can't stat"); pr_perror("Can't stat");
return 1; return 1;
} }
...@@ -890,7 +889,7 @@ static int create_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int ...@@ -890,7 +889,7 @@ static int create_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int
pr_info("\t%d: Creating pipe %x\n", pid, e->pipeid); pr_info("\t%d: Creating pipe %x\n", pid, e->pipeid);
if (pipe(pfd) < 0) { if (pipe(pfd) < 0) {
perror("Can't create pipe"); pr_perror("Can't create pipe");
return 1; return 1;
} }
...@@ -902,7 +901,7 @@ static int create_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int ...@@ -902,7 +901,7 @@ static int create_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int
pr_err("Wanted to restore %d bytes, but got %d\n", pr_err("Wanted to restore %d bytes, but got %d\n",
e->bytes, tmp); e->bytes, tmp);
if (tmp < 0) if (tmp < 0)
perror("Error splicing data"); pr_perror("Error splicing data");
return 1; return 1;
} }
} }
...@@ -979,7 +978,7 @@ static int attach_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int ...@@ -979,7 +978,7 @@ static int attach_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int
fd = open(path, e->flags); fd = open(path, e->flags);
if (fd < 0) { if (fd < 0) {
perror("Can't attach pipe"); pr_perror("Can't attach pipe");
return 1; return 1;
} }
...@@ -1005,7 +1004,7 @@ static int open_pipe(int pid, struct pipe_entry *e, int *pipes_fd) ...@@ -1005,7 +1004,7 @@ static int open_pipe(int pid, struct pipe_entry *e, int *pipes_fd)
tmp = dup(*pipes_fd); tmp = dup(*pipes_fd);
if (tmp < 0) { if (tmp < 0) {
perror("Can't dup file"); pr_perror("Can't dup file");
return 1; return 1;
} }
...@@ -1039,13 +1038,13 @@ static int prepare_pipes(int pid) ...@@ -1039,13 +1038,13 @@ static int prepare_pipes(int pid)
pipes_fd = open_fmt_ro(FMT_FNAME_PIPES, pid); pipes_fd = open_fmt_ro(FMT_FNAME_PIPES, pid);
if (pipes_fd < 0) { if (pipes_fd < 0) {
perror("Can't open pipes img"); pr_perror("Can't open pipes img");
return 1; return 1;
} }
read(pipes_fd, &type, sizeof(type)); read(pipes_fd, &type, sizeof(type));
if (type != PIPES_MAGIC) { if (type != PIPES_MAGIC) {
perror("Bad pipes file"); pr_perror("Bad pipes file");
return 1; return 1;
} }
...@@ -1060,7 +1059,7 @@ static int prepare_pipes(int pid) ...@@ -1060,7 +1059,7 @@ static int prepare_pipes(int pid)
} }
if (ret != sizeof(e)) { if (ret != sizeof(e)) {
perror("Bad pipes entry"); pr_perror("Bad pipes entry");
return 1; return 1;
} }
...@@ -1123,7 +1122,7 @@ static int restore_task_with_children(int my_pid, char *pstree_path) ...@@ -1123,7 +1122,7 @@ static int restore_task_with_children(int my_pid, char *pstree_path)
fd = open(pstree_path, O_RDONLY); fd = open(pstree_path, O_RDONLY);
if (fd < 0) { if (fd < 0) {
perror("Can't reopen pstree image"); pr_perror("Can't reopen pstree image");
exit(1); exit(1);
} }
...@@ -1136,7 +1135,7 @@ static int restore_task_with_children(int my_pid, char *pstree_path) ...@@ -1136,7 +1135,7 @@ static int restore_task_with_children(int my_pid, char *pstree_path)
if (ret != sizeof(e)) { if (ret != sizeof(e)) {
pr_err("%d: Read returned %d\n", my_pid, ret); pr_err("%d: Read returned %d\n", my_pid, ret);
if (ret < 0) if (ret < 0)
perror("Can't read pstree"); pr_perror("Can't read pstree");
exit(1); exit(1);
} }
...@@ -1153,7 +1152,7 @@ static int restore_task_with_children(int my_pid, char *pstree_path) ...@@ -1153,7 +1152,7 @@ static int restore_task_with_children(int my_pid, char *pstree_path)
pids = malloc(i); pids = malloc(i);
ret = read(fd, pids, i); ret = read(fd, pids, i);
if (ret != i) { if (ret != i) {
perror("Can't read children pids"); pr_perror("Can't read children pids");
exit(1); exit(1);
} }
...@@ -1181,7 +1180,7 @@ static int restore_root_task(char *pstree_path, int fd) ...@@ -1181,7 +1180,7 @@ static int restore_root_task(char *pstree_path, int fd)
ret = read(fd, &e, sizeof(e)); ret = read(fd, &e, sizeof(e));
if (ret != sizeof(e)) { if (ret != sizeof(e)) {
perror("Can't read root pstree entry"); pr_perror("Can't read root pstree entry");
return 1; return 1;
} }
...@@ -1205,13 +1204,13 @@ static int restore_all_tasks(pid_t pid) ...@@ -1205,13 +1204,13 @@ static int restore_all_tasks(pid_t pid)
sprintf(path, FMT_FNAME_PSTREE, pid); sprintf(path, FMT_FNAME_PSTREE, pid);
pstree_fd = open(path, O_RDONLY); pstree_fd = open(path, O_RDONLY);
if (pstree_fd < 0) { if (pstree_fd < 0) {
perror("Can't open pstree image"); pr_perror("Can't open pstree image");
return 1; return 1;
} }
read(pstree_fd, &type, sizeof(type)); read(pstree_fd, &type, sizeof(type));
if (type != PSTREE_MAGIC) { if (type != PSTREE_MAGIC) {
perror("Bad pstree magic"); pr_perror("Bad pstree magic");
return 1; return 1;
} }
......
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