diff options
Diffstat (limited to 'drivers/md/dm-ioctl.c')
-rw-r--r-- | drivers/md/dm-ioctl.c | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 65826bdac00c..8edd6435414d 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 | ||
704 | static 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 | |||
747 | out: | ||
748 | dm_put(md); | ||
749 | return r; | ||
750 | } | ||
751 | |||
703 | static int do_suspend(struct dm_ioctl *param) | 752 | static 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; |