summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);