Enable sentry/fs/host support on arm64.

newfstatat() syscall is not supported on arm64, so we resort
to use the fstatat() syscall.

Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: Iea95550ea53bcf85c01f7b3b95da70ad0952177d
This commit is contained in:
Haibo Xu
2019-11-13 06:46:02 +00:00
parent 2c6c9af904
commit c5d9b5b881
5 changed files with 85 additions and 20 deletions
+2
View File
@@ -21,6 +21,8 @@ go_library(
"socket_unsafe.go",
"tty.go",
"util.go",
"util_amd64_unsafe.go",
"util_arm64_unsafe.go",
"util_unsafe.go",
],
importpath = "gvisor.dev/gvisor/pkg/sentry/fs/host",
+1 -1
View File
@@ -155,7 +155,7 @@ func unstableAttr(mo *superOperations, s *syscall.Stat_t) fs.UnstableAttr {
AccessTime: ktime.FromUnix(s.Atim.Sec, s.Atim.Nsec),
ModificationTime: ktime.FromUnix(s.Mtim.Sec, s.Mtim.Nsec),
StatusChangeTime: ktime.FromUnix(s.Ctim.Sec, s.Ctim.Nsec),
Links: s.Nlink,
Links: uint64(s.Nlink),
}
}
+41
View File
@@ -0,0 +1,41 @@
// Copyright 2019 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build amd64
package host
import (
"syscall"
"unsafe"
)
func fstatat(fd int, name string, flags int) (syscall.Stat_t, error) {
var stat syscall.Stat_t
namePtr, err := syscall.BytePtrFromString(name)
if err != nil {
return stat, err
}
_, _, errno := syscall.Syscall6(
syscall.SYS_NEWFSTATAT,
uintptr(fd),
uintptr(unsafe.Pointer(namePtr)),
uintptr(unsafe.Pointer(&stat)),
uintptr(flags),
0, 0)
if errno != 0 {
return stat, errno
}
return stat, nil
}
+41
View File
@@ -0,0 +1,41 @@
// Copyright 2019 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build arm64
package host
import (
"syscall"
"unsafe"
)
func fstatat(fd int, name string, flags int) (syscall.Stat_t, error) {
var stat syscall.Stat_t
namePtr, err := syscall.BytePtrFromString(name)
if err != nil {
return stat, err
}
_, _, errno := syscall.Syscall6(
syscall.SYS_FSTATAT,
uintptr(fd),
uintptr(unsafe.Pointer(namePtr)),
uintptr(unsafe.Pointer(&stat)),
uintptr(flags),
0, 0)
if errno != 0 {
return stat, errno
}
return stat, nil
}
-19
View File
@@ -116,22 +116,3 @@ func setTimestamps(fd int, ts fs.TimeSpec) error {
}
return nil
}
func fstatat(fd int, name string, flags int) (syscall.Stat_t, error) {
var stat syscall.Stat_t
namePtr, err := syscall.BytePtrFromString(name)
if err != nil {
return stat, err
}
_, _, errno := syscall.Syscall6(
syscall.SYS_NEWFSTATAT,
uintptr(fd),
uintptr(unsafe.Pointer(namePtr)),
uintptr(unsafe.Pointer(&stat)),
uintptr(flags),
0, 0)
if errno != 0 {
return stat, errno
}
return stat, nil
}