diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index 1393aaeb3..0861f4d59 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -721,6 +721,7 @@ uint64_t vg_max_pv(const struct volume_group *vg); uint64_t vg_max_lv(const struct volume_group *vg); int vg_check_write_mode(struct volume_group *vg); #define vg_is_clustered(vg) (vg_status((vg)) & CLUSTERED) +#define vg_is_exported(vg) (vg_status((vg)) & EXPORTED_VG) struct vgcreate_params { char *vg_name; diff --git a/liblvm/lvm2app.h b/liblvm/lvm2app.h index d6b67ce5b..aeadd7490 100644 --- a/liblvm/lvm2app.h +++ b/liblvm/lvm2app.h @@ -480,6 +480,43 @@ int lvm_vg_reduce(vg_t vg, const char *device); */ int lvm_vg_set_extent_size(vg_t vg, uint32_t new_size); +/** + * Get whether or not a volume group is clustered. + * + * \param vg + * VG handle obtained from lvm_vg_create or lvm_vg_open. + * + * \return + * 1 if the VG is clustered, 0 if not + */ +uint64_t lvm_vg_is_clustered(vg_t vg); + +/** + * Get whether or not a volume group is exported. + * + * \param vg + * VG handle obtained from lvm_vg_create or lvm_vg_open. + * + * \return + * 1 if the VG is exported, 0 if not + */ +uint64_t lvm_vg_is_exported(vg_t vg); + +/** + * Get whether or not a volume group is a partial volume group. + * + * When one or more physical volumes belonging to the volume group + * are missing from the system the volume group is a partial volume + * group. + * + * \param vg + * VG handle obtained from lvm_vg_create or lvm_vg_open. + * + * \return + * 1 if the VG is PVs, 0 if not + */ +uint64_t lvm_vg_is_partial(vg_t vg); + /** * Get the current metadata sequence number of a volume group. * diff --git a/liblvm/lvm_vg.c b/liblvm/lvm_vg.c index dcfd72266..a0a7b1fd1 100644 --- a/liblvm/lvm_vg.c +++ b/liblvm/lvm_vg.c @@ -243,6 +243,21 @@ uint64_t lvm_vg_get_seqno(const vg_t vg) return vg_seqno(vg); } +uint64_t lvm_vg_is_clustered(const vg_t vg) +{ + return vg_is_clustered(vg); +} + +uint64_t lvm_vg_is_exported(const vg_t vg) +{ + return vg_is_exported(vg); +} + +uint64_t lvm_vg_is_partial(const vg_t vg) +{ + return (vg_missing_pv_count(vg) != 0); +} + /* FIXME: invalid handle? return INTMAX? */ uint64_t lvm_vg_get_size(const vg_t vg) {