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