Examples
Example 1: The
following example shows an API to query admin threads.
#pragma linkage(BPX1PCT, OS)
extern void BPX1PCT(char *, int, int, char *, int *, int *, int *);
#include <stdio.h>
#define ZFSCALL_CONFIG 0x40000006
#define CFGOP_QUERY_ADM_THREADS 180 /* query number of admin threads */
typedef struct syscall_parmlist_t {
int opcode; /* Operation code to perform */
int parms[7]; /* Specific to type of operation, */
/* provides access to the parms */
/* parms[4]-parms[6] are currently unused*/
} syscall_parmlist;
typedef struct config_option_t {
char co_eye[4]; /* Eye catcher */
#define CFGO_EYE "CFOP"
short co_len; /* Length of structure */
char co_ver; /* Version of structure */
#define CO_VER_INITIAL 1 /* Initial version */
#define CO_SLEN 80 /* Sizeof string */
char co_string[CO_SLEN+1]; /* String value for option must be 0 terminated */
int co_value[4]; /* Place for integer values */
char co_reserved[24]; /* Reserved for future use */
} CFG_OPTION;
struct parmstruct {
syscall_parmlist myparms;
CFG_OPTION co;
char system[9];
} myparmstruct;
int main(int argc, char **argv)
{
int bpxrv;
int bpxrc;
int bpxrs;
CFG_OPTION *coptr = &(myparmstruct.co);
/* This next field should only be set if parms[1] is non-zero */
/* strcpy(myparmstruct.system,"DCEIMGVN"); */ /* set system to query */
myparmstruct.myparms.opcode = CFGOP_QUERY_ADM_THREADS;
myparmstruct.myparms.parms[0] = sizeof(syscall_parmlist);
myparmstruct.myparms.parms[1] = 0;
/* Only specify a non-zero offset for the next field (parms[1]) if you are */
/* z/OS 1.7 and above, and you want to configquery to a different system */
/* myparmstruct.myparms.parms[1] = sizeof(syscall_parmlist) + sizeof(CFG_OPTION); */
myparmstruct.myparms.parms[2] = 0;
myparmstruct.myparms.parms[3] = 0;
myparmstruct.myparms.parms[4] = 0;
myparmstruct.myparms.parms[5] = 0;
myparmstruct.myparms.parms[6] = 0;
memset(coptr,0,sizeof(CFG_OPTION));
memcpy(coptr->co_eye,CFGO_EYE,4);
coptr->co_ver=CO_VER_INITIAL;
coptr->co_len=(int) sizeof(CFG_OPTION);
BPX1PCT("ZFS ",
ZFSCALL_CONFIG, /* Config operation */
sizeof(myparmstruct), /* Length of Argument */
(char *) &myparmstruct, /* Pointer to Argument */
&bpxrv, /* Pointer to Return_value */
&bpxrc, /* Pointer to Return_code */
&bpxrs); /* Pointer to Reason_code */
if (bpxrv < 0) {
printf("Error querying config -adm_threads, BPXRV = %d BPXRC = %d BPXRS = %x\n",bpxrv,bpxrc,bpxrs);
return bpxrc;
}
else {
printf("Config query -adm_threads = %s\n",myparmstruct.co.co_string);
}
return 0;
}
Example 2: The following example
shows an API to query the syslevel.
#pragma linkage(BPX1PCT, OS)
extern void BPX1PCT(char *, int, int, char *, int *, int *, int *);
#include <stdio.h>
#include <string.h>
#define ZFSCALL_CONFIG 0x40000006
#define CFGOP_QUERY_SYSLEVEL 238 /* Query Config option - syslevel */
#define NO_SYSPLEX_SUPPORT 0 /* Not in a sysplex shared file system environment */
#define SYSPLEX_ADMIN_LEVEL 1 /* Admin level sysplex shared file system environment */
#define SYSPLEX_FILE_LEVEL 2 /* File level sysplex shared file system environment */
#define SYSPLEX_FILESYS_LEVEL 3 /* Sysplex-aware on a File system basis */
typedef struct syscall_parmlist_t {
int opcode; /* Operation code to perform */
int parms[7]; /* Specific to type of operation, */
/* provides access to the parms */
/* parms[4]-parms[6] are currently unused*/
} syscall_parmlist;
typedef struct config_option_t {
char co_eye[4]; /* Eye catcher */
#define CFGO_EYE "CFOP"
short co_len; /* Length of structure */
char co_ver; /* Version of structure */
#define CO_VER_INITIAL 1 /* Initial version */
#define CO_SLEN 80 /* Sizeof string */
char co_string[CO_SLEN+1]; /* String value for option must be 0 terminated */
int co_value[4]; /* Place for integer vaalues */
char co_reserved[24]; /* Reserved for future use */
} CFG_OPTION;
struct parmstruct {
syscall_parmlist myparms;
CFG_OPTION co;
char system[9];
} myparmstruct;
int main(int argc, char **argv)
{
int bpxrv;
int bpxrc;
int bpxrs;
CFG_OPTION *coptr = &(myparmstruct.co);
char * version, * service, * created, * sysplex, * interface, * rwshare_default, * rest;
int sysplex_level;
/* strcpy(myparmstruct.system,"DCEIMGVN"); */ /* set system to query */
myparmstruct.myparms.opcode = CFGOP_QUERY_SYSLEVEL;
myparmstruct.myparms.parms[0] = sizeof(syscall_parmlist);
myparmstruct.myparms.parms[1] = 0;
/* myparmstruct.myparms.parms[1] = sizeof(syscall_parmlist) + sizeof(CFG_OPTION); */
myparmstruct.myparms.parms[2] = 0;
myparmstruct.myparms.parms[3] = 0;
myparmstruct.myparms.parms[4] = 0;
myparmstruct.myparms.parms[5] = 0;
myparmstruct.myparms.parms[6] = 0;
memset(coptr,0,sizeof(CFG_OPTION));
memcpy(coptr->co_eye,CFGO_EYE,4);
coptr->co_ver=CO_VER_INITIAL;
coptr->co_len=(int) sizeof(CFG_OPTION);
BPX1PCT("ZFS ",
ZFSCALL_CONFIG, /* Config operation */
sizeof(myparmstruct), /* Length of Argument */
(char *) &myparmstruct, /* Pointer to Argument */
&bpxrv, /* Pointer to Return_value */
&bpxrc, /* Pointer to Return_code */
&bpxrs); /* Pointer to Reason_code */
if (bpxrv < 0) {
printf("Error querying config -syslevel, BPXRV = %d BPXRC = %d BPXRS = %x\n",bpxrv,bpxrc,bpxrs);
return bpxrc;
}
else {
/* Parse our configquery string */
/* format is */
/* Prior to R11 APAR OA29619 or when sysplex=filesys not specified */
/* OSlevel\nServicelevel\ncreatetimestamp\nsysplex_state\ninterface_level\0 */
/* -or- */
/* OSlevel\nServicelevel\ncreatetimestamp\nsysplex_state\ninterface_level\n\0 */
/* After R11 APAR OA29619 and when sysplex=filesys is specified */
/* OSlevel\nServicelevel\ncreatetimestamp\nsysplex_state\ninterface_level\nrwshare_default\0 */
version = myparmstruct.co.co_string;
service = strchr(version, '\n'); /* find the end of the version (for 2nd line) */
*service = '\0'; /* ensure end of string for version string */
service++; /* increment to next field (service) */
created = strchr(service, '\n'); /* find the end of the service (for 2nd line) */
*created = '\0'; /* ensure end of string for service string */
created++; /* increment to next field (creation) */
sysplex = strchr(created, '\n'); /* find the end of the creation timestamp */
*sysplex = '\0'; /* ensure end of string for creation string */
sysplex++; /* increment to next field (sysplex_state) */
interface = strchr(sysplex, '\n'); /* find end of the sysplex_state */
*interface = '\0'; /* ensure end of string for sysplex_state */
interface++; /* increment to next field (interface level) */
sysplex_level = atoi(sysplex);
if (sysplex_level == NO_SYSPLEX_SUPPORT)
{
printf("zFS kernel: z/OS File System\nVersion %s Service Level %s.\nCreated \
on %s.\n",version,service,created);
}
else
{
char buffer[80];
rwshare_default = strchr(interface, '\n'); /* find the end of the interface */
if (rwshare_default!=NULL)
{
*rwshare_default = '\0';
rwshare_default++;
}
if (sysplex_level == SYSPLEX_ADMIN_LEVEL)
sprintf(buffer, "sysplex(admin-only) interface(%s)", interface);
else /* if sysplex_level is SYSPLEX_FILE_LEVEL */
if (sysplex_level == SYSPLEX_FILE_LEVEL)
sprintf(buffer, "sysplex(file) interface(%s)", interface);
else /* if sysplex_level is SYSPLEX_FILESYS_LEVEL */
{
if (sysplex_level == SYSPLEX_FILESYS_LEVEL)
{
rest = strchr(rwshare_default, '\n'); /* find the end of rwshare_default */
if (rest!=NULL)
*rest = '\0'; /* ensure that rwshare_default is null terminated */
sprintf(buffer, "sysplex(filesys,%s) interface(%s)", rwshare_default, interface);
}
else
sprintf(buffer, "sysplex(%s) interface(%s)", sysplex, interface);
}
printf("zFS kernel: z/OS File System\nVersion %s Service Level %s.\nCreated \
on %s.\n%s\n",version,service,created,buffer);
}
}
return 0;
}