List File System Names (Version 2)

Purpose

An aggregate operation that returns the names of the zFS file systems that are contained in a specified aggregate on this system and their corresponding z/OS® UNIX file system names (if they are mounted). The specified aggregate must be attached.

Start of changeIBM recommends using the List Detailed File System Information API instead of List Aggregate Status or List File System Status. End of change

Format

Start of change
syscall_parmlist
   opcode                  int              144       AGOP_LISTFSNAMES_PARMDATA2
   parms[0]                int              offset to AGGR_ID
   parms[1]                int              buffer length or 0
   parms[2]                int              offset to buffer or 0
   parms[3]                int              offset to size
   parms[4]                int              0
   parms[5]                int              0
   parms[6]                int              0
AGGR_ID
   aid_eye                 char[4]          "AGID"
   aid_len                 char             sizeof(AGGR_ID)
   aid_ver                 char             1
   aid_name                char[45]         "OMVS.PRV.AGGR001.LDS0001"
   aid_reserved            char[33]         0
FS_ID2[n]                                   Array of FS_ID2s (n can be zero)
   fsid_eye                char[4]          "FSID"
   fsid_len                char             sizeof(FS_ID2)
   fsid_ver                char             2
   fsid_res1               char             0
   fsid_res2               char             0
   fsid_id
     high                  unsigned int
     low                   unsigned int
   fsid_aggrname           char[45]
   fsid_name               char[45]
   fsid_mtname             char[45]
   fsid_reserved           char[49]
size                       int

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

Return_code
  EINTR         ZFS is shutting down
  EINVAL        Invalid parameter list
  EMVSERR       Internal error using an osi service
  ENOENT        Aggregate is not attached
  E2BIG         List is too big for buffer supplied

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

Usage notes

  • The version 2 List File System Names returns an array of FS_ID2s.
  • Reserved fields and undefined flags must be set to binary zeros.

Privilege required

None.

Related services

  • List Attached Aggregate Names
  • Start of changeList Detailed File System InformationEnd of change
  • List File System Status

Restrictions

When FS_ID2 is used, if you specify the z/OS UNIX file system name (fsid_mtname), you cannot specify the zFS file system name (fsid_name) nor the aggregate name (fsid_aggrname).

Examples

#pragma linkage(BPX1PCT, OS)
#pragma LANGLVL(EXTENDED)

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

#include <stdio.h>

#define ZFSCALL_AGGR 0x40000005
#define AGOP_LISTFSNAMES_PARMDATA2 144
#define E2BIG 145

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;

#define ZFS_MAX_AGGRNAME 44
#define ZFS_MAX_FSYSNAME 44

typedef struct aggr_id_t {
  char          aid_eye[4];                     /* Eye Catcher */
#define         AID_EYE "AGID"
  char          aid_len;                        /* Length of this structure */
  char          aid_ver;                        /* Version */
#define         AID_VER_INITIAL 1       
  char          aid_name[ZFS_MAX_AGGRNAME+1];   /* aggr name,null terminated */
  char          aid_reserved[33];               /* Reserved for the future */
} AGGR_ID;

typedef struct hyper {                          /* 64 bit integer to zFS */
  unsigned int  high;
  unsigned int  low;
} hyper;

typedef struct fs_id2_t {
  char          fsid_eye[4];                    /* Eye catcher */
#define         FSID_EYE "FSID"
  char          fsid_len;                       /* Length of this structure */
  char          fsid_ver;                       /* Version */
  char          fsid_res1;                      /* Reserved. */
  char          fsid_res2;                      /* Reserved. */
  hyper         fsid_id;                        /* Internal identifier */
#define         FSID_VER_2 2           
  char          fsid_aggrname[ZFS_MAX_AGGRNAME+1]; /* Aggregate name,    */
                                                   /* can be NULL string */
  char          fsid_name[ZFS_MAX_FSYSNAME+1];   /* Name, null terminated */
  char          fsid_mtname[ZFS_MAX_FSYSNAME+1]; /* Mount name, */ 
                                                 /* null terminated */
  char          fsid_reserved[49];               /* Reserved for the future */
} FS_ID2;

struct parmstruct {
  syscall_parmlist myparms;
  AGGR_ID          aggr_id;

