bunxtype.inc 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2001 by Free Pascal development team
  5. Types and structures for the BaseUnix unit.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. ***********************************************************************}
  12. {***********************************************************************}
  13. { Base Unix Structures }
  14. {***********************************************************************}
  15. {$i ptypes.inc}
  16. CONST
  17. SYS_NMLM = 65;
  18. UTSNAME_LENGTH = SYS_NMLM;
  19. UTSNAME_NODENAME_LENGTH = UTSNAME_LENGTH;
  20. {$ifdef usedomain}
  21. UTSNAME_DOMAIN_LENGTH = UTSNAME_LENGTH;
  22. {$endif}
  23. TYPE
  24. Blksize_t = cuint;
  25. Blkcnt_t = cuint;
  26. Ino64_t = cint64;
  27. Off64_t = cint64;
  28. TBlkSize = BlkSize_t;
  29. PBlkSize = ^BlkSize_t;
  30. TBlkCnt = Blkcnt_t;
  31. PBlkCnt = ^Blkcnt_t;
  32. TIno64 = Ino64_t;
  33. PIno64 = ^Ino64_t;
  34. TOff64 = Off64_t;
  35. POff64 = ^Off64_t;
  36. { system information services }
  37. UtsName = Record
  38. Sysname : Array[0..UTSNAME_LENGTH -1] OF Char; // Name of this OS
  39. Nodename: Array[0..UTSNAME_NODENAME_LENGTH-1] OF Char; // Name of this network node.
  40. Release : Array[0..UTSNAME_LENGTH -1] OF Char; // Release level.
  41. Version : Array[0..UTSNAME_LENGTH -1] OF Char; // Version level.
  42. Machine : Array[0..UTSNAME_LENGTH -1] OF Char; // Hardware type.
  43. {$ifdef usedomain}
  44. Domain : array[0..UTSNAME_DOMAIN_LENGTH-1] of char; // Linux addition "Domain"
  45. {$endif}
  46. end;
  47. TUtsName = UtsName;
  48. PUtsName = TUtsName;
  49. { Definition of (kernel) stat type }
  50. { see kernel/include/asm-<cpu>/stat.h, include/linux/types.h and }
  51. { include /include/asm-<cpu>/posix-types.h }
  52. {$i stat.inc}
  53. TStat = Stat;
  54. PStat = ^Stat;
  55. {$ifdef notused} // 64-bit support needs some work still :-)
  56. { file characteristics services }
  57. stat64 = record
  58. st_dev : dev_t; // inode's device
  59. pad1 : cushort;
  60. {$ifdef 64bitfs} // ??
  61. __st_ino : ino_t;
  62. {$else}
  63. st_ino : ino_t; // inode's number
  64. {$endif}
  65. st_mode : mode_t; // inode protection mode
  66. st_nlink : nlink_t; // number of hard links
  67. st_uid : uid_t; // user ID of the file's owner
  68. st_gid : gid_t; // group ID of the file's group
  69. st_rdev : dev_t; // device type
  70. pad2 : cushort;
  71. {$ifdef 64bitfs}
  72. st_size : off64_t; // file size, in bytes
  73. {$else}
  74. st_size : off_t; // file size, in bytes
  75. {$endif}
  76. st_blksize : blksize_t; // optimal blocksize for I/O
  77. {$ifdef 64bitfs}
  78. st_blocks : blkcnt64_t; // blocks allocated for file
  79. {$else}
  80. st_blocks : blkcnt_t; // blocks allocated for file
  81. {$endif}
  82. st_atime : time_t; // time of last access
  83. unused1 : culong;
  84. st_mtime : time_t; // time of last data modification
  85. unused2 : culong;
  86. st_ctime : time_t; // time of last file status change
  87. unused3 : culong;
  88. {$ifdef 64bitfs}
  89. st_ino : ino64_t
  90. {$else}
  91. unused4 : culong;
  92. unused5 : culong;
  93. {$endif}
  94. end;
  95. {$endif}
  96. { directory services }
  97. Dirent = packed record
  98. {$ifndef 64bitfs}
  99. d_fileno : ino_t; // file number of entry
  100. d_off : off_t;
  101. {$else}
  102. d_fileno : ino64_t; // file number of entry
  103. d_off : off64_t;
  104. {$endif}
  105. d_reclen : cushort; // length of string in d_name
  106. {$ifdef Uselibc} // Libc different from kernel record!
  107. d_type : cuchar; // file type, see below
  108. {$endif}
  109. d_name : array[0..(255 + 1)-1] of char; // name must be no longer than this
  110. end;
  111. TDirent = Dirent;
  112. pDirent = ^Dirent;
  113. {$ifdef oldreaddir}
  114. { Still old one. This is a userland struct}
  115. Dir = packed record
  116. fd : integer;
  117. loc : longint;
  118. size : integer;
  119. buf : pdirent;
  120. {The following are used in libc, but NOT in the linux kernel sources ??}
  121. nextoff: longint;
  122. dd_max : integer; {size of buf. Irrelevant, as buf is of type dirent}
  123. lock : pointer;
  124. end;
  125. {$else}
  126. // new libc one. NOTE that off_t must be real, so 64-bit ifdef
  127. // 64bitsfs
  128. Dir = Record // packing doesn't matter. This is a userland struct.
  129. fd : cint;
  130. data : pchar;
  131. allocation: size_t;
  132. _size : size_t;
  133. offset : size_t;
  134. filepos : off_t;
  135. end;
  136. {$endif}
  137. TDir = Dir;
  138. pDir = ^Dir;
  139. UTimBuf = Record
  140. actime : time_t;
  141. modtime : time_t;
  142. end;
  143. TUtimBuf = UtimBuf;
  144. pUtimBuf = ^UtimBuf;
  145. FLock = Record
  146. l_type : cshort; { lock type: read/write, etc. }
  147. l_whence: cshort; { type of l_start }
  148. {$ifdef 64bitfs}
  149. l_start : off64_t; { starting offset }
  150. l_len : off64_t; { len = 0 means until end of file }
  151. {$else}
  152. l_start : off_t; { starting offset }
  153. l_len : off_t; { len = 0 means until end of file }
  154. {$endif}
  155. l_pid : pid_t; { lock owner }
  156. End;
  157. tms = packed Record
  158. tms_utime : clock_t; { User CPU time }
  159. tms_stime : clock_t; { System CPU time }
  160. tms_cutime : clock_t; { User CPU time of terminated child procs }
  161. tms_cstime : clock_t; { System CPU time of terminated child procs }
  162. end;
  163. TTms = tms;
  164. PTms = ^tms;
  165. {***********************************************************************}
  166. { POSIX CONSTANT ROUTINE DEFINITIONS }
  167. {***********************************************************************}
  168. CONST
  169. { access routine - these maybe OR'ed together }
  170. F_OK = 0; { test for existence of file }
  171. R_OK = 4; { test for read permission on file }
  172. W_OK = 2; { test for write permission on file }
  173. X_OK = 1; { test for execute or search permission }
  174. { seek routine }
  175. SEEK_SET = 0; { seek from beginning of file }
  176. SEEK_CUR = 1; { seek from current position }
  177. SEEK_END = 2; { seek from end of file }
  178. { open routine }
  179. { File access modes for `open' and `fcntl'. }
  180. O_RDONLY = 0; { Open read-only. }
  181. O_WRONLY = 1; { Open write-only. }
  182. O_RDWR = 2; { Open read/write. }
  183. { Bits OR'd into the second argument to open. }
  184. O_CREAT = $40; { Create file if it doesn't exist. }
  185. O_EXCL = $80; { Fail if file already exists. }
  186. O_TRUNC = $200; { Truncate file to zero length. }
  187. O_NOCTTY = $100; { Don't assign a controlling terminal. }
  188. { File status flags for `open' and `fcntl'. }
  189. O_APPEND = $400; { Writes append to the file. }
  190. O_NONBLOCK= $800; { Non-blocking I/O. }
  191. { mode_t possible values }
  192. S_IRUSR = %0100000000; { Read permission for owner }
  193. S_IWUSR = %0010000000; { Write permission for owner }
  194. S_IXUSR = %0001000000; { Exec permission for owner }
  195. S_IRGRP = %0000100000; { Read permission for group }
  196. S_IWGRP = %0000010000; { Write permission for group }
  197. S_IXGRP = %0000001000; { Exec permission for group }
  198. S_IROTH = %0000000100; { Read permission for world }
  199. S_IWOTH = %0000000010; { Write permission for world }
  200. S_IXOTH = %0000000001; { Exec permission for world }
  201. { Used for waitpid }
  202. WNOHANG = 1; { don't block waiting }
  203. WUNTRACED = 2; { report status of stopped children }
  204. {*************************************************************************}
  205. { SIGNALS }
  206. {*************************************************************************}
  207. {$i signal.inc}
  208. // function geterrno:longint;
  209. // procedure seterrno(i:longint);
  210. {
  211. $Log$
  212. Revision 1.2 2003-05-15 22:50:50 jonas
  213. * the stat type is processor-dependent
  214. * the dev_t tpye is processor dependent. Don't use it in the stat type
  215. however, as that one is also used at a time where dev_t is already
  216. defined as qword
  217. Revision 1.1 2002/12/18 16:43:26 marco
  218. * new unix rtl, linux part.....
  219. Revision 1.1 2002/11/12 14:37:59 marco
  220. * Parts of new unix rtl
  221. }