diff options
Diffstat (limited to 'pkg/sentry/kernel/fd_map.go')
-rw-r--r-- | pkg/sentry/kernel/fd_map.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pkg/sentry/kernel/fd_map.go b/pkg/sentry/kernel/fd_map.go index ef73125fd..299506330 100644 --- a/pkg/sentry/kernel/fd_map.go +++ b/pkg/sentry/kernel/fd_map.go @@ -51,6 +51,22 @@ type FDFlags struct { CloseOnExec bool } +// ToLinuxFileFlags converts a kernel.FDFlags object to a Linux file flags representation. +func (f FDFlags) ToLinuxFileFlags() (mask uint) { + if f.CloseOnExec { + mask |= linux.O_CLOEXEC + } + return +} + +// ToLinuxFDFlags converts a kernel.FDFlags object to a Linux descriptor flags representation. +func (f FDFlags) ToLinuxFDFlags() (mask uint) { + if f.CloseOnExec { + mask |= linux.FD_CLOEXEC + } + return +} + // descriptor holds the details about a file descriptor, namely a pointer the // file itself and the descriptor flags. type descriptor struct { |