bunxtype.inc 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 baseunix unit, also used in system.
  6. This file implements all the types/constants which must
  7. be defined to port FPC to a new POSIX compliant OS.
  8. See the file COPYING.FPC, included in this distribution,
  9. for details about the copyright.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. **********************************************************************}
  14. {***********************************************************************}
  15. { POSIX STRUCTURES }
  16. {***********************************************************************}
  17. {$i ptypes.inc}
  18. // CONST SYS_NMLN=65;
  19. // Can't find these two in Posix and in FreeBSD
  20. //CONST
  21. // _UTSNAME_LENGTH = ;
  22. // _UTSNAME_NODENAME_LENGTH = ;
  23. TYPE
  24. { system information services }
  25. utsname = record
  26. sysname : Array[0..SYS_NMLN-1] OF Char; // Name of this OS
  27. nodename: Array[0..SYS_NMLN-1] OF Char; // Name of this network node.
  28. release : Array[0..SYS_NMLN-1] OF Char; // Release level.
  29. version : Array[0..SYS_NMLN-1] OF Char; // Version level.
  30. machine : Array[0..SYS_NMLN-1] OF Char; // Hardware type.
  31. end;
  32. TUtsName= utsname;
  33. pUtsName= ^utsname;
  34. { file characteristics services }
  35. stat = record { the types are real}
  36. st_dev : dev_t; // inode's device
  37. st_ino : ino_t; // inode's number
  38. st_mode : mode_t; // inode protection mode
  39. st_nlink : nlink_t; // number of hard links
  40. st_uid : uid_t; // user ID of the file's owner
  41. st_gid : gid_t; // group ID of the file's group
  42. st_rdev : dev_t; // device type
  43. st_atime : time_t; // time of last access
  44. st_atimensec : clong; // nsec of last access
  45. st_mtime : time_t; // time of last data modification
  46. st_mtimensec : clong; // nsec of last data modification
  47. st_ctime : time_t; // time of last file status change
  48. st_ctimensec : clong; // nsec of last file status change
  49. st_size : off_t; // file size, in bytes
  50. st_blocks : cint64; // blocks allocated for file
  51. st_blksize : cuint32; // optimal blocksize for I/O
  52. st_flags : cuint32; // user defined flags for file
  53. st_gen : cuint32; // file generation number
  54. {$ifndef NetBSD}
  55. st_lspare : cint32;
  56. {$endif}
  57. st_qspare : array[0..1] Of cint64;
  58. end;
  59. TStat = stat;
  60. pStat = ^stat;
  61. { directory services }
  62. dirent = record
  63. d_fileno : cuint32; // file number of entry
  64. d_reclen : cuint16; // length of this record
  65. d_type : cuint8; // file type, see below
  66. d_namlen : cuint8; // length of string in d_name
  67. d_name : array[0..(255 + 1)-1] of char; // name must be no longer than this
  68. end;
  69. TDirent = dirent;
  70. pDirent = ^dirent;
  71. dir = packed record
  72. dd_fd : cint; // file descriptor associated with directory
  73. dd_loc : clong; // offset in current buffer
  74. dd_size : clong; // amount of data returned by getdirentries
  75. dd_buf : pchar; // data buffer
  76. dd_len : cint; // size of data buffer
  77. dd_seek : clong; // magic cookie returned by getdirentries
  78. dd_rewind : clong; // magic cookie for rewinding
  79. dd_flags : cint; // flags for readdir
  80. end;
  81. TDir = dir;
  82. pDir = ^dir;
  83. utimbuf = record
  84. actime : time_t;
  85. modtime : time_t;
  86. end;
  87. TUtimBuf = utimbuf;
  88. putimbuf = ^utimbuf;
  89. flock = record
  90. l_start : off_t; { starting offset }
  91. l_len : off_t; { len = 0 means until end of file }
  92. l_pid : pid_t; { lock owner }
  93. l_type : cshort; { lock type: read/write, etc. }
  94. l_whence: cshort; { type of l_start }
  95. end;
  96. TFlock = flock;
  97. pFlock = ^flock;
  98. tms = packed record
  99. tms_utime : clock_t; { User CPU time }
  100. tms_stime : clock_t; { System CPU time }
  101. tms_cutime : clock_t; { User CPU time of terminated child procs }
  102. tms_cstime : clock_t; { System CPU time of terminated child procs }
  103. end;
  104. TTms= tms;
  105. pTms= ^tms;
  106. {***********************************************************************}
  107. { POSIX CONSTANT ROUTINE DEFINITIONS }
  108. {***********************************************************************}
  109. CONST
  110. { access routine - these maybe OR'ed together }
  111. F_OK = 0; { test for existence of file }
  112. R_OK = 4; { test for read permission on file }
  113. W_OK = 2; { test for write permission on file }
  114. X_OK = 1; { test for execute or search permission }
  115. { seek routine }
  116. SEEK_SET = 0; { seek from beginning of file }
  117. SEEK_CUR = 1; { seek from current position }
  118. SEEK_END = 2; { seek from end of file }
  119. { open routine }
  120. { File access modes for `open' and `fcntl'. }
  121. O_RDONLY = 0; { Open read-only. }
  122. O_WRONLY = 1; { Open write-only. }
  123. O_RDWR = 2; { Open read/write. }
  124. { Bits OR'd into the second argument to open. }
  125. O_CREAT = $200; { Create file if it doesn't exist. }
  126. O_EXCL = $800; { Fail if file already exists. }
  127. O_TRUNC = $400; { Truncate file to zero length. }
  128. O_NOCTTY = $8000; { Don't assign a controlling terminal. }
  129. { File status flags for `open' and `fcntl'. }
  130. O_APPEND = 8; { Writes append to the file. }
  131. O_NONBLOCK = 4; { Non-blocking I/O. }
  132. { mode_t possible values }
  133. S_IRUSR = %0100000000; { Read permission for owner }
  134. S_IWUSR = %0010000000; { Write permission for owner }
  135. S_IXUSR = %0001000000; { Exec permission for owner }
  136. S_IRGRP = %0000100000; { Read permission for group }
  137. S_IWGRP = %0000010000; { Write permission for group }
  138. S_IXGRP = %0000001000; { Exec permission for group }
  139. S_IROTH = %0000000100; { Read permission for world }
  140. S_IWOTH = %0000000010; { Write permission for world }
  141. S_IXOTH = %0000000001; { Exec permission for world }
  142. { Used for waitpid }
  143. WNOHANG = 1; { don't block waiting }
  144. WUNTRACED = 2; { report status of stopped children }
  145. {*************************************************************************}
  146. { SIGNALS }
  147. {*************************************************************************}
  148. {$i signal.inc}
  149. // function geterrno:longint;
  150. // procedure seterrno(i:longint);
  151. {
  152. $Log$
  153. Revision 1.1 2003-01-03 15:45:21 marco
  154. * Renamed to bunxtype.inc (from osposixh.inc), some minor changes
  155. (as introduced going from posix unit to baseunix)
  156. Revision 1.6 2002/10/27 17:21:29 marco
  157. * Only "difficult" functions + execvp + termios + rewinddir left to do
  158. Revision 1.5 2002/10/27 11:58:30 marco
  159. * Modifications from Saturday.
  160. Revision 1.4 2002/09/07 16:01:17 peter
  161. * old logs removed and tabs fixed
  162. Revision 1.3 2002/08/21 07:03:16 marco
  163. * Fixes from Tuesday.
  164. Revision 1.2 2002/08/19 12:29:11 marco
  165. * First working POSIX *BSD system unit.
  166. Revision 1.1 2002/08/03 19:34:19 marco
  167. * Initial *BSD versions. Seems that OpenBSD doesn't need much change,
  168. NetBSD may need some fixes to stat record and ftruncate and lseek.
  169. It is all close together, and it should be doable to have just one copy
  170. of these for *BSD.
  171. }