summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/fsutil
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-03-03 18:43:27 +0000
committergVisor bot <gvisor-bot@google.com>2021-03-03 18:43:27 +0000
commitaae5455fe381c4cbc956f61c971284ee05c52dfc (patch)
tree2b1cb0233968680dcd0374f20ee826cf311bda95 /pkg/sentry/fs/fsutil
parente2599d556573b05eb3714c1e791fa29431dc3d3f (diff)
parenta9441aea2780da8c93da1c73da860219f98438de (diff)
Merge release-20210301.0-5-ga9441aea2 (automated)
Diffstat (limited to 'pkg/sentry/fs/fsutil')
-rw-r--r--pkg/sentry/fs/fsutil/host_file_mapper.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/pkg/sentry/fs/fsutil/host_file_mapper.go b/pkg/sentry/fs/fsutil/host_file_mapper.go
index 4468f5dd2..54f7b7cdc 100644
--- a/pkg/sentry/fs/fsutil/host_file_mapper.go
+++ b/pkg/sentry/fs/fsutil/host_file_mapper.go
@@ -16,8 +16,8 @@ package fsutil
import (
"fmt"
- "syscall"
+ "golang.org/x/sys/unix"
"gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/pkg/safemem"
"gvisor.dev/gvisor/pkg/sentry/memmap"
@@ -44,7 +44,7 @@ type HostFileMapper struct {
mapsMu sync.Mutex `state:"nosave"`
// mappings maps chunk start offsets to mappings of those chunks,
- // obtained by calling syscall.Mmap. mappings is protected by
+ // obtained by calling unix.Mmap. mappings is protected by
// mapsMu.
mappings map[uint64]mapping `state:"nosave"`
}
@@ -157,19 +157,19 @@ func (f *HostFileMapper) MapInternal(fr memmap.FileRange, fd int, write bool) (s
// Preconditions: f.mapsMu must be locked.
func (f *HostFileMapper) forEachMappingBlockLocked(fr memmap.FileRange, fd int, write bool, fn func(safemem.Block)) error {
- prot := syscall.PROT_READ
+ prot := unix.PROT_READ
if write {
- prot |= syscall.PROT_WRITE
+ prot |= unix.PROT_WRITE
}
for chunkStart := fr.Start &^ chunkMask; chunkStart < fr.End; chunkStart += chunkSize {
m, ok := f.mappings[chunkStart]
if !ok {
- addr, _, errno := syscall.Syscall6(
- syscall.SYS_MMAP,
+ addr, _, errno := unix.Syscall6(
+ unix.SYS_MMAP,
0,
chunkSize,
uintptr(prot),
- syscall.MAP_SHARED,
+ unix.MAP_SHARED,
uintptr(fd),
uintptr(chunkStart))
if errno != 0 {
@@ -178,12 +178,12 @@ func (f *HostFileMapper) forEachMappingBlockLocked(fr memmap.FileRange, fd int,
m = mapping{addr, write}
f.mappings[chunkStart] = m
} else if write && !m.writable {
- addr, _, errno := syscall.Syscall6(
- syscall.SYS_MMAP,
+ addr, _, errno := unix.Syscall6(
+ unix.SYS_MMAP,
m.addr,
chunkSize,
uintptr(prot),
- syscall.MAP_SHARED|syscall.MAP_FIXED,
+ unix.MAP_SHARED|unix.MAP_FIXED,
uintptr(fd),
uintptr(chunkStart))
if errno != 0 {
@@ -219,7 +219,7 @@ func (f *HostFileMapper) UnmapAll() {
// * f.mapsMu must be locked.
// * f.mappings[chunkStart] == m.
func (f *HostFileMapper) unmapAndRemoveLocked(chunkStart uint64, m mapping) {
- if _, _, errno := syscall.Syscall(syscall.SYS_MUNMAP, m.addr, chunkSize, 0); errno != 0 {
+ if _, _, errno := unix.Syscall(unix.SYS_MUNMAP, m.addr, chunkSize, 0); errno != 0 {
// This leaks address space and is unexpected, but is otherwise
// harmless, so complain but don't panic.
log.Warningf("HostFileMapper: failed to unmap mapping %#x for chunk %#x: %v", m.addr, chunkStart, errno)
@@ -234,16 +234,16 @@ func (f *HostFileMapper) RegenerateMappings(fd int) error {
defer f.mapsMu.Unlock()
for chunkStart, m := range f.mappings {
- prot := syscall.PROT_READ
+ prot := unix.PROT_READ
if m.writable {
- prot |= syscall.PROT_WRITE
+ prot |= unix.PROT_WRITE
}
- _, _, errno := syscall.Syscall6(
- syscall.SYS_MMAP,
+ _, _, errno := unix.Syscall6(
+ unix.SYS_MMAP,
m.addr,
chunkSize,
uintptr(prot),
- syscall.MAP_SHARED|syscall.MAP_FIXED,
+ unix.MAP_SHARED|unix.MAP_FIXED,
uintptr(fd),
uintptr(chunkStart))
if errno != 0 {