1*2159047fSniklas /* The <sys/stat.h> header defines a struct that is used in the stat() and 2*2159047fSniklas * fstat functions. The information in this struct comes from the i-node of 3*2159047fSniklas * some file. These calls are the only approved way to inspect i-nodes. 4*2159047fSniklas */ 5*2159047fSniklas 6*2159047fSniklas #ifndef _STAT_H 7*2159047fSniklas #define _STAT_H 8*2159047fSniklas 9*2159047fSniklas #ifndef _TYPES_H /* not quite right */ 10*2159047fSniklas #include <sys/types.h> 11*2159047fSniklas #endif 12*2159047fSniklas 13*2159047fSniklas struct stat { 14*2159047fSniklas dev_t st_dev; /* major/minor device number */ 15*2159047fSniklas ino_t st_ino; /* i-node number */ 16*2159047fSniklas mode_t st_mode; /* file mode, protection bits, etc. */ 17*2159047fSniklas short int st_nlink; /* # links; TEMPORARY HACK: should be nlink_t*/ 18*2159047fSniklas uid_t st_uid; /* uid of the file's owner */ 19*2159047fSniklas short int st_gid; /* gid; TEMPORARY HACK: should be gid_t */ 20*2159047fSniklas dev_t st_rdev; 21*2159047fSniklas off_t st_size; /* file size */ 22*2159047fSniklas time_t st_atime; /* time of last access */ 23*2159047fSniklas time_t st_mtime; /* time of last data modification */ 24*2159047fSniklas time_t st_ctime; /* time of last file status change */ 25*2159047fSniklas }; 26*2159047fSniklas 27*2159047fSniklas /* Traditional mask definitions for st_mode. */ 28*2159047fSniklas #define S_IFMT 0170000 /* type of file */ 29*2159047fSniklas #define S_IFREG 0100000 /* regular */ 30*2159047fSniklas #define S_IFBLK 0060000 /* block special */ 31*2159047fSniklas #define S_IFDIR 0040000 /* directory */ 32*2159047fSniklas #define S_IFCHR 0020000 /* character special */ 33*2159047fSniklas #define S_IFIFO 0010000 /* this is a FIFO */ 34*2159047fSniklas #define S_ISUID 0004000 /* set user id on execution */ 35*2159047fSniklas #define S_ISGID 0002000 /* set group id on execution */ 36*2159047fSniklas /* next is reserved for future use */ 37*2159047fSniklas #define S_ISVTX 01000 /* save swapped text even after use */ 38*2159047fSniklas 39*2159047fSniklas /* POSIX masks for st_mode. */ 40*2159047fSniklas #define S_IRWXU 00700 /* owner: rwx------ */ 41*2159047fSniklas #define S_IRUSR 00400 /* owner: r-------- */ 42*2159047fSniklas #define S_IWUSR 00200 /* owner: -w------- */ 43*2159047fSniklas #define S_IXUSR 00100 /* owner: --x------ */ 44*2159047fSniklas 45*2159047fSniklas #define S_IRWXG 00070 /* group: ---rwx--- */ 46*2159047fSniklas #define S_IRGRP 00040 /* group: ---r----- */ 47*2159047fSniklas #define S_IWGRP 00020 /* group: ----w---- */ 48*2159047fSniklas #define S_IXGRP 00010 /* group: -----x--- */ 49*2159047fSniklas 50*2159047fSniklas #define S_IRWXO 00007 /* others: ------rwx */ 51*2159047fSniklas #define S_IROTH 00004 /* others: ------r-- */ 52*2159047fSniklas #define S_IWOTH 00002 /* others: -------w- */ 53*2159047fSniklas #define S_IXOTH 00001 /* others: --------x */ 54*2159047fSniklas 55*2159047fSniklas /* The following macros test st_mode (from POSIX Sec. 5.6.1.1. */ 56*2159047fSniklas #define S_ISREG(m) ((m & S_IFMT) == S_IFREG) /* is a reg file */ 57*2159047fSniklas #define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) /* is a directory */ 58*2159047fSniklas #define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR) /* is a char spec */ 59*2159047fSniklas #define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK) /* is a block spec */ 60*2159047fSniklas #define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO) /* is a pipe/FIFO */ 61*2159047fSniklas 62*2159047fSniklas 63*2159047fSniklas /* Function Prototypes. */ 64*2159047fSniklas #ifndef _ANSI_H 65*2159047fSniklas #include <ansi.h> 66*2159047fSniklas #endif 67*2159047fSniklas 68*2159047fSniklas _PROTOTYPE( int chmod, (const char *_path, int _mode) ); 69*2159047fSniklas _PROTOTYPE( int fstat, (int _fildes, struct stat *_buf) ); 70*2159047fSniklas _PROTOTYPE( int mkdir, (const char *_path, int _mode) ); 71*2159047fSniklas _PROTOTYPE( int mkfifo, (const char *_path, int _mode) ); 72*2159047fSniklas _PROTOTYPE( int stat , (const char *_path, struct stat *_buf) ); 73*2159047fSniklas _PROTOTYPE( mode_t umask, (int _cmask) ); 74*2159047fSniklas 75*2159047fSniklas #endif /* _STAT_H */ 76