diff options
Diffstat (limited to 'vm/native/dalvik_system_Zygote.cpp')
-rw-r--r-- | vm/native/dalvik_system_Zygote.cpp | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/vm/native/dalvik_system_Zygote.cpp b/vm/native/dalvik_system_Zygote.cpp index e2b618bab..e2d01022c 100644 --- a/vm/native/dalvik_system_Zygote.cpp +++ b/vm/native/dalvik_system_Zygote.cpp @@ -18,6 +18,7 @@ * dalvik.system.Zygote */ #include "Dalvik.h" +#include "Thread.h" #include "native/InternalNativePriv.h" #include <selinux/android.h> @@ -38,6 +39,7 @@ #include <sched.h> #include <sys/utsname.h> #include <sys/capability.h> +#include <sys/resource.h> #if defined(HAVE_PRCTL) # include <sys/prctl.h> @@ -285,13 +287,15 @@ static int mountEmulatedStorage(uid_t uid, u4 mountMode) { if (mountMode == MOUNT_EXTERNAL_MULTIUSER_ALL) { // Mount entire external storage tree for all users - if (mount(source, target, NULL, MS_BIND, NULL) == -1) { + if (TEMP_FAILURE_RETRY( + mount(source, target, NULL, MS_BIND, NULL)) == -1) { ALOGE("Failed to mount %s to %s: %s", source, target, strerror(errno)); return -1; } } else { // Only mount user-specific external storage - if (mount(source_user, target_user, NULL, MS_BIND, NULL) == -1) { + if (TEMP_FAILURE_RETRY( + mount(source_user, target_user, NULL, MS_BIND, NULL)) == -1) { ALOGE("Failed to mount %s to %s: %s", source_user, target_user, strerror(errno)); return -1; } @@ -302,7 +306,8 @@ static int mountEmulatedStorage(uid_t uid, u4 mountMode) { } // Finally, mount user-specific path into place for legacy users - if (mount(target_user, legacy, NULL, MS_BIND | MS_REC, NULL) == -1) { + if (TEMP_FAILURE_RETRY( + mount(target_user, legacy, NULL, MS_BIND | MS_REC, NULL)) == -1) { ALOGE("Failed to mount %s to %s: %s", target_user, legacy, strerror(errno)); return -1; } @@ -427,21 +432,22 @@ static void enableDebugFeatures(u4 debugFlags) static int setCapabilities(int64_t permitted, int64_t effective) { #ifdef HAVE_ANDROID_OS - struct __user_cap_header_struct capheader; - struct __user_cap_data_struct capdata; - + __user_cap_header_struct capheader; memset(&capheader, 0, sizeof(capheader)); - memset(&capdata, 0, sizeof(capdata)); - - capheader.version = _LINUX_CAPABILITY_VERSION; + capheader.version = _LINUX_CAPABILITY_VERSION_3; capheader.pid = 0; - capdata.effective = effective; - capdata.permitted = permitted; + __user_cap_data_struct capdata[2]; + memset(&capdata, 0, sizeof(capdata)); + capdata[0].effective = effective; + capdata[1].effective = effective >> 32; + capdata[0].permitted = permitted; + capdata[1].permitted = permitted >> 32; - ALOGV("CAPSET perm=%llx eff=%llx", permitted, effective); - if (capset(&capheader, &capdata) != 0) + if (capset(&capheader, &capdata[0]) == -1) { + ALOGE("capset(perm=%llx, eff=%llx) failed: %s", permitted, effective, strerror(errno)); return errno; + } #endif /*HAVE_ANDROID_OS*/ return 0; @@ -649,6 +655,13 @@ static pid_t forkAndSpecializeCommon(const u4* args, bool isSystemServer) ALOGE("cannot set SELinux context: %s\n", strerror(errno)); dvmAbort(); } + + // Set the comm to a nicer name. + if (isSystemServer && niceName == NULL) { + dvmSetThreadName("system_server"); + } else { + dvmSetThreadName(niceName); + } // These free(3) calls are safe because we know we're only ever forking // a single-threaded process, so we know no other thread held the heap // lock when we forked. |