summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/kernel/fd_map.go
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@gmail.com>2018-07-31 11:18:02 -0700
committerShentubot <shentubot@google.com>2018-07-31 11:19:15 -0700
commita7a0167716d71895919021692b15bd000f63b24f (patch)
tree5e41d11fe25b533a59387649e4f90c0801e1eb1e /pkg/sentry/kernel/fd_map.go
parent543c997978525ac7de3a24ff73203ddbb2cef6dc (diff)
proc: show file flags in fdinfo
Currently, there is an attempt to print FD flags, but they are not decoded into a number, so we see something like this: /criu # cat /proc/self/fdinfo/0 flags: {%!o(bool=000false)} Actually, fdinfo has to contain file flags. Change-Id: Idcbb7db908067447eb9ae6f2c3cfb861f2be1a97 PiperOrigin-RevId: 206794498
Diffstat (limited to 'pkg/sentry/kernel/fd_map.go')
-rw-r--r--pkg/sentry/kernel/fd_map.go16
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 {