[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-cpio] [PATCH] extract: retain times for symlinks
From: |
Pavel Raiskup |
Subject: |
Re: [Bug-cpio] [PATCH] extract: retain times for symlinks |
Date: |
Wed, 03 Jan 2018 09:39:50 +0100 |
Hi, I'm getting pings downstream about this issue, so forwarding here...
Would it make sense to dump symlink times into cpio archive, too?
Pavel
On Saturday, September 2, 2017 10:19:54 AM CET Pavel Raiskup wrote:
> Original report by Pat Riehecky at
> https://bugzilla.redhat.com/1486364
>
> * src/copyin.c (copyin_device): Don't check for retain_time_flag
> global, it's done by set_file_times.
> (copyin_link): Call set_file_times to restore symlink times.
> * src/util.c (set_perms): Don't check for retain_time_flag global,
> done by set_file_times call.
> (set_file_times): Do nothing if retain_time_flag global is false.
> ---
> src/copyin.c | 7 ++++---
> src/util.c | 12 +++++++-----
> 2 files changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/src/copyin.c b/src/copyin.c
> index ba887ae..189a426 100644
> --- a/src/copyin.c
> +++ b/src/copyin.c
> @@ -615,9 +615,8 @@ copyin_device (struct cpio_file_stat* file_hdr)
> /* chown may have turned off some permissions we wanted. */
> if (chmod (file_hdr->c_name, file_hdr->c_mode) < 0)
> chmod_error_details (file_hdr->c_name, file_hdr->c_mode);
> - if (retain_time_flag)
> - set_file_times (-1, file_hdr->c_name, file_hdr->c_mtime,
> - file_hdr->c_mtime);
> +
> + set_file_times (-1, file_hdr->c_name, file_hdr->c_mtime,
> file_hdr->c_mtime);
> }
>
> static void
> @@ -668,6 +667,8 @@ copyin_link (struct cpio_file_stat *file_hdr, int
> in_file_des)
> && errno != EPERM)
> chown_error_details (file_hdr->c_name, uid, gid);
> }
> +
> + set_file_times (-1, file_hdr->c_name, file_hdr->c_mtime,
> file_hdr->c_mtime);
> free (link_name);
> }
>
> diff --git a/src/util.c b/src/util.c
> index 10486dc..b98e3fb 100644
> --- a/src/util.c
> +++ b/src/util.c
> @@ -1388,8 +1388,7 @@ set_perms (int fd, struct cpio_file_stat *header)
> we have to refer to it using name+ instead of name. */
> file_hdr->c_name [cdf_char] = '+';
> #endif
> - if (retain_time_flag)
> - set_file_times (fd, header->c_name, header->c_mtime, header->c_mtime);
> + set_file_times (fd, header->c_name, header->c_mtime, header->c_mtime);
> }
>
> void
> @@ -1397,15 +1396,18 @@ set_file_times (int fd,
> const char *name, unsigned long atime, unsigned long mtime)
> {
> struct timespec ts[2];
> -
> + if (!retain_time_flag)
> + return;
> +
> memset (&ts, 0, sizeof ts);
>
> ts[0].tv_sec = atime;
> ts[1].tv_sec = mtime;
>
> - /* Silently ignore EROFS because reading the file won't have upset its
> + /* Silently ignore EROFS because reading the file won't have upset its
> timestamp if it's on a read-only filesystem. */
> - if (fdutimens (fd, name, ts) < 0 && errno != EROFS)
> + if ((fd >= 0 ? fdutimens (fd, NULL, ts) : lutimens (name, ts)) < 0
> + && errno != EROFS)
> utime_error (name);
> }
>
>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Bug-cpio] [PATCH] extract: retain times for symlinks,
Pavel Raiskup <=