version 1.1, 2012/05/29 09:29:43
|
version 1.1.1.2, 2021/03/17 13:38:46
|
Line 1
|
Line 1
|
/* Provide a more complete sys/stat header file. | /* Provide a more complete sys/stat.h header file. |
Copyright (C) 2005-2011 Free Software Foundation, Inc. | Copyright (C) 2005-2019 Free Software Foundation, Inc. |
|
|
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
Line 12
|
Line 12
|
GNU General Public License for more details. |
GNU General Public License for more details. |
|
|
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software Foundation, | along with this program; if not, see <https://www.gnu.org/licenses/>. */ |
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | |
|
|
/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */ |
/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */ |
|
|
Line 36
|
Line 35
|
|
|
#ifndef _@GUARD_PREFIX@_SYS_STAT_H |
#ifndef _@GUARD_PREFIX@_SYS_STAT_H |
|
|
/* Get nlink_t. */ | /* Get nlink_t. |
| May also define off_t to a 64-bit type on native Windows. */ |
#include <sys/types.h> |
#include <sys/types.h> |
|
|
/* Get struct timespec. */ |
/* Get struct timespec. */ |
Line 54
|
Line 54
|
|
|
/* The definition of _GL_WARN_ON_USE is copied here. */ |
/* The definition of _GL_WARN_ON_USE is copied here. */ |
|
|
|
/* Before doing "#define mknod rpl_mknod" below, we need to include all |
|
headers that may declare mknod(). OS/2 kLIBC declares mknod() in |
|
<unistd.h>, not in <sys/stat.h>. */ |
|
#ifdef __KLIBC__ |
|
# include <unistd.h> |
|
#endif |
|
|
/* Before doing "#define mkdir rpl_mkdir" below, we need to include all |
/* Before doing "#define mkdir rpl_mkdir" below, we need to include all |
headers that may declare mkdir(). */ | headers that may declare mkdir(). Native Windows platforms declare mkdir |
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | in <io.h> and/or <direct.h>, not in <sys/stat.h>. */ |
| #if defined _WIN32 && ! defined __CYGWIN__ |
# include <io.h> /* mingw32, mingw64 */ |
# include <io.h> /* mingw32, mingw64 */ |
# include <direct.h> /* mingw64 */ | # include <direct.h> /* mingw64, MSVC 9 */ |
#endif |
#endif |
|
|
|
/* Native Windows platforms declare umask() in <io.h>. */ |
|
#if 0 && (defined _WIN32 && ! defined __CYGWIN__) |
|
# include <io.h> |
|
#endif |
|
|
|
/* Large File Support on native Windows. */ |
|
#if @WINDOWS_64_BIT_ST_SIZE@ |
|
# define stat _stati64 |
|
#endif |
|
|
|
/* Optionally, override 'struct stat' on native Windows. */ |
|
#if @GNULIB_OVERRIDES_STRUCT_STAT@ |
|
|
|
# undef stat |
|
# if @GNULIB_STAT@ |
|
# define stat rpl_stat |
|
# else |
|
/* Provoke a clear link error if stat() is used as a function and |
|
module 'stat' is not in use. */ |
|
# define stat stat_used_without_requesting_gnulib_module_stat |
|
# endif |
|
|
|
# if !GNULIB_defined_struct_stat |
|
struct stat |
|
{ |
|
dev_t st_dev; |
|
ino_t st_ino; |
|
mode_t st_mode; |
|
nlink_t st_nlink; |
|
# if 0 |
|
uid_t st_uid; |
|
# else /* uid_t is not defined by default on native Windows. */ |
|
short st_uid; |
|
# endif |
|
# if 0 |
|
gid_t st_gid; |
|
# else /* gid_t is not defined by default on native Windows. */ |
|
short st_gid; |
|
# endif |
|
dev_t st_rdev; |
|
off_t st_size; |
|
# if 0 |
|
blksize_t st_blksize; |
|
blkcnt_t st_blocks; |
|
# endif |
|
|
|
# if @WINDOWS_STAT_TIMESPEC@ |
|
struct timespec st_atim; |
|
struct timespec st_mtim; |
|
struct timespec st_ctim; |
|
# else |
|
time_t st_atime; |
|
time_t st_mtime; |
|
time_t st_ctime; |
|
# endif |
|
}; |
|
# if @WINDOWS_STAT_TIMESPEC@ |
|
# define st_atime st_atim.tv_sec |
|
# define st_mtime st_mtim.tv_sec |
|
# define st_ctime st_ctim.tv_sec |
|
/* Indicator, for gnulib internal purposes. */ |
|
# define _GL_WINDOWS_STAT_TIMESPEC 1 |
|
# endif |
|
# define GNULIB_defined_struct_stat 1 |
|
# endif |
|
|
|
/* Other possible values of st_mode. */ |
|
# if 0 |
|
# define _S_IFBLK 0x6000 |
|
# endif |
|
# if 0 |
|
# define _S_IFLNK 0xA000 |
|
# endif |
|
# if 0 |
|
# define _S_IFSOCK 0xC000 |
|
# endif |
|
|
|
#endif |
|
|
|
#ifndef S_IFIFO |
|
# ifdef _S_IFIFO |
|
# define S_IFIFO _S_IFIFO |
|
# endif |
|
#endif |
|
|
#ifndef S_IFMT |
#ifndef S_IFMT |
# define S_IFMT 0170000 |
# define S_IFMT 0170000 |
#endif |
#endif |
Line 133
|
Line 226
|
# endif |
# endif |
#endif |
#endif |
|
|
|
#ifndef S_ISMPX /* AIX */ |
|
# define S_ISMPX(m) 0 |
|
#endif |
|
|
#ifndef S_ISNAM /* Xenix */ |
#ifndef S_ISNAM /* Xenix */ |
# ifdef S_IFNAM |
# ifdef S_IFNAM |
# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM) |
# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM) |
Line 312 _GL_WARN_ON_USE (fchmodat, "fchmodat is not portable -
|
Line 409 _GL_WARN_ON_USE (fchmodat, "fchmodat is not portable -
|
#endif |
#endif |
|
|
|
|
#if @REPLACE_FSTAT@ | #if @GNULIB_FSTAT@ |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) | # if @REPLACE_FSTAT@ |
# define fstat rpl_fstat | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
# endif | # undef fstat |
| # define fstat rpl_fstat |
| # endif |
_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2))); |
_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2))); |
_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf)); |
_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf)); |
#else | # else |
_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); |
_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); |
#endif | # endif |
_GL_CXXALIASWARN (fstat); |
_GL_CXXALIASWARN (fstat); |
|
#elif @GNULIB_OVERRIDES_STRUCT_STAT@ |
|
# undef fstat |
|
# define fstat fstat_used_without_requesting_gnulib_module_fstat |
|
#elif @WINDOWS_64_BIT_ST_SIZE@ |
|
/* Above, we define stat to _stati64. */ |
|
# define fstat _fstati64 |
|
#elif defined GNULIB_POSIXCHECK |
|
# undef fstat |
|
# if HAVE_RAW_DECL_FSTAT |
|
_GL_WARN_ON_USE (fstat, "fstat has portability problems - " |
|
"use gnulib module fstat for portability"); |
|
# endif |
|
#endif |
|
|
|
|
#if @GNULIB_FSTATAT@ |
#if @GNULIB_FSTATAT@ |
Line 345 _GL_CXXALIAS_SYS (fstatat, int,
|
Line 457 _GL_CXXALIAS_SYS (fstatat, int,
|
(int fd, char const *name, struct stat *st, int flags)); |
(int fd, char const *name, struct stat *st, int flags)); |
# endif |
# endif |
_GL_CXXALIASWARN (fstatat); |
_GL_CXXALIASWARN (fstatat); |
|
#elif @GNULIB_OVERRIDES_STRUCT_STAT@ |
|
# undef fstatat |
|
# define fstatat fstatat_used_without_requesting_gnulib_module_fstatat |
#elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
# undef fstatat |
# undef fstatat |
# if HAVE_RAW_DECL_FSTATAT |
# if HAVE_RAW_DECL_FSTATAT |
Line 443 _GL_CXXALIAS_SYS (lstat, int, (const char *name, struc
|
Line 558 _GL_CXXALIAS_SYS (lstat, int, (const char *name, struc
|
# if @HAVE_LSTAT@ |
# if @HAVE_LSTAT@ |
_GL_CXXALIASWARN (lstat); |
_GL_CXXALIASWARN (lstat); |
# endif |
# endif |
|
#elif @GNULIB_OVERRIDES_STRUCT_STAT@ |
|
# undef lstat |
|
# define lstat lstat_used_without_requesting_gnulib_module_lstat |
#elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
# undef lstat |
# undef lstat |
# if HAVE_RAW_DECL_LSTAT |
# if HAVE_RAW_DECL_LSTAT |
Line 465 _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_
|
Line 583 _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_
|
Additionally, it declares _mkdir (and depending on compile flags, an |
Additionally, it declares _mkdir (and depending on compile flags, an |
alias mkdir), only in the nonstandard includes <direct.h> and <io.h>, |
alias mkdir), only in the nonstandard includes <direct.h> and <io.h>, |
which are included above. */ |
which are included above. */ |
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | # if defined _WIN32 && ! defined __CYGWIN__ |
|
|
# if !GNULIB_defined_rpl_mkdir |
# if !GNULIB_defined_rpl_mkdir |
static inline int | static int |
rpl_mkdir (char const *name, mode_t mode) |
rpl_mkdir (char const *name, mode_t mode) |
{ |
{ |
return _mkdir (name); |
return _mkdir (name); |
Line 592 _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
|
Line 710 _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
|
|
|
#if @GNULIB_STAT@ |
#if @GNULIB_STAT@ |
# if @REPLACE_STAT@ |
# if @REPLACE_STAT@ |
/* We can't use the object-like #define stat rpl_stat, because of | # if !@GNULIB_OVERRIDES_STRUCT_STAT@ |
struct stat. This means that rpl_stat will not be used if the user | /* We can't use the object-like #define stat rpl_stat, because of |
does (stat)(a,b). Oh well. */ | struct stat. This means that rpl_stat will not be used if the user |
# undef stat | does (stat)(a,b). Oh well. */ |
# ifdef _LARGE_FILES | # if defined _AIX && defined stat && defined _LARGE_FILES |
/* With _LARGE_FILES defined, AIX (only) defines stat to stat64, | /* With _LARGE_FILES defined, AIX (only) defines stat to stat64, |
so we have to replace stat64() instead of stat(). */ | so we have to replace stat64() instead of stat(). */ |
# define stat stat64 | # undef stat64 |
# undef stat64 | # define stat64(name, st) rpl_stat (name, st) |
# define stat64(name, st) rpl_stat (name, st) | # elif @WINDOWS_64_BIT_ST_SIZE@ |
# else /* !_LARGE_FILES */ | /* Above, we define stat to _stati64. */ |
# define stat(name, st) rpl_stat (name, st) | # if defined __MINGW32__ && defined _stati64 |
# endif /* !_LARGE_FILES */ | # ifndef _USE_32BIT_TIME_T |
| /* The system headers define _stati64 to _stat64. */ |
| # undef _stat64 |
| # define _stat64(name, st) rpl_stat (name, st) |
| # endif |
| # elif defined _MSC_VER && defined _stati64 |
| # ifdef _USE_32BIT_TIME_T |
| /* The system headers define _stati64 to _stat32i64. */ |
| # undef _stat32i64 |
| # define _stat32i64(name, st) rpl_stat (name, st) |
| # else |
| /* The system headers define _stati64 to _stat64. */ |
| # undef _stat64 |
| # define _stat64(name, st) rpl_stat (name, st) |
| # endif |
| # else |
| # undef _stati64 |
| # define _stati64(name, st) rpl_stat (name, st) |
| # endif |
| # elif defined __MINGW32__ && defined stat |
| # ifdef _USE_32BIT_TIME_T |
| /* The system headers define stat to _stat32i64. */ |
| # undef _stat32i64 |
| # define _stat32i64(name, st) rpl_stat (name, st) |
| # else |
| /* The system headers define stat to _stat64. */ |
| # undef _stat64 |
| # define _stat64(name, st) rpl_stat (name, st) |
| # endif |
| # elif defined _MSC_VER && defined stat |
| # ifdef _USE_32BIT_TIME_T |
| /* The system headers define stat to _stat32. */ |
| # undef _stat32 |
| # define _stat32(name, st) rpl_stat (name, st) |
| # else |
| /* The system headers define stat to _stat64i32. */ |
| # undef _stat64i32 |
| # define _stat64i32(name, st) rpl_stat (name, st) |
| # endif |
| # else /* !(_AIX || __MINGW32__ || _MSC_VER) */ |
| # undef stat |
| # define stat(name, st) rpl_stat (name, st) |
| # endif /* !_LARGE_FILES */ |
| # endif /* !@GNULIB_OVERRIDES_STRUCT_STAT@ */ |
_GL_EXTERN_C int stat (const char *name, struct stat *buf) |
_GL_EXTERN_C int stat (const char *name, struct stat *buf) |
_GL_ARG_NONNULL ((1, 2)); |
_GL_ARG_NONNULL ((1, 2)); |
# endif |
# endif |
|
#elif @GNULIB_OVERRIDES_STRUCT_STAT@ |
|
/* see above: |
|
#define stat stat_used_without_requesting_gnulib_module_stat |
|
*/ |
#elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
# undef stat |
# undef stat |
# if HAVE_RAW_DECL_STAT |
# if HAVE_RAW_DECL_STAT |