diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2016-04-08 12:59:23 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2016-04-08 12:59:23 +0000 |
commit | d4c44ff1cc68bcd7ce693b29616b25f96beca379 (patch) | |
tree | 8f9f71a6b93c364b953e9c7e45cab0c7a96af1a4 /src | |
parent | 2115c8f6a7b45de1f8a073ab207eb28a0784b149 (diff) | |
download | s6-portable-utils-d4c44ff1cc68bcd7ce693b29616b25f96beca379.tar.xz |
s6-touch: ensure the times are updated even when the filesystem isn't responsive to open()
Diffstat (limited to 'src')
-rw-r--r-- | src/skaembutils/s6-touch.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/skaembutils/s6-touch.c b/src/skaembutils/s6-touch.c index b149835..ca5bdd0 100644 --- a/src/skaembutils/s6-touch.c +++ b/src/skaembutils/s6-touch.c @@ -1,5 +1,8 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/stat.h> +#include <time.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -7,6 +10,7 @@ int main (int argc, char const *const *argv) { + static struct timespec const now2[2] = { { .tv_sec = 0, .tv_nsec = UTIME_NOW }, { .tv_sec = 0, .tv_nsec = UTIME_NOW } } ; char const *const *p = argv + 1 ; PROG = "s6-touch" ; if (argc < 2) strerr_dieusage(100, USAGE) ; @@ -14,6 +18,7 @@ int main (int argc, char const *const *argv) { register int fd = open_append(*p) ; if (fd < 0) strerr_diefu2sys(111, "open_append ", *p) ; + if (futimens(fd, now2) < 0) strerr_diefu2sys(111, "futimens ", *p) ; fd_close(fd) ; } return 0 ; |