dm ioctl: allow dm_copy_name_and_uuid to return only one field
authorMilan Broz <mbroz@redhat.com>
Tue, 6 Jan 2009 03:05:04 +0000 (03:05 +0000)
committerAlasdair G Kergon <agk@redhat.com>
Tue, 6 Jan 2009 03:05:04 +0000 (03:05 +0000)
Allow NULL buffer in dm_copy_name_and_uuid if you only want to return one of
the fields.

(Required by a following patch that adds these fields to sysfs.)

Signed-off-by: Milan Broz <mbroz@redhat.com>
Reviewed-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
drivers/md/dm-ioctl.c

index 777c948180f9ae9b956f803eb92c659cb12b2937..8da7a017b4efbb84c0c1b6567e5bcf0a405479ce 100644 (file)
@@ -1550,8 +1550,10 @@ int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid)
                goto out;
        }
 
-       strcpy(name, hc->name);
-       strcpy(uuid, hc->uuid ? : "");
+       if (name)
+               strcpy(name, hc->name);
+       if (uuid)
+               strcpy(uuid, hc->uuid ? : "");
 
 out:
        up_read(&_hash_lock);