source: trunk/minix/include/sys/stat.h@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 3.1 KB
Line 
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
10#include <sys/types.h>
11#endif
12
13struct 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_IFLNK 0120000 /* symbolic link */
30#define S_IFREG 0100000 /* regular */
31#define S_IFBLK 0060000 /* block special */
32#define S_IFDIR 0040000 /* directory */
33#define S_IFCHR 0020000 /* character special */
34#define S_IFIFO 0010000 /* this is a FIFO */
35#define S_ISUID 0004000 /* set user id on execution */
36#define S_ISGID 0002000 /* set group id on execution */
37 /* next is reserved for future use */
38#define S_ISVTX 01000 /* save swapped text even after use */
39
40/* POSIX masks for st_mode. */
41#define S_IRWXU 00700 /* owner: rwx------ */
42#define S_IRUSR 00400 /* owner: r-------- */
43#define S_IWUSR 00200 /* owner: -w------- */
44#define S_IXUSR 00100 /* owner: --x------ */
45
46#define S_IRWXG 00070 /* group: ---rwx--- */
47#define S_IRGRP 00040 /* group: ---r----- */
48#define S_IWGRP 00020 /* group: ----w---- */
49#define S_IXGRP 00010 /* group: -----x--- */
50
51#define S_IRWXO 00007 /* others: ------rwx */
52#define S_IROTH 00004 /* others: ------r-- */
53#define S_IWOTH 00002 /* others: -------w- */
54#define S_IXOTH 00001 /* others: --------x */
55
56/* Synonyms for above. */
57#define S_IEXEC S_IXUSR
58#define S_IWRITE S_IWUSR
59#define S_IREAD S_IRUSR
60
61/* The following macros test st_mode (from POSIX Sec. 5.6.1.1). */
62#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) /* is a reg file */
63#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) /* is a directory */
64#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) /* is a char spec */
65#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) /* is a block spec */
66#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) /* is a symlink */
67#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) /* is a pipe/FIFO */
68
69/* Function Prototypes. */
70_PROTOTYPE( int chmod, (const char *_path, _mnx_Mode_t _mode) );
71_PROTOTYPE( int fstat, (int _fildes, struct stat *_buf) );
72_PROTOTYPE( int mkdir, (const char *_path, _mnx_Mode_t _mode) );
73_PROTOTYPE( int mkfifo, (const char *_path, _mnx_Mode_t _mode) );
74_PROTOTYPE( int stat, (const char *_path, struct stat *_buf) );
75_PROTOTYPE( mode_t umask, (_mnx_Mode_t _cmask) );
76
77/* Open Group Base Specifications Issue 6 (not complete) */
78_PROTOTYPE( int lstat, (const char *_path, struct stat *_buf) );
79
80#endif /* _STAT_H */
Note: See TracBrowser for help on using the repository browser.