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