Menu

#27 symlink file times aren't restored

None
closed-fixed
nobody
None
5
2021-01-01
2016-06-04
No

this is a forward of debian bug #735581, which lives over there: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=735581

restore should restore symlink timestamps where possible, i.e. at least on linux. the attached patch teaches restore how to do that on linux.

1 Attachments

Discussion

  • Mike Frysinger

    Mike Frysinger - 2016-06-08

    afaict, that patch is 90% whitespace noise and there's only one functional change. please filter your patches before uploading them for review.

    --- a/restore/tape.c
    +++ b/restore/tape.c
    @@ -920,6 +920,21 @@ extractfile(struct entry *ep, int doremo
                warn("%s: lchown", name);
     #endif
            extractattr(name);
    +
    +#if defined(__linux__)
    +       {
    +            struct timespec times[2];
    +
    +       times[0].tv_sec  =  timep[0].tv_sec;
    +       times[0].tv_nsec =  timep[0].tv_usec/1000;
    +       times[1].tv_sec  =  timep[1].tv_sec;
    +       times[1].tv_nsec =  timep[1].tv_usec/1000;
    +
    +           if (utimensat(AT_FDCWD, name, times, AT_SYMLINK_NOFOLLOW) < 0)
    +                warn("%s: file timestamp update failed", name);
    +       }
    +#endif
    +
            return (GOOD);
        }
    

    however, i don't think this is correct for a few reasons:

    • it's behind __linux__, but utimensat is in POSIX
    • you're creating nanoseconds by dividing microseconds by 1000 ... pretty sure you want to multiply that by 1000
    • if we only have microsecond resolution, then we can use the older utimes interface. it's also in POSIX, but has been for longer, which makes it more portable.
     
  • Alexander Zangerl

    you're mostly correct: i had the micro-to-nano conversion reversed.

    the problem with utimes() is that it doesn't let you modify symlinks, it always dereferences. utimensat() lets you choose the target of the link or the link itself. regarding posix i've reworked the patch to put that code under #ifdef HAVE_UTIMENSAT, and put it in the right spot (for some stupid reason i had added it to IFREG, not IFLNK). configure now checks for utimensat.

     
  • Mike Frysinger

    Mike Frysinger - 2021-01-01

    thanks, merge in 575766acd134cab74dc68bdd7d6808a338fc9a37

     
  • Mike Frysinger

    Mike Frysinger - 2021-01-01
    • status: open --> closed-fixed
    • Group: -->
     

Log in to post a comment.