summaryrefslogtreecommitdiffstats
path: root/lib/cache
diff options
context:
space:
mode:
authorDave Wysochanski <dwysocha@redhat.com>2010-05-19 11:52:07 +0000
committerDave Wysochanski <dwysocha@redhat.com>2010-05-19 11:52:07 +0000
commitdd4097a6a49d250dbbe592b312db94504b17e5fa (patch)
tree5824d3b6af6701b1f974c85a61156d877e093484 /lib/cache
parent1d837442bf01730d9bf9423261ebd4fa2c523480 (diff)
downloadlvm2-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')
-rw-r--r--lib/cache/lvmcache.c19
-rw-r--r--lib/cache/lvmcache.h2
2 files changed, 21 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;
diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h
index 5706dcff..faf00cf4 100644
--- a/lib/cache/lvmcache.h
+++ b/lib/cache/lvmcache.h
@@ -96,6 +96,8 @@ struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only);
const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid);
struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid,
unsigned *scan_done_once);
+const char *pvid_from_devname(struct cmd_context *cmd,
+ const char *dev_name);
int vgs_locked(void);
int vgname_is_locked(const char *vgname);