United States-English |
|
|
HP-UX Reference > Ttuneinfo2(2)HP-UX 11i Version 3: February 2007 |
|
NAMEtuneinfo2() — retrieve detailed information about kernel tunable parameters SYNOPSIS#include <sys/dyntune.h> int tuneinfo2(int version, const char *tunable, tuneinfo2_t *buf, size_t *bufsize); TUNEINFO_STRING(tunable, string) DESCRIPTIONThis function provides detailed information about one or all kernel tunable parameters. If a particular parameter is of interest, specify it by name in tunable. Otherwise, set tunable to NULL and information will be returned on all kernel tunable parameters (if the supplied buffer is big enough). version must always be set to TUNEINFO_VERSION. Information about the selected tunable parameters is returned in tuneinfo2_t structures and associated character strings. The buf parameter must specify an address in the caller's space containing space for these structures and strings. bufsize must point to a variable containing the size of the buffer (in bytes). Since the character strings are of variable length, the caller must first ask how much buffer space is needed, then allocate the necessary buffer space, and then ask for the tunable information. To calculate the size of the buffer to hold all the tunables, this function should be called with the parameters buf and bufsize set to NULL and zero, respectively. The function will return successfully with a return value of 0 and the variable at bufsize will have been changed to contain the amount of space needed to hold all of the requested data. See the example below. Each tuneinfo2_t structure describes a single tunable parameter, and contains at least the following fields, in unspecified order:
The character string location fields, ti_name, ti_desc, and ti_module, can be used to retrieve the character strings. These fields must be accessed using the TUNEINFO_STRING() macro. The first parameter of the macro is the pointer to the tuneinfo2_t structure and the second parameter is one of the four field names above. The result of the macro will be a pointer to a null-terminated string. See the example below. RETURN VALUEIf tuneinfo2() is successful, it returns the number of tunable parameters for which information was returned and sets the value of bufsize to the amount of buffer space used. When the parameters buf and bufsize are set to NULL and zero, respectively; it returns 0 and sets the value of bufsize to the amount of buffer space that needs to be preallocated. ERRORSIf this function returns -1 to indicate an error, the global variable errno will be set to one of the following values, to indicate the error that occurred:
EXAMPLES#include <stdlib.h> #include <stdio.h> #include <sys/dyntune.h> ... tuneinfo2_t *buf; size_t bufsize; int ret; int count; int i; /* To gather information on all tunables: */ /* 1. Find out how much space we need: */ bufsize = 0; ret = tuneinfo2(TUNEINFO_VERSION, NULL, NULL, &bufsize); if (ret) { ... } /* 2. Allocate that much space: */ buf = (tuneinfo2_t *)malloc(bufsize); if (buf == NULL) { ... } /* 3. Query the data: */ count = tuneinfo2(TUNEINFO_VERSION, NULL, buf, &bufsize); if (count < 0) { ... } /* 4. Print the names of all tunables: */ for (i = 0; i < count; i++) { char *name = TUNEINFO_STRING(&buf[i], ti_name); puts(name); } |
Printable version | ||
|