home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue2 / SDL.ARC / !unixlib / source / clib / sys / h / stat < prev    next >
Encoding:
Text File  |  2004-09-17  |  6.3 KB  |  212 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/sys/stat.h,v $
  4.  * $Date: 2004/09/17 18:39:54 $
  5.  * $Revision: 1.9 $
  6.  * $State: Exp $
  7.  * $Author: peter $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. /* POSIX Standard 5.6: File Characteristics <sys/stat.h>.  */
  12.  
  13. #ifndef __SYS_STAT_H
  14. #define __SYS_STAT_H
  15.  
  16. #ifndef __UNIXLIB_FEATURES_H
  17. #include <unixlib/features.h>
  18. #endif
  19.  
  20. #ifndef __UNIXLIB_TYPES_H
  21. #include <unixlib/types.h>
  22. #endif
  23.  
  24. #define __need_time_t
  25. #include <time.h>
  26.  
  27. /* The Single Unix specification says that some more types are
  28.    available here.  */
  29. #ifndef __dev_t_defined
  30. typedef __dev_t dev_t;
  31. #define __dev_t_defined
  32. #endif
  33.  
  34. #ifndef __gid_t_defined
  35. typedef __gid_t gid_t;
  36. #define __gid_t_defined
  37. #endif
  38.  
  39. #ifndef __ino_t_defined
  40. typedef __ino_t ino_t;
  41. #define __ino_t_defined
  42. #endif
  43.  
  44. #ifndef __mode_t_defined
  45. typedef __mode_t mode_t;
  46. #define __mode_t_defined
  47. #endif
  48.  
  49. #ifndef __nlink_t_defined
  50. typedef __nlink_t nlink_t;
  51. #define __nlink_t_defined
  52. #endif
  53.  
  54. #ifndef __off_t_defined
  55. typedef __off_t off_t;
  56. #define __off_t_defined
  57. #endif
  58.  
  59. #ifndef __uid_t_defined
  60. typedef __uid_t uid_t;
  61. #define __uid_t_defined
  62. #endif
  63.  
  64. #ifndef __blkcnt_t_defined
  65. typedef __blkcnt_t blkcnt_t;
  66. #define __blkcnt_t_defined
  67. #endif
  68.  
  69. #ifndef __blksize_t_defined
  70. typedef __blksize_t blksize_t;
  71. #define __blksize_t_defined
  72. #endif
  73.  
  74. __BEGIN_DECLS
  75.  
  76. struct stat64
  77. {
  78.   __dev_t     st_dev; /* Device containing the file.  */
  79.   __ino_t     st_ino; /* File serial number.  */
  80.   __mode_t     st_mode; /* File mode.  */
  81.   __nlink_t    st_nlink; /* Link count.  */
  82.   __uid_t    st_uid; /* User ID of the file's owner.  */
  83.   __gid_t    st_gid; /* Group ID of the file's group. */
  84.   __dev_t     st_rdev; /* Device number, if device.  */
  85.   __off_t     st_size; /* Size of file, in bytes.  */
  86.   __time_t    st_atime; /* Time of last access.  */
  87.   unsigned long int st_atime_usec;
  88.   __time_t    st_mtime; /* Time of last modification.  */
  89.   unsigned long int st_mtime_usec;
  90.   __time_t    st_ctime; /* Time of last status change.  */
  91.   unsigned long int st_ctime_usec;
  92.   unsigned long int st_blksize; /* Optimal block size for I/O.  */
  93. #define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
  94. /*  unsigned long int st_nblocks; / * Number of 512-byte blocks allocated.  */
  95.   unsigned long int st_blocks; /* Number of 512-byte blocks allocated.  */
  96. };
  97.  
  98. #define stat stat64
  99.  
  100. /* Bit masks.  */
  101.  
  102. /* Extract the file type code portion of a mode value.  */
  103. #define S_IFMT        0770000
  104.  
  105. /* File type code for a FIFO or pipe.  */
  106. #define S_IFIFO     0010000
  107. #define S_IFPORT    S_IFIFO
  108. /* File type code for a terminal type device file.  */
  109. #define S_IFCHR     0020000
  110. /* File type code for a directory. */
  111. #define S_IFDIR     0040000
  112. /* File type code for a block-oriented device file (disk file).  */
  113. #define S_IFBLK     0100000
  114. /* File type code for a regular file.  */
  115. #define S_IFREG     0200000
  116. /* File type code for a symbolic link.  */
  117. #define S_IFLNK     0400000
  118. /* This is the set-user-ID on execute bit.  */
  119. #define S_ISUID     0004000
  120. /* This is the set-group-ID on execute bit.  */
  121. #define S_ISGID     0002000
  122. /* Socket.  */
  123. #define S_IFSOCK        0140000
  124.  
  125. /* Protection bits.  */
  126.  
  127. /* Save swapped text after use. */
  128. #define S_ISVTX     01000
  129. /* Read by owner.  */
  130. #define S_IREAD         0400
  131. /* Write by owner.  */
  132. #define S_IWRITE    0200
  133. /* Execute by owner.  */
  134. #define S_IEXEC        0100
  135.  
  136. /* Execute (for ordinary files) or search (for directories)
  137.    permission bit for the owner of the file.  */
  138. #define S_IXUSR        S_IEXEC
  139. /* Write permission bit for the owner of the file.  */
  140. #define S_IWUSR            S_IWRITE
  141. /* Read permission bit for the owner of the file.  */
  142. #define S_IRUSR        S_IREAD
  143.  
  144. /* Read, write and execute by owner.  */
  145. #define S_IRWXU (S_IREAD | S_IWRITE | S_IEXEC)
  146.  
  147. #define S_IRGRP    (S_IRUSR >> 3)    /* Read by group.  */
  148. #define S_IWGRP    (S_IWUSR >> 3)    /* Write by group.  */
  149. #define S_IXGRP    (S_IXUSR >> 3)    /* Execute by group.  */
  150. /* Read, write, and execute by group.  */
  151. #define S_IRWXG    (S_IRWXU >> 3)
  152.  
  153. #define S_IROTH    (S_IRGRP >> 3)    /* Read by others.  */
  154. #define S_IWOTH    (S_IWGRP >> 3)    /* Write by others.  */
  155. #define S_IXOTH    (S_IXGRP >> 3)    /* Execute by others.  */
  156. /* Read, write, and execute by others.  */
  157. #define S_IRWXO    (S_IRWXG >> 3)
  158.  
  159.  
  160.  
  161. /* Return nonzero if the file is a directory.  */
  162. #define S_ISDIR(x) (((x) & S_IFSOCK) == S_IFDIR)
  163. /* Return nonzero if the file is a terminal type device.  */
  164. #define S_ISCHR(x) ((x) & S_IFCHR)
  165. /* Return nonzero if the file is a block special file (like a disk). */
  166. #define S_ISBLK(x) (((x) & S_IFSOCK) == S_IFBLK)
  167. /* Return nonzero if the file is a regular file.  */
  168. #define S_ISREG(x) ((x) & S_IFREG)
  169. /* Return nonzero if the file is a FIFO file for pipe.  */
  170. #define S_ISFIFO(x) ((x) & S_IFIFO)
  171. /* Return nonzero if the file is a symbolic link.  */
  172. #define S_ISLNK(x) ((x) & S_IFLNK)
  173. /* Return nonzero if the file is a socket.  */
  174. #define S_ISSOCK(x) (((x) & S_IFSOCK) == S_IFSOCK)
  175.  
  176. extern int stat (const char *__filename, struct stat *__buf) __THROW;
  177. extern int lstat (const char *__filename, struct stat *__buf) __THROW;
  178. extern int lstat64 (const char *__filename, struct stat *__buf) __THROW;
  179. extern int fstat (int __fd, struct stat *__buf) __THROW;
  180. extern int fstat64 (int __fd, struct stat *__buf) __THROW;
  181.  
  182. #ifdef __UNIXLIB_INTERNALS
  183. /* We declare __stat here to prevent the inclusion if <sys/stat.h> in
  184.    <unixlib/local.h>.  This function is internal to stat and fstat.  */
  185. extern void __stat (int __objtype, int __loadaddr, int __execaddr,
  186.                     int __length, int __attr, struct stat *buf);
  187. #endif
  188.  
  189. /* Set file access permissions for file to mode.  */
  190. extern int chmod (const char *__file, __mode_t __mode) __THROW;
  191.  
  192. /* Set file access permissions of the file fd is open on to mode.  */
  193. extern int fchmod (int __fd, __mode_t __mode) __THROW;
  194.  
  195. /* Set the file creation mask of the current process to mask,
  196.    return the old creation mask.  */
  197. extern __mode_t umask (__mode_t __mask) __THROW;
  198.  
  199. /* Create a new directory named path, with permission bits mode.  */
  200. extern int mkdir (const char *__path, __mode_t __mode) __THROW;
  201.  
  202. /* Create a device file named path, with permission and special bits mode
  203.    and device number dev.  */
  204. extern int mknod (const char *__path, __mode_t __mode, __dev_t __dev) __THROW;
  205.  
  206. /* Create a new FIFO named path, with permission bits mode.  */
  207. extern int mkfifo (const char *__path, __mode_t __mode) __THROW;
  208.  
  209. __END_DECLS
  210.  
  211. #endif
  212.