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