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:
parent
dd4097a6a4
commit
cfb203e14d
21
lib/cache/lvmcache.c
vendored
21
lib/cache/lvmcache.c
vendored
@ -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;
|
||||
|
1
lib/cache/lvmcache.h
vendored
1
lib/cache/lvmcache.h
vendored
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user