summaryrefslogtreecommitdiff
path: root/lib/utimens.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2021-01-02 18:59:12 +0100
committerBruno Haible <bruno@clisp.org>2021-01-02 18:59:12 +0100
commit86c8ff740b64f3724de20d71dca481bef30b18dd (patch)
tree945615bbad7020d820811cf9b7b84f8094f326ef /lib/utimens.c
parent3b123860925185b7ba330e1f24a7a9389a955f9b (diff)
downloadgnulib-86c8ff740b64f3724de20d71dca481bef30b18dd.tar.gz
utimens: Fix test failure on macOS 10.13.
* lib/utimens.c (fdutimens): Before calling utimensat, recognize a filename ending in a slash that does not point to a directory.
Diffstat (limited to 'lib/utimens.c')
-rw-r--r--lib/utimens.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/utimens.c b/lib/utimens.c
index 5bbae05813..9f9c30af2f 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -246,6 +246,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: