Procházet zdrojové kódy

Merged revisions 6750,6753,6762,6767,6775,6949,6962,6964,7000,7060,7258,7604,7717-7718,8033,8092,8120,8123,8126,8130,8140,8152,8254,8256,8330-8331,8333,8364-8365,8401,8405 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r6750 | ivost | 2007-03-08 22:40:59 +0100 (Thu, 08 Mar 2007) | 3 lines

* disabled Clone syscall in linux.pp, it was completly wrong (I will replace it)
* added ldt record and constants to linux.pp

........
r6753 | ivost | 2007-03-09 10:29:17 +0100 (Fri, 09 Mar 2007) | 2 lines

* Added InterlockedCompareExchange64 for i386 (supported over cmpxchg8b instruction)

........
r6762 | florian | 2007-03-09 22:27:06 +0100 (Fri, 09 Mar 2007) | 2 lines

* map SIGILL to rte 216, experimental

........
r6767 | ivost | 2007-03-09 23:23:42 +0100 (Fri, 09 Mar 2007) | 2 lines

* updated TLS segmentdescriptor definiton (record user_desc)

........
r6775 | ivost | 2007-03-10 19:08:21 +0100 (Sat, 10 Mar 2007) | 2 lines

* removed InterlockedCompareExchange64 for i386 from system unit

........
r6949 | ivost | 2007-03-21 21:56:57 +0100 (Wed, 21 Mar 2007) | 2 lines

* fixed bug in linux.pp / user_desc record

........
r6962 | daniel | 2007-03-23 16:53:04 +0100 (Fri, 23 Mar 2007) | 2 lines

* Change dd_nextoff to cardinal to prevent upscaling of calculations to 64-bit.

........
r6964 | daniel | 2007-03-23 23:35:12 +0100 (Fri, 23 Mar 2007) | 2 lines

* Switch to classic field names to prevent further messing with compatibility.

........
r7000 | daniel | 2007-03-25 19:55:47 +0200 (Sun, 25 Mar 2007) | 2 lines

* Revert 6964

........
r7060 | florian | 2007-04-05 11:38:06 +0200 (Thu, 05 Apr 2007) | 2 lines

* fixed another bloody stat record issue

........
r7258 | mazen | 2007-05-04 12:59:30 +0200 (Fri, 04 May 2007) | 2 lines

+ Added ATT assmebler mode directive to override any default in fpc.cfg. Otherwise we need to override it in makefile.

........
r7604 | marco | 2007-06-09 16:24:13 +0200 (Sat, 09 Jun 2007) | 2 lines

* Fix for 9220 for socket2text stuff too

........
r7717 | marco | 2007-06-17 22:29:33 +0200 (Sun, 17 Jun 2007) | 2 lines

* fixed deprecated

........
r7718 | marco | 2007-06-17 22:31:08 +0200 (Sun, 17 Jun 2007) | 2 lines

* more deprecated fixes

........
r8033 | daniel | 2007-07-13 00:02:11 +0200 (Fri, 13 Jul 2007) | 3 lines

+ Add setcap/getcap
+ Restore clone

........
r8092 | micha | 2007-07-18 22:11:07 +0200 (Wed, 18 Jul 2007) | 1 line

* call HandleErrorAddrFrame on return of signal handler, reduces amount of code called within signal handler (for linux/i386)
........
r8120 | florian | 2007-07-21 21:45:44 +0200 (Sat, 21 Jul 2007) | 2 lines

* proper definition of O_LARGEFILE for all cpu platforms

........
r8123 | daniel | 2007-07-22 09:47:34 +0200 (Sun, 22 Jul 2007) | 3 lines

* Remove double definition of O_LARGEFILE for powerpc-linux and give it
the correct value: $10000

........
r8126 | daniel | 2007-07-22 11:53:21 +0200 (Sun, 22 Jul 2007) | 2 lines

* Prevent range check errors on powerpc-linux

........
r8130 | karoly | 2007-07-22 12:22:26 +0200 (Sun, 22 Jul 2007) | 2 lines

- dec(comment_typos,2);

........
r8140 | peter | 2007-07-22 22:42:41 +0200 (Sun, 22 Jul 2007) | 2 lines

* move setting of socketerror to real socketcall

........
r8152 | micha | 2007-07-23 17:36:02 +0200 (Mon, 23 Jul 2007) | 1 line

* fix floating point signal and exception handling, for linux/i386, test tfpu2 regression
........
r8254 | hajny | 2007-08-09 20:38:09 +0200 (Thu, 09 Aug 2007) | 1 line

* missing size modifier added
........
r8256 | hajny | 2007-08-09 20:51:15 +0200 (Thu, 09 Aug 2007) | 1 line

* preserve gs in far_strlen
........
r8330 | Almindor | 2007-08-29 12:08:02 +0200 (Wed, 29 Aug 2007) | 2 lines

* fix linux sysinfo struct and function (bug 9523)

........
r8331 | Almindor | 2007-08-29 13:59:47 +0200 (Wed, 29 Aug 2007) | 2 lines

* fix typo with [T]SysInfo record

........
r8333 | jonas | 2007-08-29 16:31:17 +0200 (Wed, 29 Aug 2007) | 2 lines

* fixed compilation on 64 bit cpus

........
r8364 | Almindor | 2007-09-03 00:06:04 +0200 (Mon, 03 Sep 2007) | 3 lines

* update sysnr.inc for x86 and x86_64 to latest kernel
* add splice syscall to linux unit for x86 and x86_64

........
r8365 | Almindor | 2007-09-03 12:54:44 +0200 (Mon, 03 Sep 2007) | 3 lines

* fix x86 -> cpu86 define
* add tee() function

........
r8401 | Almindor | 2007-09-08 11:55:35 +0200 (Sat, 08 Sep 2007) | 2 lines

* fix deprecated stat calls to use the fp<> ones and not the other way around

........
r8405 | Almindor | 2007-09-08 15:51:39 +0200 (Sat, 08 Sep 2007) | 2 lines

* hopefuly fix the fp* problems for stat and others

........

git-svn-id: branches/fixes_2_2@8441 -

peter před 18 roky
rodič
revize
0c80d3aca8

+ 6 - 0
rtl/bsd/unxsysch.inc

@@ -14,3 +14,9 @@
 
 function fpgettimeofday(tp: ptimeval;tzp:ptimezone):cint; external name 'FPC_SYSC_GETTIMEOFDAY';
 
