* renamed new syscall wrapper in linux to be consist with the others

git-svn-id: trunk@48479 -
This commit is contained in:
florian 2021-01-31 22:25:18 +00:00
parent d13838ac0b
commit b4a1c27c58
5 changed files with 38 additions and 38 deletions

View File

@ -517,7 +517,7 @@ Type
end;
pstatx_timestamp = ^statx_timestamp;
statx = record
tstatx = record
stx_mask : __u32;
stx_blksize : __u32;
stx_attributes : __u64;
@ -540,9 +540,9 @@ Type
stx_dev_minor : __u32;
__spare2 : array[0..13] of __u64;
end;
pstatx = ^statx;
pstatx = ^tstatx;
function Fpstatx(dfd: cint; filename: pchar; flags,mask: cuint; var buf: statx):cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'statx'; {$ENDIF}
function statx(dfd: cint; filename: pchar; flags,mask: cuint; var buf: tstatx):cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'statx'; {$ENDIF}
Type
kernel_time64_t = clonglong;
@ -555,8 +555,8 @@ Type
tkernel_timespecs = array[0..1] of kernel_timespec;
Function fputimensat(dfd: cint; path:pchar;const times:tkernel_timespecs;flags:cint):cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'statx'; {$ENDIF}
Function fpfutimens(fd: cint; const times:tkernel_timespecs):cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'futimens'; {$ENDIF}
Function utimensat(dfd: cint; path:pchar;const times:tkernel_timespecs;flags:cint):cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'statx'; {$ENDIF}
Function futimens(fd: cint; const times:tkernel_timespecs):cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'futimens'; {$ENDIF}
implementation
@ -868,49 +868,49 @@ begin
end;
function Fpstatx(dfd: cint; filename: pchar; flags,mask: cuint; var buf: statx):cint;
function statx(dfd: cint; filename: pchar; flags,mask: cuint; var buf: tstatx):cint;
begin
Fpstatx:=do_syscall(syscall_nr_statx,TSysParam(dfd),TSysParam(filename),TSysParam(flags),TSysParam(mask),TSysParam(@buf));
statx:=do_syscall(syscall_nr_statx,TSysParam(dfd),TSysParam(filename),TSysParam(flags),TSysParam(mask),TSysParam(@buf));
end;
{$endif}
Function fputimensat(dfd: cint; path:pchar;const times:tkernel_timespecs;flags:cint):cint;
Function utimensat(dfd: cint; path:pchar;const times:tkernel_timespecs;flags:cint):cint;
var
tsa: Array[0..1] of timespec;
begin
{$if sizeof(clong)<=4}
fputimensat:=do_syscall(syscall_nr_utimensat_time64,dfd,TSysParam(path),TSysParam(@times),0);
if (fputimensat>=0) or (fpgeterrno<>ESysENOSYS) then
utimensat:=do_syscall(syscall_nr_utimensat_time64,dfd,TSysParam(path),TSysParam(@times),0);
if (utimensat>=0) or (fpgeterrno<>ESysENOSYS) then
exit;
{ try 32 bit fall back }
tsa[0].tv_sec := times[0].tv_sec;
tsa[0].tv_nsec := times[0].tv_nsec;
tsa[1].tv_sec := times[1].tv_sec;
tsa[1].tv_nsec := times[1].tv_nsec;
fputimensat:=do_syscall(syscall_nr_utimensat,dfd,TSysParam(path),TSysParam(@tsa),0);
utimensat:=do_syscall(syscall_nr_utimensat,dfd,TSysParam(path),TSysParam(@tsa),0);
{$else sizeof(clong)<=4}
fputimensat:=do_syscall(syscall_nr_utimensat,dfd,TSysParam(path),TSysParam(@times),0);
utimensat:=do_syscall(syscall_nr_utimensat,dfd,TSysParam(path),TSysParam(@times),0);
{$endif sizeof(clong)<=4}
end;
Function fpfutimens(fd: cint; const times:tkernel_timespecs):cint;
Function futimens(fd: cint; const times:tkernel_timespecs):cint;
var
tsa: Array[0..1] of timespec;
begin
{$if sizeof(clong)<=4}
fpfutimens:=do_syscall(syscall_nr_utimensat_time64,fd,TSysParam(nil),TSysParam(@times),0);
if (fpfutimens>=0) or (fpgeterrno<>ESysENOSYS) then
futimens:=do_syscall(syscall_nr_utimensat_time64,fd,TSysParam(nil),TSysParam(@times),0);
if (futimens>=0) or (fpgeterrno<>ESysENOSYS) then
exit;
{ try 32 bit fall back }
tsa[0].tv_sec := times[0].tv_sec;
tsa[0].tv_nsec := times[0].tv_nsec;
tsa[1].tv_sec := times[1].tv_sec;
tsa[1].tv_nsec := times[1].tv_nsec;
fpfutimens:=do_syscall(syscall_nr_utimensat,fd,TSysParam(nil),TSysParam(@tsa),0);
futimens:=do_syscall(syscall_nr_utimensat,fd,TSysParam(nil),TSysParam(@tsa),0);
{$else sizeof(clong)<=4}
fpfutimens:=do_syscall(syscall_nr_utimensat,fd,TSysParam(nil),TSysParam(@times),0);
futimens:=do_syscall(syscall_nr_utimensat,fd,TSysParam(nil),TSysParam(@times),0);
{$endif sizeof(clong)<=4}
end;

