bunxtype.inc 10.0 KB

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