Automated rollback of changelist 278417533

PiperOrigin-RevId: 279365629
This commit is contained in:
Kevin Krakauer
2019-11-08 12:20:11 -08:00
committed by gVisor bot
parent 66ebb6575f
commit af58a4e3bb
2 changed files with 4 additions and 6 deletions
-2
View File
@@ -221,8 +221,6 @@ type InodeOperations interface {
// sys_ftruncate.
//
// Implementations need not check that length >= 0.
//
// Truncate must only be called on regular files.
Truncate(ctx context.Context, inode *Inode, size int64) error
// Allocate allows the caller to reserve disk space for the inode.
+4 -4
View File
@@ -169,7 +169,7 @@ func openAt(t *kernel.Task, dirFD int32, addr usermem.Addr, flags uint) (fd uint
if dirPath {
return syserror.ENOTDIR
}
if flags&linux.O_TRUNC != 0 && fs.IsRegular(d.Inode.StableAttr) {
if flags&linux.O_TRUNC != 0 {
if err := d.Inode.Truncate(t, d, 0); err != nil {
return err
}
@@ -397,7 +397,7 @@ func createAt(t *kernel.Task, dirFD int32, addr usermem.Addr, flags uint, mode l
}
// Should we truncate the file?
if flags&linux.O_TRUNC != 0 && fs.IsRegular(found.Inode.StableAttr) {
if flags&linux.O_TRUNC != 0 {
if err := found.Inode.Truncate(t, found, 0); err != nil {
return err
}
@@ -1483,7 +1483,7 @@ func Truncate(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sysc
if fs.IsDir(d.Inode.StableAttr) {
return syserror.EISDIR
}
if !fs.IsRegular(d.Inode.StableAttr) {
if !fs.IsFile(d.Inode.StableAttr) {
return syserror.EINVAL
}
@@ -1523,7 +1523,7 @@ func Ftruncate(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sys
// Note that this is different from truncate(2) above, where a
// directory returns EISDIR.
if !fs.IsRegular(file.Dirent.Inode.StableAttr) {
if !fs.IsFile(file.Dirent.Inode.StableAttr) {
return 0, nil, syserror.EINVAL
}