source: branches/minix3-book/include/sys/stat.h@ 4

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

Importazione sorgenti libro

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