예제 #1
0
// This routine handles the case where we can't open either /proc/mtd or /proc/emmc
int setLocationData(const char* label, const char* blockDevice, const char* mtdDevice, const char* fstype, unsigned long long size)
{
    struct dInfo* loc = NULL;

    if (label)                  loc = findDeviceByLabel(label);
			
    if (!loc && blockDevice)    loc = findDeviceByBlockDevice(blockDevice);

    if (!loc)
        return -1;

    if (blockDevice)            strcpy(loc->blk, blockDevice);
	if (label)                  strcpy(loc->mnt, label);
    if (mtdDevice){
		strcpy(loc->dev, mtdDevice);
		loc->memory_type = mtd;
		if (strcmp(loc->mnt, "data") == 0)
			strcpy(loc->format_location, "userdata");
		else
			strcpy(loc->format_location, loc->mnt);
	} else {
		loc->memory_type = emmc;
		strcpy(loc->format_location, loc->blk);
	}

    // This is a simple 
    if (strcmp(loc->mnt, "boot") == 0 && fstype)
    {
        loc->mountable = 0;
        if (strcmp(fstype, "vfat") == 0 || memcmp(fstype, "ext", 3) == 0 || strcmp(fstype, "auto") == 0)
            loc->mountable = 1;
    }

    if (fstype)                 strcpy(loc->fst, fstype);
    if (size && loc->sze == 0)  loc->sze = size;

    return 0;
}
예제 #2
0
void
set_restore_files()
{
    const char* nan_dir = DataManager_GetStrValue("_restore");

    // Start with the default values
    int restore_system = -1;
    int restore_data = -1;
    int restore_cache = -1;
    int restore_recovery = -1;
    int restore_boot = -1;
    int restore_andsec = -1;
    int restore_sdext = -1;
    int restore_sp1 = -1;
    int restore_sp2 = -1;
    int restore_sp3 = -1;

    DIR* d;
    d = opendir(nan_dir);
    if (d == NULL)
    {
        LOGE("error opening %s\n", nan_dir);
        return;
    }

    struct dirent* de;
    while ((de = readdir(d)) != NULL)
    {
        // Strip off three components
        char str[256];
        char* label;
        char* fstype = NULL;
        char* extn = NULL;
        char* ptr;
        struct dInfo* dev = NULL;

        strcpy(str, de->d_name);
        label = str;
        ptr = label;
        while (*ptr && *ptr != '.')     ptr++;
        if (*ptr == '.')
        {
            *ptr = 0x00;
            ptr++;
            fstype = ptr;
        }
        while (*ptr && *ptr != '.')     ptr++;
        if (*ptr == '.')
        {
            *ptr = 0x00;
            ptr++;
            extn = ptr;
        }

        if (extn == NULL || strcmp(extn, "win") != 0)   continue;

        dev = findDeviceByLabel(label);
        if (dev == NULL)
        {
            LOGE(" Unable to locate device by label\n");
            continue;
        }

        strncpy(dev->fnm, de->d_name, 256);
        dev->fnm[255] = '\0';

        // Now, we just need to find the correct label
        if (dev == &sys)        restore_system = 1;
        if (dev == &dat)        restore_data = 1;
        if (dev == &boo)        restore_boot = 1;
        if (dev == &rec)        restore_recovery = 1;
        if (dev == &cac)        restore_cache = 1;
        if (dev == &sde)        restore_sdext = 1;
        if (dev == &sp1)        restore_sp1 = 1;
        if (dev == &sp2)        restore_sp2 = 1;
        if (dev == &sp3)        restore_sp3 = 1;
        if (dev == &ase)        restore_andsec = 1;
    }
    closedir(d);

    // Set the final values
    DataManager_SetIntValue(VAR_RESTORE_SYSTEM_VAR, restore_system);
    DataManager_SetIntValue(VAR_RESTORE_DATA_VAR, restore_data);
    DataManager_SetIntValue(VAR_RESTORE_CACHE_VAR, restore_cache);
    DataManager_SetIntValue(VAR_RESTORE_RECOVERY_VAR, restore_recovery);
    DataManager_SetIntValue(VAR_RESTORE_BOOT_VAR, restore_boot);
    DataManager_SetIntValue(VAR_RESTORE_ANDSEC_VAR, restore_andsec);
    DataManager_SetIntValue(VAR_RESTORE_SDEXT_VAR, restore_sdext);
    DataManager_SetIntValue(VAR_RESTORE_SP1_VAR, restore_sp1);
    DataManager_SetIntValue(VAR_RESTORE_SP2_VAR, restore_sp2);
    DataManager_SetIntValue(VAR_RESTORE_SP3_VAR, restore_sp3);

    return;
}