unixsysc.inc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Michael Van Canneyt,
  5. member of the Free Pascal development team.
  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. Function fdFlush (fd : Longint) : Boolean;
  13. begin
  14. fdFlush := (do_SysCall(syscall_nr_fsync, fd)=0);
  15. LinuxError:=fpgetErrno;
  16. end;
  17. Function Flock (fd,mode : longint) : boolean;
  18. begin
  19. flock:=do_Syscall(Syscall_nr_flock,fd,mode)=0;
  20. LinuxError:=fpgeterrno;
  21. end;
  22. Function StatFS(Path:Pathstr;Var Info:tstatfs):Boolean;
  23. {
  24. Get all information on a fileSystem, and return it in Info.
  25. Path is the name of a file/directory on the fileSystem you wish to
  26. investigate.
  27. }
  28. begin
  29. path:=path+#0;
  30. StatFS:=(do_SysCall(SysCall_nr_statfs,longint(@path[1]),longint(@Info))=0);
  31. LinuxError:=fpgeterrno;
  32. end;
  33. Function StatFS(Fd:Longint;Var Info:tstatfs):Boolean;
  34. {
  35. Get all information on a fileSystem, and return it in Info.
  36. Fd is the file descriptor of a file/directory on the fileSystem
  37. you wish to investigate.
  38. }
  39. begin
  40. StatFS:=(do_SysCall(SysCall_nr_fstatfs,fd,longint(@info))=0);
  41. LinuxError:=fpgeterrno;
  42. end;
  43. Function AssignPipe(var pipe_in,pipe_out:longint):boolean; [public, alias : 'FPC_SYSC_ASSIGNPIPE'];
  44. {
  45. Sets up a pair of file variables, which act as a pipe. The first one can
  46. be read from, the second one can be written to.
  47. If the operation was unsuccesful, linuxerror is set.
  48. }
  49. var
  50. pip : tpipe;
  51. begin
  52. assignPipe:=do_SysCall(SysCall_nr_pipe,longint(@pip))=0;
  53. pipe_in:=pip[1];
  54. pipe_out:=pip[2];
  55. linuxerror:=fpgeterrno;
  56. end;
  57. Function PClose(Var F:text) :longint;
  58. var
  59. pl : ^longint;
  60. res : longint;
  61. begin
  62. do_SysCall (syscall_nr_close,Textrec(F).Handle);
  63. { closed our side, Now wait for the other - this appears to be needed ?? }
  64. pl:=@(textrec(f).userdata[2]);
  65. fpwaitpid(pl^,@res,0);
  66. pclose:=res shr 8;
  67. end;
  68. Function PClose(Var F:file) : longint;
  69. var
  70. pl : ^longint;
  71. res : longint;
  72. begin
  73. do_SysCall (Syscall_nr_close,filerec(F).Handle);
  74. { closed our side, Now wait for the other - this appears to be needed ?? }
  75. pl:=@(filerec(f).userdata[2]);
  76. fpwaitpid(pl^,@res,0);
  77. pclose:=res shr 8;
  78. end;
  79. {--------------------------------
  80. Port IO functions
  81. --------------------------------}
  82. {$ifdef cpui386}
  83. Function IOperm (From,Num : Cardinal; Value : Longint) : boolean;
  84. {
  85. Set permissions on NUM ports starting with port FROM to VALUE
  86. this works ONLY as root.
  87. }
  88. begin
  89. IOPerm:=do_Syscall(Syscall_nr_ioperm,from,num,value)=0;
  90. LinuxError:=fpgetErrno;
  91. end;
  92. Function IoPL(Level : longint) : Boolean;
  93. begin
  94. IOPL:=do_Syscall(Syscall_nr_iopl,level)=0;
  95. LinuxError:=fpgetErrno;
  96. end;
  97. {$endif cpui386}
  98. {
  99. $Log$
  100. Revision 1.16 2003-11-09 13:48:55 marco
  101. * small fix
  102. Revision 1.15 2003/10/30 16:42:25 marco
  103. * Killing off old syscall convention anywhere except for oldlinux
  104. Revision 1.14 2003/10/17 22:11:28 olle
  105. * changed i386 to cpui386
  106. Revision 1.13 2003/09/20 12:45:34 marco
  107. * Small fix. Cycle works
  108. Revision 1.12 2003/09/16 21:46:27 marco
  109. * small fixes, checking things on linux
  110. Revision 1.11 2003/09/15 21:07:32 marco
  111. * second round of linux fixes. oldlinux now works
  112. Revision 1.10 2003/09/14 20:15:01 marco
  113. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  114. Revision 1.9 2003/07/08 21:23:24 peter
  115. * sparc fixes
  116. Revision 1.8 2002/12/18 16:43:26 marco
  117. * new unix rtl, linux part.....
  118. Revision 1.7 2002/09/07 16:01:20 peter
  119. * old logs removed and tabs fixed
  120. Revision 1.6 2002/03/05 20:04:25 michael
  121. + Patch from Sebastian for FCNTL call
  122. }