Merge pull request #1177 from xiaobo55x:fs_host

PiperOrigin-RevId: 281112758
This commit is contained in:
gVisor bot
2019-11-18 11:50:44 -08:00
7 changed files with 87 additions and 21 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
}
-1
View File
@@ -17,7 +17,6 @@
package kernel
import (
"gvisor.dev/gvisor/pkg/abi/linux"
"gvisor.dev/gvisor/pkg/sentry/usermem"
"gvisor.dev/gvisor/pkg/syserror"
)
+2
View File
@@ -268,6 +268,8 @@ func PrepareVDSO(ctx context.Context, mfp pgalloc.MemoryFileProvider) (*VDSO, er
// some applications may not be able to handle multiple [vdso]
// hints.
vdso: mm.NewSpecialMappable("", mfp, vdso),
os: info.os,
arch: info.arch,
phdrs: info.phdrs,
}, nil
}