[CRIU] Re: [PATCH v2 04/11] dump: stat fd by fstatat()
Pavel Emelyanov
xemul at parallels.com
Mon Mar 5 10:39:14 EST 2012
On 03/05/2012 04:38 PM, Kinsbursky Stanislav wrote:
> This is a cleanup patch - it allows to get stats for file descriptor without
> opening.
But you still open it anyway. Why should I apply this one?
> Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
>
> ---
> cr-dump.c | 17 +++++++++--------
> 1 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/cr-dump.c b/cr-dump.c
> index 4aa9089..3a441f6 100644
> --- a/cr-dump.c
> +++ b/cr-dump.c
> @@ -327,6 +327,15 @@ static int dump_one_fd(pid_t pid, int pid_fd_dir, char *d_name, struct cr_fdset
> struct fd_parms p;
> int lfd;
>
> + err = fstatat(pid_fd_dir, d_name, &fd_stat, 0);
> + if (err < 0) {
> + pr_perror("Failed to fstatat %d/%s", pid_fd_dir, d_name);
> + return -1;
> + }
> +
> + if (read_fd_params(pid, d_name, &fd_stat, &p))
> + return -1;
> +
> lfd = openat(pid_fd_dir, d_name, O_RDONLY);
> if (lfd < 0) {
> err = try_dump_socket(pid, atoi(d_name), cr_fdset, sk_queue);
> @@ -337,14 +346,6 @@ static int dump_one_fd(pid_t pid, int pid_fd_dir, char *d_name, struct cr_fdset
> return -1;
> }
>
> - if (fstat(lfd, &fd_stat) < 0) {
> - pr_perror("Can't get stat on %ld", p.fd_name);
> - goto out_close;
> - }
> -
> - if (read_fd_params(pid, d_name, &fd_stat, &p))
> - return -1;
> -
> if (S_ISCHR(fd_stat.st_mode) &&
> (major(fd_stat.st_rdev) == TTY_MAJOR ||
> major(fd_stat.st_rdev) == UNIX98_PTY_SLAVE_MAJOR)) {
>
More information about the CRIU
mailing list