Permalink
Browse files

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.
  • Loading branch information...
1 parent 358957c commit 372ac34d5f80412c09cc40a4e3b72379afa7f637 @bnoordhuis bnoordhuis committed Jan 17, 2013
Showing with 17 additions and 1 deletion.
  1. +17 −1 src/unix/fs.c
View
18 src/unix/fs.c
@@ -144,7 +144,23 @@ static ssize_t uv__fs_futime(uv_fs_t* req) {
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__) \

0 comments on commit 372ac34

Please sign in to comment.