rendered paste bodystatic int my_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
long size;
struct hd_geometry geo;
printk(KERN_INFO "cmd=%d\n", cmd);
switch (cmd) {
case HDIO_GETGEO:
printk(KERN_INFO "HIT HDIO_GETGEO\n");
/*
* get geometry: we have to fake one... trim the size to a
* multiple of 64 (32k): tell we have 16 sectors, 4 heads,
* whatever cylinders. Tell also that data starts at sector. 4.
*/
size = disk_size;
size &= ~0x3f; /* multiple of 64 */
geo.cylinders = size >> 6;
geo.heads = 4;
geo.sectors = 16;
geo.start = 4;
if (copy_to_user((void __user *)arg, &geo, sizeof(geo)))
return -EFAULT;
return 0;
}
printk(KERN_WARNING "return -ENOTTY\n");
return -ENOTTY; /* unknown command */
}