diff options
author | Petr Rockai <prockai@redhat.com> | 2013-07-29 18:54:59 +0200 |
---|---|---|
committer | Petr Rockai <prockai@redhat.com> | 2013-07-29 19:16:27 +0200 |
commit | 77ff425e2507e76e2b95f4cc6be1864901c0125c (patch) | |
tree | e2c2e27e0c68996aed860fe8c12c77ddbe68b494 | |
parent | c4ee8bb53d13a9c35d82189860f964a453d40dae (diff) | |
download | lvm2-77ff425e2507e76e2b95f4cc6be1864901c0125c.tar.gz |
metadata: Add a pv_label accessor (go from a PV to its label).
-rw-r--r-- | lib/metadata/pv.c | 10 | ||||
-rw-r--r-- | lib/metadata/pv.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/metadata/pv.c b/lib/metadata/pv.c index 5b08998e6..0288f0740 100644 --- a/lib/metadata/pv.c +++ b/lib/metadata/pv.c @@ -350,3 +350,13 @@ unsigned pv_mda_set_ignored(const struct physical_volume *pv, unsigned mda_ignor return 1; } +struct label *pv_label(const struct physical_volume *pv) +{ + struct lvmcache_info *info = + lvmcache_info_from_pvid((const char *)&pv->id.uuid, 0); + if (!info) { + log_error(INTERNAL_ERROR "PV %s unexpectedly not in cache.", dev_name(pv->dev)); + return NULL; + } + return lvmcache_get_label(info); +} diff --git a/lib/metadata/pv.h b/lib/metadata/pv.h index ff708f8e3..8fd3061fa 100644 --- a/lib/metadata/pv.h +++ b/lib/metadata/pv.h @@ -95,5 +95,6 @@ unsigned pv_mda_set_ignored(const struct physical_volume *pv, unsigned ignored); int is_orphan(const struct physical_volume *pv); int is_missing_pv(const struct physical_volume *pv); int is_pv(const struct physical_volume *pv); +struct label *pv_label(const struct physical_volume *pv); #endif /* _LVM_PV_H */ |