stat.h

Go to the documentation of this file.
00001 /* The <sys/stat.h> header defines a struct that is used in the stat() and
00002  * fstat functions.  The information in this struct comes from the i-node of
00003  * some file.  These calls are the only approved way to inspect i-nodes.
00004  */
00005 
00006 #ifndef _STAT_H
00007 #define _STAT_H
00008 
00009 #ifndef _TYPES_H
00010 #include <sys/types.h>
00011 #endif
00012 
00013 struct stat {
00014   dev_t st_dev;                 /* major/minor device number */
00015   ino_t st_ino;                 /* i-node number */
00016   mode_t st_mode;               /* file mode, protection bits, etc. */
00017   short int st_nlink;           /* # links; TEMPORARY HACK: should be nlink_t*/
00018   uid_t st_uid;                 /* uid of the file's owner */
00019   short int st_gid;             /* gid; TEMPORARY HACK: should be gid_t */
00020   dev_t st_rdev;
00021   off_t st_size;                /* file size */
00022   time_t st_atime;              /* time of last access */
00023   time_t st_mtime;              /* time of last data modification */
00024   time_t st_ctime;              /* time of last file status change */
00025 };
00026 
00027 /* Traditional mask definitions for st_mode. */
00028 #define S_IFMT  0170000 /* type of file */
00029 #define S_IFLNK 0120000 /* symbolic link */
00030 #define S_IFREG 0100000 /* regular */
00031 #define S_IFBLK 0060000 /* block special */
00032 #define S_IFDIR 0040000 /* directory */
00033 #define S_IFCHR 0020000 /* character special */
00034 #define S_IFIFO 0010000 /* this is a FIFO */
00035 #define S_ISUID 0004000 /* set user id on execution */
00036 #define S_ISGID 0002000 /* set group id on execution */
00037                                 /* next is reserved for future use */
00038 #define S_ISVTX   01000         /* save swapped text even after use */
00039 
00040 /* POSIX masks for st_mode. */
00041 #define S_IRWXU   00700         /* owner:  rwx------ */
00042 #define S_IRUSR   00400         /* owner:  r-------- */
00043 #define S_IWUSR   00200         /* owner:  -w------- */
00044 #define S_IXUSR   00100         /* owner:  --x------ */
00045 
00046 #define S_IRWXG   00070         /* group:  ---rwx--- */
00047 #define S_IRGRP   00040         /* group:  ---r----- */
00048 #define S_IWGRP   00020         /* group:  ----w---- */
00049 #define S_IXGRP   00010         /* group:  -----x--- */
00050 
00051 #define S_IRWXO   00007         /* others: ------rwx */
00052 #define S_IROTH   00004         /* others: ------r-- */ 
00053 #define S_IWOTH   00002         /* others: -------w- */
00054 #define S_IXOTH   00001         /* others: --------x */
00055 
00056 /* Synonyms for above. */
00057 #define S_IEXEC         S_IXUSR
00058 #define S_IWRITE        S_IWUSR
00059 #define S_IREAD         S_IRUSR
00060 
00061 /* The following macros test st_mode (from POSIX Sec. 5.6.1.1). */
00062 #define S_ISREG(m)      (((m) & S_IFMT) == S_IFREG)     /* is a reg file */
00063 #define S_ISDIR(m)      (((m) & S_IFMT) == S_IFDIR)     /* is a directory */
00064 #define S_ISCHR(m)      (((m) & S_IFMT) == S_IFCHR)     /* is a char spec */
00065 #define S_ISBLK(m)      (((m) & S_IFMT) == S_IFBLK)     /* is a block spec */
00066 #define S_ISLNK(m)      (((m) & S_IFMT) == S_IFLNK)     /* is a symlink */
00067 #define S_ISFIFO(m)     (((m) & S_IFMT) == S_IFIFO)     /* is a pipe/FIFO */
00068 
00069 /* Function Prototypes. */
00070 _PROTOTYPE( int chmod, (const char *_path, _mnx_Mode_t _mode)           );
00071 _PROTOTYPE( int fstat, (int _fildes, struct stat *_buf)                 );
00072 _PROTOTYPE( int mkdir, (const char *_path, _mnx_Mode_t _mode)           );
00073 _PROTOTYPE( int mkfifo, (const char *_path, _mnx_Mode_t _mode)          );
00074 _PROTOTYPE( int stat, (const char *_path, struct stat *_buf)            );
00075 _PROTOTYPE( mode_t umask, (_mnx_Mode_t _cmask)                          );
00076 
00077 /* Open Group Base Specifications Issue 6 (not complete) */
00078 _PROTOTYPE( int lstat, (const char *_path, struct stat *_buf)           );
00079 
00080 #endif /* _STAT_H */

Generated on Fri Apr 14 22:57:22 2006 for minix by  doxygen 1.4.6