#include <cutils/sched_policy.h>
#include <cutils/multiuser.h>
#include <sched.h>
+#include <sys/utsname.h>
#if defined(HAVE_PRCTL)
# include <sys/prctl.h>
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) {
}
#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.
*/
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);