summaryrefslogtreecommitdiff
path: root/lib/utimens.c
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-03-05 10:08:28 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-03-05 10:08:28 +0900
commitf06fb91e0373c52ed04740f8136bc7cfcc3c8766 (patch)
treef7604f9cd7573e22e6a0fb8883d81ae73ed72069 /lib/utimens.c
parenta2c7c975f0813d307b31d06da2c015916a6bb16d (diff)
downloadwget-f06fb91e0373c52ed04740f8136bc7cfcc3c8766.tar.gz
wget-f06fb91e0373c52ed04740f8136bc7cfcc3c8766.tar.bz2
wget-f06fb91e0373c52ed04740f8136bc7cfcc3c8766.zip
Imported Upstream version 1.21.1upstream/1.21.1upstream
Diffstat (limited to 'lib/utimens.c')
-rw-r--r--lib/utimens.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/utimens.c b/lib/utimens.c
index 3f53942..44d1ea0 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -1,6 +1,6 @@
/* Set file access and modification times.
- Copyright (C) 2003-2020 Free Software Foundation, Inc.
+ Copyright (C) 2003-2021 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -27,6 +27,7 @@
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
+#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
@@ -52,7 +53,9 @@
/* Avoid recursion with rpl_futimens or rpl_utimensat. */
#undef futimens
-#undef utimensat
+#if !HAVE_NEARLY_WORKING_UTIMENSAT
+# undef utimensat
+#endif
/* Solaris 9 mistakenly succeeds when given a non-directory with a
trailing slash. Force the use of rpl_stat for a fix. */
@@ -246,6 +249,20 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2])
# if HAVE_UTIMENSAT
if (fd < 0)
{
+# if defined __APPLE__ && defined __MACH__
+ size_t len = strlen (file);
+ if (len > 0 && file[len - 1] == '/')
+ {
+ struct stat statbuf;
+ if (stat (file, &statbuf) < 0)
+ return -1;
+ if (!S_ISDIR (statbuf.st_mode))
+ {
+ errno = ENOTDIR;
+ return -1;
+ }
+ }
+# endif
result = utimensat (AT_FDCWD, file, ts, 0);
# ifdef __linux__
/* Work around a kernel bug: