4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
27 /* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
29 /* All Rights Reserved */
34 #include <sys/feature_tests.h>
35 #include <sys/types.h>
36 #include <sys/time_impl.h>
38 #define _ST_FSTYPSZ 16 /* array size for file system type name */
42 * temporary additional symbols to provide ABI compat for 32-bit stat.
43 * libc performs translation from the new struct (returned by the kernel) to
44 * the old one expected by userland apps.
46 * newly compiled 32-bit binaries will use the '_new' symbols through these
47 * redefine_extnames - until we can recompile old binaries that depend on the
51 #pragma redefine_extname fstatat fstatat_new
52 #pragma redefine_extname fstat fstat_new
53 #pragma redefine_extname lstat lstat_new
54 #pragma redefine_extname stat stat_new
67 struct timespec st_atim
;
68 struct timespec st_mtim
;
69 struct timespec st_ctim
;
72 char st_fstype
[_ST_FSTYPSZ
];
75 #if defined(_KERNEL) && defined(_SYSCALL32_IMPL)
77 * 32-bit process' stat struct, as viewed by the kernel.
79 * this is almost exactly same as above, with 3 differences:
80 * - dev_t (ulong_t) vs. dev32_t (uint32_t)
81 * - struct timespec vs. struct timespec32
82 * - member alignment (struct packing)
83 * if the first two differences were fixed, we could swap this around by always
84 * using the same struct, *but* with aligned(8) for 32-bit user processes.
95 struct timespec32 st_atim
;
96 struct timespec32 st_mtim
;
97 struct timespec32 st_ctim
;
100 char st_fstype
[_ST_FSTYPSZ
];
101 } __attribute__((packed
));
102 #endif /* defined(_KERNEL) && defined(_SYSCALL32_IMPL) */
104 #define st_atime st_atim.tv_sec
105 #define st_mtime st_mtim.tv_sec
106 #define st_ctime st_ctim.tv_sec
110 /* de facto standard definitions */
112 #define S_IFMT 0xF000 /* type of file */
113 #define S_IAMB 0x1FF /* access mode bits */
114 #define S_IFIFO 0x1000 /* fifo */
115 #define S_IFCHR 0x2000 /* character special */
116 #define S_IFDIR 0x4000 /* directory */
117 /* XENIX definitions are not relevant to Solaris */
118 #define S_IFNAM 0x5000 /* XENIX special named file */
119 #define S_INSEM 0x1 /* XENIX semaphore subtype of IFNAM */
120 #define S_INSHD 0x2 /* XENIX shared data subtype of IFNAM */
121 #define S_IFBLK 0x6000 /* block special */
122 #define S_IFREG 0x8000 /* regular */
123 #define S_IFLNK 0xA000 /* symbolic link */
124 #define S_IFSOCK 0xC000 /* socket */
125 #define S_IFDOOR 0xD000 /* door */
126 #define S_IFPORT 0xE000 /* event port */
127 #define S_ISUID 0x800 /* set user id on execution */
128 #define S_ISGID 0x400 /* set group id on execution */
129 #define S_ISVTX 0x200 /* save swapped text even after use */
130 #define S_IREAD 00400 /* read permission, owner */
131 #define S_IWRITE 00200 /* write permission, owner */
132 #define S_IEXEC 00100 /* execute/search permission, owner */
133 #define S_ENFMT S_ISGID /* record locking enforcement flag */
135 /* the following macros are for POSIX conformance */
137 #define S_IRWXU 00700 /* read, write, execute: owner */
138 #define S_IRUSR 00400 /* read permission: owner */
139 #define S_IWUSR 00200 /* write permission: owner */
140 #define S_IXUSR 00100 /* execute permission: owner */
141 #define S_IRWXG 00070 /* read, write, execute: group */
142 #define S_IRGRP 00040 /* read permission: group */
143 #define S_IWGRP 00020 /* write permission: group */
144 #define S_IXGRP 00010 /* execute permission: group */
145 #define S_IRWXO 00007 /* read, write, execute: other */
146 #define S_IROTH 00004 /* read permission: other */
147 #define S_IWOTH 00002 /* write permission: other */
148 #define S_IXOTH 00001 /* execute permission: other */
150 #define S_ISFIFO(mode) (((mode)&0xF000) == 0x1000)
151 #define S_ISCHR(mode) (((mode)&0xF000) == 0x2000)
152 #define S_ISDIR(mode) (((mode)&0xF000) == 0x4000)
153 #define S_ISBLK(mode) (((mode)&0xF000) == 0x6000)
154 #define S_ISREG(mode) (((mode)&0xF000) == 0x8000)
155 #define S_ISLNK(mode) (((mode)&0xF000) == 0xa000)
156 #define S_ISSOCK(mode) (((mode)&0xF000) == 0xc000)
157 #define S_ISDOOR(mode) (((mode)&0xF000) == 0xd000)
158 #define S_ISPORT(mode) (((mode)&0xF000) == 0xe000)
161 #define S_TYPEISMQ(_buf) (0)
162 #define S_TYPEISSEM(_buf) (0)
163 #define S_TYPEISSHM(_buf) (0)
165 #if __POSIX_VISIBLE >= 200809 || defined(_KERNEL)
166 #define UTIME_NOW -1L
167 #define UTIME_OMIT -2L
170 #if !defined(_KERNEL)
176 int chmod(const char *, mode_t
);
177 int fstat(int, struct stat
*);
178 int mkdir(const char *, mode_t
);
179 int mkfifo(const char *, mode_t
);
180 int stat(const char *_RESTRICT_KYWD
, struct stat
*_RESTRICT_KYWD
);
181 mode_t
umask(mode_t
);
182 #if __XPG_VISIBLE >= 420
183 int fchmod(int, mode_t
);
184 int lstat(const char *_RESTRICT_KYWD
, struct stat
*_RESTRICT_KYWD
);
185 int mknod(const char *, mode_t
, dev_t
);
187 #if __POSIX_VISIBLE >= 200809
188 int fstatat(int, const char *, struct stat
*, int);
189 int fchmodat(int, const char *, mode_t
, int);
190 int futimens(int, const struct timespec
[2]);
191 int mkdirat(int, const char *, mode_t
);
192 int mkfifoat(int, const char *, mode_t
);
193 int mknodat(int, const char *, mode_t
, dev_t
);
194 int utimensat(int, const char *, const struct timespec
[2], int);
201 #endif /* !defined(_KERNEL) */
202 #endif /* _SYS_STAT_H */