osposixh.inc 7.5 KB

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