+function  fpfStatFS (Fd: cint; Info:pstatfs):cint;
+function  fpStatFS  (Path:pchar; Info:pstatfs):cint;
+function  fpfsync (fd : cint) : cint;
+Function  fpFlock   (fd,mode : cint)   : cint ;
+
+

+ 8 - 19
rtl/freebsd/unxsysc.inc

@@ -61,38 +61,27 @@ END;
 end;
 *)
 
-Function  fsync (fd : cint) : cint;
-
+Function  fpfStatFS (Fd: cint; Info:pstatfs):cint;
 begin
-  fsync:=do_syscall(syscall_nr_fsync,fd);
+  fpfstatfs:=do_SysCall(SysCall_nr_fstatfs,fd,TSysParam(info))
 end;
 
-Function  fpFlock (fd,mode : longint) : cint;
+Function  fpStatFS  (Path:pchar; Info:pstatfs):cint;
 
 begin
- fpFlock:=do_syscall(syscall_nr_flock,fd,mode);
+  fpstatfs:=do_SysCall(SysCall_nr_statfs,TSysParam(path),TSysParam(Info))
 end;
 
-Function fStatFS(Fd:Longint;Var Info:tstatfs):cint;
-{
-  Get all information on a fileSystem, and return it in Info.
-  Fd is the file descriptor of a file/directory on the fileSystem
-  you wish to investigate.
-}
+Function  fpfsync (fd : cint) : cint;
 
 begin
- fStatFS:=do_syscall(syscall_nr_fstatfs,fd,longint(@info));
+  fpfsync:=do_SysCall(syscall_nr_fsync, fd);
 end;
 
-Function StatFS(path:pchar;Var Info:tstatfs):cint;
-{
-  Get all information on a fileSystem, and return it in Info.
-  Fd is the file descriptor of a file/directory on the fileSystem
-  you wish to investigate.
-}
+Function  fpFlock (fd,mode : longint) : cint;
 
 begin
- StatFS:=do_syscall(syscall_nr_statfs,longint(path),longint(@info));
+ fpFlock:=do_syscall(syscall_nr_flock,fd,mode);
 end;
 
 // needs oldfpccall;

+ 3 - 3
rtl/go32v2/dpmiexcp.pp

@@ -597,7 +597,7 @@ begin
         movl    djgpp_exception_state_ptr, %eax
         movl    %eax, 60(%edi)
         { restore EDI }
-        pop     %edi
+        popl    %edi
         { we come from the initial call }
         xorl    %eax,%eax
         movl    %eax,__RESULT
@@ -1615,8 +1615,8 @@ begin
    17,                     {'Alignment Check',}
    18,                     {'Machine Check',}
    19,                     {'SSE FP error'}
-   SIGSEGV,SIGTRAP,SIGTIMR,SIGINT,SIGQUIT
-    : ErrorOfSig:=216;
+   SIGSEGV,SIGTRAP,SIGTIMR,SIGINT,SIGQUIT,SIGILL:
+     ErrorOfSig:=216;
   end;
   if assigned(djgpp_exception_state_ptr) then
     Begin

+ 2 - 0
rtl/go32v2/sysos.inc

@@ -38,6 +38,7 @@ function far_strlen(selector : word;linear_address : longint) : longint;assemble
 asm
         movl linear_address,%edx
         movl %edx,%ecx
+        pushl %gs
         movw selector,%gs
 .Larg19:
         movb %gs:(%edx),%al
@@ -46,6 +47,7 @@ asm
         incl %edx
         jmp .Larg19
 .Larg20:
+        popl %gs
         movl %edx,%eax
         subl %ecx,%eax
 end;

+ 20 - 0
rtl/i386/i386.inc

@@ -1165,6 +1165,26 @@ asm
 end;
 
 
+function InterlockedCompareExchange64(var Target: int64; NewValue: int64; Comperand: int64): int64; assembler;
+asm
+        pushl       %ebx
+        pushl       %edi
+{$ifdef REGCALL}
+        movl        %eax,%edi
+{$else}
+        movl        Target,%edi
+{$endif}
+        movl        Comperand+4,%edx
+        movl        Comperand+0,%eax
+        movl        NewValue+4,%ecx
+        movl        NewValue+0,%ebx
+        lock cmpxchg8b (%edi)
+        pop         %edi
+        pop         %ebx
+end;
+
+
+
 
 {****************************************************************************
                                   FPU

+ 11 - 0
rtl/inc/sockets.inc

@@ -115,6 +115,11 @@ begin
   TextRec(SockIn).FlushFunc:=@FlushSock;
   TextRec(SockIn).CloseFunc:=@CloseSock;
   TextRec(SockIn).Mode := fmInput;
+  Case DefaultTextLineBreakStyle Of
+    tlbsLF: TextRec(sockin).LineEnd := #10;
+    tlbsCRLF: TextRec(sockin).LineEnd := #13#10;
+    tlbsCR: TextRec(sockin).LineEnd := #13;
+   End;
 { Now the writing part. }
   Assign(SockOut,'.');
   Textrec(SockOut).Handle:=Sock;
@@ -124,6 +129,12 @@ begin
   TextRec(SockOut).FlushFunc:=@FlushSock;
   TextRec(SockOut).CloseFunc:=@CloseSock;
   TextRec(SockOut).Mode := fmOutput;
+
+   Case DefaultTextLineBreakStyle Of
+    tlbsLF: TextRec(sockout).LineEnd := #10;
+    tlbsCRLF: TextRec(sockout).LineEnd := #13#10;
+    tlbsCR: TextRec(sockout).LineEnd := #13;
+   End;
 end;
 
 

+ 1 - 0
rtl/linux/i386/si_c.inc

@@ -50,6 +50,7 @@ procedure PASCALMAIN; external name 'PASCALMAIN';
 {******************************************************************************
                           C library start/halt
  ******************************************************************************}
+{$asmmode ATT}
 
 procedure _FPC_libc_start; assembler; nostackframe; public name '_start';
 asm

+ 1 - 0
rtl/linux/i386/si_c21.inc

@@ -46,6 +46,7 @@ procedure PASCALMAIN; external name 'PASCALMAIN';
 {******************************************************************************
                          glibc 2.1 library start/halt
  ******************************************************************************}
+{$asmmode ATT}
 
 procedure _FPC_libc21_start; assembler; nostackframe; public name '_start';
 asm

+ 1 - 0
rtl/linux/i386/si_c21g.inc

@@ -54,6 +54,7 @@ procedure PASCALMAIN; external name 'PASCALMAIN';
 {******************************************************************************
                        glibc 2.1 lib + profiling start/halt
  ******************************************************************************}
+{$asmmode ATT}
 
 procedure _FPC_libc21_gprof_gmon_start; assembler; nostackframe;
 asm

+ 1 - 0
rtl/linux/i386/si_dll.inc

@@ -38,6 +38,7 @@ procedure PASCALMAIN; external name 'PASCALMAIN';
 {******************************************************************************
                         Shared library start/halt
  ******************************************************************************}
+{$asmmode ATT}
 
 procedure _FPC_shared_lib_start(argc : dword;argv,envp : pointer); cdecl; public name '_start';
 begin

+ 1 - 0
rtl/linux/i386/si_g.inc

@@ -51,6 +51,7 @@ procedure PASCALMAIN; external name 'PASCALMAIN';
 {******************************************************************************
                        Process + profiling start/halt
  ******************************************************************************}
+{$asmmode ATT}
 
 procedure _FPC_proc_gprof_start; assembler; nostackframe; public name '_start';
 asm

+ 1 - 0
rtl/linux/i386/si_prc.inc

@@ -38,6 +38,7 @@ procedure PASCALMAIN; external name 'PASCALMAIN';
 {******************************************************************************
                           Process start/halt
  ******************************************************************************}
+{$asmmode ATT}
 
 procedure _FPC_proc_start; assembler; nostackframe; public name '_start';
 asm

+ 26 - 33
rtl/linux/i386/sighnd.inc

@@ -16,22 +16,6 @@
  **********************************************************************}
 
 
