Separate O_DSYNC and O_SYNC.

PiperOrigin-RevId: 258657913
This commit is contained in:
Jamie Liu
2019-07-17 15:52:38 -07:00
committed by gVisor bot
parent 84a59de5dc
commit 2bc398bfd8
3 changed files with 11 additions and 2 deletions
+2 -1
View File
@@ -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
)
+8 -1
View File
@@ -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
}
+1
View File
@@ -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,