diff options
-rw-r--r-- | pkg/abi/linux/file.go | 3 | ||||
-rw-r--r-- | pkg/sentry/fs/flags.go | 9 | ||||
-rw-r--r-- | pkg/sentry/syscalls/linux/flags.go | 1 |
3 files changed, 11 insertions, 2 deletions
diff --git a/pkg/abi/linux/file.go b/pkg/abi/linux/file.go index f78ffaa82..285338e47 100644 --- a/pkg/abi/linux/file.go +++ b/pkg/abi/linux/file.go @@ -34,13 +34,14 @@ const ( O_TRUNC = 00001000 O_APPEND = 00002000 O_NONBLOCK = 00004000 + O_DSYNC = 00010000 O_ASYNC = 00020000 O_DIRECT = 00040000 O_LARGEFILE = 00100000 O_DIRECTORY = 00200000 O_NOFOLLOW = 00400000 O_CLOEXEC = 02000000 - O_SYNC = 04010000 + O_SYNC = 04000000 O_PATH = 010000000 ) diff --git a/pkg/sentry/fs/flags.go b/pkg/sentry/fs/flags.go index 1278f9c78..0fab876a9 100644 --- a/pkg/sentry/fs/flags.go +++ b/pkg/sentry/fs/flags.go @@ -28,7 +28,11 @@ type FileFlags struct { // NonBlocking indicates that I/O should not block. NonBlocking bool - // Sync indicates that any writes should be synchronous. + // DSync indicates that each write will flush data and metadata required to + // read the file's contents. + DSync bool + + // Sync indicates that each write will flush data and all file metadata. Sync bool // Append indicates this file is append only. @@ -96,6 +100,9 @@ func (f FileFlags) ToLinux() (mask uint) { if f.NonBlocking { mask |= linux.O_NONBLOCK } + if f.DSync { + mask |= linux.O_DSYNC + } if f.Sync { mask |= linux.O_SYNC } diff --git a/pkg/sentry/syscalls/linux/flags.go b/pkg/sentry/syscalls/linux/flags.go index 0c1b5ec27..444f2b004 100644 --- a/pkg/sentry/syscalls/linux/flags.go +++ b/pkg/sentry/syscalls/linux/flags.go @@ -41,6 +41,7 @@ func flagsToPermissions(mask uint) (p fs.PermMask) { func linuxToFlags(mask uint) fs.FileFlags { return fs.FileFlags{ Direct: mask&linux.O_DIRECT != 0, + DSync: mask&(linux.O_DSYNC|linux.O_SYNC) != 0, Sync: mask&linux.O_SYNC != 0, NonBlocking: mask&linux.O_NONBLOCK != 0, Read: (mask & linux.O_ACCMODE) != linux.O_WRONLY, |