Restore the "GPL licensing not permitted" in GLUT license headers.
[haiku.git] / headers / posix / sys / stat.h
blob05df3d9f4aef3f35bc6bfea010c480b6936c3afd
1 /*
2 * Copyright 2002-2012 Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _SYS_STAT_H_
6 #define _SYS_STAT_H_
9 #include <sys/types.h>
10 #include <time.h>
13 struct stat {
14 dev_t st_dev; /* device ID that this file resides on */
15 ino_t st_ino; /* this file's serial inode ID */
16 mode_t st_mode; /* file mode (rwx for user, group, etc) */
17 nlink_t st_nlink; /* number of hard links to this file */
18 uid_t st_uid; /* user ID of the owner of this file */
19 gid_t st_gid; /* group ID of the owner of this file */
20 off_t st_size; /* size in bytes of this file */
21 dev_t st_rdev; /* device type (not used) */
22 blksize_t st_blksize; /* preferred block size for I/O */
23 struct timespec st_atim; /* last access time */
24 struct timespec st_mtim; /* last modification time */
25 struct timespec st_ctim; /* last change time, not creation time */
26 struct timespec st_crtim; /* creation time */
27 __haiku_uint32 st_type; /* attribute/index type */
28 blkcnt_t st_blocks; /* number of blocks allocated for object */
31 /* source compatibility with old stat structure */
32 #define st_atime st_atim.tv_sec
33 #define st_mtime st_mtim.tv_sec
34 #define st_ctime st_ctim.tv_sec
35 #define st_crtime st_crtim.tv_sec
38 /* extended file types */
39 #define S_ATTR_DIR 01000000000 /* attribute directory */
40 #define S_ATTR 02000000000 /* attribute */
41 #define S_INDEX_DIR 04000000000 /* index (or index directory) */
42 #define S_STR_INDEX 00100000000 /* string index */
43 #define S_INT_INDEX 00200000000 /* int32 index */
44 #define S_UINT_INDEX 00400000000 /* uint32 index */
45 #define S_LONG_LONG_INDEX 00010000000 /* int64 index */
46 #define S_ULONG_LONG_INDEX 00020000000 /* uint64 index */
47 #define S_FLOAT_INDEX 00040000000 /* float index */
48 #define S_DOUBLE_INDEX 00001000000 /* double index */
49 #define S_ALLOW_DUPS 00002000000 /* allow duplicate entries (currently unused) */
51 /* link types */
52 #define S_LINK_SELF_HEALING 00001000000 /* link will be updated if you move its target */
53 #define S_LINK_AUTO_DELETE 00002000000 /* link will be deleted if you delete its target */
55 /* standard file types */
56 #define S_IFMT 00000170000 /* type of file */
57 #define S_IFSOCK 00000140000 /* socket */
58 #define S_IFLNK 00000120000 /* symbolic link */
59 #define S_IFREG 00000100000 /* regular */
60 #define S_IFBLK 00000060000 /* block special */
61 #define S_IFDIR 00000040000 /* directory */
62 #define S_IFCHR 00000020000 /* character special */
63 #define S_IFIFO 00000010000 /* fifo */
65 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
66 #define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
67 #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
68 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
69 #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
70 #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
71 #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
72 #define S_ISINDEX(mode) (((mode) & S_INDEX_DIR) == S_INDEX_DIR)
74 #define S_IUMSK 07777 /* user settable bits */
76 #define S_ISUID 04000 /* set user id on execution */
77 #define S_ISGID 02000 /* set group id on execution */
79 #define S_ISVTX 01000 /* save swapped text even after use (sticky bit) */
81 #define S_IRWXU 00700 /* read, write, execute: owner */
82 #define S_IRUSR 00400 /* read permission: owner */
83 #define S_IWUSR 00200 /* write permission: owner */
84 #define S_IXUSR 00100 /* execute permission: owner */
85 #define S_IRWXG 00070 /* read, write, execute: group */
86 #define S_IRGRP 00040 /* read permission: group */
87 #define S_IWGRP 00020 /* write permission: group */
88 #define S_IXGRP 00010 /* execute permission: group */
89 #define S_IRWXO 00007 /* read, write, execute: other */
90 #define S_IROTH 00004 /* read permission: other */
91 #define S_IWOTH 00002 /* write permission: other */
92 #define S_IXOTH 00001 /* execute permission: other */
94 /* BSD extensions */
95 #define S_IREAD S_IRUSR
96 #define S_IWRITE S_IWUSR
97 #define S_IEXEC S_IXUSR
99 #define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO)
100 #define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
101 #define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
102 /* default file mode, everyone can read/write */
104 /* special values for timespec::tv_nsec passed to utimensat(), futimens() */
105 #define UTIME_NOW 1000000000
106 #define UTIME_OMIT 1000000001
108 #ifdef __cplusplus
109 extern "C" {
110 #endif
112 extern int chmod(const char *path, mode_t mode);
113 extern int fchmod(int fd, mode_t mode);
114 extern int fchmodat(int fd, const char *path, mode_t mode, int flag);
115 extern int stat(const char *path, struct stat *st);
116 extern int fstat(int fd, struct stat *st);
117 extern int lstat(const char *path, struct stat *st);
118 extern int fstatat(int fd, const char *path, struct stat *st, int flag);
119 extern int mkdir(const char *path, mode_t mode);
120 extern int mkdirat(int fd, const char *path, mode_t mode);
121 extern int mkfifo(const char *path, mode_t mode);
122 extern int mkfifoat(int fd, const char *path, mode_t mode);
123 extern int mknod(const char *name, mode_t mode, dev_t dev);
124 extern int mknodat(int fd, const char *name, mode_t mode, dev_t dev);
125 extern mode_t umask(mode_t cmask);
127 extern int utimensat(int fd, const char *path,
128 const struct timespec times[2], int flag);
129 extern int futimens(int fd, const struct timespec times[2]);
131 #ifdef __cplusplus
133 #endif
135 #endif /* _SYS_STAT_H_ */