changeset 274 | cea6d2f4f728 |
parent 272 | e9ffa471eeb3 |
child 275 | 4a25a40d0c59 |
273:63ec80976891 | 274:cea6d2f4f728 |
---|---|
40 |
40 |
41 func (cmsg *Cmsghdr) SetLen(length int) { |
41 func (cmsg *Cmsghdr) SetLen(length int) { |
42 cmsg.Len = uint32(length) |
42 cmsg.Len = uint32(length) |
43 } |
43 } |
44 |
44 |
45 func (d *PtraceIoDesc) SetLen(length int) { |
|
46 d.Len = uint64(length) |
|
47 } |
|
48 |
|
45 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { |
49 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { |
46 var writtenOut uint64 = 0 |
50 var writtenOut uint64 = 0 |
47 _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) |
51 _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) |
48 |
52 |
49 written = int(writtenOut) |
53 written = int(writtenOut) |
53 } |
57 } |
54 return |
58 return |
55 } |
59 } |
56 |
60 |
57 func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) |
61 func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) |
58 |
|
59 func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) { |
|
60 ioDesc := PtraceIoDesc{ |
|
61 Op: int32(req), |
|
62 Offs: offs, |
|
63 Addr: uintptr(unsafe.Pointer(&out[0])), // TODO(#58351): this is not safe. |
|
64 Len: uint64(countin), |
|
65 } |
|
66 err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) |
|
67 return int(ioDesc.Len), err |
|
68 } |