Exemplo n.º 1
0
static struct ramdisk_struct *create_ramdisk(const unsigned int disk_size,
                                             const unsigned int lba_shift)
{
        struct ramdisk_struct *ramdiskp;
        unsigned int aligned_size;

        if (lba_shift < DEFAULT_LBA_SHIFT)
                return NULL;

        /* round down disk size and see if we can still create a ramdisk */
        aligned_size = disk_size & (~(lba_shift-1));
        if (aligned_size == 0)
                return NULL;

        ramdiskp = malloc(sizeof*ramdiskp);
        if (!ramdiskp)
                return NULL;

        if (raw_initialize_ramdisk(ramdiskp, aligned_size) < 0) {
                destroy_ramdisk(ramdiskp);
                return NULL;
        }

        ramdiskp->lba_shift = lba_shift;
        ramdiskp->lba_count = aligned_size >> lba_shift;

        return ramdiskp;
}
Exemplo n.º 2
0
int main(void)
{
        struct ramdisk_struct *simulated_disk;

        simulated_disk = create_ramdisk(RAMDISK_SIZE, DEFAULT_LBA_SHIFT);
        if (!simulated_disk) {
                fprintf(stderr, "error initializing ramdisk");
                return -1;
        }

        start_simulation(simulated_disk);

        destroy_ramdisk(simulated_disk);

        return 0;
}
Exemplo n.º 3
0
static void __exit cleanup_ramdisk(void)
{
	printk("Remove Ramdisk module\n");
	destroy_ramdisk();
}