stat.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:5k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* stat.h - POSIX definitions for obtaining file characteristics */
  2. /* Copyright 1984-1995 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01m,23sep01,jkf  added const to mkdir
  7. 01l,28mar95,kdl  removed obsolete date/time fields from stat structure.
  8. 01k,19apr94,jmm  added support for file system stat ({f}statfs())
  9. 01j,22sep92,rrr  added support for c++
  10. 01i,18sep92,smb  added mkdir prototype
  11. 01h,26may92,rrr  the tree shuffle
  12. 01g,04oct91,rrr  passed through the ansification filter
  13.   -fixed #else and #endif
  14.   -changed TINY and UTINY to INT8 and UINT8
  15.   -changed copyright notice
  16. 01f,10jun91.del  added pragma for gnu960 alignment.
  17. 01e,05oct90,dnw  added fstat() and stat() declarations.
  18. 01d,05oct90,shl  added copyright notice.
  19.                  made #endif ANSI style.
  20. 01c,03oct90,kdl  changed comments.
  21. 01b,05may90,llk  added st_blksize and st_blocks fields so that net directory
  22.    can use stat structure.  Coincided with removal of
  23.    h/net/stat.h.
  24. 01a,30apr90,kdl  written.
  25. */
  26. #ifndef __INCstath
  27. #define __INCstath
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  32. #pragma align 1 /* tell gcc960 not to optimize alignments */
  33. #endif /* CPU_FAMILY==I960 */
  34. #define TIME ULONG /* type for file time fields */
  35. struct stat
  36.     {
  37.     ULONG st_dev; /* device ID number */
  38.     ULONG st_ino; /* file serial number */
  39.     USHORT st_mode; /* file mode (see below) */
  40.     short st_nlink; /* number of links to file */
  41.     short st_uid; /* user ID of file's owner */
  42.     short st_gid; /* group ID of file's group */
  43.     ULONG st_rdev; /* device ID, only if special file */
  44.     ULONG st_size; /* size of file, in bytes */
  45.     TIME st_atime; /* time of last access */
  46.     TIME st_mtime; /* time of last modification */
  47.     TIME st_ctime; /* time of last change of file status */
  48.     long st_blksize;
  49.     long st_blocks;
  50.     UINT8 st_attrib; /* file attribute byte (dosFs only) */
  51.     int reserved1; /* reserved for future use */
  52.     int reserved2; /* reserved for future use */
  53.     int reserved3; /* reserved for future use */
  54.     int reserved4; /* reserved for future use */
  55.     int reserved5; /* reserved for future use */
  56.     int reserved6; /* reserved for future use */
  57.     };
  58. typedef struct
  59.     {
  60.     long val[2];                    /* file system id type */
  61.     } fsid_t;
  62. /*
  63.  * file system statistics
  64.  */
  65. struct statfs
  66.     {
  67.     long f_type;                    /* type of info, zero for now */
  68.     long f_bsize;                   /* fundamental file system block size */
  69.     long f_blocks;                  /* total blocks in file system */
  70.     long f_bfree;                   /* free block in fs */
  71.     long f_bavail;                  /* free blocks avail to non-superuser */
  72.     long f_files;                   /* total file nodes in file system */
  73.     long f_ffree;                   /* free file nodes in fs */
  74.     fsid_t f_fsid;                  /* file system id */
  75.     long f_spare[7];                /* spare for later */
  76.     };
  77. /* File mode (st_mode) bit masks */
  78. #define S_IFMT  0xf000 /* file type field */
  79. #define S_IFIFO  0x1000 /*  fifo */
  80. #define S_IFCHR  0x2000 /*  character special */
  81. #define S_IFDIR  0x4000 /*  directory */
  82. #define S_IFBLK  0x6000 /*  block special */
  83. #define S_IFREG  0x8000 /*  regular */
  84. #define S_IFLNK  0xa000 /*  symbolic link */
  85. #define S_IFSOCK 0xc000 /*  socket */
  86. #define S_ISUID  0x0800 /* set user id on execution */
  87. #define S_ISGID  0x0400 /* set group id on execution */
  88. #define S_IRUSR  0x0100 /* read permission, owner */
  89. #define S_IWUSR  0x0080 /* write permission, owner */
  90. #define S_IXUSR  0x0040 /* execute/search permission, owner */
  91. #define S_IRWXU  0x01c0 /* read/write/execute permission, owner */
  92. #define S_IRGRP  0x0020 /* read permission, group */
  93. #define S_IWGRP  0x0010 /* write permission, group */
  94. #define S_IXGRP  0x0008 /* execute/search permission, group */
  95. #define S_IRWXG  0x0038 /* read/write/execute permission, group */
  96. #define S_IROTH  0x0004 /* read permission, other */
  97. #define S_IWOTH  0x0002 /* write permission, other */
  98. #define S_IXOTH  0x0001 /* execute/search permission, other */
  99. #define S_IRWXO  0x0007 /* read/write/execute permission, other */
  100. /* File type test macros */
  101. #define S_ISDIR(mode) ((mode & S_IFMT) == S_IFDIR) /* directory */
  102. #define S_ISCHR(mode) ((mode & S_IFMT) == S_IFCHR) /* character special */
  103. #define S_ISBLK(mode) ((mode & S_IFMT) == S_IFBLK) /* block special */
  104. #define S_ISREG(mode) ((mode & S_IFMT) == S_IFREG) /* regular file */
  105. #define S_ISFIFO(mode) ((mode & S_IFMT) == S_IFIFO) /* fifo special */
  106. /* function declarations */
  107. #if defined(__STDC__) || defined(__cplusplus)
  108. extern    STATUS       mkdir (const char *dirName);
  109. extern   STATUS       fstat (int fd, struct stat *pStat);
  110. extern   STATUS       stat (char *name, struct stat *pStat);
  111. extern   STATUS       fstatfs (int fd, struct statfs *pStat);
  112. extern   STATUS       statfs (char *name, struct statfs *pStat);
  113. #else
  114. extern    STATUS       mkdir ();
  115. extern   STATUS       fstat ();
  116. extern   STATUS       stat ();
  117. extern   STATUS       fstatfs ();
  118. extern   STATUS       statfs ();
  119. #endif /* __STDC__ */
  120. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  121. #pragma align 0 /* turn off alignment requirement */
  122. #endif /* CPU_FAMILY==I960 */
  123. #ifdef __cplusplus
  124. }
  125. #endif
  126. #endif /* __INCstath */