bunxtype.inc 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. Stat = Packed Record // No unix typing because of differences
  50. // kernel <->libc
  51. st_dev : word;
  52. pad1 : word;
  53. st_ino : longint;
  54. st_mode,
  55. nlink,
  56. uid,
  57. gid : word;
  58. rdev : word;
  59. pad2 : word;
  60. st_size,
  61. blksze,
  62. blocks,
  63. atime,
  64. unused1,
  65. mtime,
  66. unused2,
  67. ctime,
  68. unused3,
  69. unused4,
  70. unused5 : longint;
  71. end;
  72. TStat = Stat;
  73. PStat = ^Stat;
  74. {$ifdef notused} // 64-bit support needs some work still :-)
  75. { file characteristics services }
  76. stat64 = record
  77. st_dev : dev_t; // inode's device
  78. pad1 : cushort;
  79. {$ifdef 64bitfs} // ??
  80. __st_ino : ino_t;
  81. {$else}
  82. st_ino : ino_t; // inode's number
  83. {$endif}
  84. st_mode : mode_t; // inode protection mode
  85. st_nlink : nlink_t; // number of hard links
  86. st_uid : uid_t; // user ID of the file's owner
  87. st_gid : gid_t; // group ID of the file's group
  88. st_rdev : dev_t; // device type
  89. pad2 : cushort;
  90. {$ifdef 64bitfs}
  91. st_size : off64_t; // file size, in bytes
  92. {$else}
  93. st_size : off_t; // file size, in bytes
  94. {$endif}
  95. st_blksize : blksize_t; // optimal blocksize for I/O
  96. {$ifdef 64bitfs}
  97. st_blocks : blkcnt64_t; // blocks allocated for file
  98. {$else}
  99. st_blocks : blkcnt_t; // blocks allocated for file
  100. {$endif}
  101. st_atime : time_t; // time of last access
  102. unused1 : culong;
  103. st_mtime : time_t; // time of last data modification
  104. unused2 : culong;
  105. st_ctime : time_t; // time of last file status change
  106. unused3 : culong;
  107. {$ifdef 64bitfs}
  108. st_ino : ino64_t
  109. {$else}
  110. unused4 : culong;
  111. unused5 : culong;
  112. {$endif}
  113. end;
  114. {$endif}
  115. { directory services }
  116. Dirent = packed record
  117. {$ifndef 64bitfs}
  118. d_fileno : ino_t; // file number of entry
  119. d_off : off_t;
  120. {$else}
  121. d_fileno : ino64_t; // file number of entry
  122. d_off : off64_t;
  123. {$endif}
  124. d_reclen : cushort; // length of string in d_name
  125. {$ifdef Uselibc} // Libc different from kernel record!
  126. d_type : cuchar; // file type, see below
  127. {$endif}
  128. d_name : array[0..(255 + 1)-1] of char; // name must be no longer than this
  129. end;
  130. TDirent = Dirent;
  131. pDirent = ^Dirent;
  132. {$ifdef oldreaddir}
  133. { Still old one. This is a userland struct}
  134. Dir = packed record
  135. fd : integer;
  136. loc : longint;
  137. size : integer;
  138. buf : pdirent;
  139. {The following are used in libc, but NOT in the linux kernel sources ??}
  140. nextoff: longint;
  141. dd_max : integer; {size of buf. Irrelevant, as buf is of type dirent}
  142. lock : pointer;
  143. end;
  144. {$else}
  145. // new libc one. NOTE that off_t must be real, so 64-bit ifdef
  146. // 64bitsfs
  147. Dir = Record // packing doesn't matter. This is a userland struct.
  148. fd : cint;
  149. data : pchar;
  150. allocation: size_t;
  151. _size : size_t;
  152. offset : size_t;
  153. filepos : off_t;
  154. end;
  155. {$endif}
  156. TDir = Dir;
  157. pDir = ^Dir;
  158. UTimBuf = Record
  159. actime : time_t;
  160. modtime : time_t;
  161. end;
  162. TUtimBuf = UtimBuf;
  163. pUtimBuf = ^UtimBuf;
  164. FLock = Record
  165. l_type : cshort; { lock type: read/write, etc. }
  166. l_whence: cshort; { type of l_start }
  167. {$ifdef 64bitfs}
  168. l_start : off64_t; { starting offset }
  169. l_len : off64_t; { len = 0 means until end of file }
  170. {$else}
  171. l_start : off_t; { starting offset }
  172. l_len : off_t; { len = 0 means until end of file }
  173. {$endif}
  174. l_pid : pid_t; { lock owner }
  175. End;
  176. tms = packed Record
  177. tms_utime : clock_t; { User CPU time }
  178. tms_stime : clock_t; { System CPU time }
  179. tms_cutime : clock_t; { User CPU time of terminated child procs }
  180. tms_cstime : clock_t; { System CPU time of terminated child procs }
  181. end;
  182. TTms = tms;
  183. PTms = ^tms;
  184. {***********************************************************************}
  185. { POSIX CONSTANT ROUTINE DEFINITIONS }
  186. {***********************************************************************}
  187. CONST
  188. { access routine - these maybe OR'ed together }
  189. F_OK = 0; { test for existence of file }
  190. R_OK = 4; { test for read permission on file }
  191. W_OK = 2; { test for write permission on file }
  192. X_OK = 1; { test for execute or search permission }
  193. { seek routine }
  194. SEEK_SET = 0; { seek from beginning of file }
  195. SEEK_CUR = 1; { seek from current position }
  196. SEEK_END = 2; { seek from end of file }
  197. { open routine }
  198. { File access modes for `open' and `fcntl'. }
  199. O_RDONLY = 0; { Open read-only. }
  200. O_WRONLY = 1; { Open write-only. }
  201. O_RDWR = 2; { Open read/write. }
  202. { Bits OR'd into the second argument to open. }
  203. O_CREAT = $40; { Create file if it doesn't exist. }
  204. O_EXCL = $80; { Fail if file already exists. }
  205. O_TRUNC = $200; { Truncate file to zero length. }
  206. O_NOCTTY = $100; { Don't assign a controlling terminal. }
  207. { File status flags for `open' and `fcntl'. }
  208. O_APPEND = $400; { Writes append to the file. }
  209. O_NONBLOCK= $800; { Non-blocking I/O. }
  210. { mode_t possible values }
  211. S_IRUSR = %0100000000; { Read permission for owner }
  212. S_IWUSR = %0010000000; { Write permission for owner }
  213. S_IXUSR = %0001000000; { Exec permission for owner }
  214. S_IRGRP = %0000100000; { Read permission for group }
  215. S_IWGRP = %0000010000; { Write permission for group }
  216. S_IXGRP = %0000001000; { Exec permission for group }
  217. S_IROTH = %0000000100; { Read permission for world }
  218. S_IWOTH = %0000000010; { Write permission for world }
  219. S_IXOTH = %0000000001; { Exec permission for world }
  220. { Used for waitpid }
  221. WNOHANG = 1; { don't block waiting }
  222. WUNTRACED = 2; { report status of stopped children }
  223. {*************************************************************************}
  224. { SIGNALS }
  225. {*************************************************************************}
  226. {$i signal.inc}
  227. // function geterrno:longint;
  228. // procedure seterrno(i:longint);
  229. {
  230. $Log$
  231. Revision 1.1 2002-12-18 16:43:26 marco
  232. * new unix rtl, linux part.....
  233. Revision 1.1 2002/11/12 14:37:59 marco
  234. * Parts of new unix rtl
  235. }