vmem_disk
提供block_device_operations
结构体中的getgeo()成员函数。如下给出了vmem_disk
设备驱动的block_device_operations
结构体定义及其成员函数的实现。
static int vmem_disk_getgeo(struct block_device *bdev,struct hd_geometry *geo)
{
long size;
struct vmem_disk_dev *dev = bdev->bd_disk->private_data;
size = dev->size*(HARDSECT_SIZE/KERNEL_SECTOR_SIZE);
geo->cylinders = (size & ~0x3f) >> 6;
geo->heads = 4;
geo->sector = 16;
geo->start=4;
return 0;
}
static struct block_device_operations vmem_disk_ops = {
.getgeo = vmem_disk_getgeo;
};