Zephyr API Documentation 4.0.0
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
41
42/* dj's stat defines _STAT_H_ */
43#ifndef _STAT_H_
44
45/*
46 * It is intended that the layout of this structure not change when the
47 * sizes of any of the basic types change (short, int, long) [via a compile
48 * time option].
49 */
50
51#ifdef __CYGWIN__
52#include <cygwin/stat.h>
53#ifdef _LIBC
54#define stat64 stat
55#endif
56#else
57struct stat {
64#if defined(__linux) && defined(__x86_64__)
65 int __pad0;
66#endif
68#if defined(__linux) && !defined(__x86_64__)
69 unsigned short int __pad2;
70#endif
72#if defined(__linux)
75 struct timespec st_atim;
76 struct timespec st_mtim;
77 struct timespec st_ctim;
78#define st_atime st_atim.tv_sec /* Backward compatibility */
79#define st_mtime st_mtim.tv_sec
80#define st_ctime st_ctim.tv_sec
81#if defined(__linux) && defined(__x86_64__)
82 uint64_t __glibc_reserved[3];
83#endif
84#else
85#if defined(__rtems__)
86 struct timespec st_atim;
87 struct timespec st_mtim;
88 struct timespec st_ctim;
91#else
92 /* SysV/sco doesn't have the rest... But Solaris, eabi does. */
93#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)
97#else
103#if !defined(__rtems__)
104 long st_spare4[2];
105#endif
106#endif
107#endif
108#endif
109};
110
111#if !(defined(__svr4__) && !defined(__PPC__) && !defined(__sun__))
112#define st_atime st_atim.tv_sec
113#define st_ctime st_ctim.tv_sec
114#define st_mtime st_mtim.tv_sec
115#endif
116
117#endif
118
119#define _IFMT 0170000 /* type of file */
120#define _IFDIR 0040000 /* directory */
121#define _IFCHR 0020000 /* character special */
122#define _IFBLK 0060000 /* block special */
123#define _IFREG 0100000 /* regular */
124#define _IFLNK 0120000 /* symbolic link */
125#define _IFSOCK 0140000 /* socket */
126#define _IFIFO 0010000 /* fifo */
127
128#define S_BLKSIZE 1024 /* size of a block */
129
130#define S_ISUID 0004000 /* set user id on execution */
131#define S_ISGID 0002000 /* set group id on execution */
132#define S_ISVTX 0001000 /* save swapped text even after use */
133#if __BSD_VISIBLE
134#define S_IREAD 0000400 /* read permission, owner */
135#define S_IWRITE 0000200 /* write permission, owner */
136#define S_IEXEC 0000100 /* execute/search permission, owner */
137#define S_ENFMT 0002000 /* enforcement-mode locking */
138#endif /* !_BSD_VISIBLE */
139
140#define S_IFMT _IFMT
141#define S_IFDIR _IFDIR
142#define S_IFCHR _IFCHR
143#define S_IFBLK _IFBLK
144#define S_IFREG _IFREG
145#define S_IFLNK _IFLNK
146#define S_IFSOCK _IFSOCK
147#define S_IFIFO _IFIFO
148
149#ifdef _WIN32
150/*
151 * The Windows header files define _S_ forms of these, so we do too
152 * for easier portability.
153 */
154#define _S_IFMT _IFMT
155#define _S_IFDIR _IFDIR
156#define _S_IFCHR _IFCHR
157#define _S_IFIFO _IFIFO
158#define _S_IFREG _IFREG
159#define _S_IREAD 0000400
160#define _S_IWRITE 0000200
161#define _S_IEXEC 0000100
162#endif
163
164#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
165#define S_IRUSR 0000400 /* read permission, owner */
166#define S_IWUSR 0000200 /* write permission, owner */
167#define S_IXUSR 0000100 /* execute/search permission, owner */
168#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
169#define S_IRGRP 0000040 /* read permission, group */
170#define S_IWGRP 0000020 /* write permission, grougroup */
171#define S_IXGRP 0000010 /* execute/search permission, group */
172#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
173#define S_IROTH 0000004 /* read permission, other */
174#define S_IWOTH 0000002 /* write permission, other */
175#define S_IXOTH 0000001 /* execute/search permission, other */
176
177#if __BSD_VISIBLE
178#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
179#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */
180#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
181#endif
182
183#define S_ISBLK(m) (((m)&_IFMT) == _IFBLK)
184#define S_ISCHR(m) (((m)&_IFMT) == _IFCHR)
185#define S_ISDIR(m) (((m)&_IFMT) == _IFDIR)
186#define S_ISFIFO(m) (((m)&_IFMT) == _IFIFO)
187#define S_ISREG(m) (((m)&_IFMT) == _IFREG)
188#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK)
189#define S_ISSOCK(m) (((m)&_IFMT) == _IFSOCK)
190
191#if defined(__CYGWIN__) || defined(__rtems__)
192/* Special tv_nsec values for futimens(2) and utimensat(2). */
193#define UTIME_NOW -2L
194#define UTIME_OMIT -1L
195#endif
196
197int chmod(const char *__path, mode_t __mode);
198int fchmod(int __fd, mode_t __mode);
199int fstat(int __fd, struct stat *__sbuf);
200int mkdir(const char *_path, mode_t __mode);
201int mkfifo(const char *__path, mode_t __mode);
202int stat(const char *__restrict __path, struct stat *__restrict __sbuf);
204
205#if defined(__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
206int lstat(const char *__restrict __path, struct stat *__restrict __buf);
207int mknod(const char *__path, mode_t __mode, dev_t __dev);
208#endif
209
210#if __ATFILE_VISIBLE && !defined(__INSIDE_CYGWIN__)
211int fchmodat(int __fd, const char *__path, mode_t __mode, int __flag);
212int fstatat(int __fd, const char *__restrict __path, struct stat *__restrict __buf, int __flag);
213int mkdirat(int __fd, const char *__path, mode_t __mode);
214int mkfifoat(int __fd, const char *__path, mode_t __mode);
215int mknodat(int __fd, const char *__path, mode_t __mode, dev_t __dev);
216int utimensat(int __fd, const char *__path, const struct timespec __times[2], int __flag);
217#endif
218#if __POSIX_VISIBLE >= 200809 && !defined(__INSIDE_CYGWIN__)
219int futimens(int __fd, const struct timespec __times[2]);
220#endif
221
222/*
223 * Provide prototypes for most of the _<systemcall> names that are
224 * provided in newlib for some compilers.
225 */
226#ifdef _LIBC
227int _fstat(int __fd, struct stat *__sbuf);
228int _stat(const char *__restrict __path, struct stat *__restrict __sbuf);
229int _mkdir(const char *_path, mode_t __mode);
230#ifdef __LARGE64_FILES
231struct stat64;
232int _stat64(const char *__restrict __path, struct stat64 *__restrict __sbuf);
233int _fstat64(int __fd, struct stat64 *__sbuf);
234#endif
235#endif
236
237#endif /* !_STAT_H_ */
238#ifdef __cplusplus
239}
240#endif
241#endif /* ZEPHYR_POSIX_SYS_STAT_H_ */
_TIME_T_ time_t
Definition _timespec.h:14
__INTPTR_TYPE__ off_t
Definition types.h:36
unsigned int mode_t
Definition types.h:14
int dev_t
Definition posix_types.h:37
unsigned short gid_t
Definition posix_types.h:61
unsigned long blksize_t
Definition posix_types.h:67
unsigned short uid_t
Definition posix_types.h:55
int ino_t
Definition posix_types.h:43
unsigned short nlink_t
Definition posix_types.h:49
unsigned long blkcnt_t
Definition posix_types.h:73
int stat(const char *__restrict __path, struct stat *__restrict __sbuf)
int fstat(int __fd, struct stat *__sbuf)
#define st_ctime
Definition stat.h:113
#define st_atime
Definition stat.h:112
int fchmod(int __fd, mode_t __mode)
mode_t umask(mode_t __mask)
int chmod(const char *__path, mode_t __mode)
int mkfifo(const char *__path, mode_t __mode)
#define st_mtime
Definition stat.h:114
int mkdir(const char *_path, mode_t __mode)
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
Definition stat.h:57
off_t st_size
Definition stat.h:71
nlink_t st_nlink
Definition stat.h:61
long st_spare4[2]
Definition stat.h:104
blksize_t st_blksize
Definition stat.h:101
blkcnt_t st_blocks
Definition stat.h:102
uid_t st_uid
Definition stat.h:62
mode_t st_mode
Definition stat.h:60
struct timespec st_mtim
Definition stat.h:99
struct timespec st_atim
Definition stat.h:98
struct timespec st_ctim
Definition stat.h:100
ino_t st_ino
Definition stat.h:59
dev_t st_rdev
Definition stat.h:67
gid_t st_gid
Definition stat.h:63
dev_t st_dev
Definition stat.h:58
Definition _timespec.h:22