OSDN Git Service

am d99c1f6b: am 42e89067: am 2e3748ed: Final shuffle to make /sdcard work in shell.
authorJeff Sharkey <jsharkey@android.com>
Mon, 1 Oct 2012 20:46:22 +0000 (13:46 -0700)
committerAndroid Git Automerger <android-git-automerger@android.com>
Mon, 1 Oct 2012 20:46:22 +0000 (13:46 -0700)
* commit 'd99c1f6b7eccdc30e316065eda1bf9f40508e0c8':
  Final shuffle to make /sdcard work in shell.

1  2 
vm/native/dalvik_system_Zygote.cpp

@@@ -38,7 -38,6 +38,7 @@@
  #include <cutils/sched_policy.h>
  #include <cutils/multiuser.h>
  #include <sched.h>
 +#include <sys/utsname.h>
  
  #if defined(HAVE_PRCTL)
  # include <sys/prctl.h>
@@@ -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);