View File

@ -56,7 +56,7 @@ uses
{$ENDIF}
{$if defined(LINUX)}
{$if sizeof(clong)<=4}
{$if sizeof(clong)<8}
{$DEFINE USE_STATX}
{$DEFINE USE_UTIMENSAT}
{$endif sizeof(clong)<=4}
@ -562,14 +562,14 @@ Var
Info : Stat;
SystemFileName: RawByteString;
{$ifdef USE_STATX}
Infox : Statx;
Infox : TStatx;
{$endif USE_STATX}
begin
SystemFileName:=ToSingleByteFileSystemEncodedFileName(FileName);
{$ifdef USE_STATX}
{ first try statx }
if (Fpstatx(0,pchar(SystemFileName),0,STATX_MTIME or STATX_MODE,Infox)>=0) and not(fpS_ISDIR(Infox.stx_mode)) then
if (statx(0,pchar(SystemFileName),0,STATX_MTIME or STATX_MODE,Infox)>=0) and not(fpS_ISDIR(Infox.stx_mode)) then
begin
Result:=Infox.stx_mtime.tv_sec;
exit;
@ -611,7 +611,7 @@ end;
{$ifdef USE_STATX}
Function LinuxToWinAttr (const FN : RawByteString; Const Info : Statx) : Longint;
Function LinuxToWinAttr (const FN : RawByteString; Const Info : TStatx) : Longint;
Var
LinkInfo : Stat;
nm : RawByteString;
@ -928,16 +928,16 @@ end;
Function FindGetFileInfo(const s: RawByteString; var f: TAbstractSearchRec; var Name: RawByteString):boolean;
Var
{$ifdef USE_STATX}
stx : linux.statx;
stx : linux.tstatx;
{$endif USE_STATX}
st : baseunix.stat;
WinAttr : longint;
begin
{$ifdef USE_STATX}
if Assigned(f.FindHandle) and ( (PUnixFindData(F.FindHandle)^.searchattr and faSymlink) > 0) then
FindGetFileInfo:=Fpstatx(AT_FDCWD,pointer(s),AT_SYMLINK_NOFOLLOW,STATX_ALL,stx)=0
FindGetFileInfo:=statx(AT_FDCWD,pointer(s),AT_SYMLINK_NOFOLLOW,STATX_ALL,stx)=0
else
FindGetFileInfo:=Fpstatx(AT_FDCWD,pointer(s),0,STATX_ALL,stx)=0;
FindGetFileInfo:=statx(AT_FDCWD,pointer(s),0,STATX_ALL,stx)=0;
if FindGetFileInfo then
begin
WinAttr:=LinuxToWinAttr(s,stx);
@ -1080,12 +1080,12 @@ Function FileGetDate (Handle : Longint) : Int64;
Var
Info : Stat;
{$ifdef USE_STATX}
Infox : Statx;
Infox : TStatx;
{$endif USE_STATX}
begin
Result:=-1;
{$ifdef USE_STATX}
if Fpstatx(Handle,nil,0,STATX_MTIME,Infox)=0 then
if statx(Handle,nil,0,STATX_MTIME,Infox)=0 then
Result:=Infox.stx_Mtime.tv_sec
else if fpgeterrno=ESysENOSYS then
{$endif USE_STATX}
@ -1108,7 +1108,7 @@ begin
times[0].tv_nsec:=0;
times[1].tv_sec:=Age;
times[1].tv_nsec:=0;
if fpfutimens(Handle,times) = -1 then
if futimens(Handle,times) = -1 then
Result:=fpgeterrno;
{$else USE_FUTIMES}
FileSetDate:=-1;
@ -1181,7 +1181,7 @@ begin
times[0].tv_nsec:=0;
times[1].tv_sec:=Age;
times[1].tv_nsec:=0;
if fputimensat(AT_FDCWD,PChar(SystemFileName),times,0) = -1 then
if utimensat(AT_FDCWD,PChar(SystemFileName),times,0) = -1 then
Result:=fpgeterrno;
if fpgeterrno=ESysENOSYS then
{$endif USE_UTIMENSAT}

