aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-ioctl.c
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@us.ibm.com>2006-03-27 04:17:54 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-27 11:44:59 -0500
commit3ac51e741a46af7a20f55e79d3e3aeaa93c6c544 (patch)
treecab595a4d9691d7602616337b7862a1a3d692b97 /drivers/md/dm-ioctl.c
parent1134e5ae79bab61c05657ca35a6297cf87202e35 (diff)
[PATCH] dm store geometry
Allow drive geometry to be stored with a new DM_DEV_SET_GEOMETRY ioctl. Device-mapper will now respond to HDIO_GETGEO. If the geometry information is not available, zero will be returned for all of the parameters. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md/dm-ioctl.c')
-rw-r--r--drivers/md/dm-ioctl.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 65826bdac00..8edd6435414 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -15,6 +15,7 @@
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/devfs_fs_kernel.h> 16#include <linux/devfs_fs_kernel.h>
17#include <linux/dm-ioctl.h> 17#include <linux/dm-ioctl.h>
18#include <linux/hdreg.h>
18 19
19#include <asm/uaccess.h> 20#include <asm/uaccess.h>
20 21
@@ -700,6 +701,54 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size)
700 return dm_hash_rename(param->name, new_name); 701 return dm_hash_rename(param->name, new_name);
701} 702}
702 703
704static int dev_set_geometry(struct dm_ioctl *param, size_t param_size)
705{
706 int r = -EINVAL, x;
707 struct mapped_device *md;
708 struct hd_geometry geometry;
709 unsigned long indata[4];
710 char *geostr = (char *) param + param->data_start;
711
712 md = find_device(param);
713 if (!md)
714 return -ENXIO;
715
716 if (geostr < (char *) (param + 1) ||
717 invalid_str(geostr, (void *) param + param_size)) {
718 DMWARN("Invalid geometry supplied.");
719 goto out;
720 }
721
722 x = sscanf(geostr, "%lu %lu %lu %lu", indata,
723 indata + 1, indata + 2, indata + 3);
724
725 if (x != 4) {
726 DMWARN("Unable to interpret geometry settings.");
727 goto out;
728 }
729
730 if (indata[0] > 65535 || indata[1] > 255 ||
731 indata[2] > 255 || indata[3] > ULONG_MAX) {
732 DMWARN("Geometry exceeds range limits.");
733 goto out;
734 }
735
736 geometry.cylinders = indata[0];
737 geometry.heads = indata[1];
738 geometry.sectors = indata[2];
739 geometry.start = indata[3];
740
741 r = dm_set_geometry(md, &geometry);
742 if (!r)
743 r = __dev_status(md, param);
744
745 param->data_size = 0;
746
747out:
748 dm_put(md);
749 return r;
750}
751
703static int do_suspend(struct dm_ioctl *param) 752static int do_suspend(struct dm_ioctl *param)
704{ 753{
705 int r = 0; 754 int r = 0;
@@ -1234,7 +1283,8 @@ static ioctl_fn lookup_ioctl(unsigned int cmd)
1234 1283
1235 {DM_LIST_VERSIONS_CMD, list_versions}, 1284 {DM_LIST_VERSIONS_CMD, list_versions},
1236 1285
1237 {DM_TARGET_MSG_CMD, target_message} 1286 {DM_TARGET_MSG_CMD, target_message},
1287 {DM_DEV_SET_GEOMETRY_CMD, dev_set_geometry}
1238 }; 1288 };
1239 1289
1240 return (cmd >= ARRAY_SIZE(_ioctls)) ? NULL : _ioctls[cmd].fn; 1290 return (cmd >= ARRAY_SIZE(_ioctls)) ? NULL : _ioctls[cmd].fn;