[CRIU] Re: [PATCH v3 3/8] dump: stat fd by fstatat()
Pavel Emelyanov
xemul at parallels.com
Mon Mar 5 13:14:31 EST 2012
On 03/05/2012 10:00 PM, Kinsbursky Stanislav wrote:
> This is a cleanup patch - it allows to get stats for file descriptor without
> opening.
>
> Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
>
> ---
> cr-dump.c | 19 ++++++++++---------
> 1 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/cr-dump.c b/cr-dump.c
> index 718685e..064304c 100644
> --- a/cr-dump.c
> +++ b/cr-dump.c
> @@ -327,10 +327,19 @@ static int dump_one_fd(pid_t pid, int pid_fd_dir, char *d_name, struct cr_fdset
> struct sk_queue *sk_queue)
> {
> struct stat fd_stat;
> - int err = -1;
> + int err;
> 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;
In patch #1 you moved this read_fd_parms lower. Now you move it back.
I like to move it, move it, I like to move it move it?
> +
> lfd = openat(pid_fd_dir, d_name, O_RDONLY);
> if (lfd < 0) {
> err = try_dump_socket(pid, atoi(d_name), cr_fdset, sk_queue);
> @@ -341,14 +350,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