View File

@ -7,7 +7,7 @@ var
res : cint;
f1,f2 : text;
err : word;
mystatx1,mystatx2 : statx;
mystatx1,mystatx2 : tstatx;
times : tkernel_timespecs;
st,major,minor : string;
i,p,e : longint;
@ -57,17 +57,17 @@ begin
rewrite(f2);
write(f2,'ccccc');
res:=fpstatx(AT_FDCWD,'tutimensat1.txt',AT_SYMLINK_NOFOLLOW,STATX_ALL,mystatx1);
res:=statx(AT_FDCWD,'tutimensat1.txt',AT_SYMLINK_NOFOLLOW,STATX_ALL,mystatx1);
if res<>0 then
halt(1);
times[0].tv_sec:=mystatx1.stx_atime.tv_sec;
times[0].tv_nsec:=mystatx1.stx_atime.tv_nsec;
times[1].tv_sec:=mystatx1.stx_mtime.tv_sec;
times[1].tv_nsec:=mystatx1.stx_mtime.tv_nsec;
res:=fpfutimens(textrec(f2).handle,times);
res:=futimens(textrec(f2).handle,times);
if res<>0 then
halt(1);
res:=fpstatx(AT_FDCWD,'tutimensat2.txt',AT_SYMLINK_NOFOLLOW,STATX_ALL,mystatx2);
res:=statx(AT_FDCWD,'tutimensat2.txt',AT_SYMLINK_NOFOLLOW,STATX_ALL,mystatx2);
if res<>0 then
halt(1);

View File

@ -4,7 +4,7 @@ uses
var
un : utsname;
mystatx : statx;
mystatx : tstatx;
res : cint;
f : text;
st,major,minor : string;
@ -53,7 +53,7 @@ begin
rewrite(f);
write(f,'ccccc');
close(f);
res:=fpstatx(AT_FDCWD,'test.txt',AT_SYMLINK_NOFOLLOW,STATX_ALL,mystatx);
res:=statx(AT_FDCWD,'test.txt',AT_SYMLINK_NOFOLLOW,STATX_ALL,mystatx);
erase(f);
if res<>0 then
begin

View File

@ -7,7 +7,7 @@ var
res : cint;
f1,f2 : text;
err : word;
mystatx1,mystatx2 : statx;
mystatx1,mystatx2 : tstatx;
times : tkernel_timespecs;
st,major,minor : string;
i,p,e : longint;
@ -59,17 +59,17 @@ begin
write(f2,'ccccc');
close(f2);
res:=fpstatx(AT_FDCWD,'tutimensat1.txt',AT_SYMLINK_NOFOLLOW,STATX_ALL,mystatx1);
res:=statx(AT_FDCWD,'tutimensat1.txt',AT_SYMLINK_NOFOLLOW,STATX_ALL,mystatx1);
if res<>0 then
halt(1);
times[0].tv_sec:=mystatx1.stx_atime.tv_sec;
times[0].tv_nsec:=mystatx1.stx_atime.tv_nsec;
times[1].tv_sec:=mystatx1.stx_mtime.tv_sec;
times[1].tv_nsec:=mystatx1.stx_mtime.tv_nsec;
res:=fputimensat(AT_FDCWD,'tutimensat2.txt',times,0);
res:=utimensat(AT_FDCWD,'tutimensat2.txt',times,0);
if res<>0 then
halt(1);
res:=fpstatx(AT_FDCWD,'tutimensat2.txt',AT_SYMLINK_NOFOLLOW,STATX_ALL,mystatx2);
res:=statx(AT_FDCWD,'tutimensat2.txt',AT_SYMLINK_NOFOLLOW,STATX_ALL,mystatx2);
if res<>0 then
halt(1);