1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-02-04 21:47:46 +03:00

Add as-yet-unused vg_read_error() and vg_might_exist(). (mornfall)

This commit is contained in:
Alasdair Kergon 2009-01-27 01:48:47 +00:00
parent 22c4076818
commit ab448cdb57
2 changed files with 49 additions and 1 deletions

View File

@ -387,12 +387,20 @@ vg_t *vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
uint32_t lock_flags, uint32_t status_flags,
uint32_t misc_flags);
/* Loading volume group metadata. */
/*
* Return a handle to VG metadata.
*/
vg_t *vg_read(struct cmd_context *cmd, const char *vg_name,
const char *vgid, uint32_t flags);
vg_t *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
const char *vgid, uint32_t flags);
/*
* Test validity of a VG handle.
*/
uint32_t vg_read_error(vg_t *vg_handle);
uint32_t vg_might_exist(vg_t *vg_handle);
/* pe_start and pe_end relate to any existing data so that new metadata
* areas can avoid overlap */
pv_t *pv_create(const struct cmd_context *cmd,

View File

@ -2673,6 +2673,46 @@ vg_t *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
return vg_read(cmd, vg_name, vgid, flags | READ_FOR_UPDATE);
}
/*
* Test the validity of a VG handle returned by vg_read() or vg_read_for_update().
*
* If READ_CHECK_EXISTENCE was supplied the non-existence of the volume group
* is not considered an error.
*
* !vg_read_error() && vg_might_exist() => valid handle to VG.
* vg_read_error() && vg_might_exist() => handle invalid, but VG might
* exist but cannot be read.
* !vg_read_error() && !vg_might_exist() => the VG does not exist
* vg_read_error() && !vg_might_exist() is impossible.
*/
uint32_t vg_read_error(vg_t *vg_handle)
{
if (!vg_handle)
return FAILED_ALLOCATION;
if (vg_handle->read_status & READ_CHECK_EXISTENCE)
return vg_handle->read_status &
~(READ_CHECK_EXISTENCE | FAILED_NOTFOUND);
return vg_handle->read_status;
}
/*
* Returns true if the volume group already exists.
* If unsure, it will return true. It might exist but the read failed
* for some other reason.
*/
uint32_t vg_might_exist(vg_t *vg_handle)
{
if (!vg_handle)
return 1;
if (vg_handle->read_status == (FAILED_NOTFOUND | READ_CHECK_EXISTENCE))
return 0;
return 1;
}
/*
* Gets/Sets for external LVM library
*/