diff options
author | Mike Anderson <andmike@linux.vnet.ibm.com> | 2007-10-19 22:47:59 +0100 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2007-10-20 02:01:23 +0100 |
commit | 96a1f7dba6e464155c0d1dc69c6c2efa96b644ac (patch) | |
tree | 8051a11c07624c9e5f9b049273462c307c447624 /drivers/md/dm-ioctl.c | |
parent | aa5617c55357d86c9082ba1d66fa9795370c9954 (diff) | |
download | op-kernel-dev-96a1f7dba6e464155c0d1dc69c6c2efa96b644ac.zip op-kernel-dev-96a1f7dba6e464155c0d1dc69c6c2efa96b644ac.tar.gz |
dm: export name and uuid
This patch adds a function to obtain a copy of a mapped device's name and uuid.
Signed-off-by: Mike Anderson <andmike@linux.vnet.ibm.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-ioctl.c')
-rw-r--r-- | drivers/md/dm-ioctl.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 6af95f9..138200b 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1515,3 +1515,35 @@ void dm_interface_exit(void) dm_hash_exit(); } + +/** + * dm_copy_name_and_uuid - Copy mapped device name & uuid into supplied buffers + * @md: Pointer to mapped_device + * @name: Buffer (size DM_NAME_LEN) for name + * @uuid: Buffer (size DM_UUID_LEN) for uuid or empty string if uuid not defined + */ +int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid) +{ + int r = 0; + struct hash_cell *hc; + + if (!md) + return -ENXIO; + + dm_get(md); + down_read(&_hash_lock); + hc = dm_get_mdptr(md); + if (!hc || hc->md != md) { + r = -ENXIO; + goto out; + } + + strcpy(name, hc->name); + strcpy(uuid, hc->uuid ? : ""); + +out: + up_read(&_hash_lock); + dm_put(md); + + return r; +} |