Clean up the cpuacct cruft.
Change-Id: I6ed63af8dfc2368e211420389fa8af4d5dc0908f
diff --git a/libc/Android.mk b/libc/Android.mk
index 20f190a..6742340 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -80,14 +80,12 @@
bionic/bindresvport.c \
bionic/bionic_clone.c \
bionic/clearenv.c \
- bionic/cpuacct.c \
bionic/daemon.c \
bionic/err.c \
bionic/ether_aton.c \
bionic/ether_ntoa.c \
bionic/fdprintf.c \
bionic/flockfile.c \
- bionic/fork.c \
bionic/ftime.c \
bionic/ftok.c \
bionic/fts.c \
@@ -123,12 +121,7 @@
bionic/sched_getcpu.c \
bionic/semaphore.c \
bionic/send.c \
- bionic/setegid.c \
- bionic/seteuid.c \
bionic/setpgrp.c \
- bionic/setresuid.c \
- bionic/setreuid.c \
- bionic/setuid.c \
bionic/sigblock.c \
bionic/siginterrupt.c \
bionic/siglist.c \
@@ -225,6 +218,7 @@
bionic/__errno.cpp \
bionic/eventfd_read.cpp \
bionic/eventfd_write.cpp \
+ bionic/fork.cpp \
bionic/futimens.cpp \
bionic/getauxval.cpp \
bionic/getcwd.cpp \
@@ -247,7 +241,9 @@
bionic/sbrk.cpp \
bionic/scandir.cpp \
bionic/sched_getaffinity.cpp \
+ bionic/setegid.cpp \
bionic/__set_errno.cpp \
+ bionic/seteuid.cpp \
bionic/setlocale.cpp \
bionic/signalfd.cpp \
bionic/sigwait.cpp \
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index f926ad0..0902357 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -41,8 +41,6 @@
int execve(const char*, char* const*, char* const*) all
-int __setuid:setuid32(uid_t) arm,x86
-int __setuid:setuid(uid_t) mips,x86_64
uid_t getuid:getuid32() arm,x86
uid_t getuid:getuid() mips,x86_64
gid_t getgid:getgid32() arm,x86
@@ -65,11 +63,13 @@
pid_t setsid() all
int setgid:setgid32(gid_t) arm,x86
int setgid:setgid(gid_t) mips,x86_64
+int setuid:setuid32(uid_t) arm,x86
+int setuid:setuid(uid_t) mips,x86_64
int seteuid:seteuid32(uid_t) custom
-int __setreuid:setreuid32(uid_t, uid_t) arm,x86
-int __setreuid:setreuid(uid_t, uid_t) mips,x86_64
-int __setresuid:setresuid32(uid_t, uid_t, uid_t) arm,x86
-int __setresuid:setresuid(uid_t, uid_t, uid_t) mips,x86_64
+int setreuid:setreuid32(uid_t, uid_t) arm,x86
+int setreuid:setreuid(uid_t, uid_t) mips,x86_64
+int setresuid:setresuid32(uid_t, uid_t, uid_t) arm,x86
+int setresuid:setresuid(uid_t, uid_t, uid_t) mips,x86_64
int setresgid:setresgid32(gid_t, gid_t, gid_t) arm,x86
int setresgid:setresgid(gid_t, gid_t, gid_t) mips,x86_64
void* __brk:brk(void*) all
diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk
index e1d02b3..d28c975 100644
--- a/libc/arch-arm/syscalls.mk
+++ b/libc/arch-arm/syscalls.mk
@@ -7,7 +7,6 @@
syscall_src += arch-arm/syscalls/wait4.S
syscall_src += arch-arm/syscalls/__sys_clone.S
syscall_src += arch-arm/syscalls/execve.S
-syscall_src += arch-arm/syscalls/__setuid.S
syscall_src += arch-arm/syscalls/getuid.S
syscall_src += arch-arm/syscalls/getgid.S
syscall_src += arch-arm/syscalls/geteuid.S
@@ -22,8 +21,9 @@
syscall_src += arch-arm/syscalls/getsid.S
syscall_src += arch-arm/syscalls/setsid.S
syscall_src += arch-arm/syscalls/setgid.S
-syscall_src += arch-arm/syscalls/__setreuid.S
-syscall_src += arch-arm/syscalls/__setresuid.S
+syscall_src += arch-arm/syscalls/setuid.S
+syscall_src += arch-arm/syscalls/setreuid.S
+syscall_src += arch-arm/syscalls/setresuid.S
syscall_src += arch-arm/syscalls/setresgid.S
syscall_src += arch-arm/syscalls/__brk.S
syscall_src += arch-arm/syscalls/__ptrace.S
diff --git a/libc/arch-arm/syscalls/__setresuid.S b/libc/arch-arm/syscalls/setresuid.S
similarity index 88%
rename from libc/arch-arm/syscalls/__setresuid.S
rename to libc/arch-arm/syscalls/setresuid.S
index 0fd8ae6..6d640f7 100644
--- a/libc/arch-arm/syscalls/__setresuid.S
+++ b/libc/arch-arm/syscalls/setresuid.S
@@ -3,7 +3,7 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(__setresuid)
+ENTRY(setresuid)
mov ip, r7
ldr r7, =__NR_setresuid32
swi #0
@@ -12,4 +12,4 @@
bxls lr
neg r0, r0
b __set_errno
-END(__setresuid)
+END(setresuid)
diff --git a/libc/arch-arm/syscalls/__setreuid.S b/libc/arch-arm/syscalls/setreuid.S
similarity index 89%
rename from libc/arch-arm/syscalls/__setreuid.S
rename to libc/arch-arm/syscalls/setreuid.S
index bc2fe84..fa4a5dd 100644
--- a/libc/arch-arm/syscalls/__setreuid.S
+++ b/libc/arch-arm/syscalls/setreuid.S
@@ -3,7 +3,7 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(__setreuid)
+ENTRY(setreuid)
mov ip, r7
ldr r7, =__NR_setreuid32
swi #0
@@ -12,4 +12,4 @@
bxls lr
neg r0, r0
b __set_errno
-END(__setreuid)
+END(setreuid)
diff --git a/libc/arch-arm/syscalls/__setuid.S b/libc/arch-arm/syscalls/setuid.S
similarity index 90%
rename from libc/arch-arm/syscalls/__setuid.S
rename to libc/arch-arm/syscalls/setuid.S
index f7b94da..2efe5f2 100644
--- a/libc/arch-arm/syscalls/__setuid.S
+++ b/libc/arch-arm/syscalls/setuid.S
@@ -3,7 +3,7 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(__setuid)
+ENTRY(setuid)
mov ip, r7
ldr r7, =__NR_setuid32
swi #0
@@ -12,4 +12,4 @@
bxls lr
neg r0, r0
b __set_errno
-END(__setuid)
+END(setuid)
diff --git a/libc/arch-mips/syscalls.mk b/libc/arch-mips/syscalls.mk
index 9a1038c..4611cd8 100644
--- a/libc/arch-mips/syscalls.mk
+++ b/libc/arch-mips/syscalls.mk
@@ -8,7 +8,6 @@
syscall_src += arch-mips/syscalls/wait4.S
syscall_src += arch-mips/syscalls/__sys_clone.S
syscall_src += arch-mips/syscalls/execve.S
-syscall_src += arch-mips/syscalls/__setuid.S
syscall_src += arch-mips/syscalls/getuid.S
syscall_src += arch-mips/syscalls/getgid.S
syscall_src += arch-mips/syscalls/geteuid.S
@@ -23,8 +22,9 @@
syscall_src += arch-mips/syscalls/getsid.S
syscall_src += arch-mips/syscalls/setsid.S
syscall_src += arch-mips/syscalls/setgid.S
-syscall_src += arch-mips/syscalls/__setreuid.S
-syscall_src += arch-mips/syscalls/__setresuid.S
+syscall_src += arch-mips/syscalls/setuid.S
+syscall_src += arch-mips/syscalls/setreuid.S
+syscall_src += arch-mips/syscalls/setresuid.S
syscall_src += arch-mips/syscalls/setresgid.S
syscall_src += arch-mips/syscalls/__brk.S
syscall_src += arch-mips/syscalls/kill.S
diff --git a/libc/arch-mips/syscalls/__setresuid.S b/libc/arch-mips/syscalls/setresuid.S
similarity index 77%
rename from libc/arch-mips/syscalls/__setresuid.S
rename to libc/arch-mips/syscalls/setresuid.S
index e43e121..a077867 100644
--- a/libc/arch-mips/syscalls/__setresuid.S
+++ b/libc/arch-mips/syscalls/setresuid.S
@@ -1,11 +1,11 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
.text
- .globl __setresuid
+ .globl setresuid
.align 4
- .ent __setresuid
+ .ent setresuid
-__setresuid:
+setresuid:
.set noreorder
.cpload $t9
li $v0, __NR_setresuid
@@ -19,4 +19,4 @@
j $t9
nop
.set reorder
- .end __setresuid
+ .end setresuid
diff --git a/libc/arch-mips/syscalls/__setreuid.S b/libc/arch-mips/syscalls/setreuid.S
similarity index 78%
rename from libc/arch-mips/syscalls/__setreuid.S
rename to libc/arch-mips/syscalls/setreuid.S
index 72bca16..934c8db 100644
--- a/libc/arch-mips/syscalls/__setreuid.S
+++ b/libc/arch-mips/syscalls/setreuid.S
@@ -1,11 +1,11 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
.text
- .globl __setreuid
+ .globl setreuid
.align 4
- .ent __setreuid
+ .ent setreuid
-__setreuid:
+setreuid:
.set noreorder
.cpload $t9
li $v0, __NR_setreuid
@@ -19,4 +19,4 @@
j $t9
nop
.set reorder
- .end __setreuid
+ .end setreuid
diff --git a/libc/arch-mips/syscalls/__setuid.S b/libc/arch-mips/syscalls/setuid.S
similarity index 80%
rename from libc/arch-mips/syscalls/__setuid.S
rename to libc/arch-mips/syscalls/setuid.S
index 360552c..fedfb1e 100644
--- a/libc/arch-mips/syscalls/__setuid.S
+++ b/libc/arch-mips/syscalls/setuid.S
@@ -1,11 +1,11 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
.text
- .globl __setuid
+ .globl setuid
.align 4
- .ent __setuid
+ .ent setuid
-__setuid:
+setuid:
.set noreorder
.cpload $t9
li $v0, __NR_setuid
@@ -19,4 +19,4 @@
j $t9
nop
.set reorder
- .end __setuid
+ .end setuid
diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk
index 424bd1e..79b4f2c 100644
--- a/libc/arch-x86/syscalls.mk
+++ b/libc/arch-x86/syscalls.mk
@@ -8,7 +8,6 @@
syscall_src += arch-x86/syscalls/wait4.S
syscall_src += arch-x86/syscalls/__sys_clone.S
syscall_src += arch-x86/syscalls/execve.S
-syscall_src += arch-x86/syscalls/__setuid.S
syscall_src += arch-x86/syscalls/getuid.S
syscall_src += arch-x86/syscalls/getgid.S
syscall_src += arch-x86/syscalls/geteuid.S
@@ -23,8 +22,9 @@
syscall_src += arch-x86/syscalls/getsid.S
syscall_src += arch-x86/syscalls/setsid.S
syscall_src += arch-x86/syscalls/setgid.S
-syscall_src += arch-x86/syscalls/__setreuid.S
-syscall_src += arch-x86/syscalls/__setresuid.S
+syscall_src += arch-x86/syscalls/setuid.S
+syscall_src += arch-x86/syscalls/setreuid.S
+syscall_src += arch-x86/syscalls/setresuid.S
syscall_src += arch-x86/syscalls/setresgid.S
syscall_src += arch-x86/syscalls/__brk.S
syscall_src += arch-x86/syscalls/kill.S
diff --git a/libc/arch-x86/syscalls/__setresuid.S b/libc/arch-x86/syscalls/setresuid.S
similarity index 93%
rename from libc/arch-x86/syscalls/__setresuid.S
rename to libc/arch-x86/syscalls/setresuid.S
index 537c897..891d004 100644
--- a/libc/arch-x86/syscalls/__setresuid.S
+++ b/libc/arch-x86/syscalls/setresuid.S
@@ -3,7 +3,7 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(__setresuid)
+ENTRY(setresuid)
pushl %ebx
pushl %ecx
pushl %edx
@@ -24,4 +24,4 @@
popl %ecx
popl %ebx
ret
-END(__setresuid)
+END(setresuid)
diff --git a/libc/arch-x86/syscalls/__setreuid.S b/libc/arch-x86/syscalls/setreuid.S
similarity index 92%
rename from libc/arch-x86/syscalls/__setreuid.S
rename to libc/arch-x86/syscalls/setreuid.S
index bc6cd25..fda43a8 100644
--- a/libc/arch-x86/syscalls/__setreuid.S
+++ b/libc/arch-x86/syscalls/setreuid.S
@@ -3,7 +3,7 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(__setreuid)
+ENTRY(setreuid)
pushl %ebx
pushl %ecx
mov 12(%esp), %ebx
@@ -21,4 +21,4 @@
popl %ecx
popl %ebx
ret
-END(__setreuid)
+END(setreuid)
diff --git a/libc/arch-x86/syscalls/__setuid.S b/libc/arch-x86/syscalls/setuid.S
similarity index 92%
rename from libc/arch-x86/syscalls/__setuid.S
rename to libc/arch-x86/syscalls/setuid.S
index 5a5ff6d..ef158ca 100644
--- a/libc/arch-x86/syscalls/__setuid.S
+++ b/libc/arch-x86/syscalls/setuid.S
@@ -3,7 +3,7 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(__setuid)
+ENTRY(setuid)
pushl %ebx
mov 8(%esp), %ebx
movl $__NR_setuid32, %eax
@@ -18,4 +18,4 @@
1:
popl %ebx
ret
-END(__setuid)
+END(setuid)
diff --git a/libc/arch-x86_64/syscalls.mk b/libc/arch-x86_64/syscalls.mk
index 08fdf38..51c3646 100644
--- a/libc/arch-x86_64/syscalls.mk
+++ b/libc/arch-x86_64/syscalls.mk
@@ -7,7 +7,6 @@
syscall_src += arch-x86_64/syscalls/wait4.S
syscall_src += arch-x86_64/syscalls/__sys_clone.S
syscall_src += arch-x86_64/syscalls/execve.S
-syscall_src += arch-x86_64/syscalls/__setuid.S
syscall_src += arch-x86_64/syscalls/getuid.S
syscall_src += arch-x86_64/syscalls/getgid.S
syscall_src += arch-x86_64/syscalls/geteuid.S
@@ -22,8 +21,9 @@
syscall_src += arch-x86_64/syscalls/getsid.S
syscall_src += arch-x86_64/syscalls/setsid.S
syscall_src += arch-x86_64/syscalls/setgid.S
-syscall_src += arch-x86_64/syscalls/__setreuid.S
-syscall_src += arch-x86_64/syscalls/__setresuid.S
+syscall_src += arch-x86_64/syscalls/setuid.S
+syscall_src += arch-x86_64/syscalls/setreuid.S
+syscall_src += arch-x86_64/syscalls/setresuid.S
syscall_src += arch-x86_64/syscalls/setresgid.S
syscall_src += arch-x86_64/syscalls/__brk.S
syscall_src += arch-x86_64/syscalls/kill.S
diff --git a/libc/arch-x86_64/syscalls/__setresuid.S b/libc/arch-x86_64/syscalls/setresuid.S
similarity index 89%
rename from libc/arch-x86_64/syscalls/__setresuid.S
rename to libc/arch-x86_64/syscalls/setresuid.S
index e4ca4b8..fe1f41c 100644
--- a/libc/arch-x86_64/syscalls/__setresuid.S
+++ b/libc/arch-x86_64/syscalls/setresuid.S
@@ -3,7 +3,7 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(__setresuid)
+ENTRY(setresuid)
movl $__NR_setresuid, %eax
syscall
cmpq $-MAX_ERRNO, %rax
@@ -14,4 +14,4 @@
orq $-1, %rax
1:
ret
-END(__setresuid)
+END(setresuid)
diff --git a/libc/arch-x86_64/syscalls/__setreuid.S b/libc/arch-x86_64/syscalls/setreuid.S
similarity index 89%
rename from libc/arch-x86_64/syscalls/__setreuid.S
rename to libc/arch-x86_64/syscalls/setreuid.S
index 89d2aad..e064b55 100644
--- a/libc/arch-x86_64/syscalls/__setreuid.S
+++ b/libc/arch-x86_64/syscalls/setreuid.S
@@ -3,7 +3,7 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(__setreuid)
+ENTRY(setreuid)
movl $__NR_setreuid, %eax
syscall
cmpq $-MAX_ERRNO, %rax
@@ -14,4 +14,4 @@
orq $-1, %rax
1:
ret
-END(__setreuid)
+END(setreuid)
diff --git a/libc/arch-x86_64/syscalls/__setuid.S b/libc/arch-x86_64/syscalls/setuid.S
similarity index 90%
rename from libc/arch-x86_64/syscalls/__setuid.S
rename to libc/arch-x86_64/syscalls/setuid.S
index 20b5089..c443c79 100644
--- a/libc/arch-x86_64/syscalls/__setuid.S
+++ b/libc/arch-x86_64/syscalls/setuid.S
@@ -3,7 +3,7 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(__setuid)
+ENTRY(setuid)
movl $__NR_setuid, %eax
syscall
cmpq $-MAX_ERRNO, %rax
@@ -14,4 +14,4 @@
orq $-1, %rax
1:
ret
-END(__setuid)
+END(setuid)
diff --git a/libc/bionic/cpuacct.c b/libc/bionic/cpuacct.c
deleted file mode 100644
index 1321d0e..0000000
--- a/libc/bionic/cpuacct.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include "cpuacct.h"
-#include <fcntl.h>
-
-int cpuacct_add(uid_t uid)
-{
- int count;
- int fd;
- char buf[80];
- ssize_t n;
- int ret = 0;
-
- count = snprintf(buf, sizeof(buf), "/acct/uid/%d/tasks", uid);
- fd = open(buf, O_RDWR | O_CREAT, 0666);
- if (fd == -1) {
- /* Note: sizeof("tasks") returns 6, which includes the NULL char */
- buf[count - sizeof("tasks")] = 0;
- if (mkdir(buf, 0775) < 0)
- return -errno;
-
- /* Note: sizeof("tasks") returns 6, which includes the NULL char */
- buf[count - sizeof("tasks")] = '/';
- fd = open(buf, O_RDWR | O_CREAT, 0666);
- }
- if (fd == -1)
- return -errno;
-
- n = TEMP_FAILURE_RETRY(write(fd, "0", 1));
- if (n < 0)
- ret = -errno;
- else if (n == 0)
- ret = -EIO;
-
- if (TEMP_FAILURE_RETRY(close(fd)) == -1)
- return -errno;
-
- return ret;
-}
diff --git a/libc/bionic/cpuacct.h b/libc/bionic/cpuacct.h
deleted file mode 100644
index 8e24c8c..0000000
--- a/libc/bionic/cpuacct.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _BIONIC_CPUACCT_H
-#define _BIONIC_CPUACCT_H
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-__BEGIN_DECLS
-
-extern int cpuacct_add(uid_t uid);
-
-__END_DECLS
-
-#endif /* _BIONIC_CPUACCT_H */
diff --git a/libc/bionic/fork.c b/libc/bionic/fork.c
deleted file mode 100644
index d30b41b..0000000
--- a/libc/bionic/fork.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <unistd.h>
-#include "pthread_internal.h"
-#include "cpuacct.h"
-
-#include "private/bionic_pthread.h"
-
-extern int __fork(void);
-
-int fork(void)
-{
- int ret;
-
- /* Posix mandates that the timers of a fork child process be
- * disarmed, but not destroyed. To avoid a race condition, we're
- * going to stop all timers now, and only re-start them in case
- * of error, or in the parent process
- */
- __timer_table_start_stop(1);
- __bionic_atfork_run_prepare();
-
- ret = __fork();
- if (ret != 0) { /* not a child process */
- __timer_table_start_stop(0);
- __bionic_atfork_run_parent();
- } else {
- // Fix the tid in the pthread_internal_t struct after a fork.
- __pthread_settid(pthread_self(), gettid());
-
- /*
- * Newly created process must update cpu accounting.
- * Call cpuacct_add passing in our uid, which will take
- * the current task id and add it to the uid group passed
- * as a parameter.
- */
- cpuacct_add(getuid());
- __bionic_atfork_run_child();
- }
- return ret;
-}
diff --git a/libc/bionic/setegid.c b/libc/bionic/fork.cpp
similarity index 66%
copy from libc/bionic/setegid.c
copy to libc/bionic/fork.cpp
index 9bd697b..a3bea20 100644
--- a/libc/bionic/setegid.c
+++ b/libc/bionic/fork.cpp
@@ -25,9 +25,30 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
-int setegid(gid_t egid)
-{
- return setresgid(-1, egid, -1);
+#include <unistd.h>
+#include "pthread_internal.h"
+
+#include "private/bionic_pthread.h"
+
+extern "C" int __fork();
+
+int fork() {
+ // POSIX mandates that the timers of a fork child process be
+ // disarmed, but not destroyed. To avoid a race condition, we're
+ // going to stop all timers now, and only re-start them in case
+ // of error, or in the parent process
+ __timer_table_start_stop(1);
+ __bionic_atfork_run_prepare();
+
+ int result = __fork();
+ if (result != 0) { // Not a child process.
+ __timer_table_start_stop(0);
+ __bionic_atfork_run_parent();
+ } else {
+ // Fix the tid in the pthread_internal_t struct after a fork.
+ __pthread_settid(pthread_self(), gettid());
+ __bionic_atfork_run_child();
+ }
+ return result;
}
diff --git a/libc/bionic/setegid.c b/libc/bionic/setegid.cpp
similarity index 95%
rename from libc/bionic/setegid.c
rename to libc/bionic/setegid.cpp
index 9bd697b..2030ee7 100644
--- a/libc/bionic/setegid.c
+++ b/libc/bionic/setegid.cpp
@@ -25,9 +25,9 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
#include <unistd.h>
-int setegid(gid_t egid)
-{
- return setresgid(-1, egid, -1);
+int setegid(gid_t egid) {
+ return setresgid(-1, egid, -1);
}
diff --git a/libc/bionic/seteuid.c b/libc/bionic/seteuid.c
deleted file mode 100644
index b3ea372..0000000
--- a/libc/bionic/seteuid.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <unistd.h>
-#include "cpuacct.h"
-
-extern int __setresuid(uid_t, uid_t, uid_t);
-
-int seteuid(uid_t euid)
-{
- cpuacct_add(euid);
- return __setresuid(-1, euid,-1);
-}
diff --git a/libc/bionic/setegid.c b/libc/bionic/seteuid.cpp
similarity index 95%
copy from libc/bionic/setegid.c
copy to libc/bionic/seteuid.cpp
index 9bd697b..6d2c89c 100644
--- a/libc/bionic/setegid.c
+++ b/libc/bionic/seteuid.cpp
@@ -25,9 +25,9 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
#include <unistd.h>
-int setegid(gid_t egid)
-{
- return setresgid(-1, egid, -1);
+int seteuid(uid_t euid) {
+ return setresuid(-1, euid,-1);
}
diff --git a/libc/bionic/setresuid.c b/libc/bionic/setresuid.c
deleted file mode 100644
index e62b3e9..0000000
--- a/libc/bionic/setresuid.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <unistd.h>
-#include "cpuacct.h"
-
-extern int __setresuid(uid_t ruid, uid_t euid, uid_t suid);
-
-int setresuid(uid_t ruid, uid_t euid, uid_t suid)
-{
- cpuacct_add(euid);
- return __setresuid(ruid, euid, suid);
-
-}
diff --git a/libc/bionic/setreuid.c b/libc/bionic/setreuid.c
deleted file mode 100644
index 32e70c8..0000000
--- a/libc/bionic/setreuid.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <unistd.h>
-#include "cpuacct.h"
-
-extern int __setreuid(uid_t ruid, uid_t euid);
-
-int setreuid(uid_t ruid, uid_t euid)
-{
- cpuacct_add(euid);
- return __setreuid(ruid, euid);
-}
diff --git a/libc/bionic/setuid.c b/libc/bionic/setuid.c
deleted file mode 100644
index 30785d6..0000000
--- a/libc/bionic/setuid.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <unistd.h>
-#include "cpuacct.h"
-
-extern int __setuid(uid_t);
-
-int setuid(uid_t uid)
-{
- cpuacct_add(uid);
- return __setuid(uid);
-}