2000-02-18 03:39:52 +08:00
|
|
|
#ifndef _SYS_STAT_H
|
|
|
|
#define _SYS_STAT_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <_ansi.h>
|
|
|
|
#include <time.h>
|
2014-01-07 04:59:38 +08:00
|
|
|
#include <sys/cdefs.h>
|
2000-02-18 03:39:52 +08:00
|
|
|
#include <sys/types.h>
|
2015-03-11 22:38:54 +08:00
|
|
|
#include <sys/_timespec.h>
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
/* dj's stat defines _STAT_H_ */
|
|
|
|
#ifndef _STAT_H_
|
|
|
|
|
|
|
|
/* It is intended that the layout of this structure not change when the
|
|
|
|
sizes of any of the basic types change (short, int, long) [via a compile
|
|
|
|
time option]. */
|
|
|
|
|
2002-02-10 04:40:37 +08:00
|
|
|
#ifdef __CYGWIN__
|
|
|
|
#include <cygwin/stat.h>
|
2021-11-09 11:22:27 +08:00
|
|
|
#ifdef _LIBC
|
2013-04-23 17:42:25 +08:00
|
|
|
#define stat64 stat
|
2003-08-27 04:54:04 +08:00
|
|
|
#endif
|
2002-02-10 04:40:37 +08:00
|
|
|
#else
|
2000-02-18 03:39:52 +08:00
|
|
|
struct stat
|
|
|
|
{
|
|
|
|
dev_t st_dev;
|
|
|
|
ino_t st_ino;
|
|
|
|
mode_t st_mode;
|
|
|
|
nlink_t st_nlink;
|
|
|
|
uid_t st_uid;
|
|
|
|
gid_t st_gid;
|
|
|
|
dev_t st_rdev;
|
|
|
|
off_t st_size;
|
|
|
|
#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)
|
|
|
|
time_t st_atime;
|
|
|
|
time_t st_mtime;
|
|
|
|
time_t st_ctime;
|
|
|
|
#else
|
2019-08-16 16:52:17 +08:00
|
|
|
struct timespec st_atim;
|
|
|
|
struct timespec st_mtim;
|
|
|
|
struct timespec st_ctim;
|
|
|
|
blksize_t st_blksize;
|
2016-04-15 19:44:20 +08:00
|
|
|
blkcnt_t st_blocks;
|
2019-08-16 16:52:17 +08:00
|
|
|
#if !defined(__rtems__)
|
2019-08-20 05:46:51 +08:00
|
|
|
long st_spare4[2];
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif
|
2009-12-18 03:22:23 +08:00
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
};
|
2009-12-18 03:22:23 +08:00
|
|
|
|
Complete revert of 2019-08-19, st_atime in libc/include/sys/stat.h
The revert-part of the revert-and-fix commit, b99887c4283f a.k.a.
"Revert previous change to sys/stat.h and fix cris libgloss",
apparently intending to revert f75aa6785151 a.k.a. "Fix regression in
cris-elf caused by sys/stat.h change" and fix it in another way,
wasn't complete. Although the fix-part added the prerequisite "#undef
st_atime" (et al) to gensyscalls, the revert-part didn't revert the
"&& !defined(__cris__)" in sys/stat.h, stopping st_atime (et al) from
being defined.
The effect of the unreverted change is that accessing the struct stat
compatibility member names "st_atime" (et al) as in "struct stat
mystat; mystat.st_atime;" yields errors, observable for example when
building libgfortran in gcc:
/x/gcc/libgfortran/intrinsics/stat.c:114:42: error: 'struct stat' has \
no member named 'st_atime'; did you mean 'st_atim'?
114 | sarray->base_addr[8 * stride] = sb.st_atime;
| ^~~~~~~~
| st_atim
(etc.)
Trivially fixed by completing the reversion, removing the "&&
!defined(__cris__)" in sys/stat.h.
Beware: the net effect of the earlier related change to struct stat in
sys/stat.h, leading up to the fix, *does* change its definition as a
type. Thankfully, replacing members like "time_t st_atime; long
st_spare1;" by "struct timespec st_atim;", ditto st_mtim and st_ctim,
is layout-compatible. To wit, that change is "binary compatible".
Incidentally, related to the simulator / Linux ABI, there's a
transitional stage (see gensyscalls), reloading between "struct stat"
(sys/stat.h) and "struct new_stat" (kernel/simulator) as necessary.
Tested by a cris-elf gcc build (including libgfortran).
2021-02-16 04:20:35 +08:00
|
|
|
#if !(defined(__svr4__) && !defined(__PPC__) && !defined(__sun__))
|
2009-12-18 03:22:23 +08:00
|
|
|
#define st_atime st_atim.tv_sec
|
|
|
|
#define st_ctime st_ctim.tv_sec
|
|
|
|
#define st_mtime st_mtim.tv_sec
|
|
|
|
#endif
|
|
|
|
|
2002-02-10 04:40:37 +08:00
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
#define _IFMT 0170000 /* type of file */
|
|
|
|
#define _IFDIR 0040000 /* directory */
|
|
|
|
#define _IFCHR 0020000 /* character special */
|
|
|
|
#define _IFBLK 0060000 /* block special */
|
|
|
|
#define _IFREG 0100000 /* regular */
|
|
|
|
#define _IFLNK 0120000 /* symbolic link */
|
|
|
|
#define _IFSOCK 0140000 /* socket */
|
|
|
|
#define _IFIFO 0010000 /* fifo */
|
|
|
|
|
|
|
|
#define S_BLKSIZE 1024 /* size of a block */
|
|
|
|
|
|
|
|
#define S_ISUID 0004000 /* set user id on execution */
|
|
|
|
#define S_ISGID 0002000 /* set group id on execution */
|
|
|
|
#define S_ISVTX 0001000 /* save swapped text even after use */
|
2016-03-15 09:57:45 +08:00
|
|
|
#if __BSD_VISIBLE
|
2000-02-18 03:39:52 +08:00
|
|
|
#define S_IREAD 0000400 /* read permission, owner */
|
|
|
|
#define S_IWRITE 0000200 /* write permission, owner */
|
|
|
|
#define S_IEXEC 0000100 /* execute/search permission, owner */
|
|
|
|
#define S_ENFMT 0002000 /* enforcement-mode locking */
|
2016-03-15 09:57:45 +08:00
|
|
|
#endif /* !_BSD_VISIBLE */
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
#define S_IFMT _IFMT
|
|
|
|
#define S_IFDIR _IFDIR
|
|
|
|
#define S_IFCHR _IFCHR
|
|
|
|
#define S_IFBLK _IFBLK
|
|
|
|
#define S_IFREG _IFREG
|
|
|
|
#define S_IFLNK _IFLNK
|
|
|
|
#define S_IFSOCK _IFSOCK
|
|
|
|
#define S_IFIFO _IFIFO
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
/* The Windows header files define _S_ forms of these, so we do too
|
|
|
|
for easier portability. */
|
|
|
|
#define _S_IFMT _IFMT
|
|
|
|
#define _S_IFDIR _IFDIR
|
|
|
|
#define _S_IFCHR _IFCHR
|
|
|
|
#define _S_IFIFO _IFIFO
|
|
|
|
#define _S_IFREG _IFREG
|
|
|
|
#define _S_IREAD 0000400
|
|
|
|
#define _S_IWRITE 0000200
|
|
|
|
#define _S_IEXEC 0000100
|
|
|
|
#endif
|
|
|
|
|
2001-03-05 13:13:06 +08:00
|
|
|
#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
|
2000-02-18 03:39:52 +08:00
|
|
|
#define S_IRUSR 0000400 /* read permission, owner */
|
|
|
|
#define S_IWUSR 0000200 /* write permission, owner */
|
2001-03-05 13:13:06 +08:00
|
|
|
#define S_IXUSR 0000100/* execute/search permission, owner */
|
|
|
|
#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
|
2000-02-18 03:39:52 +08:00
|
|
|
#define S_IRGRP 0000040 /* read permission, group */
|
|
|
|
#define S_IWGRP 0000020 /* write permission, grougroup */
|
2001-03-05 13:13:06 +08:00
|
|
|
#define S_IXGRP 0000010/* execute/search permission, group */
|
|
|
|
#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
|
2000-02-18 03:39:52 +08:00
|
|
|
#define S_IROTH 0000004 /* read permission, other */
|
|
|
|
#define S_IWOTH 0000002 /* write permission, other */
|
2001-03-05 13:13:06 +08:00
|
|
|
#define S_IXOTH 0000001/* execute/search permission, other */
|
|
|
|
|
2016-03-15 09:57:45 +08:00
|
|
|
#if __BSD_VISIBLE
|
2010-07-01 16:45:52 +08:00
|
|
|
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
|
|
|
|
#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */
|
|
|
|
#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
|
|
|
|
#endif
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
#define S_ISBLK(m) (((m)&_IFMT) == _IFBLK)
|
|
|
|
#define S_ISCHR(m) (((m)&_IFMT) == _IFCHR)
|
|
|
|
#define S_ISDIR(m) (((m)&_IFMT) == _IFDIR)
|
|
|
|
#define S_ISFIFO(m) (((m)&_IFMT) == _IFIFO)
|
|
|
|
#define S_ISREG(m) (((m)&_IFMT) == _IFREG)
|
|
|
|
#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK)
|
|
|
|
#define S_ISSOCK(m) (((m)&_IFMT) == _IFSOCK)
|
|
|
|
|
2021-05-20 02:43:25 +08:00
|
|
|
#if defined(__CYGWIN__) || defined(__rtems__)
|
2008-04-24 17:39:21 +08:00
|
|
|
/* Special tv_nsec values for futimens(2) and utimensat(2). */
|
|
|
|
#define UTIME_NOW -2L
|
|
|
|
#define UTIME_OMIT -1L
|
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2017-12-04 13:54:48 +08:00
|
|
|
int chmod (const char *__path, mode_t __mode );
|
|
|
|
int fchmod (int __fd, mode_t __mode);
|
|
|
|
int fstat (int __fd, struct stat *__sbuf );
|
|
|
|
int mkdir (const char *_path, mode_t __mode );
|
|
|
|
int mkfifo (const char *__path, mode_t __mode );
|
|
|
|
int stat (const char *__restrict __path, struct stat *__restrict __sbuf );
|
|
|
|
mode_t umask (mode_t __mask );
|
2000-02-18 03:39:52 +08:00
|
|
|
|
Cygwin: simplify some function names
Remove "32" or "64" from each of the following names: acl32,
aclcheck32, aclfrommode32, aclfrompbits32, aclfromtext32, aclsort32,
acltomode32, acltopbits32, acltotext32, facl32, fchown32, fcntl64,
fstat64, _fstat64, _fstat64_r, ftruncate64, getgid32, getgrent32,
getgrgid32, getgrnam32, getgroups32, getpwuid32, getpwuid_r32,
getuid32, getuid32, initgroups32, lseek64, lstat64, mknod32, mmap64,
setegid32, seteuid32, setgid32, setgroups32, setregid32, setreuid32,
setuid32, stat64, _stat64_r, truncate64.
Remove prototypes and macro definitions of these names.
Remove "#ifndef __INSIDE_CYGWIN__" from some headers so that the new
names will be available when compiling Cygwin.
Remove aliases that are no longer needed.
Include <unistd.h> in fhandler_clipboard.cc for the declarations of
geteuid and getegid.
2022-05-23 03:18:48 +08:00
|
|
|
#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__)
|
2017-12-04 13:54:48 +08:00
|
|
|
int lstat (const char *__restrict __path, struct stat *__restrict __buf );
|
|
|
|
int mknod (const char *__path, mode_t __mode, dev_t __dev );
|
2001-02-09 09:01:06 +08:00
|
|
|
#endif
|
|
|
|
|
2024-01-25 00:15:53 +08:00
|
|
|
#if __ATFILE_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
int fchmodat (int, const char *, mode_t, int);
|
|
|
|
int fstatat (int, const char *__restrict , struct stat *__restrict, int);
|
|
|
|
int mkdirat (int, const char *, mode_t);
|
|
|
|
int mkfifoat (int, const char *, mode_t);
|
|
|
|
int mknodat (int, const char *, mode_t, dev_t);
|
2021-01-26 22:16:31 +08:00
|
|
|
int utimensat (int, const char *, const struct timespec [2], int);
|
2016-03-15 09:57:45 +08:00
|
|
|
#endif
|
2024-01-25 00:15:53 +08:00
|
|
|
#if __POSIX_VISIBLE >= 200809
|
2021-01-26 22:16:31 +08:00
|
|
|
int futimens (int, const struct timespec [2]);
|
2008-04-23 19:13:24 +08:00
|
|
|
#endif
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
/* Provide prototypes for most of the _<systemcall> names that are
|
|
|
|
provided in newlib for some compilers. */
|
2021-11-09 11:22:27 +08:00
|
|
|
#ifdef _LIBC
|
2017-12-04 13:54:48 +08:00
|
|
|
int _fstat (int __fd, struct stat *__sbuf );
|
|
|
|
int _stat (const char *__restrict __path, struct stat *__restrict __sbuf );
|
|
|
|
int _mkdir (const char *_path, mode_t __mode );
|
2003-11-19 03:17:17 +08:00
|
|
|
#ifdef __LARGE64_FILES
|
2003-11-27 03:15:17 +08:00
|
|
|
struct stat64;
|
2017-12-04 13:54:48 +08:00
|
|
|
int _stat64 (const char *__restrict __path, struct stat64 *__restrict __sbuf );
|
|
|
|
int _fstat64 (int __fd, struct stat64 *__sbuf );
|
2003-11-19 03:17:17 +08:00
|
|
|
#endif
|
2002-02-24 04:46:28 +08:00
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
#endif /* !_STAT_H_ */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* _SYS_STAT_H */
|