Commit 56f91edf authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Pavel Emelyanov

open_proc: don't print error twice

open_proc* and fopen_proc* are all macros, and they print errors in case
something is wrong (and as they are macros they print correct file:line
info, too). So, there is no need to print another error message
right after calling those.

This fixes double error messages like these:

(00.047295) Error (criu/proc_parse.c:990): Can't open 18472/status on procfs: No such file or directory
(00.047298) Error (criu/proc_parse.c:992): Can't open proc status: No such file or directory

travis-ci: success for Assorted nitpicks
Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 7b07ac5f
...@@ -297,10 +297,8 @@ static int autofs_revisit_options(struct mount_info *pm) ...@@ -297,10 +297,8 @@ static int autofs_revisit_options(struct mount_info *pm)
} }
f = fopen_proc(getpid(), "mountinfo"); f = fopen_proc(getpid(), "mountinfo");
if (!f) { if (!f)
pr_perror("Can't open %d mountinfo", getpid());
goto free_str; goto free_str;
}
while (fgets(str, 1024, f)) { while (fgets(str, 1024, f)) {
int mnt_id = -1; int mnt_id = -1;
......
...@@ -838,10 +838,8 @@ static int check_autofs_pipe_ino(void) ...@@ -838,10 +838,8 @@ static int check_autofs_pipe_ino(void)
int ret = -ENOENT; int ret = -ENOENT;
f = fopen_proc(PROC_SELF, "mountinfo"); f = fopen_proc(PROC_SELF, "mountinfo");
if (!f) { if (!f)
pr_perror("Can't open %d mountinfo", getpid());
return -1; return -1;
}
while (fgets(str, sizeof(str), f)) { while (fgets(str, sizeof(str), f)) {
if (strstr(str, " autofs ")) { if (strstr(str, " autofs ")) {
......
...@@ -901,10 +901,8 @@ static inline int fork_with_pid(struct pstree_item *item) ...@@ -901,10 +901,8 @@ static inline int fork_with_pid(struct pstree_item *item)
int len; int len;
ca.fd = open_proc_rw(PROC_GEN, LAST_PID_PATH); ca.fd = open_proc_rw(PROC_GEN, LAST_PID_PATH);
if (ca.fd < 0) { if (ca.fd < 0)
pr_perror("%d: Can't open %s", pid, LAST_PID_PATH);
goto err; goto err;
}
if (flock(ca.fd, LOCK_EX)) { if (flock(ca.fd, LOCK_EX)) {
close(ca.fd); close(ca.fd);
...@@ -1727,10 +1725,8 @@ static int restore_root_task(struct pstree_item *init) ...@@ -1727,10 +1725,8 @@ static int restore_root_task(struct pstree_item *init)
if (root_ns_mask & CLONE_NEWNS) { if (root_ns_mask & CLONE_NEWNS) {
mnt_ns_fd = open_proc(init->pid.real, "ns/mnt"); mnt_ns_fd = open_proc(init->pid.real, "ns/mnt");
if (mnt_ns_fd < 0) { if (mnt_ns_fd < 0)
pr_perror("Can't open init's mntns fd");
goto out_kill; goto out_kill;
}
} }
ret = run_scripts(ACT_SETUP_NS); ret = run_scripts(ACT_SETUP_NS);
......
...@@ -74,10 +74,8 @@ static int parse_self_maps(unsigned long vm_start, dev_t *device) ...@@ -74,10 +74,8 @@ static int parse_self_maps(unsigned long vm_start, dev_t *device)
char buf[1024]; char buf[1024];
maps = fopen_proc(PROC_SELF, "maps"); maps = fopen_proc(PROC_SELF, "maps");
if (maps == NULL) { if (maps == NULL)
pr_perror("Can't open self maps");
return -1; return -1;
}
while (fgets(buf, sizeof(buf), maps) != NULL) { while (fgets(buf, sizeof(buf), maps) != NULL) {
char *end, *aux; char *end, *aux;
......
...@@ -225,10 +225,8 @@ int switch_ns(int pid, struct ns_desc *nd, int *rst) ...@@ -225,10 +225,8 @@ int switch_ns(int pid, struct ns_desc *nd, int *rst)
int ret; int ret;
nsfd = open_proc(pid, "ns/%s", nd->str); nsfd = open_proc(pid, "ns/%s", nd->str);
if (nsfd < 0) { if (nsfd < 0)
pr_perror("Can't open ns file");
return -1; return -1;
}
ret = switch_ns_by_fd(nsfd, nd, rst); ret = switch_ns_by_fd(nsfd, nd, rst);
......
...@@ -1152,10 +1152,8 @@ static int restore_one_macvlan(NetDeviceEntry *nde, int nlsk, int criu_nlsk) ...@@ -1152,10 +1152,8 @@ static int restore_one_macvlan(NetDeviceEntry *nde, int nlsk, int criu_nlsk)
extras.link = (int) (unsigned long) val; extras.link = (int) (unsigned long) val;
my_netns = open_proc(PROC_SELF, "ns/net"); my_netns = open_proc(PROC_SELF, "ns/net");
if (my_netns < 0) { if (my_netns < 0)
pr_perror("couldn't get my netns");
return -1; return -1;
}
{ {
struct newlink_req req; struct newlink_req req;
......
...@@ -423,10 +423,8 @@ int parse_self_maps_lite(struct vm_area_list *vms) ...@@ -423,10 +423,8 @@ int parse_self_maps_lite(struct vm_area_list *vms)
vm_area_list_init(vms); vm_area_list_init(vms);
maps = fopen_proc(PROC_SELF, "maps"); maps = fopen_proc(PROC_SELF, "maps");
if (maps == NULL) { if (maps == NULL)
pr_perror("Can't open self maps");
return -1; return -1;
}
while (fgets(buf, BUF_SIZE, maps) != NULL) { while (fgets(buf, BUF_SIZE, maps) != NULL) {
struct vma_area *vma; struct vma_area *vma;
...@@ -988,10 +986,8 @@ int parse_pid_status(pid_t pid, struct proc_status_creds *cr) ...@@ -988,10 +986,8 @@ int parse_pid_status(pid_t pid, struct proc_status_creds *cr)
bool parsed_seccomp = false; bool parsed_seccomp = false;
f.fd = open_proc(pid, "status"); f.fd = open_proc(pid, "status");
if (f.fd < 0) { if (f.fd < 0)
pr_perror("Can't open proc status");
return -1; return -1;
}
cr->sigpnd = 0; cr->sigpnd = 0;
cr->shdpnd = 0; cr->shdpnd = 0;
...@@ -1414,10 +1410,8 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid, bool for_dump) ...@@ -1414,10 +1410,8 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid, bool for_dump)
FILE *f; FILE *f;
f = fopen_proc(pid, "mountinfo"); f = fopen_proc(pid, "mountinfo");
if (!f) { if (!f)
pr_perror("Can't open %d mountinfo", pid);
return NULL; return NULL;
}
while (fgets(buf, BUF_SIZE, f)) { while (fgets(buf, BUF_SIZE, f)) {
struct mount_info *new; struct mount_info *new;
...@@ -1626,10 +1620,8 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type, ...@@ -1626,10 +1620,8 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type,
int ret, exit_code = -1;; int ret, exit_code = -1;;
f.fd = open_proc(pid, "fdinfo/%d", fd); f.fd = open_proc(pid, "fdinfo/%d", fd);
if (f.fd < 0) { if (f.fd < 0)
pr_perror("Can't open fdinfo/%d to parse", fd);
return -1; return -1;
}
if (bfdopenr(&f)) if (bfdopenr(&f))
return -1; return -1;
...@@ -2029,10 +2021,8 @@ int parse_file_locks(void) ...@@ -2029,10 +2021,8 @@ int parse_file_locks(void)
return 0; return 0;
fl_locks = fopen_proc(PROC_GEN, "locks"); fl_locks = fopen_proc(PROC_GEN, "locks");
if (!fl_locks) { if (!fl_locks)
pr_perror("Can't open file locks file!");
return -1; return -1;
}
while (fgets(buf, BUF_SIZE, fl_locks)) { while (fgets(buf, BUF_SIZE, fl_locks)) {
is_blocked = strstr(buf, "->") != NULL; is_blocked = strstr(buf, "->") != NULL;
...@@ -2117,10 +2107,8 @@ int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args) ...@@ -2117,10 +2107,8 @@ int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args)
args->timer_n = 0; args->timer_n = 0;
f.fd = open_proc(pid, "timers"); f.fd = open_proc(pid, "timers");
if (f.fd < 0) { if (f.fd < 0)
pr_perror("Can't open posix timers file!");
return -1; return -1;
}
if (bfdopenr(&f)) if (bfdopenr(&f))
return -1; return -1;
...@@ -2323,10 +2311,8 @@ int parse_task_cgroup(int pid, struct parasite_dump_cgroup_args *args, struct li ...@@ -2323,10 +2311,8 @@ int parse_task_cgroup(int pid, struct parasite_dump_cgroup_args *args, struct li
struct cg_ctl *intern, *ext; struct cg_ctl *intern, *ext;
f = fopen_proc(pid, "cgroup"); f = fopen_proc(pid, "cgroup");
if (!f) { if (!f)
pr_perror("couldn't open task cgroup file");
return -1; return -1;
}
ret = parse_cgroup_file(f, retl, n); ret = parse_cgroup_file(f, retl, n);
fclose(f); fclose(f);
......
...@@ -273,7 +273,7 @@ static int log_unfrozen_stacks(char *root) ...@@ -273,7 +273,7 @@ static int log_unfrozen_stacks(char *root)
stack = open_proc(pid, "stack"); stack = open_proc(pid, "stack");
if (stack < 0) { if (stack < 0) {
pr_perror("couldn't log %d's stack", pid); pr_err("`- couldn't log %d's stack\n", pid);
fclose(f); fclose(f);
return -1; return -1;
} }
......
...@@ -448,9 +448,6 @@ static int shmem_wait_and_open(int pid, struct shmem_info *si, VmaEntry *vi) ...@@ -448,9 +448,6 @@ static int shmem_wait_and_open(int pid, struct shmem_info *si, VmaEntry *vi)
pr_info("Opening shmem [%s] \n", path); pr_info("Opening shmem [%s] \n", path);
ret = open_proc_rw(si->pid, "fd/%d", si->fd); ret = open_proc_rw(si->pid, "fd/%d", si->fd);
if (ret < 0)
pr_perror(" %d: Can't stat shmem at %s",
si->pid, path);
futex_inc_and_wake(&si->lock); futex_inc_and_wake(&si->lock);
if (ret < 0) if (ret < 0)
return -1; return -1;
......
...@@ -223,10 +223,8 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s) ...@@ -223,10 +223,8 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s)
*s = (struct vdso_symtable)VDSO_SYMTABLE_INIT; *s = (struct vdso_symtable)VDSO_SYMTABLE_INIT;
maps = fopen_proc(PROC_SELF, "maps"); maps = fopen_proc(PROC_SELF, "maps");
if (!maps) { if (!maps)
pr_perror("Can't open self-vma");
return -1; return -1;
}
while (fgets(buf, sizeof(buf), maps)) { while (fgets(buf, sizeof(buf), maps)) {
unsigned long start, end; unsigned long start, end;
......
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