From 96cfa783a24e154fd3d3124e159aec277537f494 Mon Sep 17 00:00:00 2001 From: Milad Farazmand Date: Wed, 23 Oct 2019 14:38:34 -0400 Subject: [PATCH] fs: handle non-functional statx system call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit statx is not implemented on RHEL 7 and trying to call it from within a docker container might result in a return value of 1 (which is not an expected value according to statx man page, expected values are 0 or -1) and errno is set to 0, in which case assume statx is not implemented. Above behaviour has been seen on RHEL 7 running on a s390. PR-URL: https://github.com/libuv/libuv/pull/2529 Refs: https://bugzilla.redhat.com/show_bug.cgi?id=1759152 Reviewed-By: Ben Noordhuis Reviewed-By: Richard Lau Reviewed-By: Santiago Gimeno Reviewed-By: Saúl Ibarra Corretgé --- src/unix/fs.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/unix/fs.c b/src/unix/fs.c index fae8f48d..896cd516 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -1234,13 +1234,22 @@ static int uv__fs_statx(int fd, rc = uv__statx(dirfd, path, flags, mode, &statxbuf); - if (rc == -1) { + switch (rc) { + case 0: + break; + case -1: /* EPERM happens when a seccomp filter rejects the system call. * Has been observed with libseccomp < 2.3.3 and docker < 18.04. */ if (errno != EINVAL && errno != EPERM && errno != ENOSYS) return -1; - + /* Fall through. */ + default: + /* Normally on success, zero is returned and On error, -1 is returned. + * Observed on S390 RHEL running in a docker container with statx not + * implemented, rc might return 1 with 0 set as the error code in which + * case we return ENOSYS. + */ no_statx = 1; return UV_ENOSYS; }