mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fixing O_TRUNC behavior to match Linux.
PiperOrigin-RevId: 224351139 Change-Id: I9453bd75e5a8d38db406bb47fdc01038ac60922e
This commit is contained in:
@@ -22,6 +22,9 @@ import (
|
||||
// flagsToPermissions returns a Permissions object from Linux flags.
|
||||
// This includes truncate permission if O_TRUNC is set in the mask.
|
||||
func flagsToPermissions(mask uint) (p fs.PermMask) {
|
||||
if mask&linux.O_TRUNC != 0 {
|
||||
p.Write = true
|
||||
}
|
||||
switch mask & linux.O_ACCMODE {
|
||||
case linux.O_WRONLY:
|
||||
p.Write = true
|
||||
|
||||
@@ -170,7 +170,7 @@ func openAt(t *kernel.Task, dirFD kdefs.FD, addr usermem.Addr, flags uint) (fd u
|
||||
if dirPath {
|
||||
return syserror.ENOTDIR
|
||||
}
|
||||
if fileFlags.Write && flags&linux.O_TRUNC != 0 {
|
||||
if flags&linux.O_TRUNC != 0 {
|
||||
if err := d.Inode.Truncate(t, d, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user