示例#1
0
文件: roots.c 项目: cherojeong/utopic
int get_num_extra_volumes() {
    int num = 0;
    int i;
    for (i = 0; i < get_num_volumes(); i++) {
        Volume* v = get_device_volumes() + i;
        if ((strcmp("/external_sd", v->mount_point) == 0) ||
                ((strcmp(get_primary_storage_path(), v->mount_point) != 0) &&
                fs_mgr_is_voldmanaged(v) && vold_is_volume_available(v->mount_point)))
            num++;
    }
    return num;
}
示例#2
0
storage_item* get_storage_items() {
    storage_item* items = (storage_item*)calloc(MAX_NUM_MANAGED_VOLUMES+1, sizeof(storage_item));
    int i;
    storage_item* item = items;

    if (is_data_media()) {
        item->vol = volume_for_path("/data");
        item->label = strdup("internal storage");
        item->path = strdup("/data/media");
        ++item;
    }
    for (i = 0; i < get_num_volumes(); i++) {
        fstab_rec* v = get_device_volumes() + i;

        // Internal storage was allocated above
        if (strcmp(v->fs_type, "datamedia") == 0)
            continue;

        if (strcmp(v->mount_point, "/external_sd") == 0 ||
                strncmp(v->mount_point, "/sdcard", 7) == 0) {
            item->vol = v;
            item->label = strdup(&v->mount_point[1]);
            item->path = strdup(v->mount_point);
            ++item;
        }
        else if (strncmp(v->mount_point, "/mnt/media_rw/sdcard", 20) == 0) {
            item->vol = v;
            item->label = strdup(&v->mount_point[14]);
            item->path = strdup(v->mount_point);
            ++item;
        }
        else if (fs_mgr_is_voldmanaged(v) && strncmp(v->label, "sdcard", 6) == 0) {
            char* path = (char*)malloc(9+strlen(v->label)+1);
            sprintf(path, "/storage/%s", v->label);
            if (vold_is_volume_available(path)) {
                item->vol = v;
                item->label = strdup(v->label);
                item->path = strdup(path);
                ++item;
            }
            free(path);
        }
    }

    return items;
}