-const
-  FPU_All = $7f;
-
-function GetFPUState(const SigContext : TSigContext) : longint;
-begin
-  if assigned(SigContext.fpstate) then
-    GetfpuState:=SigContext.fpstate^.sw;
-{$ifdef SYSTEM_DEBUG}
-  writeln('xx:',sigcontext.en_tw,' ',sigcontext.en_cw);
-{$endif SYSTEM_DEBUG}
-{$ifdef SYSTEM_DEBUG}
-  Writeln(stderr,'FpuState = ',GetFpuState);
-{$endif SYSTEM_DEBUG}
-end;
-
-
 procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; UContext: Pucontext);cdecl;
 var
   res,fpustate : word;
@@ -43,24 +27,28 @@ begin
         { this is not allways necessary but I don't know yet
           how to tell if it is or not PM }
         res:=200;
-        fpustate:=GetFPUState(UContext^.uc_mcontext);
-        if (FpuState and FPU_All) <> 0 then
+        if assigned(ucontext^.uc_mcontext.fpstate) then
           begin
-            { first check the more precise options }
-            if (FpuState and FPU_DivisionByZero)<>0 then
-              res:=200
-            else if (FpuState and (FPU_StackOverflow or FPU_StackUnderflow or FPU_Invalid))<>0 Then
-              res:=207
-            else if (FpuState and FPU_Overflow)<>0 then
-              res:=205
-            else if (FpuState and FPU_Underflow)<>0 then
-              res:=206
-            else if (FpuState and FPU_Denormal)<>0 then
-              res:=216
-            else
-              res:=207;  {'Coprocessor Error'}
+            FpuState:=ucontext^.uc_mcontext.fpstate^.sw;
+            if (FpuState and FPU_ExceptionMask) <> 0 then
+              begin
+                { first check the more precise options }
+                if (FpuState and FPU_DivisionByZero)<>0 then
+                  res:=200
+                else if (FpuState and (FPU_StackOverflow or FPU_StackUnderflow or FPU_Invalid))<>0 Then
+                  res:=207
+                else if (FpuState and FPU_Overflow)<>0 then
+                  res:=205
+                else if (FpuState and FPU_Underflow)<>0 then
+                  res:=206
+                else if (FpuState and FPU_Denormal)<>0 then
+                  res:=216
+                else
+                  res:=207;  {'Coprocessor Error'}
+              end;
+            with ucontext^.uc_mcontext.fpstate^ do
+              sw:=sw and not FPU_ExceptionMask;
           end;
-        sysResetFPU;
       end;
     SIGBUS:
       res:=214;
@@ -79,6 +67,11 @@ begin
   reenable_signal(sig);
 { give runtime error at the position where the signal was raised }
   if res<>0 then
-    HandleErrorAddrFrame(res,pointer(UContext^.uc_mcontext.eip),pointer(UContext^.uc_mcontext.ebp));
+  begin
+    ucontext^.uc_mcontext.eax := res;
+    ucontext^.uc_mcontext.edx := ucontext^.uc_mcontext.eip;
+    ucontext^.uc_mcontext.ecx := ucontext^.uc_mcontext.ebp;
+    ucontext^.uc_mcontext.eip := ptruint(@HandleErrorAddrFrame);
+  end;
 end;
 

+ 26 - 180
rtl/linux/i386/sysnr.inc

@@ -313,184 +313,30 @@ Const
         syscall_nr_inotify_init          = 291;
         syscall_nr_inotify_add_watch     = 292;
         syscall_nr_inotify_rm_watch      = 293;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+        syscall_nr_migrate_pages         = 294;
+        syscall_nr_openat                = 295;
+        syscall_nr_mkdirat               = 296;
+        syscall_nr_mknodat               = 297;
+        syscall_nr_fchownat              = 298;
+        syscall_nr_futimesat             = 299;
+        syscall_nr_fstatat64             = 300;
+        syscall_nr_unlinkat              = 301;
+        syscall_nr_renameat              = 302;
+        syscall_nr_linkat                = 303;
+        syscall_nr_symlinkat             = 304;
+        syscall_nr_readlinkat            = 305;
+        syscall_nr_fchmodat              = 306;
+        syscall_nr_faccessat             = 307;
+        syscall_nr_pselect6              = 308;
+        syscall_nr_ppoll                 = 309;
+        syscall_nr_unshare               = 310;
+        syscall_nr_set_robust_list       = 311;
+        syscall_nr_get_robust_list       = 312;
+        syscall_nr_splice                = 313;
+        syscall_nr_sync_file_range       = 314;
+        syscall_nr_tee                   = 315;
+        syscall_nr_vmsplice              = 316;
+        syscall_nr_move_pages            = 317;
+        syscall_nr_getcpu                = 318;
+        syscall_nr_epoll_pwait           = 319;
 

+ 190 - 31
rtl/linux/linux.pp

@@ -22,26 +22,33 @@ unit Linux;
 interface
 
 uses
