MCPcopy
hub / github.com/google/gvisor / Pwrite64

Function Pwrite64

pkg/sentry/syscalls/linux/sys_read_write.go:375–407  ·  view source on GitHub ↗

Pwrite64 implements Linux syscall pwrite64(2).

(t *kernel.Task, sysno uintptr, args arch.SyscallArguments)

Source from the content-addressed store, hash-verified

373
374// Pwrite64 implements Linux syscall pwrite64(2).
375func Pwrite64(t *kernel.Task, sysno uintptr, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) {
376 fd := args[0].Int()
377 addr := args[1].Pointer()
378 size := args[2].SizeT()
379 offset := args[3].Int64()
380
381 file := t.GetFile(fd)
382 if file == nil {
383 return 0, nil, linuxerr.EBADF
384 }
385 defer file.DecRef(t)
386
387 // Check that the offset is legitimate and does not overflow.
388 if offset < 0 || offset+int64(size) < 0 {
389 return 0, nil, linuxerr.EINVAL
390 }
391
392 // Check that the size is legitimate.
393 si := int(size)
394 if si < 0 {
395 return 0, nil, linuxerr.EINVAL
396 }
397
398 // Get the source of the write.
399 src, err := t.SingleIOSequence(addr, si, usermem.IOOpts{})
400 if err != nil {
401 return 0, nil, err
402 }
403
404 n, err := pwrite(t, file, src, offset, vfs.WriteOptions{})
405 t.IOUsage().AccountWriteSyscall(n)
406 return uintptr(n), nil, HandleIOError(t, n != 0, err, linuxerr.ERESTARTSYS, "pwrite64", file)
407}
408
409// Pwritev implements Linux syscall pwritev(2).
410func Pwritev(t *kernel.Task, sysno uintptr, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) {

Callers

nothing calls this directly

Calls 11

pwriteFunction · 0.85
HandleIOErrorFunction · 0.85
SizeTMethod · 0.80
GetFileMethod · 0.80
SingleIOSequenceMethod · 0.80
AccountWriteSyscallMethod · 0.80
DecRefMethod · 0.65
IOUsageMethod · 0.65
IntMethod · 0.45
PointerMethod · 0.45
Int64Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…