From 372ac34d5f80412c09cc40a4e3b72379afa7f637 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 17 Jan 2013 18:34:02 +0100 Subject: [PATCH] linux: translate futimes() fallback error codes The fallback added in 9d4a16e uses the /proc filesystem to emulate utimensat(). Translate error codes that indicate no procfs is mounted to ENOSYS. Letting those error codes through unchecked will only confuse callers. --- src/unix/fs.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/unix/fs.c b/src/unix/fs.c index eaccb294..6b7ac6c5 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -144,7 +144,23 @@ skip: tv[1].tv_usec = (unsigned long)(req->mtime * 1000000) % 1000000; snprintf(path, sizeof(path), "/proc/self/fd/%d", (int) req->file); - return utimes(path, tv); + r = utimes(path, tv); + if (r == 0) + return r; + + switch (errno) { + case ENOENT: + if (fcntl(req->file, F_GETFL) == -1 && errno == EBADF) + break; + /* Fall through. */ + + case EACCES: + case ENOTDIR: + errno = ENOSYS; + break; + } + + return r; #elif defined(__APPLE__) \ || defined(__DragonFly__) \