#ifndef __STAT_LOADED #define __STAT_LOADED 1 /**************************************************************************** ** ** - stat/fstat UNIX emulation functions ** ***************************************************************************** ** Header introduced by the ISO POSIX-1 Standard ***************************************************************************** */ /* ************************************************************************* */ /* * * */ /* * HPE CONFIDENTIAL. This software is confidential proprietary software * */ /* * licensed by Hewlett Packard Enterprise Development, LP, and is not * */ /* * authorized to be used, duplicated or disclosed to anyone without the * */ /* * prior written permission of HPE. * */ /* * Copyright 2017 Hewlett Packard Enterprise Development, LP * */ /* * * */ /* * VMS SOFTWARE, INC. CONFIDENTIAL. This software is confidential * */ /* * proprietary software licensed by VMS Software, Inc., and is not * */ /* * authorized to be used, duplicated or disclosed to anyone without * */ /* * the prior written permission of VMS Software, Inc. * */ /* * Copyright 2017-2020 VMS Software, Inc. * */ /* * * */ /* ************************************************************************* */ #pragma __nostandard #include #ifdef __cplusplus extern "C" { #endif #if __INITIAL_POINTER_SIZE # pragma __pointer_size __save # pragma __pointer_size 32 #endif /* ** Create 'public' typedefs that are either insensitive to pointer or are ** sensitive to pointer size and must use short pointers. */ /* ** X/Open definitions */ #if defined _XOPEN_SOURCE || (!defined _POSIX_C_SOURCE && !defined _DECC_V4_SOURCE) # ifndef __TIME_T # define __TIME_T 1 #ifdef __NAMESPACE_STD namespace std { #endif typedef __time_t time_t; #ifdef __NAMESPACE_STD } /* namespace std */ using std::time_t; #endif # endif # ifndef __DEV_T # define __DEV_T 1 typedef __dev_t dev_t; # endif # ifndef __INO_T # define __INO_T 1 typedef __ino_t ino_t; # endif # ifndef __NLINK_T # define __NLINK_T 1 typedef __nlink_t nlink_t; # endif # ifndef __MODE_T # define __MODE_T 1 typedef __mode_t mode_t; # endif # ifndef __OFF_T # define __OFF_T 1 typedef __off_t off_t; # endif # ifndef __UID_T # define __UID_T 1 typedef __uid_t uid_t; # endif # ifndef __GID_T # define __GID_T 1 # if __USE_LONG_GID_T typedef __gid32_t gid_t; # else typedef __gid16_t gid_t; # endif # endif #endif /* ** Define some macros to use to access the component fields of ino values. ** S_ names are those intended for application use; _S_ names are internal. ** S_INO_NUM - file number ** S_INO_SEQ - file sequence number ** S_INO_RVN - relative volume number ** S_INO_RVN_NMX - file number extension, portion of S_INO_RVN ** S_INO_RVN_RVN - relative volume number portion of S_INO_RVN */ #if __USING_STD_STAT # define _S_INO_NUM_MASK 0x000000000000FFFF # define _S_INO_SEQ_MASK 0x00000000FFFF0000 # define _S_INO_RVN_MASK 0x0000FFFF00000000 # define _S_INO_RVN_RVN_MASK 0x000000FF00000000 # define _S_INO_RVN_NMX_MASK 0x0000FF0000000000 # define S_INO_NUM(ino) ((unsigned short)((ino)&_S_INO_NUM_MASK)) # define S_INO_SEQ(ino) ((unsigned short)(((ino)&_S_INO_SEQ_MASK)>>16)) # define S_INO_RVN(ino) ((unsigned short)(((ino)&_S_INO_RVN_MASK)>>32)) # define S_INO_RVN_RVN(ino) ((unsigned char)(((ino)&_S_INO_RVN_RVN_MASK)>>32)) # define S_INO_RVN_NMX(ino) ((unsigned char)(((ino)&_S_INO_RVN_NMX_MASK)>>40)) #else # define _S_INO_RVN_RVN_MASK 0x00FF # define _S_INO_RVN_NMX_MASK 0xFF00 # define S_INO_NUM(ino) ((unsigned short)((ino)[0])) # define S_INO_SEQ(ino) ((unsigned short)((ino)[1])) # define S_INO_RVN(ino) ((unsigned short)((ino)[2])) # define S_INO_RVN_RVN(ino) ((unsigned char)(S_INO_RVN(ino)&_S_INO_RVN_RVN_MASK)) # define S_INO_RVN_NMX(ino) ((unsigned char)((S_INO_RVN(ino)&_S_INO_RVN_NMX_MASK)>8)) #endif /* ** This is the beginning of the standard stat structure definition. ** It is in effect if feature macro _USE_STD_STAT is defined. */ #if __USING_STD_STAT /* ** Define the size of the output buffer for $GETDVI item DVI$_ALLDEVNAM. */ # define __ALLDEVNAM_LEN 64 /* ** Define the number of quadwords held in reserve at the tail of the ** new stat struct, for HP's future use. */ # define __STD_STAT_QWORDS_RESERVED 20 /* ** Define some macros that will assist us in the stat structure definition. ** These automate the naming and sizing of the fill fields. ** The __USING_64BIT_TIME_T macro is set in decc$types.h. */ # define __MODE_FILL_SIZE (sizeof(int) - sizeof(__mode_t)) # define __MODEFILL(mem) char mem ## Fill [__MODE_FILL_SIZE]; # if __USING_64BIT_TIME_T # define __TIMEFILL(mem) # else # define __TIME_FILL_SIZE (sizeof(__int64) - sizeof(__time_t)) # define __TIMEFILL(mem) char mem ## Fill [__TIME_FILL_SIZE]; # endif # pragma __member_alignment __save # pragma __member_alignment struct stat { __dev_t st_dev; /* device id */ __ino_t st_ino; /* file number */ __mode_t st_mode; /* file mode */ __MODEFILL( st_mode) __nlink_t st_nlink; /* number of hard links */ __uid_t st_uid; /* user id */ __gid_t st_gid; /* group id */ __dev_t st_rdev; __off_t st_size; /* file size in bytes */ __time_t st_atime; /* file access time */ __TIMEFILL( st_atime) __time_t st_mtime; /* file mod time */ __TIMEFILL( st_mtime) __time_t st_ctime; /* file creation time */ __TIMEFILL( st_ctime) char st_fab_rfm; /* record format */ char st_fab_rat; /* record attributes */ char st_fab_fsz; /* fixed header size */ char st_fabFill; unsigned st_fab_mrs; /* record size */ blksize_t st_blksize; /* filesystem-specific preferred I/O block size for this file */ blkcnt_t st_blocks; /* number of blocks allocated for this file */ char st_reserved[sizeof(__int64)*__STD_STAT_QWORDS_RESERVED]; }; # pragma __member_alignment __restore #else /* end of __USING_STD_STAT section */ /* ** There are two definitions of the stat structure. The first ** is intended for newly compiled applications and is larger ** than the traditional structure. ** ** The new structure has aligned fields and has a fixed size. ** It contains padding for elements shorter than type int, ** and in some cases where a field may have 2 sizes such as ** st_size and st_gid. It also has spare fields at the end for ** future expansion. ** ** The traditional structure is for use when passing pointers ** to stat structures with previously compiled objects. This ** structure does not have aligned elements. Its size varies, ** depending on whether datatype gid_t is short or long. ** ** Note that times are given in units of seconds since the ** Epoch i.e. times returned are measured in seconds since ** 00:00:00 GMT, Jan. 1, 1970. ** ** ISO POSIX-1 defines off_t to be a signed arithmetic type, and ** requires the st_size field to be of type off_t. DEC C V5.0 ** and prior declared the field as unsigned. */ #if __USE_OFF64_T /* ** This is the new stat structure. It has aligned fields, ** extra padding to allow fields to expand and extra space at ** the end for future expansion. */ #pragma __member_alignment __save #pragma member_alignment struct stat { __dev_t st_dev; /* pointer to physical device name */ __dev_t st_fill_dev; #if __USE_INO64 __ino64_t st_ino; #elif __USE_INO32 __ino32_t st_ino; __ino32_t st_fill_ino; #else __ino16_t st_ino[3]; /* 3 words to receive fid */ __ino16_t st_fill_ino; /* spare word for fill */ #endif __mode_t st_mode; /* file "mode" i.e. prot, dir, reg, etc. */ __mode_t st_fill_mode; /* fill because mode_t is defined as short */ __nlink_t st_nlink; /* number of hard links */ __uid_t st_uid; /* from ACP - QIO uic field */ # if __USE_LONG_GID_T __gid32_t st_gid; /* long group number from POSIX_OWNER ACE */ # else __gid16_t st_gid; /* short group number extracted st_uid*/ __gid16_t st_fill_gid; /* padding because short GID is only 16 bits */ # endif # if defined _XOPEN_SOURCE || !defined _POSIX_C_SOURCE __dev_t st_rdev; /* for compatibility - always zero */ # else __dev_t st_fill_rdev; /* padding when st_rdev is not defined */ # endif # if defined _DECC_V4_SOURCE unsigned int st_size; /* file size in bytes, was unsigned */ int st_fill_size; /* padding */ # else __off64_t st_size; /* file size in bytes */ # endif __time_t st_atime; /* file access time; always same as st_mtime */ __time_t st_fill_atime; /* padding */ __time_t st_mtime; /* last modification time */ __time_t st_fill_mtime; /* padding */ __time_t st_ctime; /* file creation time */ __time_t st_fill_ctime; /* padding */ # ifndef _POSIX_C_SOURCE char st_fab_rfm; /* record format */ char st_fab_rat; /* record attributes */ char st_fab_fsz; /* fixed header size */ char st_fab_fill; /* padding */ unsigned int st_fab_mrs; /* record size */ # else char st_fill_fab[4]; unsigned int st_fill_mrs; # endif int st_fill_expand[8]; /* room for expansion */ }; # pragma __member_alignment __restore #else /* ** This is the traditional stat structure. Its size varies depending ** on whether long or short gid_t is being used. */ /* ** Disable warning messages */ # pragma __message __save # pragma __message __disable (__MISALGNDSTRCT) # pragma __message __disable (__MISALGNDMEM) /* ** Do not naturally align older data structures */ # pragma __member_alignment __save # pragma __nomember_alignment struct stat { __dev_t st_dev; /* pointer to physical device name */ __ino16_t st_ino[3]; /* 3 words to receive fid */ __mode_t st_mode; /* file "mode" i.e. prot, dir, reg, etc. */ __nlink_t st_nlink; /* number of hard links */ __uid_t st_uid; /* from ACP - QIO uic field */ #if __USE_LONG_GID_T __gid32_t st_gid; /* long group number from POSIX_OWNER ACE */ #else __gid16_t st_gid; /* short group number extracted st_uid */ #endif # if defined _XOPEN_SOURCE || !defined _POSIX_C_SOURCE __dev_t st_rdev; /* for compatibility - always zero */ # else __dev_t st_fill1; # endif # if defined _DECC_V4_SOURCE unsigned int st_size; /* file size in bytes, was unsigned */ # else __off32_t st_size; /* file size in bytes */ # endif __time_t st_atime; /* file access time; always same as st_mtime */ __time_t st_mtime; /* last modification time */ __time_t st_ctime; /* file creation time */ # ifndef _POSIX_C_SOURCE char st_fab_rfm; /* record format */ char st_fab_rat; /* record attributes */ char st_fab_fsz; /* fixed header size */ unsigned int st_fab_mrs; /* record size */ # else char st_fill2[3]; unsigned int st_fill3; # endif }; # pragma __message __restore # pragma __member_alignment __restore #endif #endif /* __USING_STD_STAT */ /* ** DEC C extensions */ #ifndef _POSIX_C_SOURCE typedef struct stat stat_t; #endif /* ** Private definitions */ #define __S_IFMT 0170000 /* type of file */ #define __S_IFIFO 0010000 /* pipe or fifo */ #define __S_IFDIR 0040000 /* directory */ #define __S_IFCHR 0020000 /* character special */ #define __S_IFBLK 0060000 /* block special */ #define __S_IFREG 0100000 /* regular */ #define __S_IFMPC 0030000 /* multiplexed char special */ #define __S_IFMPB 0070000 /* multiplexed block special */ #define __S_IFSOCK 0140000 /* socket */ #define __S_IFLNK 0120000 /* symbolic link */ /* ** ISO POSIX-1 definitions */ #define S_ISUID 0004000 /* set user id on execution */ #define S_ISGID 0002000 /* set group id on execution */ #define S_IRWXU 0000700 /* read,write,execute perm: owner */ #define S_IRUSR 0000400 /* read permission: owner */ #define S_IWUSR 0000200 /* write permission: owner */ #define S_IXUSR 0000100 /* execute/search permission: owner */ #define S_IRWXG 0000070 /* read,write,execute perm: group */ #define S_IRGRP 0000040 /* read permission: group */ #define S_IWGRP 0000020 /* write permission: group */ #define S_IXGRP 0000010 /* execute/search permission: group */ #define S_IRWXO 0000007 /* read,write,execute perm: other */ #define S_IROTH 0000004 /* read permission: other */ #define S_IWOTH 0000002 /* write permission: other */ #define S_IXOTH 0000001 /* execute/search permission: other */ #define S_ISFIFO(m) (((m)& __S_IFMT) == __S_IFIFO) #define S_ISDIR(m) (((m)& __S_IFMT) == __S_IFDIR) #define S_ISCHR(m) (((m)& __S_IFMT) == __S_IFCHR) #define S_ISBLK(m) (((m)& __S_IFMT) == __S_IFBLK) #define S_ISREG(m) (((m)& __S_IFMT) == __S_IFREG) /* ** X/Open XPG4 definitions */ #if defined _XOPEN_SOURCE || !defined _POSIX_C_SOURCE # define S_IFMT __S_IFMT /* type of file */ # define S_IFIFO __S_IFIFO /* pipe or fifo */ # define S_IFDIR __S_IFDIR /* directory */ # define S_IFCHR __S_IFCHR /* character special */ # define S_IFBLK __S_IFBLK /* block special */ # define S_IFREG __S_IFREG /* regular */ #endif /* ** X/Open XPG4 V2 definitions */ #if defined _XOPEN_SOURCE_EXTENDED || !defined _POSIX_C_SOURCE # define S_IFSOCK __S_IFSOCK /* socket */ # define S_IFLNK __S_IFLNK /* symbolic link */ # define S_ISLNK(m) (((m)& S_IFMT) == S_IFLNK) # define S_ISSOCK(m) (((m)& S_IFMT) == S_IFSOCK) # define S_ISVTX 0001000 /* save swapped text even after use */ #endif /* ** DEC C extensions */ #ifndef _POSIX_C_SOURCE # define S_IREAD 0000400 /* read permission, owner */ # define S_IWRITE 0000200 /* write permission, owner */ # define S_IEXEC 0000100 /* execute/search permission, owner */ # define S_IFMPC __S_IFMPC /* multiplexed char special */ # define S_IFMPB __S_IFMPB /* multiplexed block special */ #endif /* ** We are done defining things which must always be short pointers. If ** the user has used /pointer_size=short or /pointer_size=long, we will ** allow long pointers to be used in function calls. */ #if __INITIAL_POINTER_SIZE # pragma __pointer_size 64 #endif #if __USING_STD_STAT # pragma __extern_prefix __save # pragma __extern_prefix "__std_" #else #if __USE_OFF64_T # pragma __extern_prefix __save # if __USE_LONG_GID_T # pragma __extern_prefix "__off64_long_gid_" # elif !defined _VMS_V6_SOURCE # pragma __extern_prefix "__off64_utc_" # else # pragma __extern_prefix "__off64_" # endif #elif __USE_LONG_GID_T /* ** On Alpha, beginning in version of OpenVMS Alpha following V7.3, stat ** and fstat support 32-bit gid_t datatype. The stat and fstat functions ** supporting long gid_t datatype can return UTC time only. If local time ** is required, define _VMS_V6_SOURCE macro. Defining _DECC_SHORT_GID_T ** or _VMS_V6_SOURCE macro causes DEC C RTL to use 16-bit gid_t datatype. */ # pragma __extern_prefix __save # pragma __extern_prefix "__long_gid_" #elif __CRTL_VER >= 70000000 /* ** Beginning in OpenVMS Version 7.0 stat has two implementations. ** One for compatibility stat() which returns time in terms of ** local time and one __utc_stat() which returns time in terms of UTC. */ # if !defined _VMS_V6_SOURCE # ifdef __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __save # pragma __extern_prefix "__utc_" # else # define stat(__p1,__p2) __utc_stat(__p1,__p2) # define fstat(__p1,__p2) __utc_fstat(__p1,__p2) # if __CRTL_VER >= 70301000 # define lstat(__p1,__p2) __utc_lstat(__p1,__p2) # endif # endif # endif #endif /* __USE_OFF64_T */ #endif /* __USING_STD_STAT */ /* ** Function prototypes */ int fstat (int __file_desc, struct stat *__buffer); /* ** If we cannot use extern prefix, then the user cannot get the ellipsis form ** of the prototype. Applications which must use the optional arguments may ** either upgrade the compiler or change the call site to use decc$stat or ** decc$__utc_stat instead of stat. */ #if (defined _POSIX_C_SOURCE) || (!defined __CAN_USE_EXTERN_PREFIX) int stat (const char *__path, struct stat *__buf); # if __CRTL_VER >= 70301000 int lstat (const char *__path, struct stat *__buf); # endif #else int stat (const char *__path, struct stat *__buf, ...); # if __CRTL_VER >= 70301000 int lstat (const char *__path, struct stat *__buf, ...); # endif #endif /* ** Disable extern_prefix if we enabled it earlier */ #if __USING_STD_STAT # pragma __extern_prefix __restore #else #if __USE_LONG_GID_T || __USE_OFF64_T # pragma __extern_prefix __restore #elif __CRTL_VER >= 70000000 # if !defined _VMS_V6_SOURCE # ifdef __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __restore # endif # endif #endif #endif #if __USE_LONG_GID_T # pragma __extern_prefix __save # pragma __extern_prefix "__long_gid_" #endif int chmod (const char *__file_spec, __mode_t __mode); int fchmod (int __fd, __mode_t __mode); #if __USE_LONG_GID_T # pragma __extern_prefix __restore #endif __mode_t umask (__mode_t __old_mask); #ifdef _POSIX_C_SOURCE int mkdir (const char *__dir_spec, __mode_t __mode); #else int mkdir (const char *__dir_spec, __mode_t __mode, ...); #endif /* ** Restore the users pointer context */ #if __INITIAL_POINTER_SIZE # pragma __pointer_size __restore #endif #ifdef __cplusplus } #endif #pragma __standard #endif /* __STAT_LOADED */