whoops - forgot to commit header files
[reactos.git] / posix / include / sys / stat.h
1 /*
2 * sys/stat.h
3 *
4 * data returned by the stat() function. Based on the Single UNIX(r) Specification,
5 * Version 2
6 *
7 * This file is part of the ReactOS Operating System.
8 *
9 * Contributors:
10 * Created by KJK::Hyperion <noog@libero.it>
11 *
12 * THIS SOFTWARE IS NOT COPYRIGHTED
13 *
14 * This source code is offered for use in the public domain. You may
15 * use, modify or distribute it freely.
16 *
17 * This code is distributed in the hope that it will be useful but
18 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
19 * DISCLAMED. This includes but is not limited to warranties of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 *
22 */
23 #ifndef __SYS_STAT_H_INCLUDED__
24 #define __SYS_STAT_H_INCLUDED__
25
26 /* INCLUDES */
27 #include <sys/types.h>
28
29 /* OBJECTS */
30
31 /* TYPES */
32 struct stat
33 {
34 dev_t st_dev; /* ID of device containing file */
35 ino_t st_ino; /* file serial number */
36 mode_t st_mode; /* mode of file (see below) */
37 nlink_t st_nlink; /* number of links to the file */
38 uid_t st_uid; /* user ID of file */
39 gid_t st_gid; /* group ID of file */
40 dev_t st_rdev; /* device ID (if file is character or block special) */
41 off_t st_size; /* file size in bytes (if file is a regular file) */
42 time_t st_atime; /* time of last access */
43 time_t st_mtime; /* time of last data modification */
44 time_t st_ctime; /* time of last status change */
45 blksize_t st_blksize; /* a filesystem-specific preferred I/O block size for
46 this object. In some filesystem types, this may
47 vary from file to file */
48 blkcnt_t st_blocks; /* number of blocks allocated for this object */
49 };
50
51 /* CONSTANTS */
52 /*
53 file type
54 */
55 #define S_IFBLK (1) /* block special */
56 #define S_IFCHR (2) /* character special */
57 #define S_IFIFO (3) /* FIFO special */
58 #define S_IFREG (4) /* regular */
59 #define S_IFDIR (5) /* directory */
60 #define S_IFLNK (6) /* symbolic link */
61
62 /* type of file */
63 #define S_IFMT (S_IFBLK | S_IFCHR | S_IFIFO | S_IFREG | S_IFDIR | S_IFLNK)
64
65 /*
66 file mode bits
67 */
68 #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) /* read, write, execute/search by owner */
69 #define S_IRUSR (0x00000001) /* read permission, owner */
70 #define S_IWUSR (0x00000002) /* write permission, owner */
71 #define S_IXUSR (0x00000004) /* execute/search permission, owner */
72
73 #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) /* read, write, execute/search by group */
74 #define S_IRGRP (0x00000010) /* read permission, group */
75 #define S_IWGRP (0x00000020) /* write permission, group */
76 #define S_IXGRP (0x00000040) /* execute/search permission, group */
77
78 #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) /* read, write, execute/search by others */
79 #define S_IROTH (0x00000100) /* read permission, others */
80 #define S_IWOTH (0x00000200) /* write permission, others */
81 #define S_IXOTH (0x00000400) /* execute/search permission, others */
82
83 #define S_ISUID (0x00001000) /* set-user-ID on execution */
84 #define S_ISGID (0x00002000) /* set-group-ID on execution */
85 #define S_ISVTX (0x00004000) /* on directories, restricted deletion flag */
86
87 /*
88 the following macros will test whether a file is of the specified type
89 */
90 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
91 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
92 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
93 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
94 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
95 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
96 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
97
98 /* shared memory, semaphores and message queues are unlikely to be ever
99 implemented as files */
100 #define S_TYPEISMQ(buf) (0) /* Test for a message queue */
101 #define S_TYPEISSEM(buf) (0) /* Test for a semaphore */
102 #define S_TYPEISSHM(buf) (0) /* Test for a shared memory object */
103
104 /* PROTOTYPES */
105 int chmod(const char *, mode_t);
106 int fchmod(int, mode_t);
107 int fstat(int, struct stat *);
108 int lstat(const char *, struct stat *);
109 int mkdir(const char *, mode_t);
110 int mkfifo(const char *, mode_t);
111 int mknod(const char *, mode_t, dev_t);
112 int stat(const char *, struct stat *);
113 mode_t umask(mode_t);
114
115 /* MACROS */
116
117 #endif /* __SYS_STAT_H_INCLUDED__ */
118
119 /* EOF */
120