Bootstrap

linux stat 文件状态头文件定义

wujun@wj-vBox:~/freescale/linux-imx/include$ vi ./uapi/asm-generic/stat.h

  1 #ifndef __ASM_GENERIC_STAT_H
  2 #define __ASM_GENERIC_STAT_H
  3 
  4 /*
  5  * Everybody gets this wrong and has to stick with it for all
  6  * eternity. Hopefully, this version gets used by new architectures
  7  * so they don't fall into the same traps.
  8  *
  9  * stat64 is copied from powerpc64, with explicit padding added.
 10  * stat is the same structure layout on 64-bit, without the 'long long'
 11  * types.
 12  *
 13  * By convention, 64 bit architectures use the stat interface, while
 14  * 32 bit architectures use the stat64 interface. Note that we don't
 15  * provide an __old_kernel_stat here, which new architecture should
 16  * not have to start with.
 17  */
 18 
 19 #include <asm/bitsperlong.h>
 20 
 21 #define STAT_HAVE_NSEC 1
 22 
 23 struct stat {
 24     unsigned long   st_dev;     /* Device.  */
 25     unsigned long   st_ino;     /* File serial number.  */
 26     unsigned int    st_mode;    /* File mode.  文件的类型和存取的权限 */
 27     unsigned int    st_nlink;   /* Link count.  */
 28     unsigned int    st_uid;     /* User ID of the file's owner.  */
 29     unsigned int    st_gid;     /* Group ID of the file's group. */
 30     unsigned long   st_rdev;    /* Device number, if device.  */
 31     unsigned long   __pad1;
 32     long        st_size;    /* Size of file, in bytes.  文件大小,以字节计算*/
 33     int     st_blksize; /* Optimal block size for I/O.  */
 34     int     __pad2;
 35     long        st_blocks;  /* Number 512-byte blocks allocated. */
 36     long        st_atime;   /* Time of last access.  */
 37     unsigned long   st_atime_nsec;
 38     long        st_mtime;   /* Time of last modification.  */
 39     unsigned long   st_mtime_nsec;
 40     long        st_ctime;   /* Time of last status change.  */
 41     unsigned long   st_ctime_nsec;
 42     unsigned int    __unused4;
 43     unsigned int    __unused5;
 44 };
 45 
 46 /* This matches struct stat64 in glibc2.1. Only used for 32 bit. */
 47 #if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64)
 48 struct stat64 {
 49     unsigned long long st_dev;  /* Device.  */
 50     unsigned long long st_ino;  /* File serial number.  */
 51     unsigned int    st_mode;    /* File mode.  */
 52     unsigned int    st_nlink;   /* Link count.  */
 53     unsigned int    st_uid;     /* User ID of the file's owner.  */
 54     unsigned int    st_gid;     /* Group ID of the file's group. */
 55     unsigned long long st_rdev; /* Device number, if device.  */
 56     unsigned long long __pad1;
 57     long long   st_size;    /* Size of file, in bytes.  */
 58     int     st_blksize; /* Optimal block size for I/O.  */
 59     int     __pad2;
 60     long long   st_blocks;  /* Number 512-byte blocks allocated. */
 61     int     st_atime;   /* Time of last access.  */
 62     unsigned int    st_atime_nsec;
 63     int     st_mtime;   /* Time of last modification.  */
 64     unsigned int    st_mtime_nsec;
 65     int     st_ctime;   /* Time of last status change.  */
 66     unsigned int    st_ctime_nsec;
 67     unsigned int    __unused4;
 68     unsigned int    __unused5;
 69 };
 70 #endif

 71 

 72 #endif /* __ASM_GENERIC_STAT_H */


wujun@wj-vBox:~/freescale/linux-imx/include$ vi ./uapi/linux/stat.h 

  1 #ifndef _UAPI_LINUX_STAT_H
  2 #define _UAPI_LINUX_STAT_H
  3 
  4 
  5 #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
  6 
  7 #define S_IFMT  00170000
  8 #define S_IFSOCK 0140000
  9 #define S_IFLNK  0120000
 10 #define S_IFREG  0100000
 11 #define S_IFBLK  0060000
 12 #define S_IFDIR  0040000
 13 #define S_IFCHR  0020000
 14 #define S_IFIFO  0010000
 15 #define S_ISUID  0004000
 16 #define S_ISGID  0002000
 17 #define S_ISVTX  0001000
 18 
 19 #define S_ISLNK(m)  (((m) & S_IFMT) == S_IFLNK)
 20 #define S_ISREG(m)  (((m) & S_IFMT) == S_IFREG)
 21 #define S_ISDIR(m)  (((m) & S_IFMT) == S_IFDIR)
 22 #define S_ISCHR(m)  (((m) & S_IFMT) == S_IFCHR)
 23 #define S_ISBLK(m)  (((m) & S_IFMT) == S_IFBLK)
 24 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
 25 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
 26 
 27 #define S_IRWXU 00700
 28 #define S_IRUSR 00400
 29 #define S_IWUSR 00200
 30 #define S_IXUSR 00100
 31 
 32 #define S_IRWXG 00070
 33 #define S_IRGRP 00040
 34 #define S_IWGRP 00020
 35 #define S_IXGRP 00010
 36 
 37 #define S_IRWXO 00007
 38 #define S_IROTH 00004
 39 #define S_IWOTH 00002
 40 #define S_IXOTH 00001
 41 
 42 #endif
 43 
 44 
 45 #endif /* _UAPI_LINUX_STAT_H */



;