Commit 459828b6 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

dump: Read aux vector in one pass

No need to read it in cycle.
Repored-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c76ac46c
...@@ -375,9 +375,9 @@ static int check_sysvipc_map_dump(pid_t pid, VmaEntry *vma) ...@@ -375,9 +375,9 @@ static int check_sysvipc_map_dump(pid_t pid, VmaEntry *vma)
return -1; return -1;
} }
static int get_task_auxv(pid_t pid, MmEntry *mm, size_t *size) static int get_task_auxv(pid_t pid, MmEntry *mm)
{ {
int fd, ret, i; int fd, ret;
pr_info("Obtaining task auvx ...\n"); pr_info("Obtaining task auvx ...\n");
...@@ -385,20 +385,14 @@ static int get_task_auxv(pid_t pid, MmEntry *mm, size_t *size) ...@@ -385,20 +385,14 @@ static int get_task_auxv(pid_t pid, MmEntry *mm, size_t *size)
if (fd < 0) if (fd < 0)
return -1; return -1;
for (i = 0; i < AT_VECTOR_SIZE; i++) { ret = read(fd, mm->mm_saved_auxv, pb_repeated_size(mm, mm_saved_auxv));
ret = read(fd, &mm->mm_saved_auxv[i], if (ret < 0) {
sizeof(auxv_t)); ret = -1;
if (ret == 0) pr_perror("Error reading %d's auxv", pid);
break; goto err;
else if (ret != sizeof(auxv_t)) { } else
ret = -1; mm->n_mm_saved_auxv = ret / sizeof(mm->mm_saved_auxv[0]);
pr_perror("Error reading %d's auxv[%d]",
pid, i);
goto err;
}
}
*size = i;
ret = 0; ret = 0;
err: err:
close_safe(&fd); close_safe(&fd);
...@@ -466,7 +460,7 @@ static int dump_task_mm(pid_t pid, const struct proc_pid_stat *stat, ...@@ -466,7 +460,7 @@ static int dump_task_mm(pid_t pid, const struct proc_pid_stat *stat,
if (!mme.mm_saved_auxv) if (!mme.mm_saved_auxv)
goto err; goto err;
if (get_task_auxv(pid, &mme, &mme.n_mm_saved_auxv)) if (get_task_auxv(pid, &mme))
goto err; goto err;
if (dump_task_exe_link(pid, &mme)) if (dump_task_exe_link(pid, &mme))
......
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