From: Jeff Sharkey Date: Mon, 1 Oct 2012 20:46:22 +0000 (-0700) Subject: am d99c1f6b: am 42e89067: am 2e3748ed: Final shuffle to make /sdcard work in shell. X-Git-Tag: android-x86-4.4-r1~247 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=dda63b6c937703cfb13c2e76a86758fbeb4e662a;hp=-c;p=android-x86%2Fdalvik.git am d99c1f6b: am 42e89067: am 2e3748ed: Final shuffle to make /sdcard work in shell. * commit 'd99c1f6b7eccdc30e316065eda1bf9f40508e0c8': Final shuffle to make /sdcard work in shell. --- dda63b6c937703cfb13c2e76a86758fbeb4e662a diff --combined vm/native/dalvik_system_Zygote.cpp index 6c6f04035,269b961d0..0d2252087 --- a/vm/native/dalvik_system_Zygote.cpp +++ b/vm/native/dalvik_system_Zygote.cpp @@@ -38,7 -38,6 +38,7 @@@ #include #include #include +#include #if defined(HAVE_PRCTL) # include @@@ -313,7 -312,8 +313,8 @@@ static int mountEmulatedStorage(uid_t u snprintf(target_obb, PATH_MAX, "%s/%d/Android/obb", target, userid); if (fs_prepare_dir(target_android, 0000, 0, 0) == -1 - || fs_prepare_dir(target_obb, 0000, 0, 0) == -1) { + || fs_prepare_dir(target_obb, 0000, 0, 0) == -1 + || fs_prepare_dir(legacy, 0000, 0, 0) == -1) { return -1; } if (mount(source_obb, target_obb, NULL, MS_BIND, NULL) == -1) { @@@ -484,22 -484,6 +485,22 @@@ static int setSELinuxContext(uid_t uid } #endif +static bool needsNoRandomizeWorkaround() { + int major; + int minor; + struct utsname uts; + if (uname(&uts) == -1) { + return false; + } + + if (sscanf(uts.release, "%d.%d", &major, &minor) != 2) { + return false; + } + + // Kernels before 3.4.* need the workaround. + return (major < 3) || ((major == 3) && (minor < 4)); +} + /* * Utility routine to fork zygote and specialize the child process. */ @@@ -630,12 -614,10 +631,12 @@@ static pid_t forkAndSpecializeCommon(co dvmAbort(); } - int current = personality(0xffffFFFF); - int success = personality((ADDR_NO_RANDOMIZE | current)); - if (success == -1) { - ALOGW("Personality switch failed. current=%d error=%d\n", current, errno); + if (needsNoRandomizeWorkaround()) { + int current = personality(0xffffFFFF); + int success = personality((ADDR_NO_RANDOMIZE | current)); + if (success == -1) { + ALOGW("Personality switch failed. current=%d error=%d\n", current, errno); + } } err = setCapabilities(permittedCapabilities, effectiveCapabilities);