-  ctypes;
-
-Type
-  TSysinfo = packed record
-    uptime    : longint;
-    loads     : array[1..3] of longint;
-    totalram,
-    freeram,
-    sharedram,
-    bufferram,
-    totalswap,
-    freeswap  : longint;
-    procs     : integer;
-    s         : string[18];
+  BaseUnix;//, ctypes;
+
+type
+  TSysInfo = record
+    uptime: clong;                     //* Seconds since boot */
+    loads: array[0..2] of culong;      //* 1, 5, and 15 minute load averages */
+    totalram: culong;                  //* Total usable main memory size */
+    freeram: culong;                   //* Available memory size */
+    sharedram: culong;                 //* Amount of shared memory */
+    bufferram: culong;                 //* Memory used by buffers */
+    totalswap: culong;                 //* Total swap space size */
+    freeswap: culong;                  //* swap space still available */
+    procs: cushort;                    //* Number of current processes */
+    pad: cushort;                      //* explicit padding for m68k */
+    totalhigh: culong;                 //* Total high memory size */
+    freehigh: culong;                  //* Available high memory size */
+    mem_unit: cuint;                   //* Memory unit size in bytes */
+{$ifndef cpu64}
+    { the upper bound of the array below is negative for 64 bit cpus }
+    _f: array[0..19-2*sizeof(clong)-sizeof(cint)] of cChar;  //* Padding: libc5 uses this.. */
+{$endif cpu64}
   end;
   PSysInfo = ^TSysInfo;
 
-Function Sysinfo(var Info:TSysinfo):Boolean; {$ifdef FPC_USE_LIBC} cdecl; external name 'sysinfo'; {$endif}
+function Sysinfo(Info: PSysinfo): cInt; {$ifdef FPC_USE_LIBC} cdecl; external name 'sysinfo'; {$endif}
 
-Const
+const
   CSIGNAL              = $000000ff; // signal mask to be sent at exit
   CLONE_VM             = $00000100; // set if VM shared between processes
   CLONE_FS             = $00000200; // set if fs info shared between processes
@@ -94,7 +101,9 @@ Const
    if (oldval CMP CMPARG)
      wake UADDR2; }
 
-function FUTEX_OP(op, oparg, cmp, cmparg: cint): cint; {inline;}
+{$ifndef FPC_USE_LIBC}
+function futex_op(op, oparg, cmp, cmparg: cint): cint; {$ifdef SYSTEMINLINE}inline;{$endif}
+{$endif}
 
 const
   EPOLLIN  = $01; { The associated file is available for read(2) operations. }
@@ -153,7 +162,7 @@ const
   LED_SCR         = 1;    {scroll lock led}
   LED_NUM         = 2;    {num lock led}
   LED_CAP         = 4;    {caps lock led}
-
+    
   {Tty modes. (for KDSETMODE)}
   KD_TEXT         = 0;
   KD_GRAPHICS     = 1;
@@ -169,6 +178,46 @@ const
 type
   TCloneFunc = function(args:pointer):longint;cdecl;
 
+{$ifdef cpui386}
+  {$define clone_implemented}
+{$endif}
+{$ifdef cpum68k}
+  {$define clone_implemented}
+{$endif}
+
+{$ifdef clone_implemented}
+function clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint; {$ifdef FPC_USE_LIBC} cdecl; external name 'clone'; {$endif}
+{$endif}
+
+const
+  MODIFY_LDT_CONTENTS_DATA       = 0;
+  MODIFY_LDT_CONTENTS_STACK      = 1;
+  MODIFY_LDT_CONTENTS_CODE       = 2;
+
+{ Flags for user_desc.flags }
+  UD_SEG_32BIT            = $01;
+  UD_CONTENTS_DATA        = MODIFY_LDT_CONTENTS_DATA  shl 1;
+  UD_CONTENTS_STACK       = MODIFY_LDT_CONTENTS_STACK shl 1;
+  UD_CONTENTS_CODE        = MODIFY_LDT_CONTENTS_CODE  shl 1;
+  UD_READ_EXEC_ONLY       = $08;
+  UD_LIMIT_IN_PAGES       = $10;
+  UD_SEG_NOT_PRESENT      = $20;
+  UD_USEABLE              = $40;
+  UD_LM                   = $80;
+
+type
+  user_desc = packed record
+    entry_number  : cint;
+    base_addr     : cuint;
+    limit         : cuint;
+    flags         : cuint;
+  end;
+
+  TUser_Desc = user_desc;
+  PUser_Desc = ^user_desc;
+
+
+type
   EPoll_Data = record
     case integer of
       0: (ptr: pointer);
@@ -183,10 +232,10 @@ type
     Events: cuint32;
     Data  : TEpoll_Data;
   end;
+
   TEPoll_Event =  Epoll_Event;
   PEpoll_Event = ^Epoll_Event;
 
-function Clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint; {$ifdef FPC_USE_LIBC} cdecl; external name 'clone'; {$endif}
 
 { open an epoll file descriptor }
 function epoll_create(size: cint): cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'epoll_create'; {$endif}
