[PATCH] Add block_device_operations.getgeo block device method
HDIO_GETGEO is implemented in most block drivers, and all of them have to duplicate the code to copy the structure to userspace, as well as getting the start sector. This patch moves that to common code [1] and adds a ->getgeo method to fill out the raw kernel hd_geometry structure. For many drivers this means ->ioctl can go away now. [1] the s390 block drivers are odd in this respect. xpram sets ->start to 4 always which seems more than odd, and the dasd driver shifts the start offset around, probably because of it's non-standard sector size. Signed-off-by: Christoph Hellwig <hch@lst.de> Cc: Jens Axboe <axboe@suse.de> Cc: <mike.miller@hp.com> Cc: Jeff Dike <jdike@addtoit.com> Cc: Paolo Giarrusso <blaisorblade@yahoo.it> Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl> Cc: Neil Brown <neilb@cse.unsw.edu.au> Cc: Markus Lidel <Markus.Lidel@shadowconnect.com> Cc: Russell King <rmk@arm.linux.org.uk> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: James Bottomley <James.Bottomley@steeleye.com> Signed-off-by: Adrian Bunk <bunk@stusta.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Цей коміт міститься в:

зафіксовано
Linus Torvalds

джерело
5b0ed2c64d
коміт
a885c8c431
@@ -658,22 +658,14 @@ static void do_hd_request (request_queue_t * q)
|
||||
enable_irq(HD_IRQ);
|
||||
}
|
||||
|
||||
static int hd_ioctl(struct inode * inode, struct file * file,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
static int hd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
{
|
||||
struct hd_i_struct *disk = inode->i_bdev->bd_disk->private_data;
|
||||
struct hd_geometry __user *loc = (struct hd_geometry __user *) arg;
|
||||
struct hd_geometry g;
|
||||
struct hd_i_struct *disk = bdev->bd_disk->private_data;
|
||||
|
||||
if (cmd != HDIO_GETGEO)
|
||||
return -EINVAL;
|
||||
if (!loc)
|
||||
return -EINVAL;
|
||||
g.heads = disk->head;
|
||||
g.sectors = disk->sect;
|
||||
g.cylinders = disk->cyl;
|
||||
g.start = get_start_sect(inode->i_bdev);
|
||||
return copy_to_user(loc, &g, sizeof g) ? -EFAULT : 0;
|
||||
geo->heads = disk->head;
|
||||
geo->sectors = disk->sect;
|
||||
geo->cylinders = disk->cyl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -695,7 +687,7 @@ static irqreturn_t hd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
|
||||
}
|
||||
|
||||
static struct block_device_operations hd_fops = {
|
||||
.ioctl = hd_ioctl,
|
||||
.getgeo = hd_getgeo,
|
||||
};
|
||||
|
||||
/*
|
||||
|
Посилання в новій задачі
Заблокувати користувача