  /* Real malloc'd structure will have an array of FS_ID2s here */
  int              size;
};

int main(int argc, char **argv) 
{
  int               buffer_success = 0;  
  int               bpxrv;
  int               bpxrc;
  int               bpxrs;
  int               t;
  struct parmstruct myparmstruct;
  AGGR_ID           *aggPtr;
  FS_ID2            *fsPtr;
  int               fsSize       = sizeof(FS_ID2);
  int               buflen       = sizeof(FS_ID2);
  struct parmstruct *myp         = &myparmstruct;
  int               mypsize;
  int               count_fs, total_fs;

  char              aggrname[45] = "PLEX.DCEIMGQX.FS";
  int               *p;
  
  memset(&myparmstruct.aggr_id, 0, sizeof(AGGR_ID)); /* Ensure reserved */
                                                     /* fields are 0    */
  memcpy(&myparmstruct.aggr_id.aid_eye, AID_EYE, 4);
  myparmstruct.aggr_id.aid_len = sizeof(AGGR_ID);
  myparmstruct.aggr_id.aid_ver = AID_VER_INITIAL;
  strcpy(myparmstruct.aggr_id.aid_name, aggrname);
  
  myparmstruct.myparms.opcode = AGOP_LISTFSNAMES_PARMDATA2;
  myparmstruct.myparms.parms[0] = sizeof(syscall_parmlist);
  myparmstruct.myparms.parms[1] = 0;
  myparmstruct.myparms.parms[2] = 0;
  myparmstruct.myparms.parms[3] = sizeof(syscall_parmlist) + sizeof(AGGR_ID);
  myparmstruct.myparms.parms[4] = 0;
  myparmstruct.myparms.parms[5] = 0;
  myparmstruct.myparms.parms[6] = 0;

  BPX1PCT("ZFS     ",
          ZFSCALL_AGGR,                 /* Aggregate 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 = myp->size;               /* Get buffer size needed */
        mypsize = buflen + 
                  sizeof(syscall_parmlist) +
                  sizeof(AGGR_ID) + 
                  sizeof(myparmstruct.size);

        free(myp);

        myp = (struct parmstruct *)malloc((int)mypsize);
        memset(myp, 0, mypsize);
        memcpy(myp->aggr_id.aid_eye, AID_EYE, 4);
        myp->aggr_id.aid_len = sizeof(AGGR_ID);
        myp->aggr_id.aid_ver = AID_VER_INITIAL;
        strcpy(myp->aggr_id.aid_name, aggrname);
      
        myp->myparms.opcode = AGOP_LISTFSNAMES_PARMDATA2;
        myp->myparms.parms[0] = sizeof(syscall_parmlist);
        myp->myparms.parms[1] = buflen;
        myp->myparms.parms[2] = sizeof(syscall_parmlist) + sizeof(AGGR_ID);
        myp->myparms.parms[3] = sizeof(syscall_parmlist) + 
                                sizeof(AGGR_ID) + buflen;
        myp->myparms.parms[4] = 0;
        myp->myparms.parms[5] = 0;
        myp->myparms.parms[6] = 0;
      
        BPX1PCT("ZFS     ",
                ZFSCALL_AGGR,     /* Aggregate 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;
          total_fs = buflen / fsSize;
          printf("total file systems = %d in aggregate %s\n", 
                 total_fs, aggrname);
          count_fs = 1;
          for (fsPtr = (FS_ID2*) & (myp->size); 
               count_fs <= total_fs; 
               fsPtr++, count_fs++) 
          {
            printf("\n");
            printf("zFS  file system name: [%s]\n", fsPtr->fsid_name);
            printf("UNIX file system name: [%s]\n", fsPtr->fsid_mtname);
          }
          free(myp);
        } 
        else 
        {   /* lsaggr names failed with large enough buffer */
          printf("Error on ls fs 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 */
        printf("Error on ls fs 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 are no file systems */
      if (myparmstruct.size == 0) 
        printf("No file systems\n");
      else /* No, there was some other problem with getting the size needed */
        printf("Error getting size required\n");
      
      free(myp);
      return bpxrc;
    }
  }

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

  free(myp);
  return 0;
}