Re: [hackers] [sbase] [PATCH 10/10] cp: Check result of utimensat

From: Silvan Jegen <s.jegen_AT_gmail.com>
Date: Mon, 5 Dec 2016 14:35:22 +0100

On Mon, Dec 5, 2016 at 6:55 AM, Michael Forney <mforney_AT_mforney.org> wrote:
> POSIX says that if duplicating the modification/access times fails, then
> an error should be written to stderr.
> ---
> libutil/cp.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)

LGTM

> diff --git a/libutil/cp.c b/libutil/cp.c
> index 339c892..15e4ce5 100644
> --- a/libutil/cp.c
> +++ b/libutil/cp.c
> _AT_@ -142,8 +142,10 @@ cp(const char *s1, const char *s2, int depth)
> if (!S_ISLNK(st.st_mode)) {
> times[0] = st.st_atim;
> times[1] = st.st_mtim;
> - utimensat(AT_FDCWD, s2, times, 0);
> -
> + if (utimensat(AT_FDCWD, s2, times, 0) < 0) {
> + weprintf("utimensat %s:", s2);
> + cp_status = 1;
> + }
> if (chown(s2, st.st_uid, st.st_gid) < 0) {
> weprintf("chown %s:", s2);
> cp_status = 1;
> --
> 2.11.0
>
>
Received on Mon Dec 05 2016 - 14:35:22 CET

This archive was generated by hypermail 2.3.0 : Mon Dec 05 2016 - 14:36:19 CET