@@ -195,20 +244,95 @@ function epoll_ctl(epfd, op, fd: cint; event: pepoll_event): cint; {$ifdef FPC_U
 { wait for an I/O event on an epoll file descriptor }
 function epoll_wait(epfd: cint; events: pepoll_event; maxevents, timeout: cint): cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'epoll_wait'; {$endif}
 
+type Puser_cap_header=^user_cap_header;
+     user_cap_header=packed record
+       version,pid:cardinal;
+     end;
+     
+     Puser_cap_data=^user_cap_data;
+     user_cap_data=packed record
+        effective,permitted,inheritable:cardinal;
+     end;
+
+{Get a capability.}
+function capget(header:Puser_cap_header;data:Puser_cap_data):cint;{$ifdef FPC_USE_LIBC} cdecl; external name 'capget'; {$endif}
+{Set a capability.}
+function capset(header:Puser_cap_header;data:Puser_cap_data):cint;{$ifdef FPC_USE_LIBC} cdecl; external name 'capset'; {$endif}
+
+     
+const CAP_CHOWN            = 0;
+      CAP_DAC_OVERRIDE     = 1;
+      CAP_DAC_READ_SEARCH  = 2;
+      CAP_FOWNER           = 3;
+      CAP_FSETID           = 4;
+      CAP_FS_MASK          = $1f;
+      CAP_KILL             = 5;
+      CAP_SETGID           = 6;
+      CAP_SETUID           = 7;
+      CAP_SETPCAP          = 8;
+      CAP_LINUX_IMMUTABLE  = 9;
+      CAP_NET_BIND_SERVICE = 10;
+      CAP_NET_BROADCAST    = 11;
+      CAP_NET_ADMIN        = 12;
+      CAP_NET_RAW          = 13;
+      CAP_IPC_LOCK         = 14;
+      CAP_IPC_OWNER        = 15;
+      CAP_SYS_MODULE       = 16;
+      CAP_SYS_RAWIO        = 17;
+      CAP_SYS_CHROOT       = 18;
+      CAP_SYS_PTRACE       = 19;
+      CAP_SYS_PACCT        = 20;
+      CAP_SYS_ADMIN        = 21;
+      CAP_SYS_BOOT         = 22;
+      CAP_SYS_NICE         = 23;
+      CAP_SYS_RESOURCE     = 24;
+      CAP_SYS_TIME         = 25;
+      CAP_SYS_TTY_CONFIG   = 26;
+      CAP_MKNOD            = 27;
+      CAP_LEASE            = 28;
+      CAP_AUDIT_WRITE      = 29;
+      CAP_AUDIT_CONTROL    = 30;
+
+      LINUX_CAPABILITY_VERSION = $19980330;
+
+
+//***********************************************SPLICE from kernel 2.6.17+****************************************
+
+const
+{* Flags for SPLICE and VMSPLICE.  *}
+  SPLICE_F_MOVE		= 1;   { Move pages instead of copying.  }
+  SPLICE_F_NONBLOCK	= 2;   {* Don't block on the pipe splicing
+                            (but we may still block on the fd
+                                        we splice from/to).  *}
+  SPLICE_F_MORE	    = 4;   {* Expect more data.  *}
+  SPLICE_F_GIFT	    = 8;   {* Pages passed in are a gift.  *}
+
+{$ifdef cpu86}
+{* Splice address range into a pipe.  *}
+function vmsplice (fdout: cInt; iov: PIOVec; count: size_t; flags: cuInt): cInt; {$ifdef FPC_USE_LIBC} cdecl; external name 'vmsplice'; {$ENDIF}
+
+{* Splice two files together.  *}
+// NOTE: offin and offout should be "off64_t" but we don't have that type. It's an "always 64 bit offset" so I use cint64
+function splice (fdin: cInt; offin: cInt64; fdout: cInt;
+                             offout: cInt64; len: size_t; flags: cuInt): cInt; {$ifdef FPC_USE_LIBC} cdecl; external name 'splice'; {$ENDIF}
+                             
+function tee(fd_in: cInt; fd_out: cInt; len: size_t; flags: cuInt): cInt; {$ifdef FPC_USE_LIBC} cdecl; external name 'tee'; {$ENDIF}
+
+{$endif} // x86
+
 implementation
 
+
 {$ifndef FPC_USE_LIBC}
 Uses Syscall;
 
-Function Sysinfo(var Info:TSysinfo):Boolean;
-{
-  Get system info
-}
-Begin
-  Sysinfo:=do_SysCall(SysCall_nr_Sysinfo,TSysParam(@info))=0;
-End;
+function Sysinfo(Info: PSysinfo): cInt;
+begin
+  Sysinfo := do_SysCall(SysCall_nr_Sysinfo, TSysParam(info));
+end;
 
-function Clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint;
+{$ifdef clone_implemented}
+function clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint;
 
 begin
   if (pointer(func)=nil) or (sp=nil) then
@@ -286,6 +410,7 @@ begin
   *)
 {$endif cpum68k}
 end;
+{$endif}
 
 function epoll_create(size: cint): cint;
 begin
@@ -294,7 +419,7 @@ end;
 
 function epoll_ctl(epfd, op, fd: cint; event: pepoll_event): cint;
 begin
