aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/dm-ioctl.c63
-rw-r--r--include/linux/dm-ioctl.h4
2 files changed, 38 insertions, 29 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 1622a6bc0bfd..99d38a6925a4 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -719,24 +719,49 @@ static int dev_create(struct dm_ioctl *param, size_t param_size)
719static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param) 719static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
720{ 720{
721 struct mapped_device *md; 721 struct mapped_device *md;
722 void *mdptr = NULL; 722 struct hash_cell *hc = NULL;
723 723
724 if (*param->uuid) 724 if (*param->uuid) {
725 return __get_uuid_cell(param->uuid); 725 hc = __get_uuid_cell(param->uuid);
726 if (!hc)
727 return NULL;
728 goto fill_params;
729 }
726 730
727 if (*param->name) 731 if (*param->name) {
728 return __get_name_cell(param->name); 732 hc = __get_name_cell(param->name);
733 if (!hc)
734 return NULL;
735 goto fill_params;
736 }
729 737
730 md = dm_get_md(huge_decode_dev(param->dev)); 738 md = dm_get_md(huge_decode_dev(param->dev));
731 if (!md) 739 if (!md)
732 goto out; 740 return NULL;
733 741
734 mdptr = dm_get_mdptr(md); 742 hc = dm_get_mdptr(md);
735 if (!mdptr) 743 if (!hc) {
736 dm_put(md); 744 dm_put(md);
745 return NULL;
746 }
737 747
738out: 748fill_params:
739 return mdptr; 749 /*
750 * Sneakily write in both the name and the uuid
751 * while we have the cell.
752 */
753 strlcpy(param->name, hc->name, sizeof(param->name));
754 if (hc->uuid)
755 strlcpy(param->uuid, hc->uuid, sizeof(param->uuid));
756 else
757 param->uuid[0] = '\0';
758
759 if (hc->new_map)
760 param->flags |= DM_INACTIVE_PRESENT_FLAG;
761 else
762 param->flags &= ~DM_INACTIVE_PRESENT_FLAG;
763
764 return hc;
740} 765}
741 766
742static struct mapped_device *find_device(struct dm_ioctl *param) 767static struct mapped_device *find_device(struct dm_ioctl *param)
@@ -746,24 +771,8 @@ static struct mapped_device *find_device(struct dm_ioctl *param)
746 771
747 down_read(&_hash_lock); 772 down_read(&_hash_lock);
748 hc = __find_device_hash_cell(param); 773 hc = __find_device_hash_cell(param);
749 if (hc) { 774 if (hc)
750 md = hc->md; 775 md = hc->md;
751
752 /*
753 * Sneakily write in both the name and the uuid
754 * while we have the cell.
755 */
756 strlcpy(param->name, hc->name, sizeof(param->name));
757 if (hc->uuid)
758 strlcpy(param->uuid, hc->uuid, sizeof(param->uuid));
759 else
760 param->uuid[0] = '\0';
761
762 if (hc->new_map)
763 param->flags |= DM_INACTIVE_PRESENT_FLAG;
764 else
765 param->flags &= ~DM_INACTIVE_PRESENT_FLAG;
766 }
767 up_read(&_hash_lock); 776 up_read(&_hash_lock);
768 777
769 return md; 778 return md;
diff --git a/include/linux/dm-ioctl.h b/include/linux/dm-ioctl.h
index 3708455ee6c3..0cb8eff76bd6 100644
--- a/include/linux/dm-ioctl.h
+++ b/include/linux/dm-ioctl.h
@@ -267,9 +267,9 @@ enum {
267#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) 267#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
268 268
269#define DM_VERSION_MAJOR 4 269#define DM_VERSION_MAJOR 4
270#define DM_VERSION_MINOR 20 270#define DM_VERSION_MINOR 21
271#define DM_VERSION_PATCHLEVEL 0 271#define DM_VERSION_PATCHLEVEL 0
272#define DM_VERSION_EXTRA "-ioctl (2011-02-02)" 272#define DM_VERSION_EXTRA "-ioctl (2011-07-06)"
273 273
274/* Status bits */ 274/* Status bits */
275#define DM_READONLY_FLAG (1 << 0) /* In/Out */ 275#define DM_READONLY_FLAG (1 << 0) /* In/Out */