Failed to mount emulated storage机器没法启动问题查找

错误日志:


E/cutils  ( 1180): Not a directory: /storage/sdcard0



W/Zygote  ( 1180): Failed to mount emulated storage: 22


E/Zygote  ( 1180): Cannot continue without emulated storage


F/art     ( 1180): art/runtime/jni_internal.cc:776] JNI FatalError called: RuntimeAbort


F/libc    ( 1180): Fatal signal 6 (SIGABRT), code -6 in tid 1180 (main)


日志输出代码:

frameworks//base/core/jni/com_android_internal_os_Zygote.cpp


// Utility routine to fork zygote and specialize the child process.
static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray javaGids,
                                     jint debug_flags, jobjectArray javaRlimits,
                                     jlong permittedCapabilities, jlong effectiveCapabilities,
                                     jint mount_external,
                                     jstring java_se_info, jstring java_se_name,
                                     bool is_system_server, jintArray fdsToClose,
                                     jstring instructionSet, jstring dataDir) {


   if (!MountEmulatedStorage(uid, mount_external, need_native_bridge)) {


      ALOGW("Failed to mount emulated storage: %d", errno);
      if (errno == ENOTCONN || errno == EROFS) {
        // When device is actively encrypting, we get ENOTCONN here
        // since FUSE was mounted before the framework restarted.
        // When encrypted device is booting, we get EROFS since
        // FUSE hasn't been created yet by init.
        // In either case, continue without external storage.
      } else {
        ALOGE("Cannot continue without emulated storage");
        RuntimeAbort(env);
      }
    }





static bool MountEmulatedStorage(uid_t uid, jint mount_mode, bool force_mount_namespace) {

 if (mount_mode == MOUNT_EXTERNAL_MULTIUSER || mount_mode == MOUNT_EXTERNAL_MULTIUSER_ALL) {
    // These paths must already be created by init.rc
    const char* source = getenv("EMULATED_STORAGE_SOURCE");
    const char* target = getenv("EMULATED_STORAGE_TARGET");
    const char* legacy = getenv("EXTERNAL_STORAGE");

//这几个环境变量是从init.rc中设置的

//分区没法加载,怀疑是变量设置有问题

//查找设置果然是这个问题


    if (source == NULL || target == NULL || legacy == NULL) {
      ALOGW("Storage environment undefined; unable to provide external storage");
      return false;
    }


    // Prepare source paths


    // /mnt/shell/emulated/0
    const String8 source_user(String8::format("%s/%d", source, user_id));
    // /storage/emulated/0
    const String8 target_user(String8::format("%s/%d", target, user_id));


    if (fs_prepare_dir(source_user.string(), 0000, 0, 0) == -1
        || fs_prepare_dir(target_user.string(), 0000, 0, 0) == -1) {
      return false;
    }


    if (mount_mode == MOUNT_EXTERNAL_MULTIUSER_ALL) {
      // Mount entire external storage tree for all users
      if (TEMP_FAILURE_RETRY(mount(source, target, NULL, MS_BIND, NULL)) == -1) {
        ALOGW("Failed to mount %s to %s :%d", source, target, errno);
        return false;
      }
    } else {
      // Only mount user-specific external storage
      if (TEMP_FAILURE_RETRY(
              mount(source_user.string(), target_user.string(), NULL, MS_BIND, NULL)) == -1) {
        ALOGW("Failed to mount %s to %s: %d", source_user.string(), target_user.string(), errno);
        return false;
      }
    }


    if (fs_prepare_dir(legacy, 0000, 0, 0) == -1) {
        return false;
    }

你可能感兴趣的:(linux,Android)