diff options
author | Dave Wysochanski <dwysocha@redhat.com> | 2010-05-19 11:52:07 +0000 |
---|---|---|
committer | Dave Wysochanski <dwysocha@redhat.com> | 2010-05-19 11:52:07 +0000 |
commit | dd4097a6a49d250dbbe592b312db94504b17e5fa (patch) | |
tree | 5824d3b6af6701b1f974c85a61156d877e093484 /lib/cache/lvmcache.c | |
parent | 1d837442bf01730d9bf9423261ebd4fa2c523480 (diff) | |
download | lvm2-dd4097a6a49d250dbbe592b312db94504b17e5fa.tar.gz lvm2-dd4097a6a49d250dbbe592b312db94504b17e5fa.tar.xz lvm2-dd4097a6a49d250dbbe592b312db94504b17e5fa.zip |
Add pvid_from_devname() lvmcache function.
Add supporting function for mappings from devname -> pvid -> vgname.
Diffstat (limited to 'lib/cache/lvmcache.c')
-rw-r--r-- | lib/cache/lvmcache.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 1f1e1e6a..6e46e31c 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -757,6 +757,25 @@ struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid, return NULL; } +const char *pvid_from_devname(struct cmd_context *cmd, + const char *devname) +{ + struct device *dev; + struct label *label; + + if (!(dev = dev_cache_get(devname, cmd->filter))) { + log_error("%s: Couldn't find device. Check your filters?", + devname); + return NULL; + } + + if (!(label_read(dev, &label, UINT64_C(0)))) + return NULL; + + return dev->pvid; +} + + static int _free_vginfo(struct lvmcache_vginfo *vginfo) { struct lvmcache_vginfo *primary_vginfo, *vginfo2; |