1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

Add lvmcache_vgname_from_pvid().

Add lvmcache function to lookup a vgname from a pvid.
This commit is contained in:
Dave Wysochanski 2010-05-19 11:52:21 +00:00
parent dd4097a6a4
commit cfb203e14d
2 changed files with 22 additions and 0 deletions

21
lib/cache/lvmcache.c vendored
View File

@ -509,6 +509,27 @@ struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only)
return info;
}
char *lvmcache_vgname_from_pvid(struct cmd_context *cmd, const char *pvid)
{
struct lvmcache_info *info;
char *vgname;
if (!device_from_pvid(cmd, (struct id *)pvid, NULL)) {
log_error("Couldn't find device with uuid %s.", pvid);
return NULL;
}
info = info_from_pvid(pvid, 0);
if (!info)
return_NULL;
if (!(vgname = dm_pool_strdup(cmd->mem, info->vginfo->vgname))) {
log_errno(ENOMEM, "vgname allocation failed");
return NULL;
}
return vgname;
}
static void _rescan_entry(struct lvmcache_info *info)
{
struct label *label;

View File

@ -98,6 +98,7 @@ 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);
char *lvmcache_vgname_from_pvid(struct cmd_context *cmd, const char *pvid);
int vgs_locked(void);
int vgname_is_locked(const char *vgname);