Change length type, and let fadvise64 return ESPIPE if file is a pipe
Kernel before 2.6.16 return EINVAL, but later return ESPIPE for this case. Also change type of "length" from Uint(uint32) to Int64. Because C header uses type "size_t" (unsigned long) or "off_t" (long) for length. And it makes more sense to check length < 0 with Int64 because Uint cannot be negative. Change-Id: Ifd7fea2dcded7577a30760558d0d31f479f074c4 PiperOrigin-RevId: 197616743
This commit is contained in:
parent
705605f901
commit
7b2b7a3946
|
@ -871,7 +871,7 @@ const (
|
||||||
func Fadvise64(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) {
|
func Fadvise64(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) {
|
||||||
fd := kdefs.FD(args[0].Int())
|
fd := kdefs.FD(args[0].Int())
|
||||||
offset := args[1].Int64()
|
offset := args[1].Int64()
|
||||||
length := args[2].Uint()
|
length := args[2].Int64()
|
||||||
advice := args[3].Int()
|
advice := args[3].Int()
|
||||||
|
|
||||||
if offset < 0 || length < 0 {
|
if offset < 0 || length < 0 {
|
||||||
|
@ -884,6 +884,11 @@ func Fadvise64(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sys
|
||||||
}
|
}
|
||||||
defer file.DecRef()
|
defer file.DecRef()
|
||||||
|
|
||||||
|
// If the FD refers to a pipe or FIFO, return error.
|
||||||
|
if fs.IsPipe(file.Dirent.Inode.StableAttr) {
|
||||||
|
return 0, nil, syserror.ESPIPE
|
||||||
|
}
|
||||||
|
|
||||||
switch advice {
|
switch advice {
|
||||||
case _FADV_NORMAL:
|
case _FADV_NORMAL:
|
||||||
case _FADV_RANDOM:
|
case _FADV_RANDOM:
|
||||||
|
|
Loading…
Reference in New Issue