Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
stat.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause */
2/*
3 * Copyright (c) 1982, 1986, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the University nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30#ifndef ZEPHYR_POSIX_SYS_STAT_H_
31#define ZEPHYR_POSIX_SYS_STAT_H_
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#include <time.h>
38#include <sys/cdefs.h>
39#include <sys/types.h>
40#include <sys/_timespec.h>
41
42#ifndef _DEV_T_DECLARED
43typedef int dev_t;
44#define _DEV_T_DECLARED
45#endif
46
47#ifndef _INO_T_DECLARED
48typedef int ino_t;
49#define _INO_T_DECLARED
50#endif
51
52#ifndef _NLINK_T_DECLARED
53typedef unsigned short nlink_t;
54#define _NLINK_T_DECLARED
55#endif
56
57#ifndef _UID_T_DECLARED
58typedef unsigned short uid_t;
59#define _UID_T_DECLARED
60#endif
61
62#ifndef _GID_T_DECLARED
63typedef unsigned short gid_t;
64#define _GID_T_DECLARED
65#endif
66
67#ifndef _BLKSIZE_T_DECLARED
68typedef unsigned long blksize_t;
69#define _BLKSIZE_T_DECLARED
70#endif
71
72#ifndef _BLKCNT_T_DECLARED
73typedef unsigned long blkcnt_t;
74#define _BLKCNT_T_DECLARED
75#endif
76
77/* dj's stat defines _STAT_H_ */
78#ifndef _STAT_H_
79
80/*
81 * It is intended that the layout of this structure not change when the
82 * sizes of any of the basic types change (short, int, long) [via a compile
83 * time option].
84 */
85
86#ifdef __CYGWIN__
87#include <cygwin/stat.h>
88#ifdef _LIBC
89#define stat64 stat
90#endif
91#else
92struct stat {
99#if defined(__linux) && defined(__x86_64__)
100 int __pad0;
101#endif
103#if defined(__linux) && !defined(__x86_64__)
104 unsigned short int __pad2;
105#endif
107#if defined(__linux)
110 struct timespec st_atim;
111 struct timespec st_mtim;
112 struct timespec st_ctim;
113#define st_atime st_atim.tv_sec /* Backward compatibility */
114#define st_mtime st_mtim.tv_sec
115#define st_ctime st_ctim.tv_sec
116#if defined(__linux) && defined(__x86_64__)
117 uint64_t __glibc_reserved[3];
118#endif
119#else
120#if defined(__rtems__)
121 struct timespec st_atim;
122 struct timespec st_mtim;
123 struct timespec st_ctim;
126#else
127 /* SysV/sco doesn't have the rest... But Solaris, eabi does. */
128#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)
132#else
138#if !defined(__rtems__)
139 long st_spare4[2];
140#endif
141#endif
142#endif
143#endif
144};
145
146#if !(defined(__svr4__) && !defined(__PPC__) && !defined(__sun__))
147#define st_atime st_atim.tv_sec
148#define st_ctime st_ctim.tv_sec
149#define st_mtime st_mtim.tv_sec
150#endif
151
152#endif
153
154#define _IFMT 0170000 /* type of file */
155#define _IFDIR 0040000 /* directory */
156#define _IFCHR 0020000 /* character special */
157#define _IFBLK 0060000 /* block special */
158#define _IFREG 0100000 /* regular */
159#define _IFLNK 0120000 /* symbolic link */
160#define _IFSOCK 0140000 /* socket */
161#define _IFIFO 0010000 /* fifo */
162
163#define S_BLKSIZE 1024 /* size of a block */
164
165#define S_ISUID 0004000 /* set user id on execution */
166#define S_ISGID 0002000 /* set group id on execution */
167#define S_ISVTX 0001000 /* save swapped text even after use */
168#if __BSD_VISIBLE
169#define S_IREAD 0000400 /* read permission, owner */
170#define S_IWRITE 0000200 /* write permission, owner */
171#define S_IEXEC 0000100 /* execute/search permission, owner */
172#define S_ENFMT 0002000 /* enforcement-mode locking */
173#endif /* !_BSD_VISIBLE */
174
175#define S_IFMT _IFMT
176#define S_IFDIR _IFDIR
177#define S_IFCHR _IFCHR
178#define S_IFBLK _IFBLK
179#define S_IFREG _IFREG
180#define S_IFLNK _IFLNK
181#define S_IFSOCK _IFSOCK
182#define S_IFIFO _IFIFO
183
184#ifdef _WIN32
185/*
186 * The Windows header files define _S_ forms of these, so we do too
187 * for easier portability.
188 */
189#define _S_IFMT _IFMT
190#define _S_IFDIR _IFDIR
191#define _S_IFCHR _IFCHR
192#define _S_IFIFO _IFIFO
193#define _S_IFREG _IFREG
194#define _S_IREAD 0000400
195#define _S_IWRITE 0000200
196#define _S_IEXEC 0000100
197#endif
198
199#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
200#define S_IRUSR 0000400 /* read permission, owner */
201#define S_IWUSR 0000200 /* write permission, owner */
202#define S_IXUSR 0000100 /* execute/search permission, owner */
203#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
204#define S_IRGRP 0000040 /* read permission, group */
205#define S_IWGRP 0000020 /* write permission, grougroup */
206#define S_IXGRP 0000010 /* execute/search permission, group */
207#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
208#define S_IROTH 0000004 /* read permission, other */
209#define S_IWOTH 0000002 /* write permission, other */
210#define S_IXOTH 0000001 /* execute/search permission, other */
211
212#if __BSD_VISIBLE
213#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
214#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */
215#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
216#endif
217
218#define S_ISBLK(m) (((m)&_IFMT) == _IFBLK)
219#define S_ISCHR(m) (((m)&_IFMT) == _IFCHR)
220#define S_ISDIR(m) (((m)&_IFMT) == _IFDIR)
221#define S_ISFIFO(m) (((m)&_IFMT) == _IFIFO)
222#define S_ISREG(m) (((m)&_IFMT) == _IFREG)
223#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK)
224#define S_ISSOCK(m) (((m)&_IFMT) == _IFSOCK)
225
226#if defined(__CYGWIN__) || defined(__rtems__)
227/* Special tv_nsec values for futimens(2) and utimensat(2). */
228#define UTIME_NOW -2L
229#define UTIME_OMIT -1L
230#endif
231
232int chmod(const char *__path, mode_t __mode);
233int fchmod(int __fd, mode_t __mode);
234int fstat(int __fd, struct stat *__sbuf);
235int mkdir(const char *_path, mode_t __mode);
236int mkfifo(const char *__path, mode_t __mode);
237int stat(const char *__restrict __path, struct stat *__restrict __sbuf);
239
240#if defined(__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
241int lstat(const char *__restrict __path, struct stat *__restrict __buf);
242int mknod(const char *__path, mode_t __mode, dev_t __dev);
243#endif
244
245#if __ATFILE_VISIBLE && !defined(__INSIDE_CYGWIN__)
246int fchmodat(int __fd, const char *__path, mode_t __mode, int __flag);
247int fstatat(int __fd, const char *__restrict __path, struct stat *__restrict __buf, int __flag);
248int mkdirat(int __fd, const char *__path, mode_t __mode);
249int mkfifoat(int __fd, const char *__path, mode_t __mode);
250int mknodat(int __fd, const char *__path, mode_t __mode, dev_t __dev);
251int utimensat(int __fd, const char *__path, const struct timespec __times[2], int __flag);
252#endif
253#if __POSIX_VISIBLE >= 200809 && !defined(__INSIDE_CYGWIN__)
254int futimens(int __fd, const struct timespec __times[2]);
255#endif
256
257/*
258 * Provide prototypes for most of the _<systemcall> names that are
259 * provided in newlib for some compilers.
260 */
261#ifdef _LIBC
262int _fstat(int __fd, struct stat *__sbuf);
263int _stat(const char *__restrict __path, struct stat *__restrict __sbuf);
264int _mkdir(const char *_path, mode_t __mode);
265#ifdef __LARGE64_FILES
266struct stat64;
267int _stat64(const char *__restrict __path, struct stat64 *__restrict __sbuf);
268int _fstat64(int __fd, struct stat64 *__sbuf);
269#endif
270#endif
271
272#endif /* !_STAT_H_ */
273#ifdef __cplusplus
274}
275#endif
276#endif /* ZEPHYR_POSIX_SYS_STAT_H_ */
_TIME_T_ time_t
Definition: _timespec.h:14
int dev_t
Definition: stat.h:43
int fstat(int __fd, struct stat *__sbuf)
#define st_ctime
Definition: stat.h:148
unsigned short gid_t
Definition: stat.h:63
#define st_atime
Definition: stat.h:147
unsigned long blksize_t
Definition: stat.h:68
int fchmod(int __fd, mode_t __mode)
unsigned short uid_t
Definition: stat.h:58
int ino_t
Definition: stat.h:48
mode_t umask(mode_t __mask)
unsigned short nlink_t
Definition: stat.h:53
int chmod(const char *__path, mode_t __mode)
unsigned long blkcnt_t
Definition: stat.h:73
int mkfifo(const char *__path, mode_t __mode)
#define st_mtime
Definition: stat.h:149
int mkdir(const char *_path, mode_t __mode)
__INTPTR_TYPE__ off_t
Definition: types.h:36
unsigned int mode_t
Definition: types.h:14
__UINT64_TYPE__ uint64_t
Definition: stdint.h:91
Definition: stat.h:92
off_t st_size
Definition: stat.h:106
nlink_t st_nlink
Definition: stat.h:96
long st_spare4[2]
Definition: stat.h:139
blksize_t st_blksize
Definition: stat.h:136
blkcnt_t st_blocks
Definition: stat.h:137
uid_t st_uid
Definition: stat.h:97
mode_t st_mode
Definition: stat.h:95
struct timespec st_mtim
Definition: stat.h:134
struct timespec st_atim
Definition: stat.h:133
struct timespec st_ctim
Definition: stat.h:135
ino_t st_ino
Definition: stat.h:94
dev_t st_rdev
Definition: stat.h:102
gid_t st_gid
Definition: stat.h:98
dev_t st_dev
Definition: stat.h:93
Definition: _timespec.h:22