2
0

unixsysc.inc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. do_SysCall(SysCall_nr_pipe,longint(@pip));
  53. pipe_in:=pip[1];
  54. pipe_out:=pip[2];
  55. linuxerror:=fpgeterrno;
  56. AssignPipe:=(LinuxError=0);
  57. end;
  58. Function PClose(Var F:text) :longint;
  59. var
  60. pl : ^longint;
  61. res : longint;
  62. begin
  63. do_SysCall (syscall_nr_close,Textrec(F).Handle);
  64. { closed our side, Now wait for the other - this appears to be needed ?? }
  65. pl:=@(textrec(f).userdata[2]);
  66. fpwaitpid(pl^,@res,0);
  67. pclose:=res shr 8;
  68. end;
  69. Function PClose(Var F:file) : longint;
  70. var
  71. pl : ^longint;
  72. res : longint;
  73. begin
  74. do_SysCall (Syscall_nr_close,filerec(F).Handle);
  75. { closed our side, Now wait for the other - this appears to be needed ?? }
  76. pl:=@(filerec(f).userdata[2]);
  77. fpwaitpid(pl^,@res,0);
  78. pclose:=res shr 8;
  79. end;
  80. {--------------------------------
  81. Port IO functions
  82. --------------------------------}
  83. {$ifdef cpui386}
  84. Function IOperm (From,Num : Cardinal; Value : Longint) : boolean;
  85. {
  86. Set permissions on NUM ports starting with port FROM to VALUE
  87. this works ONLY as root.
  88. }
  89. begin
  90. IOPerm:=do_Syscall(Syscall_nr_ioperm,from,num,value)=0;
  91. LinuxError:=fpgetErrno;
  92. end;
  93. Function IoPL(Level : longint) : Boolean;
  94. begin
  95. IOPL:=do_Syscall(Syscall_nr_iopl,level)=0;
  96. LinuxError:=fpgetErrno;
  97. end;
  98. {$endif cpui386}
  99. {
  100. $Log$
  101. Revision 1.15 2003-10-30 16:42:25 marco
  102. * Killing off old syscall convention anywhere except for oldlinux
  103. Revision 1.14 2003/10/17 22:11:28 olle
  104. * changed i386 to cpui386
  105. Revision 1.13 2003/09/20 12:45:34 marco
  106. * Small fix. Cycle works
  107. Revision 1.12 2003/09/16 21:46:27 marco
  108. * small fixes, checking things on linux
  109. Revision 1.11 2003/09/15 21:07:32 marco
  110. * second round of linux fixes. oldlinux now works
  111. Revision 1.10 2003/09/14 20:15:01 marco
  112. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  113. Revision 1.9 2003/07/08 21:23:24 peter
  114. * sparc fixes
  115. Revision 1.8 2002/12/18 16:43:26 marco
  116. * new unix rtl, linux part.....
  117. Revision 1.7 2002/09/07 16:01:20 peter
  118. * old logs removed and tabs fixed
  119. Revision 1.6 2002/03/05 20:04:25 michael
  120. + Patch from Sebastian for FCNTL call
  121. }