]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
dm: export name and uuid
authorMike Anderson <andmike@linux.vnet.ibm.com>
Fri, 19 Oct 2007 21:47:59 +0000 (22:47 +0100)
committerAlasdair G Kergon <agk@redhat.com>
Sat, 20 Oct 2007 01:01:23 +0000 (02:01 +0100)
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>
drivers/md/dm-ioctl.c
include/linux/device-mapper.h

index 6af95f9b7b528ca92e3caba3d5edb8cb5d64a1fa..138200bf5e0befa90ff67d7ac50c231313f94380 100644 (file)
@@ -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;
+}
index 499f5373e2134d7a1a0fa8b9a84bddc3ad23b26b..8b3c7cdc599c6739e2f33f4e4e27698772642211 100644 (file)
@@ -188,6 +188,7 @@ int dm_wait_event(struct mapped_device *md, int event_nr);
  * Info functions.
  */
 const char *dm_device_name(struct mapped_device *md);
+int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid);
 struct gendisk *dm_disk(struct mapped_device *md);
 int dm_suspended(struct mapped_device *md);
 int dm_noflush_suspending(struct dm_target *ti);