summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2019-06-24 15:18:29 -0700
committergVisor bot <gvisor-bot@google.com>2019-06-24 15:19:36 -0700
commit87df9aab246fc1e72362bafcf98e1a746fd94187 (patch)
treee5070990960f49e0abeb596aae38cbb8554e0ab3
parentb21b1db7003aea8615ab9e6a4f07b74c97a32c24 (diff)
Use correct statx syscall number for amd64.
The previous number was for the arm architecture. Also change the statx tests to force them to run on gVisor, which would have caught this issue. PiperOrigin-RevId: 254846831
-rw-r--r--pkg/sentry/syscalls/linux/linux64.go2
-rw-r--r--test/syscalls/linux/stat.cc14
2 files changed, 10 insertions, 6 deletions
diff --git a/pkg/sentry/syscalls/linux/linux64.go b/pkg/sentry/syscalls/linux/linux64.go
index 2a41e8176..7f18b1ac8 100644
--- a/pkg/sentry/syscalls/linux/linux64.go
+++ b/pkg/sentry/syscalls/linux/linux64.go
@@ -379,7 +379,7 @@ var AMD64 = &kernel.SyscallTable{
326: syscalls.ErrorWithEvent("copy_file_range", syscall.ENOSYS, "", nil),
327: syscalls.Undocumented("preadv2", Preadv2),
328: syscalls.Undocumented("pwritev2", Pwritev2),
- 397: syscalls.Undocumented("statx", Statx),
+ 332: syscalls.Supported("statx", Statx),
},
Emulate: map[usermem.Addr]uintptr{
diff --git a/test/syscalls/linux/stat.cc b/test/syscalls/linux/stat.cc
index 0e914215d..510f7bee5 100644
--- a/test/syscalls/linux/stat.cc
+++ b/test/syscalls/linux/stat.cc
@@ -558,7 +558,7 @@ TEST(SimpleStatTest, AnonDeviceAllocatesUniqueInodesAcrossSaveRestore) {
#ifndef SYS_statx
#if defined(__x86_64__)
-#define SYS_statx 397
+#define SYS_statx 332
#else
#error "Unknown architecture"
#endif
@@ -607,7 +607,8 @@ int statx(int dirfd, const char *pathname, int flags, unsigned int mask,
}
TEST_F(StatTest, StatxAbsPath) {
- SKIP_IF(statx(-1, nullptr, 0, 0, 0) < 0 && errno == ENOSYS);
+ SKIP_IF(!IsRunningOnGvisor() && statx(-1, nullptr, 0, 0, 0) < 0 &&
+ errno == ENOSYS);
struct kernel_statx stx;
EXPECT_THAT(statx(-1, test_file_name_.c_str(), 0, STATX_ALL, &stx),
@@ -616,7 +617,8 @@ TEST_F(StatTest, StatxAbsPath) {
}
TEST_F(StatTest, StatxRelPathDirFD) {
- SKIP_IF(statx(-1, nullptr, 0, 0, 0) < 0 && errno == ENOSYS);
+ SKIP_IF(!IsRunningOnGvisor() && statx(-1, nullptr, 0, 0, 0) < 0 &&
+ errno == ENOSYS);
struct kernel_statx stx;
auto const dirfd =
@@ -629,7 +631,8 @@ TEST_F(StatTest, StatxRelPathDirFD) {
}
TEST_F(StatTest, StatxRelPathCwd) {
- SKIP_IF(statx(-1, nullptr, 0, 0, 0) < 0 && errno == ENOSYS);
+ SKIP_IF(!IsRunningOnGvisor() && statx(-1, nullptr, 0, 0, 0) < 0 &&
+ errno == ENOSYS);
ASSERT_THAT(chdir(GetAbsoluteTestTmpdir().c_str()), SyscallSucceeds());
auto filename = std::string(Basename(test_file_name_));
@@ -640,7 +643,8 @@ TEST_F(StatTest, StatxRelPathCwd) {
}
TEST_F(StatTest, StatxEmptyPath) {
- SKIP_IF(statx(-1, nullptr, 0, 0, 0) < 0 && errno == ENOSYS);
+ SKIP_IF(!IsRunningOnGvisor() && statx(-1, nullptr, 0, 0, 0) < 0 &&
+ errno == ENOSYS);
const auto fd = ASSERT_NO_ERRNO_AND_VALUE(Open(test_file_name_, O_RDONLY));
struct kernel_statx stx;