-  epoll_ctl := do_syscall(syscall_nr_epoll_ctl, tsysparam(epfd), 
+  epoll_ctl := do_syscall(syscall_nr_epoll_ctl, tsysparam(epfd),
     tsysparam(op), tsysparam(fd), tsysparam(event));
 end;
 
@@ -303,13 +428,47 @@ begin
   epoll_wait := do_syscall(syscall_nr_epoll_wait, tsysparam(epfd),
     tsysparam(events), tsysparam(maxevents), tsysparam(timeout));
 end;
-{$endif}
 
-// FUTEX_OP is a macro, doesn't exist in libC as function
+function capget(header:Puser_cap_header;data:Puser_cap_data):cint;
+
+begin
+  capget:=do_syscall(syscall_nr_capget,Tsysparam(header),Tsysparam(data));
+end;
+
+function capset(header:Puser_cap_header;data:Puser_cap_data):cint;
+
+begin
+  capset:=do_syscall(syscall_nr_capset,Tsysparam(header),Tsysparam(data));
+end;
+
+// TODO: update also on non x86!
+{$ifdef cpu86} // didn't update syscall_nr on others yet
+
+function vmsplice (fdout: cInt; iov: PIOVec; count: size_t; flags: cuInt): cInt;
+begin
+  vmsplice := do_syscall(syscall_nr_vmsplice, TSysParam(fdout), TSysParam(iov), TSysParam(count), TSysParam(flags));
+end;
+
+function splice (fdin: cInt; offin: cint64; fdout: cInt; offout: cint64; len: size_t; flags: cuInt): cInt; 
+begin
+  splice := do_syscall(syscall_nr_splice, TSysParam(fdin), TSysParam(offin), TSysParam(fdout), TSysParam(offout), 
+                       TSysParam(len), TSysParam(flags));
+end;
+
+function tee(fd_in: cInt; fd_out: cInt; len: size_t; flags: cuInt): cInt;
+begin
+  tee := do_syscall(syscall_nr_tee, TSysParam(fd_in), TSysParam(fd_out),
+                    TSysParam(len), TSysParam(flags));
+end;
+
+{$endif} // x86
+
+{$endif} // non-libc
+
+{ FUTEX_OP is a macro, doesn't exist in libC as function}
 function FUTEX_OP(op, oparg, cmp, cmparg: cint): cint; {$ifdef SYSTEMINLINE}inline;{$endif}
 begin
   FUTEX_OP := ((op and $F) shl 28) or ((cmp and $F) shl 24) or ((oparg and $FFF) shl 12) or (cmparg and $FFF);
 end;
 
-
 end.

+ 19 - 6
rtl/linux/ostypes.inc

@@ -181,7 +181,7 @@ CONST
     O_RDONLY  =          0;        { Open read-only.  }
     O_WRONLY  =          1;        { Open write-only. }
     O_RDWR    =          2;        { Open read/write. }
-{$ifdef sparc}
+{$ifdef cpusparc}
     O_APPEND  =          8;
     O_CREAT   =       $200;
     O_TRUNC   =       $400;
@@ -192,9 +192,8 @@ CONST
     O_NOCTTY  =      $8000;
     O_DIRECTORY =   $10000;
     O_NOFOLLOW =    $20000;
-    O_LARGEFILE =   $40000;
     O_DIRECT  =    $100000;
-{$else sparc}
+{$else cpusparc}
     O_CREAT   =        $40;
     O_EXCL    =        $80;
     O_NOCTTY  =       $100;
@@ -204,11 +203,25 @@ CONST
     O_NDELAY  =     O_NONBLOCK;
     O_SYNC    =      $1000;
     O_DIRECT  =      $4000;
-    O_LARGEFILE =    $8000;
     O_DIRECTORY =   $10000;
     O_NOFOLLOW =    $20000;
-{$endif sparc}
+{$endif cpusparc}
 
+{$if defined(cpuarm) or defined(cpualpha) or defined(cpublackfin) or defined(cpum68k)}
+    O_LARGEFILE =   $20000;
+{$endif}
+{$if defined(cpusparc) or defined(cpusparc64)}
+    O_LARGEFILE =   $40000;
+{$endif}
+{$if defined(cpupowerpc)}
+    O_LARGEFILE =   $10000;
+{$endif}
+{$if defined(cpui386) or defined(cpux86_64) or defined(cpuia64)}
+    O_LARGEFILE =    $8000;
+{$endif}
+{$if defined(cpumips)}
+    O_LARGEFILE =    $2000;
+{$endif}
     { mode_t possible values                                 }
     S_IRUSR =  %0100000000;     { Read permission for owner   }
     S_IWUSR =  %0010000000;     { Write permission for owner  }
@@ -287,7 +300,7 @@ const
   { FP exception related constants for prctl(); PowerPC specific }
   PR_GET_FPEXC    = 11;   { get floating point exception mode }
   PR_SET_FPEXC    = 12;   { set floating point exception mode }
-  
+
   PR_FP_EXC_DISABLED = 0; { FP exceptions disabled }
   PR_FP_EXC_NONREC   = 1; { async non-recoverable exc. mode }
   PR_FP_EXC_ASYNC    = 2; { async recoverable exc. mode }

+ 1 - 0
rtl/linux/sparc/stat.inc

@@ -18,6 +18,7 @@
   { to its largest member (i.e., 8 bytes), and declaring it as packed    }
   { disables that                                                        }
   Stat = record  // No unix typing because of differences
+    case byte of
     case byte of
     0:
       (dev   : culonglong deprecated;

+ 1 - 1
rtl/linux/termiosproc.inc

@@ -13,7 +13,7 @@ end;
 
 Function TCSetAttr(fd:cint;OptAct:cint;const tios:TermIOS):cint;
 var
-  nr:cint;
+  nr:culong;
 begin
   case OptAct of
    TCSANOW   : nr:=TCSETS;

+ 3 - 3
rtl/linux/unixsock.inc

@@ -48,7 +48,7 @@ Const
   Socket_Sys_RECVMSG     = 17;
 
 
-Function SocketCall(SockCallNr,a1,a2,a3,a4,a5,a6:TSysParam):longint; inline;
+Function SocketCall(SockCallNr,a1,a2,a3,a4,a5,a6:TSysParam):cint; inline;
 var
   Args:array[1..6] of TSysParam;
 begin
@@ -59,13 +59,13 @@ begin
   args[5]:=a5;
   args[6]:=a6;
   SocketCall:=do_Syscall(syscall_nr_socketcall,sockcallnr,TSysParam(@args));
+  internal_socketerror:=fpgeterrno;
 end;
 
 
-function SocketCall(SockCallNr,a1,a2,a3:TSysParam):longint;
+function SocketCall(SockCallNr,a1,a2,a3:TSysParam):cint;inline;
 begin
   SocketCall:=SocketCall(SockCallNr,a1,a2,a3,0,0,0);
-  internal_socketerror:=fpgeterrno;
 end;
 
 function  fpsocket (domain:cint; xtype:cint; protocol: cint):cint;

+ 9 - 19
rtl/linux/unxsysc.inc

@@ -13,38 +13,28 @@
 
  ***********************************************************************}
 
-Function  fsync (fd : cint) : cint;
+Function  fpFlock (fd,mode : cint) : cint;
 begin
-  fsync := do_SysCall(syscall_nr_fsync, fd);
+  fpflock:=do_Syscall(Syscall_nr_flock,fd,mode);
 end;
 
-Function  fpFlock (fd,mode : cint) : cint;
+Function  fpfStatFS (Fd: cint; Info:pstatfs):cint;
 begin
-  fpflock:=do_Syscall(Syscall_nr_flock,fd,mode);
+  fpfstatfs:=do_SysCall(SysCall_nr_fstatfs,fd,TSysParam(info))
 end;
 
+Function  fpStatFS  (Path:pchar; Info:pstatfs):cint;
 
-Function StatFS(Path:Pchar;Var Info:tstatfs):cint;
-{
-  Get all information on a fileSystem, and return it in Info.
-  Path is the name of a file/directory on the fileSystem you wish to
-  investigate.
-}
 begin
-  StatFS:=(do_SysCall(SysCall_nr_statfs,TSysParam(path),TSysParam(@Info)));
+  fpstatfs:=do_SysCall(SysCall_nr_statfs,TSysParam(path),TSysParam(Info))
 end;
 
-Function fStatFS(Fd:cint;Var Info:tstatfs):cint;
-{
-  Get all information on a fileSystem, and return it in Info.
-  Fd is the file descriptor of a file/directory on the fileSystem
-  you wish to investigate.
-}
+Function  fpfsync (fd : cint) : cint;
+
 begin
-  fStatFS:=(do_SysCall(SysCall_nr_fstatfs,fd,TSysParam(@info)));
+  fpfsync:=do_SysCall(syscall_nr_fsync, fd);
 end;
 
-
 {--------------------------------
       Port IO functions
 --------------------------------}

+ 6 - 0
rtl/linux/unxsysch.inc

@@ -15,3 +15,9 @@
 
 function fpgettimeofday(tp: ptimeval;tzp:ptimezone):cint; external name 'FPC_SYSC_GETTIMEOFDAY';
 
+function  fpfStatFS (Fd: cint; Info:pstatfs):cint;
+function  fpStatFS  (Path:pchar; Info:pstatfs):cint;
+function  fpfsync (fd : cint) : cint;
+Function  fpFlock   (fd,mode : cint)   : cint ;
+
+

+ 25 - 0
rtl/linux/x86_64/sysnr.inc

@@ -316,3 +316,28 @@ const
   syscall_nr_inotify_add_watch  = 254;
   syscall_nr_inotify_rm_watch   = 255;
 
+  syscall_migrate_pages	        = 256;
+  syscall_openat		        = 257;
+  syscall_mkdirat		        = 258;
+  syscall_mknodat		        = 259;
+  syscall_fchownat		        = 260;
+  syscall_futimesat		        = 261;
+  syscall_newfstatat		    = 262;
+  syscall_unlinkat		        = 263;
+  syscall_renameat		        = 264;
+  syscall_linkat		        = 265;
+  syscall_symlinkat		        = 266;
+  syscall_readlinkat		    = 267;
+  syscall_fchmodat		        = 268;
+  syscall_faccessat		        = 269;
+  syscall_pselect6		        = 270;
+  syscall_ppoll		            = 271;
+  syscall_unshare		        = 272;
+  syscall_set_robust_list	    = 273;
+  syscall_get_robust_list	    = 274;
+  syscall_splice		        = 275;
+  syscall_tee		            = 276;
+  syscall_sync_file_range	    = 277;
+  syscall_vmsplice		        = 278;
+  syscall_move_pages		    = 279;
+

+ 8 - 19
rtl/netbsd/unxsysc.inc

@@ -62,38 +62,27 @@ end;
 }
 
 {$ifndef FPC_USE_LIBC}
-Function  fsync (fd : cint) : cint;
+Function  fpFlock (fd,mode : longint) : cint;
 
 begin
-  fsync:=do_syscall(syscall_nr_fsync,fd);
+ fpFlock:=do_syscall(syscall_nr_flock,fd,mode);
 end;
 
-Function  fpFlock (fd,mode : longint) : cint;
-
+Function  fpfStatFS (Fd: cint; Info:pstatfs):cint;
 begin
- fpFlock:=do_syscall(syscall_nr_flock,fd,mode);
+  fpfstatfs:=do_SysCall(SysCall_nr_fstatfs,fd,TSysParam(info))
 end;
 
-Function fStatFS(Fd:Longint;Var Info:tstatfs):cint;
-{
-  Get all information on a fileSystem, and return it in Info.
-  Fd is the file descriptor of a file/directory on the fileSystem
-  you wish to investigate.
-}
+Function  fpStatFS  (Path:pchar; Info:pstatfs):cint;
 
 begin
- fStatFS:=do_syscall(syscall_nr_fstatfs,fd,longint(@info));
+  fpstatfs:=do_SysCall(SysCall_nr_statfs,TSysParam(path),TSysParam(Info))
 end;
 
-Function StatFS(path:pchar;Var Info:tstatfs):cint;
-{
-  Get all information on a fileSystem, and return it in Info.
-  Fd is the file descriptor of a file/directory on the fileSystem
-  you wish to investigate.
-}
+Function  fpfsync (fd : cint) : cint;
 
 begin
- StatFS:=do_syscall(syscall_nr_statfs,longint(path),longint(@info));
+  fpfsync:=do_SysCall(syscall_nr_fsync, fd);
 end;
 
 // needs oldfpccall;

+ 9 - 19
rtl/openbsd/unixsysc.inc

@@ -62,38 +62,28 @@ end;
 }
 
 {$ifndef FPC_USE_LIBC}
