summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/syscalls
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry/syscalls')
-rw-r--r--pkg/sentry/syscalls/linux/flags.go43
-rw-r--r--pkg/sentry/syscalls/linux/sys_file.go4
2 files changed, 2 insertions, 45 deletions
diff --git a/pkg/sentry/syscalls/linux/flags.go b/pkg/sentry/syscalls/linux/flags.go
index b2e173f3e..e8db3e0de 100644
--- a/pkg/sentry/syscalls/linux/flags.go
+++ b/pkg/sentry/syscalls/linux/flags.go
@@ -17,7 +17,6 @@ package linux
import (
"gvisor.googlesource.com/gvisor/pkg/abi/linux"
"gvisor.googlesource.com/gvisor/pkg/sentry/fs"
- "gvisor.googlesource.com/gvisor/pkg/sentry/kernel"
)
// flagsToPermissions returns a Permissions object from Linux flags.
@@ -35,48 +34,6 @@ func flagsToPermissions(mask uint) (p fs.PermMask) {
return
}
-// fdFlagsToLinux converts a kernel.FDFlags object to a Linux representation.
-func fdFlagsToLinux(flags kernel.FDFlags) (mask uint) {
- if flags.CloseOnExec {
- mask |= linux.FD_CLOEXEC
- }
- return
-}
-
-// flagsToLinux converts a FileFlags object to a Linux representation.
-func flagsToLinux(flags fs.FileFlags) (mask uint) {
- if flags.Direct {
- mask |= linux.O_DIRECT
- }
- if flags.NonBlocking {
- mask |= linux.O_NONBLOCK
- }
- if flags.Sync {
- mask |= linux.O_SYNC
- }
- if flags.Append {
- mask |= linux.O_APPEND
- }
- if flags.Directory {
- mask |= linux.O_DIRECTORY
- }
- if flags.Async {
- mask |= linux.O_ASYNC
- }
- if flags.LargeFile {
- mask |= linux.O_LARGEFILE
- }
- switch {
- case flags.Read && flags.Write:
- mask |= linux.O_RDWR
- case flags.Write:
- mask |= linux.O_WRONLY
- case flags.Read:
- mask |= linux.O_RDONLY
- }
- return
-}
-
// linuxToFlags converts linux file flags to a FileFlags object.
func linuxToFlags(mask uint) (flags fs.FileFlags) {
return fs.FileFlags{
diff --git a/pkg/sentry/syscalls/linux/sys_file.go b/pkg/sentry/syscalls/linux/sys_file.go
index 2f28fbea6..692f11ed7 100644
--- a/pkg/sentry/syscalls/linux/sys_file.go
+++ b/pkg/sentry/syscalls/linux/sys_file.go
@@ -809,14 +809,14 @@ func Fcntl(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Syscall
}
return uintptr(fd), nil, nil
case linux.F_GETFD:
- return uintptr(fdFlagsToLinux(flags)), nil, nil
+ return uintptr(flags.ToLinuxFDFlags()), nil, nil
case linux.F_SETFD:
flags := args[2].Uint()
t.FDMap().SetFlags(fd, kernel.FDFlags{
CloseOnExec: flags&syscall.FD_CLOEXEC != 0,
})
case linux.F_GETFL:
- return uintptr(flagsToLinux(file.Flags())), nil, nil
+ return uintptr(file.Flags().ToLinux()), nil, nil
case linux.F_SETFL:
flags := uint(args[2].Uint())
file.SetFlags(linuxToSettableFlags(flags))