Beispiel #1
0
static void
init()
{
#ifdef MOZ_NO_REPLACE_FUNC_DECL
  replace_malloc_init_funcs();
#endif
  // Set this *before* calling replace_init, otherwise if replace_init calls
  // malloc() we'll get an infinite loop.
  replace_malloc_initialized = 1;
  if (replace_init)
    replace_init(&malloc_table);
}
Beispiel #2
0
int main(int argc, char **argv)
{
    struct stat sStat;
    char *ramdisk_path = NULL;

    // Make sure this is being called from the 2ndinit stub
    if (argc < 2 || strcmp(argv[1], "2ndinit"))
    {
        return -1;
    }

    // Modify the selinux policy to make init permissive
    selinux_permissive();

    // sloane needs USB to be enabled
    FILE *mode = fopen("/sys/devices/bus.8/11270000.SSUSB/mode", "w");
    if (mode)
    {
        fwrite("1", 1, 1, mode);
        fclose(mode);
        sleep(3);
    }

    // Check for the ramdisk on secondary storage first
    char *devices[] = { "/dev/block/mmcblk1", "/dev/block/mmcblk1p1",
                        "/dev/block/sda", "/dev/block/sda1" };
    int i;
    for (i = 0; i < (sizeof(devices) / sizeof(char *)) && (ramdisk_path == NULL); i++)
    {
        mount(devices[i], MNT_DIR, "vfat", 0, NULL);
        if (stat(MNT_RECOVERY_RAMDISK, &sStat) == 0)
            ramdisk_path = MNT_RECOVERY_RAMDISK;
        else
            umount(MNT_DIR);
    }

    // If the ramdisk wasn't found, try /system
    if (ramdisk_path == NULL && stat(SYSTEM_RECOVERY_RAMDISK, &sStat) == 0)
        ramdisk_path = SYSTEM_RECOVERY_RAMDISK;

    // If the ramdisk was found
    if (ramdisk_path != NULL)
    {
        // Extract the ramdisk
        extract_recovery(ramdisk_path);

        // Unmount secondary storage if the ramdisk was on it
        if (!strcmp(ramdisk_path, MNT_RECOVERY_RAMDISK))
            umount(MNT_DIR);

        // stop adbd
        system("/system/bin/setprop ctl.stop adbd");

        // Use ptrace to replace init
        replace_init();

        return 0;
    }

    return -1;
}