-Function  fsync (fd : cint) : cint;
+
+Function  fpFlock (fd,mode : longint) : cint;
 
 begin
-  fsync:=do_syscall(syscall_nr_fsync,fd);
+ Flock:=do_syscall(syscall_nr_flock,fd,mode);
 end;
 
-Function  Flock (fd,mode : longint) : cint;
-
+Function  fpfStatFS (Fd: cint; Info:pstatfs):cint;
 begin
- Flock:=do_syscall(syscall_nr_flock,fd,mode);
+  fpfstatfs:=do_SysCall(SysCall_nr_fstatfs,fd,TSysParam(info))
 end;
 
-Function fStatFS(Fd:Longint;Var Info:tstatfs):cint;
-{
-  Get all information on a fileSystem, and return it in Info.
-  Fd is the file descriptor of a file/directory on the fileSystem
-  you wish to investigate.
-}
+Function  fpStatFS  (Path:pchar; Info:pstatfs):cint;
 
 begin
- fStatFS:=do_syscall(syscall_nr_fstatfs,fd,longint(@info));
+  fpstatfs:=do_SysCall(SysCall_nr_statfs,TSysParam(path),TSysParam(Info))
 end;
 
-Function StatFS(path:pchar;Var Info:tstatfs):cint;
-{
-  Get all information on a fileSystem, and return it in Info.
-  Fd is the file descriptor of a file/directory on the fileSystem
-  you wish to investigate.
-}
+Function  fpfsync (fd : cint) : cint;
 
 begin
- StatFS:=do_syscall(syscall_nr_statfs,longint(path),longint(@info));
+  fpfsync:=do_SysCall(syscall_nr_fsync, fd);
 end;
 
 // needs oldfpccall;

+ 8 - 6
rtl/unix/dos.pp

@@ -31,7 +31,8 @@ Type
     DirPtr     : Pointer;     {directory pointer for reading directory}
     SearchType : Byte;        {0=normal, 1=open will close, 2=only 1 file}
     SearchAttr : Byte;        {attribute we are searching for}
-    Fill       : Array[1..03] of Byte; {future use}
+    Mode       : Word;
+    Fill       : Array[1..1] of Byte; {future use}
   {End of fill}
     Attr       : Byte;        {attribute of found file}
     Time       : LongInt;     {last modify date of found file}
