Mark sockets on accept().
Conflicts:
libc/SYSCALLS.TXT
Change-Id: I5d09be413cf720fbed905f96313b007997ada76c
diff --git a/libc/Android.mk b/libc/Android.mk
index ed7d055..817c767 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -98,6 +98,7 @@
libc_bionic_src_files := \
bionic/abort.cpp \
+ bionic/accept.cpp \
bionic/access.cpp \
bionic/assert.cpp \
bionic/atof.cpp \
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index e9fb575..83feb65 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -236,7 +236,7 @@
int bind(int, struct sockaddr*, int) arm,arm64,mips,mips64,x86_64
int __connect:connect(int, struct sockaddr*, socklen_t) arm,arm64,mips,mips64,x86_64
int listen(int, int) arm,arm64,mips,mips64,x86_64
-int accept(int, struct sockaddr*, socklen_t*) arm,arm64,mips,mips64,x86_64
+int __accept:accept(int, struct sockaddr*, socklen_t*) arm,arm64,mips,mips64,x86_64
int accept4(int, struct sockaddr*, socklen_t*, int) arm,arm64,mips,mips64,x86_64
int getsockname(int, struct sockaddr*, socklen_t*) arm,arm64,mips,mips64,x86_64
int getpeername(int, struct sockaddr*, socklen_t*) arm,arm64,mips,mips64,x86_64
@@ -255,7 +255,7 @@
int bind:socketcall:2(int, struct sockaddr*, int) x86
int __connect:socketcall:3(int, struct sockaddr*, socklen_t) x86
int listen:socketcall:4(int, int) x86
-int accept:socketcall:5(int, struct sockaddr*, socklen_t*) x86
+int __accept:socketcall:5(int, struct sockaddr*, socklen_t*) x86
int getsockname:socketcall:6(int, struct sockaddr*, socklen_t*) x86
int getpeername:socketcall:7(int, struct sockaddr*, socklen_t*) x86
int socketpair:socketcall:8(int, int, int, int*) x86
diff --git a/libc/arch-arm/syscalls/accept.S b/libc/arch-arm/syscalls/__accept.S
similarity index 89%
rename from libc/arch-arm/syscalls/accept.S
rename to libc/arch-arm/syscalls/__accept.S
index e2a51f5..bae11bc 100644
--- a/libc/arch-arm/syscalls/accept.S
+++ b/libc/arch-arm/syscalls/__accept.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(accept)
+ENTRY(__accept)
mov ip, r7
ldr r7, =__NR_accept
swi #0
@@ -11,4 +11,4 @@
bxls lr
neg r0, r0
b __set_errno
-END(accept)
+END(__accept)
diff --git a/libc/arch-arm64/syscalls/accept.S b/libc/arch-arm64/syscalls/__accept.S
similarity index 88%
rename from libc/arch-arm64/syscalls/accept.S
rename to libc/arch-arm64/syscalls/__accept.S
index dae6121..21b68bc 100644
--- a/libc/arch-arm64/syscalls/accept.S
+++ b/libc/arch-arm64/syscalls/__accept.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(accept)
+ENTRY(__accept)
stp x29, x30, [sp, #-16]!
mov x29, sp
str x8, [sp, #-16]!
@@ -18,4 +18,5 @@
b.hi __set_errno
ret
-END(accept)
+END(__accept)
+.hidden __accept
diff --git a/libc/arch-mips/syscalls/accept.S b/libc/arch-mips/syscalls/__accept.S
similarity index 89%
rename from libc/arch-mips/syscalls/accept.S
rename to libc/arch-mips/syscalls/__accept.S
index 09496ab..d8141fe 100644
--- a/libc/arch-mips/syscalls/accept.S
+++ b/libc/arch-mips/syscalls/__accept.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(accept)
+ENTRY(__accept)
.set noreorder
.cpload t9
li v0, __NR_accept
@@ -16,4 +16,4 @@
j t9
nop
.set reorder
-END(accept)
+END(__accept)
diff --git a/libc/arch-mips64/syscalls/accept.S b/libc/arch-mips64/syscalls/__accept.S
similarity index 87%
rename from libc/arch-mips64/syscalls/accept.S
rename to libc/arch-mips64/syscalls/__accept.S
index 6c38556..4404a68 100644
--- a/libc/arch-mips64/syscalls/accept.S
+++ b/libc/arch-mips64/syscalls/__accept.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(accept)
+ENTRY(__accept)
.set push
.set noreorder
li v0, __NR_accept
@@ -22,4 +22,5 @@
j t9
move ra, t0
.set pop
-END(accept)
+END(__accept)
+.hidden __accept
diff --git a/libc/arch-x86/syscalls/accept.S b/libc/arch-x86/syscalls/__accept.S
similarity index 94%
rename from libc/arch-x86/syscalls/accept.S
rename to libc/arch-x86/syscalls/__accept.S
index f7e8a58..31cb350 100644
--- a/libc/arch-x86/syscalls/accept.S
+++ b/libc/arch-x86/syscalls/__accept.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(accept)
+ENTRY(__accept)
pushl %ebx
pushl %ecx
.cfi_def_cfa_offset 8
@@ -24,4 +24,4 @@
popl %ecx
popl %ebx
ret
-END(accept)
+END(__accept)
diff --git a/libc/arch-x86_64/syscalls/accept.S b/libc/arch-x86_64/syscalls/__accept.S
similarity index 85%
rename from libc/arch-x86_64/syscalls/accept.S
rename to libc/arch-x86_64/syscalls/__accept.S
index 588fb82..ff0f5e7 100644
--- a/libc/arch-x86_64/syscalls/accept.S
+++ b/libc/arch-x86_64/syscalls/__accept.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(accept)
+ENTRY(__accept)
movl $__NR_accept, %eax
syscall
cmpq $-MAX_ERRNO, %rax
@@ -13,4 +13,5 @@
orq $-1, %rax
1:
ret
-END(accept)
+END(__accept)
+.hidden __accept
diff --git a/libc/bionic/NetdClient.cpp b/libc/bionic/NetdClient.cpp
index 6826ee8..72d90b7 100644
--- a/libc/bionic/NetdClient.cpp
+++ b/libc/bionic/NetdClient.cpp
@@ -40,6 +40,7 @@
// default implementations of functions that it would've overridden.
return;
}
+ netdClientInitFunction(netdClientHandle, "netdClientInitAccept", &__netdClientDispatch.accept);
netdClientInitFunction(netdClientHandle, "netdClientInitConnect",
&__netdClientDispatch.connect);
}
diff --git a/libc/bionic/NetdClientDispatch.cpp b/libc/bionic/NetdClientDispatch.cpp
index 31728d2..adfe16d 100644
--- a/libc/bionic/NetdClientDispatch.cpp
+++ b/libc/bionic/NetdClientDispatch.cpp
@@ -22,8 +22,10 @@
#define __socketcall
#endif
+extern "C" __socketcall int __accept(int, sockaddr*, socklen_t*);
extern "C" __socketcall int __connect(int, const sockaddr*, socklen_t);
NetdClientDispatch __netdClientDispatch __attribute__((aligned(32))) = {
- __connect
+ __accept,
+ __connect,
};
diff --git a/libc/bionic/accept.cpp b/libc/bionic/accept.cpp
new file mode 100644
index 0000000..46b4efc
--- /dev/null
+++ b/libc/bionic/accept.cpp
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <private/NetdClient.h>
+#include <sys/socket.h>
+
+int accept(int sockfd, sockaddr* addr, socklen_t* addrlen) {
+ return __netdClientDispatch.accept(sockfd, addr, addrlen);
+}
diff --git a/libc/private/NetdClient.h b/libc/private/NetdClient.h
index 48c05cb..b2ce7a6 100644
--- a/libc/private/NetdClient.h
+++ b/libc/private/NetdClient.h
@@ -20,6 +20,7 @@
#include <sys/socket.h>
struct NetdClientDispatch {
+ int (*accept)(int, sockaddr*, socklen_t*);
int (*connect)(int, const sockaddr*, socklen_t);
};