access, connect, socket.
In Android-L, logging is done by writing the log messages to the logd
process through a unix domain socket.
Also, changed the arg types of those syscall stubs to match linux
programming APIs.
For golang/go#10743
Change-Id: I66368a03316e253561e9e76aadd180c2cd2e48f3
Reviewed-on: https://go-review.googlesource.com/15993
Reviewed-by: David Crawshaw <crawshaw@golang.org>
_EPOLL_CTL_ADD = 0x1
_EPOLL_CTL_DEL = 0x2
_EPOLL_CTL_MOD = 0x3
+
+ _AF_UNIX = 0x1
+ _F_SETFL = 0x4
+ _SOCK_DGRAM = 0x2
)
type timespec struct {
fpstate *fpstate1
__reserved1 [8]uint64
}
+
+type sockaddr_un struct {
+ family uint16
+ path [108]byte
+}
exit(2)
}
- errno := connect(uintptr(fd), unsafe.Pointer(&logdAddr), int32(unsafe.Sizeof(logdAddr)))
+ errno := connect(fd, unsafe.Pointer(&logdAddr), int32(unsafe.Sizeof(logdAddr)))
if errno < 0 {
msg := []byte("runtime: cannot connect to /dev/socket/logdw\x00")
write(2, unsafe.Pointer(&msg[0]), int32(len(msg)))
import "unsafe"
+// Return values of access/connect/socket are the return values of the syscall
+// (may encode error numbers).
+
+// int access(const char *, int)
//go:noescape
func access(name *byte, mode int32) int32
-func connect(fd uintptr, addr unsafe.Pointer, len int32) int32
+// int connect(int, const struct sockaddr*, socklen_t)
+func connect(fd int32, addr unsafe.Pointer, len int32) int32
+// int socket(int, int, int)
func socket(domain int32, typ int32, prot int32) int32
MOVL $72, AX // fcntl
SYSCALL
RET
+
+
+// int access(const char *name, int mode)
+TEXT runtime·access(SB),NOSPLIT,$0
+ MOVQ name+0(FP), DI
+ MOVL mode+8(FP), SI
+ MOVL $21, AX // syscall entry
+ SYSCALL
+ MOVL AX, ret+16(FP)
+ RET
+
+// int connect(int fd, const struct sockaddr *addr, socklen_t addrlen)
+TEXT runtime·connect(SB),NOSPLIT,$0-28
+ MOVL fd+0(FP), DI
+ MOVQ addr+8(FP), SI
+ MOVL addrlen+16(FP), DX
+ MOVL $42, AX // syscall entry
+ SYSCALL
+ MOVL AX, ret+24(FP)
+ RET
+
+// int socket(int domain, int type, int protocol)
+TEXT runtime·socket(SB),NOSPLIT,$0-20
+ MOVL domain+0(FP), DI
+ MOVL type+4(FP), SI
+ MOVL protocol+8(FP), DX
+ MOVL $41, AX // syscall entry
+ SYSCALL
+ MOVL AX, ret+16(FP)
+ RET