@@ -362,7 +363,7 @@ End;
 
 {
   The Diskfree and Disksize functions need a file on the specified drive, since this
-  is required for the statfs system call.
+  is required for the fpstatfs system call.
   These filenames are set in drivestr[0..26], and have been preset to :
    0 - '.'      (default drive - hence current dir is ok.)
    1 - '/fd0/.'  (floppy drive 1 - should be adapted to local system )
@@ -402,8 +403,8 @@ Function DiskFree(Drive: Byte): int64;
 var
   fs : tstatfs;
 Begin
-  if ((Drive<4) and (not (fixdrivestr[Drive]=nil)) and (StatFS(fixdrivestr[drive],fs)<>-1)) or
-     ((not (drivestr[Drive]=nil)) and (StatFS(drivestr[drive],fs)<>-1)) then
+  if ((Drive<4) and (not (fixdrivestr[Drive]=nil)) and (fpStatFS(fixdrivestr[drive],@fs)<>-1)) or
+     ((not (drivestr[Drive]=nil)) and (fpStatFS(drivestr[drive],@fs)<>-1)) then
    Diskfree:=int64(fs.bavail)*int64(fs.bsize)
   else
    Diskfree:=-1;
@@ -415,8 +416,8 @@ Function DiskSize(Drive: Byte): int64;
 var
   fs : tstatfs;
 Begin
-  if ((Drive<4) and (not (fixdrivestr[Drive]=nil)) and (StatFS(fixdrivestr[drive],fs)<>-1)) or
-     ((not (drivestr[Drive]=nil)) and (StatFS(drivestr[drive],fs)<>-1)) then
+  if ((Drive<4) and (not (fixdrivestr[Drive]=nil)) and (fpStatFS(fixdrivestr[drive],@fs)<>-1)) or
+     ((not (drivestr[Drive]=nil)) and (fpStatFS(drivestr[drive],@fs)<>-1)) then
    DiskSize:=int64(fs.blocks)*int64(fs.bsize)
   else
    DiskSize:=-1;
@@ -574,6 +575,7 @@ begin
      f.Name:=Copy(s,f.NamePos+1,255);
      f.Attr:=Info.FMode;
      f.Size:=Info.FSize;
+     f.mode:=st.st_mode;
      UnixDateToDT(Info.FMTime, DT);
      PackTime(DT,f.Time);
      FindGetFileInfo:=true;

+ 1 - 1
rtl/unix/serial.pp

@@ -80,7 +80,7 @@ end;
 
 procedure SerFlush(Handle: TSerialHandle);
 begin
-  fsync(Handle);
+  fpfsync(Handle);
 end;
 
 function SerRead(Handle: TSerialHandle; var Buffer; Count: LongInt): LongInt;

+ 2 - 2
rtl/unix/sockets.pp

@@ -18,11 +18,11 @@ Uses baseunix,UnixType;
 {$endif}
 
 {$ifdef FreeBSD}
-{$DEFINE SOCK_HAS_SINLEN}               // BSD definition of scoketaddr
+{$DEFINE SOCK_HAS_SINLEN}               // BSD definition of socketaddr
 {$endif}
 
 {$ifdef Darwin}
-{$DEFINE SOCK_HAS_SINLEN}               // BSD definition of scoketaddr
+{$DEFINE SOCK_HAS_SINLEN}               // BSD definition of socketaddr
 {$endif}
 
 {$i unxsockh.inc}

+ 16 - 15
rtl/unix/unix.pp

@@ -96,17 +96,10 @@ Function W_STOPCODE (Signal: Integer): Integer;
 
 {**      File Handling     **}
 
-{$ifndef FPC_USE_LIBC} // defined using cdecl for libc.
 // some of these are formally listed as deprecated, but specially statfs will remain for a while, no rush.
 Function  fsync (fd : cint) : cint; deprecated;	
-Function  fpFlock   (fd,mode : cint)   : cint ;
 Function  fStatFS (Fd: cint;Var Info:tstatfs):cint; deprecated;
 Function  StatFS  (Path:pchar;Var Info:tstatfs):cint; deprecated;
-{$endif}
-
-Function  fpfStatFS (Fd: cint; Info:pstatfs):cint;
-Function  fpStatFS  (Path:pchar; Info:pstatfs):cint;
-Function  fpfsync (fd : cint) : cint;
 
 Function  fpFlock   (var T : text;mode : cint) : cint;
 Function  fpFlock   (var F : File;mode : cint) : cint;
@@ -1306,21 +1299,29 @@ Begin
  FSearch:=FSearch(path,dirlist,CurrentDirectoryFirst);
 End;
 
-Function  fpfStatFS (Fd: cint; Info:pstatfs):cint;
+Function  fsync (fd : cint) : cint;
 begin
-  fpfstatfs:=fstatfs(fd,info^);
+  fsync := fpFSync(fd);
 end;
 
-Function  fpStatFS  (Path:pchar; Info:pstatfs):cint;
-
+Function StatFS(Path:Pchar;Var Info:tstatfs):cint;
+{
+  Get all information on a fileSystem, and return it in Info.
+  Path is the name of a file/directory on the fileSystem you wish to
+  investigate.
+}
 begin
-  fpstatfs:=statfs(Path,info^);
+  StatFS:=fpStatFS(Path, @Info);;
 end;
 
-Function  fpfsync (fd : cint) : cint;
-
+Function fStatFS(Fd:cint;Var Info:tstatfs):cint;
+{
+  Get all information on a fileSystem, and return it in Info.
+  Fd is the file descriptor of a file/directory on the fileSystem
+  you wish to investigate.
+}
 begin
-  fpfsync:=fsync(fd);
+  fStatFS:=fpfStatFS(fd, @Info);
 end;
 
 Initialization

+ 16 - 3
rtl/unix/unxdeclh.inc

@@ -18,11 +18,24 @@ type filedesarray=array[0..1] of cint;
 {$ifdef solaris}
 Function fpFlock (fd,mode : longint) : cint;{$ifdef IN_SYSTEM}forward;{$endif IN_SYSTEM}
 {$else solaris}
+{$ifndef beos}
 Function fpFlock (fd,mode : longint) : cint; cdecl; external clib name 'flock';
+{$endif beos}
 {$endif solaris}
 
-Function fStatFS(Fd:Longint;Var Info:tstatfs):cint; cdecl; external clib name 'fstatfs';
-Function fsync (fd : cint) : cint; cdecl; external clib name 'fsync';
-Function StatFS  (Path:pchar;Var Info:tstatfs):cint; cdecl; external clib name 'statfs';
+{$ifdef beos}
+Function fpfStatFS(Fd:Longint; Info:pstatfs):cint; cdecl; external clib name 'fstatvfs';
+{$else beos}
+Function fpfStatFS(Fd:Longint; Info:pstatfs):cint; cdecl; external clib name 'fstatfs';
+{$endif beos}
+
+Function fpfsync (fd : cint) : cint; cdecl; external clib name 'fsync';
+
+{$ifdef beos}
+Function fpStatFS  (Path:pchar; Info:pstatfs):cint; cdecl; external clib name 'statvfs';
+{$else beos}
+Function fpStatFS  (Path:pchar; Info:pstatfs):cint; cdecl; external clib name 'statfs';
+{$endif beos}
+
 function pipe (var fildes: filedesarray):cint;  cdecl; external clib name 'pipe';
 function fpgettimeofday(tp: ptimeval;tzp:ptimezone):cint;   cdecl; external clib name 'gettimeofday';