glibc (2.38)

(root)/
include/
bits/
struct_stat.h
       1  /* Definition for struct stat.
       2     Copyright (C) 2020-2023 Free Software Foundation, Inc.
       3     This file is part of the GNU C Library.
       4  
       5     The GNU C Library is free software; you can redistribute it and/or
       6     modify it under the terms of the GNU Lesser General Public
       7     License as published by the Free Software Foundation; either
       8     version 2.1 of the License, or (at your option) any later version.
       9  
      10     The GNU C Library is distributed in the hope that it will be useful,
      11     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13     Lesser General Public License for more details.
      14  
      15     You should have received a copy of the GNU Lesser General Public
      16     License along with the GNU C Library.  If not, see
      17     <https://www.gnu.org/licenses/>.  */
      18  
      19  #if !defined _SYS_STAT_H && !defined _FCNTL_H
      20  # error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
      21  #endif
      22  
      23  #ifndef _BITS_STRUCT_STAT_H
      24  #define _BITS_STRUCT_STAT_H	1
      25  
      26  struct stat
      27    {
      28  #ifdef __USE_TIME_BITS64
      29  # include <bits/struct_stat_time64_helper.h>
      30  #else
      31      __dev_t st_dev;		/* Device.  */
      32  # ifndef __x86_64__
      33      unsigned short int __pad1;
      34  # endif
      35  # if defined __x86_64__ || !defined __USE_FILE_OFFSET64
      36      __ino_t st_ino;		/* File serial number.	*/
      37  # else
      38      __ino_t __st_ino;			/* 32bit file serial number.	*/
      39  # endif
      40  # ifndef __x86_64__
      41      __mode_t st_mode;			/* File mode.  */
      42      __nlink_t st_nlink;			/* Link count.  */
      43  # else
      44      __nlink_t st_nlink;		/* Link count.  */
      45      __mode_t st_mode;		/* File mode.  */
      46  # endif
      47      __uid_t st_uid;		/* User ID of the file's owner.	*/
      48      __gid_t st_gid;		/* Group ID of the file's group.*/
      49  # ifdef __x86_64__
      50      int __pad0;
      51  # endif
      52      __dev_t st_rdev;		/* Device number, if device.  */
      53  # ifndef __x86_64__
      54      unsigned short int __pad2;
      55  # endif
      56  # if defined __x86_64__ || !defined __USE_FILE_OFFSET64
      57      __off_t st_size;			/* Size of file, in bytes.  */
      58  # else
      59      __off64_t st_size;			/* Size of file, in bytes.  */
      60  # endif
      61      __blksize_t st_blksize;	/* Optimal block size for I/O.  */
      62  # if defined __x86_64__  || !defined __USE_FILE_OFFSET64
      63      __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
      64  # else
      65      __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
      66  # endif
      67  # ifdef __USE_XOPEN2K8
      68      /* Nanosecond resolution timestamps are stored in a format
      69         equivalent to 'struct timespec'.  This is the type used
      70         whenever possible but the Unix namespace rules do not allow the
      71         identifier 'timespec' to appear in the <sys/stat.h> header.
      72         Therefore we have to handle the use of this header in strictly
      73         standard-compliant sources special.  */
      74      struct timespec st_atim;		/* Time of last access.  */
      75      struct timespec st_mtim;		/* Time of last modification.  */
      76      struct timespec st_ctim;		/* Time of last status change.  */
      77  #  define st_atime st_atim.tv_sec	/* Backward compatibility.  */
      78  #  define st_mtime st_mtim.tv_sec
      79  #  define st_ctime st_ctim.tv_sec
      80  # else
      81      __time_t st_atime;			/* Time of last access.  */
      82      __syscall_ulong_t st_atimensec;	/* Nscecs of last access.  */
      83      __time_t st_mtime;			/* Time of last modification.  */
      84      __syscall_ulong_t st_mtimensec;	/* Nsecs of last modification.  */
      85      __time_t st_ctime;			/* Time of last status change.  */
      86      __syscall_ulong_t st_ctimensec;	/* Nsecs of last status change.  */
      87  # endif
      88  # ifdef __x86_64__
      89      __syscall_slong_t __glibc_reserved[3];
      90  # else
      91  #  ifndef __USE_FILE_OFFSET64
      92      unsigned long int __glibc_reserved4;
      93      unsigned long int __glibc_reserved5;
      94  #  else
      95      __ino64_t st_ino;			/* File serial number.	*/
      96  #  endif
      97  # endif
      98  #endif /* __USE_TIME_BITS64  */
      99    };
     100  
     101  #ifdef __USE_LARGEFILE64
     102  /* Note stat64 has the same shape as stat for x86-64.  */
     103  struct stat64
     104    {
     105  # ifdef __USE_TIME_BITS64
     106  #  include <bits/struct_stat_time64_helper.h>
     107  # else
     108      __dev_t st_dev;		/* Device.  */
     109  #  ifdef __x86_64__
     110      __ino64_t st_ino;		/* File serial number.  */
     111      __nlink_t st_nlink;		/* Link count.  */
     112      __mode_t st_mode;		/* File mode.  */
     113  #  else
     114      unsigned int __pad1;
     115      __ino_t __st_ino;			/* 32bit file serial number.	*/
     116      __mode_t st_mode;			/* File mode.  */
     117      __nlink_t st_nlink;			/* Link count.  */
     118  #  endif
     119      __uid_t st_uid;		/* User ID of the file's owner.	*/
     120      __gid_t st_gid;		/* Group ID of the file's group.*/
     121  #  ifdef __x86_64__
     122      int __pad0;
     123      __dev_t st_rdev;		/* Device number, if device.  */
     124      __off_t st_size;		/* Size of file, in bytes.  */
     125  #  else
     126      __dev_t st_rdev;			/* Device number, if device.  */
     127      unsigned int __pad2;
     128      __off64_t st_size;			/* Size of file, in bytes.  */
     129  #  endif
     130      __blksize_t st_blksize;	/* Optimal block size for I/O.  */
     131      __blkcnt64_t st_blocks;	/* Nr. 512-byte blocks allocated.  */
     132  #  ifdef __USE_XOPEN2K8
     133      /* Nanosecond resolution timestamps are stored in a format
     134         equivalent to 'struct timespec'.  This is the type used
     135         whenever possible but the Unix namespace rules do not allow the
     136         identifier 'timespec' to appear in the <sys/stat.h> header.
     137         Therefore we have to handle the use of this header in strictly
     138         standard-compliant sources special.  */
     139      struct timespec st_atim;		/* Time of last access.  */
     140      struct timespec st_mtim;		/* Time of last modification.  */
     141      struct timespec st_ctim;		/* Time of last status change.  */
     142  #  else
     143      __time_t st_atime;			/* Time of last access.  */
     144      __syscall_ulong_t st_atimensec;	/* Nscecs of last access.  */
     145      __time_t st_mtime;			/* Time of last modification.  */
     146      __syscall_ulong_t st_mtimensec;	/* Nsecs of last modification.  */
     147      __time_t st_ctime;			/* Time of last status change.  */
     148      __syscall_ulong_t st_ctimensec;	/* Nsecs of last status change.  */
     149  #  endif
     150  #  ifdef __x86_64__
     151      __syscall_slong_t __glibc_reserved[3];
     152  #  else
     153      __ino64_t st_ino;			/* File serial number.		*/
     154  #  endif
     155  # endif /* __USE_TIME_BITS64  */
     156    };
     157  #endif
     158  
     159  /* Tell code we have these members.  */
     160  #define	_STATBUF_ST_BLKSIZE
     161  #define _STATBUF_ST_RDEV
     162  /* Nanosecond resolution time values are supported.  */
     163  #define _STATBUF_ST_NSEC
     164  
     165  #endif /* _BITS_STRUCT_STAT_H  */