Queries a volume group and returns pertinent information.
Logical Volume Manager Library (liblvm.a)
#include <lvm.h>
int lvm_queryvg (VG_ID, QueryVG, PVName) struct unique_id *VG_ID; struct queryvg **QueryVG; char *PVName;
Note: You must have root user authority to use this subroutine.
The lvm_queryvg subroutine returns information on the volume group specified by the VG_ID parameter.
The queryvg structure , found in the lvm.h file, contains the following fields:
struct queryvg { long maxlvs; long ppsize; long freespace; long num_lvs; long num_pvs; long total_vgdas; struct lv_array *lvs; struct pv_array *pvs; } struct pv_array { struct unique_id pv_id; long pvnum_vgdas; char state; char res[3]; } struct lv_array { struct lv_id lv_id; char lvname[LVM_NAMESIZ]; char state; char res[3]; }
The PVName parameter enables the user to query from a descriptor area on a specific physical volume instead of from the Logical Volume Manager's (LVM) most recent, in-memory copy of the descriptor area. This method should only be used if the volume group is varied off. The data returned is not guaranteed to be most recent or correct, and it can reflect a back level descriptor area. The Pvname parameter should specify either the full path name of the physical volume that contains the descriptor area to query or a single file name that must reside in the /dev directory (for example, rhdisk1). The name must represent a raw device. If a raw or character device is not specified for the PVName parameter, the Logical Volume Manager will add an r to the file name in order to have a raw device name. If there is no raw device entry for this name, the LVM returns the LVM_NOTCHARDEV error code. This field must be a null-terminated string of from 1 to LVM_NAMESIZ bytes, including the null byte. If a PVName is specified, the LVM will return the VG_ID to the user through the VG_ID pointer passed in. If the user wishes to query from the LVM in-memory copy, the PVName parameter should be set to null. When using this method of query, the volume group must be varied on, or an error will be returned.
Note: As long as the PVName parameter is not null, the LVM will attempt a query from a physical volume and not its in-memory copy of data.
In addition to the PVName parameter, the caller passes the unique ID of the volume group to be queried (VG_ID) and the address of a pointer to a queryvg structure. The LVM will separately allocate enough space for the queryvg structure, as well as the lv_array and pv_array structures, and return the address of the completed structure in the QueryVG parameter passed in by the user. The user is responsible for freeing the space by freeing the lv and pv pointers and then freeing the QueryVG pointer.
The lvm_queryvgn subroutine returns a value of 0 upon successful completion.
If the lvm_queryvg subroutine fails it returns one of the following error codes:
If the query originates from the varied-on volume group's current volume group descriptor area, one of the following error codes may be returned:
If a physical volume name has been passed, requesting that the query originate from a specific physical volume, one of the following error codes may be returned:
This subroutine is part of Base Operating System (BOS) Runtime.
The lvm_varyonvg subroutine.
List of Logical Volume Subroutines and Logical Volume Programming Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.