1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 03:27:58 +03:00

Add pvid_from_devname() lvmcache function.

Add supporting function for mappings from devname -> pvid -> vgname.
This commit is contained in:
Dave Wysochanski 2010-05-19 11:52:07 +00:00
parent 1d837442bf
commit dd4097a6a4
2 changed files with 21 additions and 0 deletions

19
lib/cache/lvmcache.c vendored
View File

@ -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;

View File

@ -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);