aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2009-10-03 14:52:01 -0400
committerJens Axboe <jens.axboe@oracle.com>2009-10-03 14:52:01 -0400
commitac481c20ef8f6c6f2be75d581863f40c43874ef7 (patch)
tree90512cadc1c9dea89c0a24149166d3ab464d065e /block
parent61f0c1dcaaac71faabac6ef7c839b29f20204bea (diff)
block: Topology ioctls
Not all users of the topology information want to use libblkid. Provide the topology information through bdev ioctls. Also clarify sector size comments for existing BLK ioctls. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block')
-rw-r--r--block/compat_ioctl.c13
-rw-r--r--block/ioctl.c17
2 files changed, 28 insertions, 2 deletions
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
index 7865a34e0faa..9bd086c1a4d5 100644
--- a/block/compat_ioctl.c
+++ b/block/compat_ioctl.c
@@ -21,6 +21,11 @@ static int compat_put_int(unsigned long arg, int val)
21 return put_user(val, (compat_int_t __user *)compat_ptr(arg)); 21 return put_user(val, (compat_int_t __user *)compat_ptr(arg));
22} 22}
23 23
24static int compat_put_uint(unsigned long arg, unsigned int val)
25{
26 return put_user(val, (compat_uint_t __user *)compat_ptr(arg));
27}
28
24static int compat_put_long(unsigned long arg, long val) 29static int compat_put_long(unsigned long arg, long val)
25{ 30{
26 return put_user(val, (compat_long_t __user *)compat_ptr(arg)); 31 return put_user(val, (compat_long_t __user *)compat_ptr(arg));
@@ -734,6 +739,14 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
734 switch (cmd) { 739 switch (cmd) {
735 case HDIO_GETGEO: 740 case HDIO_GETGEO:
736 return compat_hdio_getgeo(disk, bdev, compat_ptr(arg)); 741 return compat_hdio_getgeo(disk, bdev, compat_ptr(arg));
742 case BLKPBSZGET:
743 return compat_put_uint(arg, bdev_physical_block_size(bdev));
744 case BLKIOMIN:
745 return compat_put_uint(arg, bdev_io_min(bdev));
746 case BLKIOOPT:
747 return compat_put_uint(arg, bdev_io_opt(bdev));
748 case BLKALIGNOFF:
749 return compat_put_int(arg, bdev_alignment_offset(bdev));
737 case BLKFLSBUF: 750 case BLKFLSBUF:
738 case BLKROSET: 751 case BLKROSET:
739 case BLKDISCARD: 752 case BLKDISCARD:
diff --git a/block/ioctl.c b/block/ioctl.c
index d3e6b5827a34..1f4d1de12b09 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -138,6 +138,11 @@ static int put_int(unsigned long arg, int val)
138 return put_user(val, (int __user *)arg); 138 return put_user(val, (int __user *)arg);
139} 139}
140 140
141static int put_uint(unsigned long arg, unsigned int val)
142{
143 return put_user(val, (unsigned int __user *)arg);
144}
145
141static int put_long(unsigned long arg, long val) 146static int put_long(unsigned long arg, long val)
142{ 147{
143 return put_user(val, (long __user *)arg); 148 return put_user(val, (long __user *)arg);
@@ -263,10 +268,18 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
263 return put_long(arg, (bdi->ra_pages * PAGE_CACHE_SIZE) / 512); 268 return put_long(arg, (bdi->ra_pages * PAGE_CACHE_SIZE) / 512);
264 case BLKROGET: 269 case BLKROGET:
265 return put_int(arg, bdev_read_only(bdev) != 0); 270 return put_int(arg, bdev_read_only(bdev) != 0);
266 case BLKBSZGET: /* get the logical block size (cf. BLKSSZGET) */ 271 case BLKBSZGET: /* get block device soft block size (cf. BLKSSZGET) */
267 return put_int(arg, block_size(bdev)); 272 return put_int(arg, block_size(bdev));
268 case BLKSSZGET: /* get block device hardware sector size */ 273 case BLKSSZGET: /* get block device logical block size */
269 return put_int(arg, bdev_logical_block_size(bdev)); 274 return put_int(arg, bdev_logical_block_size(bdev));
275 case BLKPBSZGET: /* get block device physical block size */
276 return put_uint(arg, bdev_physical_block_size(bdev));
277 case BLKIOMIN:
278 return put_uint(arg, bdev_io_min(bdev));
279 case BLKIOOPT:
280 return put_uint(arg, bdev_io_opt(bdev));
281 case BLKALIGNOFF:
282 return put_int(arg, bdev_alignment_offset(bdev));
270 case BLKSECTGET: 283 case BLKSECTGET:
271 return put_ushort(arg, queue_max_sectors(bdev_get_queue(bdev))); 284 return put_ushort(arg, queue_max_sectors(bdev_get_queue(bdev)));
272 case BLKRASET: 285 case BLKRASET: