mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix vfs2 handling of preadv2/pwritev2 flags.
Check for unsupported flags, and silently support RWF_HIPRI by doing nothing. From pkg/abi/linux/file.go: "gVisor does not implement the RWF_HIPRI feature, but the flag is accepted as a valid flag argument for preadv2/pwritev2." Updates #2923. PiperOrigin-RevId: 317330631
This commit is contained in:
@@ -72,7 +72,9 @@ func (fd *regularFileFD) PRead(ctx context.Context, dst usermem.IOSequence, offs
|
||||
if offset < 0 {
|
||||
return 0, syserror.EINVAL
|
||||
}
|
||||
if opts.Flags != 0 {
|
||||
|
||||
// Check that flags are supported. Silently ignore RWF_HIPRI.
|
||||
if opts.Flags&^linux.RWF_HIPRI != 0 {
|
||||
return 0, syserror.EOPNOTSUPP
|
||||
}
|
||||
|
||||
@@ -123,9 +125,12 @@ func (fd *regularFileFD) PWrite(ctx context.Context, src usermem.IOSequence, off
|
||||
if offset < 0 {
|
||||
return 0, syserror.EINVAL
|
||||
}
|
||||
if opts.Flags != 0 {
|
||||
|
||||
// Check that flags are supported. Silently ignore RWF_HIPRI.
|
||||
if opts.Flags&^linux.RWF_HIPRI != 0 {
|
||||
return 0, syserror.EOPNOTSUPP
|
||||
}
|
||||
|
||||
limit, err := vfs.CheckLimit(ctx, offset, src.NumBytes())
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
||||
@@ -129,7 +129,9 @@ func (fd *specialFileFD) PRead(ctx context.Context, dst usermem.IOSequence, offs
|
||||
if fd.seekable && offset < 0 {
|
||||
return 0, syserror.EINVAL
|
||||
}
|
||||
if opts.Flags != 0 {
|
||||
|
||||
// Check that flags are supported. Silently ignore RWF_HIPRI.
|
||||
if opts.Flags&^linux.RWF_HIPRI != 0 {
|
||||
return 0, syserror.EOPNOTSUPP
|
||||
}
|
||||
|
||||
@@ -173,7 +175,9 @@ func (fd *specialFileFD) PWrite(ctx context.Context, src usermem.IOSequence, off
|
||||
if fd.seekable && offset < 0 {
|
||||
return 0, syserror.EINVAL
|
||||
}
|
||||
if opts.Flags != 0 {
|
||||
|
||||
// Check that flags are supported. Silently ignore RWF_HIPRI.
|
||||
if opts.Flags&^linux.RWF_HIPRI != 0 {
|
||||
return 0, syserror.EOPNOTSUPP
|
||||
}
|
||||
|
||||
|
||||
@@ -279,6 +279,12 @@ func (fd *regularFileFD) PRead(ctx context.Context, dst usermem.IOSequence, offs
|
||||
if offset < 0 {
|
||||
return 0, syserror.EINVAL
|
||||
}
|
||||
|
||||
// Check that flags are supported. Silently ignore RWF_HIPRI.
|
||||
if opts.Flags&^linux.RWF_HIPRI != 0 {
|
||||
return 0, syserror.EOPNOTSUPP
|
||||
}
|
||||
|
||||
if dst.NumBytes() == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
@@ -304,6 +310,12 @@ func (fd *regularFileFD) PWrite(ctx context.Context, src usermem.IOSequence, off
|
||||
if offset < 0 {
|
||||
return 0, syserror.EINVAL
|
||||
}
|
||||
|
||||
// Check that flags are supported. Silently ignore RWF_HIPRI.
|
||||
if opts.Flags&^linux.RWF_HIPRI != 0 {
|
||||
return 0, syserror.EOPNOTSUPP
|
||||
}
|
||||
|
||||
srclen := src.NumBytes()
|
||||
if srclen == 0 {
|
||||
return 0, nil
|
||||
|
||||
@@ -463,6 +463,7 @@ syscall_test(
|
||||
syscall_test(
|
||||
add_overlay = True,
|
||||
test = "//test/syscalls/linux:preadv2_test",
|
||||
vfs2 = "True",
|
||||
)
|
||||
|
||||
syscall_test(
|
||||
|
||||
Reference in New Issue
Block a user