aboutsummaryrefslogtreecommitdiffstats
path: root/testing/bfs/no-statx.patch
blob: b737b5e0c8d0c991a21f6b6fa0ea0b5e2eab96a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
From 71a1b65ba926ff9c6db3cb671580b5491db0bd97 Mon Sep 17 00:00:00 2001
From: Tavian Barnes <tavianator@tavianator.com>
Date: Fri, 5 Jul 2019 19:11:20 -0400
Subject: [PATCH] stat: Treat EPERM like ENOSYS for statx()

On some configurations (e.g. old Docker with the default seccomp()
profile), statx() fails with EPERM.  Consider this to mean statx() is
unsupported, as EPERM is not a documented error code in normal
operation.

Possible fix for https://github.com/alpinelinux/aports/pull/9277
---
 stat.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/stat.c b/stat.c
index e3d5400..a2e2c8d 100644
--- a/stat.c
+++ b/stat.c
@@ -282,7 +282,9 @@ static int bfs_stat_explicit(int at_fd, const char *at_path, int at_flags, enum
 
 	if (has_statx) {
 		int ret = bfs_statx_impl(at_fd, at_path, at_flags, flags, buf);
-		if (ret != 0 && errno == ENOSYS) {
+		// EPERM is commonly returned in a seccomp() sandbox that does
+		// not allow statx()
+		if (ret != 0 && (errno == ENOSYS || errno == EPERM)) {
 			has_statx = false;
 		} else {
 			return ret;