diff options
-rw-r--r-- | drivers/md/dm-ioctl.c | 32 | ||||
-rw-r--r-- | include/linux/device-mapper.h | 1 |
2 files changed, 33 insertions, 0 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 6af95f9b7b52..138200bf5e0b 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c | |||
@@ -1515,3 +1515,35 @@ void dm_interface_exit(void) | |||
1515 | 1515 | ||
1516 | dm_hash_exit(); | 1516 | dm_hash_exit(); |
1517 | } | 1517 | } |
1518 | |||
1519 | /** | ||
1520 | * dm_copy_name_and_uuid - Copy mapped device name & uuid into supplied buffers | ||
1521 | * @md: Pointer to mapped_device | ||
1522 | * @name: Buffer (size DM_NAME_LEN) for name | ||
1523 | * @uuid: Buffer (size DM_UUID_LEN) for uuid or empty string if uuid not defined | ||
1524 | */ | ||
1525 | int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid) | ||
1526 | { | ||
1527 | int r = 0; | ||
1528 | struct hash_cell *hc; | ||
1529 | |||
1530 | if (!md) | ||
1531 | return -ENXIO; | ||
1532 | |||
1533 | dm_get(md); | ||
1534 | down_read(&_hash_lock); | ||
1535 | hc = dm_get_mdptr(md); | ||
1536 | if (!hc || hc->md != md) { | ||
1537 | r = -ENXIO; | ||
1538 | goto out; | ||
1539 | } | ||
1540 | |||
1541 | strcpy(name, hc->name); | ||
1542 | strcpy(uuid, hc->uuid ? : ""); | ||
1543 | |||
1544 | out: | ||
1545 | up_read(&_hash_lock); | ||
1546 | dm_put(md); | ||
1547 | |||
1548 | return r; | ||
1549 | } | ||
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 499f5373e213..8b3c7cdc599c 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h | |||
@@ -188,6 +188,7 @@ int dm_wait_event(struct mapped_device *md, int event_nr); | |||
188 | * Info functions. | 188 | * Info functions. |
189 | */ | 189 | */ |
190 | const char *dm_device_name(struct mapped_device *md); | 190 | const char *dm_device_name(struct mapped_device *md); |
191 | int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid); | ||
191 | struct gendisk *dm_disk(struct mapped_device *md); | 192 | struct gendisk *dm_disk(struct mapped_device *md); |
192 | int dm_suspended(struct mapped_device *md); | 193 | int dm_suspended(struct mapped_device *md); |
193 | int dm_noflush_suspending(struct dm_target *ti); | 194 | int dm_noflush_suspending(struct dm_target *ti); |