Chapter Contents

Previous

Next
sfsstat

sfsstat



Return Information about a CMS Shared File System File or Directory

Portability: SAS/C extension


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
IMPLEMENTATION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <cmsstat.h>

int sfsstat(const char *path, struct sfsstat *buf);


DESCRIPTION

The sfsstat function fills in an sfsstat structure with system-dependent information about a Shared File System (SFS) file or directory. You can specify the path parameter as any name in the sf or sfd style. The buf parameter must point to an sfsstat structure as defined in <cmsstat.h> . The sfsstat structure is defined as

struct sfsstat {
  time_t        st_updt;     /* date and time last updated     */
  time_t        st_crdt;     /* date and time file was created */
  unsigned int  st_type;     /* device type flag               */
                             /*  S_DISK - disk file            */
                             /*  S_SFS -shared file system file*/
                             /*  S_SFSDIR - sfs directory      */
                             /*  S_DIRCNTL -sfs dircontrol dir */
                             /*  S_FILCNTL -sfs filecontrol dir*/
  char  st_owner[9];         /* null-terminated owner id       */
  char  st_dir[154]          /* null-terminated directory name */
  char  st_fname[9];         /* null-terminated CMS filename   */
  char  st_ftype[9];         /* null-terminated CMS filetype   */
  char  st_fmno[2];          /* null-terminated CMS fm number  */
  char  st_flags;            /* access flags                   */
                             /*  S_RW  - read/write            */
                             /*  S_RO  - only readable         */
                             /*  S_NO  - not read or write     */
                             /*  S_EP  - externally protected  */
  int           st_dirlen;   /* length of directory name       */
  int           st_numblks;  /* number of blocks in file       */
  unsigned int  st_lrecl;    /* logical record length (LRECL)  */
  int           st_norecs;   /* number of logical records      */
  char          st_recfm;    /* record format (RECFM)          */
  char          st_status;   /* '1'= base, '2'= alias,         */
                             /*  '3'= erased, '4'=revoked      */
  char          st_dirauth;  /* special directory authorities  */
                             /*  S_NR  - NewRead auth on dir   */
                             /*  S_NW  - NewWrite auth on dir  */
                             /*  S_AR  - Accessed Read only    */
                             /*  S_AW  - Accessed Write        */
  char          st_resrv1;   /* reserved                       */
  unsigned int  st_resrv2;   /* reserved                       */
  unsigned int  st_resrv3;   /* reserved                       */
  unsigned int  st_resrv4;   /* reserved                       */
  unsigned int  st_resrv5;   /* reserved                       */
  };

The st_type flag can have one of, or a combination of, these values:
S_DISK indicates a CMS disk file.
S_SFS indicates an SFS file.
S_SFSDIR indicates an SFS directory.
S_DIRCNTL indicates an SFS directory-control directory.
S_FILCNTL indicates an SFS file-control directory.

The st_flags access flag can have one of these values:
S_RW indicates read or write authority to a file or directory.
S_RO indicates only read authority to a file or directory.
S_NO indicates no authority to a file or directory.
S_EP indicates a file or directory is externally protected.

The st_status flag can have one of these values:
1 indicates the file is a base file.
2 indicates the file is an alias.
3 indicates the file is erased.
4 indicates the authority for the file is revoked.

The st_dirauth flag can have one of, or a combination of, these values:
S_NR indicates new-read authority to the directory.
S_NW indicates new-write authority to the directory.
S_AR indicates the directory is accessed as a minidisk in read-only status.
S_AW indicates the directory is accessed as a minidisk in read or write status.


RETURN VALUE

If the file exists and the program has at least read authority to the parent directory and the file, sfsstat returns 0 and fills in the appropriate fields in the sfsstat structure. If the file does not exist, the program has insufficient authority, or the fileid is invalid, sfsstat returns -1.


CAUTION

Some fields in the sfsstat structure may not be useful for all successful calls to sfsstat . For some files, some of the fields of the sfsstat structure are not applicable or are unavailable in some releases of CMS.

The values returned for each such field are

Function Return Values
sfsstat.st_updt ( time_t ) - 1
sfsstat.st_crdt ( time_t ) - 1
sfsstat.st_fname " "
sfsstat.st_ftype " "
sfsstat.st_fmno " "
sfsstat.st_recfm 0xffff
sfsstat.st_lrcel 0xffff
sfsstat.st_numblks - 1
sfsstat.st_norecs - 1
sfsstat.st_status 0xffff
st_dirauth '\0'

Fields in the sfsstat structure may have been modified, even if the function returns -1.


IMPLEMENTATION

The CMS callable services library routine DMSEXIST is invoked.


EXAMPLE

#include <cmsstat.h>
#include <stdio.h>

main()
{
   struct sfsstat info;
   int rc;
   rc = sfsstat("sf:my file cuser.subdir1", &info);
   if (rc == 0){
      puts("access field (auth)");
      if (info.st_flags == S_RW)
         puts("   st_flags   = S_RW");
      if ((info.st_flags & S_RO) ==      S_RO)
         puts("   st_flags   = S_RO");
      if ((info.st_flags & S_NO) ==      S_NO)
         puts("   st_flags   = S_NO");
      if ((info.st_flags & S_EP) ==      S_EP)
         puts("   st_flags   = S_EP");
   }
   return rc;
}


RELATED FUNCTIONS

cmsstat


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.