ITEM: P8365L
Question about the unique_id structure and lvm_querylv
Question:
ENV: AIX 3.2.5
DESC: Customer is using the ODM subroutines odm_get_first and
odm_get_next and gets an ascii representation of
the volume group id in return.
He wants to know if there is a function that will
translate the ascii value into the unique_id structure.
Response:
ACTION: The unique_id struct is in /usr/include/sys/types.h:
struct unique_id {
unsigned long word1;
unsigned long word2;
unsigned long word3;
unsigned long word4;
};
There is no supplied function (as of today) for
converting the ascii string to unique_id values.
The get_uniq_id does exist but it is for INTERNAL
USE ONLY and is not shipped with AIX.
You can use sscanf as a workaround. The following is
an example. Note: it provides no error checking and
should be use only as a guide.
sscanf(CuAt.value, "%8x", &id.word1);
sscanf(CuAt.value+8, "%8x", &id.word2);
ACTION: Customer called back in. He is getting a 133 error,
which is a programming error. He will need to look at
his code to determine the problem.
Customer agrees, and thinks his problem is actually with the
lvm_querylv function. He has not been able to find sufficient
documentation about what to pass to this structure. He would
like some additional information.
Response:
Action: Here is a short sample C program that demonstrates the use
of the lvm_querylv subroutine. The executable expects two
arguments, the lvid and the pvname to read the information
from. Please note that this code is provided as a sample
only and IBM does not provide support for this program and
it is provided as-is.
\#include\
\#include\
\#include\
main(int argc, char **argv)
{struct querylv *query;
struct lv_id lv_id;
char sstring[40];
int rc=0, i;
sscanf(argv[1], "%8x", &lv_id.vg_id.word1);
sscanf(argv[1]+8, "%8x", &lv_id.vg_id.word2);
sscanf(argv[1]+17, "%d", &lv_id.minor_num);
rc = lvm_querylv(&lv_id, &query, argv[2]);
if (rc != 0)
{ printf("errno = %d\\n", errno);
perror ("myquerylv: lvm_querylv ");
}printf("lv_id = %08x%8x.%-3d\\n", lv_id.vg_id.word1, lv_id.vg_id.word2,
lv_id.minor_num);
printf("pvname = %s\\n", argv[2]);
printf("lvname = %s\\n", query->lvname);
}
Compile with the following: cc -g -o myquerylv myquerylv.c -llvm
Sample run and output:
\# myquerylv 00001595346a2edb.5 hdisk0
lv_id = 00001595346a2edb.5
pvname = hdisk0
lvname = hd4
Support Line: Question about the unique_id structure and lvm_querylv ITEM: P8365L
Dated: December 1994 Category: N/A
This HTML file was generated 99/06/24~13:30:38
Comments or suggestions?
Contact us