List Systems

Purpose

Retrieves the system names that are part of the zFS XCF group.

Format

Start of change
syscall_parmlist
   opcode            int                174     CFGOP_LSSYS
   parms[0]          int                size of buffer
   parms[1]          int                offset to buffer
   parms[2]          int                offset to bytes returned
   parms[3]          int                0
   parms[4]          int                0
   parms[5]          int                0
   parms[6]          int                0
buffer               char[ ]
bytes_returned       int

Return_value     0 if request successful, -1 if it is not successful

Return_code
  E2BIG D        Data to return is too large for buffer supplied
  EINTR          ZFS is shutting down
  EMVSERR        Internal error
  ERANGE         No systems to return

Reason_code
  0xEFnnxxx      See z/OS Distributed File Service Messages and Codes
End of change

Usage notes

  • Reserved fields and undefined flags must be set to binary zeros.
  • Start of changeAn array of char[9] fields is returned in buffer. Each element in the array contains a NULL-terminated string with a system name.End of change
  • Start of changeBytes_returned / 9 is the number of elements in the array.End of change

Privilege required

None.

Related services

  • Query sysplex_state

Restrictions

None.

Examples

Start of change
#pragma linkage(BPX1PCT, OS)
#pragma LANGLVL(EXTENDED)

extern void BPX1PCT(char *, int, int, char *, int *, int *, int *);

#include <stdio.h>

#define ZFSCALL_CONFIG 0x40000006
#define CFGOP_LSSYS 174 /* List names of systems in the sysplex */
#define E2BIG 145       /* data to return is too big for buffer */
#define ERANGE 2        /* there were no systems to return */

typedef struct system_name_t {
  char sys_name[9];   /* 8 byte name, null terminated */
} SYSTEM_NAME;

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;

struct parmstruct {
  syscall_parmlist myparms;
  /* SYSTEM_NAME buffer[32]; */ 

  /* output buffer for sysnames */
  int              size;
} myparmstruct;

int main(int argc, char **argv)
{
  int               buffer_success = 0;
  int               bpxrv;
  int               bpxrc;
  int               bpxrs;
  int               i,t;
  struct parmstruct *myp    = &myparmstruct;
  int               mypsize,
                    buflen;

  myparmstruct.myparms.opcode = CFGOP_LSSYS;
  myparmstruct.myparms.parms[0] = 0;                  /* size of buffer */
  myparmstruct.myparms.parms[1] = 0;                  /* offset to buffer */
  myparmstruct.myparms.parms[2] = sizeof(syscall_parmlist); /*offset to size*/
                                                            /*(required size)*/
  myparmstruct.myparms.parms[3] = 0;
  myparmstruct.myparms.parms[4] = 0;
  myparmstruct.myparms.parms[5] = 0;
  myparmstruct.myparms.parms[6] = 0;

  BPX1PCT("ZFS     ",
          ZFSCALL_CONFIG,             /* Config query 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 */

  for(t = 0; t < 1000 && buffer_success == 0; t++)
  {
    if (bpxrv < 0) 
    {
      if (bpxrc == E2BIG) 
      {
        buflen = myparmstruct.size; /* Get buffer size needed */
        mypsize = sizeof(syscall_parmlist) + 
                  buflen + 
                  sizeof(myparmstruct.size);
        
        free(myp);

        myp = (struct parmstruct *)malloc((int)mypsize);
        memset(myp, 0, mypsize);

        myp->myparms.opcode = CFGOP_LSSYS;
        myp->myparms.parms[0] = buflen;                             
        myp->myparms.parms[1] = sizeof(syscall_parmlist);           
        myp->myparms.parms[2] = sizeof(syscall_parmlist) + buflen;  
        myp->myparms.parms[3] = 0;
        myp->myparms.parms[4] = 0;
        myp->myparms.parms[5] = 0;
        myp->myparms.parms[6] = 0;

        BPX1PCT("ZFS     ",
                ZFSCALL_CONFIG,     /* Config query operation */
                mypsize,            /* Length of Argument */
                (char *)myp,        /* Pointer to Argument */
                &bpxrv,             /* Pointer to Return_value */
                &bpxrc,             /* Pointer to Return_code */
                &bpxrs);            /* Pointer to Reason_code */

        if( bpxrv != 0 && bpxrc == E2BIG )
          printf("E2BIG: %d times total\n", t++);
        else if( bpxrv == 0 )
        {
          buffer_success = 1;
          int         j, syscount;
          SYSTEM_NAME *syslist;
          int         *sizep;

          sizep   = (int *)((int)myp + sizeof(syscall_parmlist) + buflen);
          syslist = (SYSTEM_NAME * )((int)myp + sizeof(syscall_parmlist));
          syscount = (*sizep) / sizeof(SYSTEM_NAME);

          for (j = 1; j <= syscount; j++) 
          {
            printf("%-8.8s\n", syslist->sys_name);
            syslist++;
          }
          free(myp);
        } 
        else 
        { /* lssys failed with large enough buffer */
          if (bpxrc == ERANGE) 
            printf("No systems to display\n");
          else 
          {
            printf("Error on lssys with large enough buffer\n");
            printf("BPXRV = %d BPXRC = %d BPXRS = %x\n", bpxrv, bpxrc, bpxrs);
          }
          free(myp);
          return bpxrc;
        }
      } 
      else 
      { /* error was not E2BIG on the original BPX1PCT */
        if (bpxrc == ERANGE) 
          printf("No systems to display from original BPX1PCT\n");
        else 
        {
          printf("Error on lssys trying to get required size\n");
          printf("BPXRV = %d BPXRC = %d BPXRS = %x\n", bpxrv, bpxrc, bpxrs);
        }
        free(myp);
        return bpxrc;
      }
    } 
    else 
    { /* asking for buffer size gave rv = 0; maybe there is no data */
      if (myparmstruct.size == 0) 
      {
        printf("No data\n");
        printf("BPXRV = %d BPXRC = %d BPXRS = %x\n", bpxrv, bpxrc, bpxrs);
      } 
      else 
      { /* No, there was some other problem with getting the size needed */
        printf("Error getting size required\n");
        printf("BPXRV = %d BPXRC = %d BPXRS = %x\n", bpxrv, bpxrc, bpxrs);
      }
      free(myp);
      return bpxrc;
    }
  }

  if( t == 1000 )
    printf("Number of failed buffer resizes exceeded.\n");

  free(myp);
  return 0;
}
End of change