mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 23:19:24 +02:00
* renamed new syscall wrapper in linux to be consist with the others
git-svn-id: trunk@48479 -
This commit is contained in:
parent
d13838ac0b
commit
b4a1c27c58
@ -517,7 +517,7 @@ Type
|
|||||||
end;
|
end;
|
||||||
pstatx_timestamp = ^statx_timestamp;
|
pstatx_timestamp = ^statx_timestamp;
|
||||||
|
|
||||||
statx = record
|
tstatx = record
|
||||||
stx_mask : __u32;
|
stx_mask : __u32;
|
||||||
stx_blksize : __u32;
|
stx_blksize : __u32;
|
||||||
stx_attributes : __u64;
|
stx_attributes : __u64;
|
||||||
@ -540,9 +540,9 @@ Type
|
|||||||
stx_dev_minor : __u32;
|
stx_dev_minor : __u32;
|
||||||
__spare2 : array[0..13] of __u64;
|
__spare2 : array[0..13] of __u64;
|
||||||
end;
|
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
|
Type
|
||||||
kernel_time64_t = clonglong;
|
kernel_time64_t = clonglong;
|
||||||
@ -555,8 +555,8 @@ Type
|
|||||||
|
|
||||||
tkernel_timespecs = array[0..1] of kernel_timespec;
|
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 utimensat(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 futimens(fd: cint; const times:tkernel_timespecs):cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'futimens'; {$ENDIF}
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -868,49 +868,49 @@ begin
|
|||||||
end;
|
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
|
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;
|
end;
|
||||||
|
|
||||||
{$endif}
|
{$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
|
var
|
||||||
tsa: Array[0..1] of timespec;
|
tsa: Array[0..1] of timespec;
|
||||||
begin
|
begin
|
||||||
{$if sizeof(clong)<=4}
|
{$if sizeof(clong)<=4}
|
||||||
fputimensat:=do_syscall(syscall_nr_utimensat_time64,dfd,TSysParam(path),TSysParam(@times),0);
|
utimensat:=do_syscall(syscall_nr_utimensat_time64,dfd,TSysParam(path),TSysParam(@times),0);
|
||||||
if (fputimensat>=0) or (fpgeterrno<>ESysENOSYS) then
|
if (utimensat>=0) or (fpgeterrno<>ESysENOSYS) then
|
||||||
exit;
|
exit;
|
||||||
{ try 32 bit fall back }
|
{ try 32 bit fall back }
|
||||||
tsa[0].tv_sec := times[0].tv_sec;
|
tsa[0].tv_sec := times[0].tv_sec;
|
||||||
tsa[0].tv_nsec := times[0].tv_nsec;
|
tsa[0].tv_nsec := times[0].tv_nsec;
|
||||||
tsa[1].tv_sec := times[1].tv_sec;
|
tsa[1].tv_sec := times[1].tv_sec;
|
||||||
tsa[1].tv_nsec := times[1].tv_nsec;
|
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}
|
{$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}
|
{$endif sizeof(clong)<=4}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function fpfutimens(fd: cint; const times:tkernel_timespecs):cint;
|
Function futimens(fd: cint; const times:tkernel_timespecs):cint;
|
||||||
var
|
var
|
||||||
tsa: Array[0..1] of timespec;
|
tsa: Array[0..1] of timespec;
|
||||||
begin
|
begin
|
||||||
{$if sizeof(clong)<=4}
|
{$if sizeof(clong)<=4}
|
||||||
fpfutimens:=do_syscall(syscall_nr_utimensat_time64,fd,TSysParam(nil),TSysParam(@times),0);
|
futimens:=do_syscall(syscall_nr_utimensat_time64,fd,TSysParam(nil),TSysParam(@times),0);
|
||||||
if (fpfutimens>=0) or (fpgeterrno<>ESysENOSYS) then
|
if (futimens>=0) or (fpgeterrno<>ESysENOSYS) then
|
||||||
exit;
|
exit;
|
||||||
{ try 32 bit fall back }
|
{ try 32 bit fall back }
|
||||||
tsa[0].tv_sec := times[0].tv_sec;
|
tsa[0].tv_sec := times[0].tv_sec;
|
||||||
tsa[0].tv_nsec := times[0].tv_nsec;
|
tsa[0].tv_nsec := times[0].tv_nsec;
|
||||||
tsa[1].tv_sec := times[1].tv_sec;
|
tsa[1].tv_sec := times[1].tv_sec;
|
||||||
tsa[1].tv_nsec := times[1].tv_nsec;
|
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}
|
{$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}
|
{$endif sizeof(clong)<=4}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ uses
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{$if defined(LINUX)}
|
{$if defined(LINUX)}
|
||||||
{$if sizeof(clong)<=4}
|
{$if sizeof(clong)<8}
|
||||||
{$DEFINE USE_STATX}
|
{$DEFINE USE_STATX}
|
||||||
{$DEFINE USE_UTIMENSAT}
|
{$DEFINE USE_UTIMENSAT}
|
||||||
{$endif sizeof(clong)<=4}
|
{$endif sizeof(clong)<=4}
|
||||||
@ -562,14 +562,14 @@ Var
|
|||||||
Info : Stat;
|
Info : Stat;
|
||||||
SystemFileName: RawByteString;
|
SystemFileName: RawByteString;
|
||||||
{$ifdef USE_STATX}
|
{$ifdef USE_STATX}
|
||||||
Infox : Statx;
|
Infox : TStatx;
|
||||||
{$endif USE_STATX}
|
{$endif USE_STATX}
|
||||||
begin
|
begin
|
||||||
SystemFileName:=ToSingleByteFileSystemEncodedFileName(FileName);
|
SystemFileName:=ToSingleByteFileSystemEncodedFileName(FileName);
|
||||||
|
|
||||||
{$ifdef USE_STATX}
|
{$ifdef USE_STATX}
|
||||||
{ first try 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
|
begin
|
||||||
Result:=Infox.stx_mtime.tv_sec;
|
Result:=Infox.stx_mtime.tv_sec;
|
||||||
exit;
|
exit;
|
||||||
@ -611,7 +611,7 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
{$ifdef USE_STATX}
|
{$ifdef USE_STATX}
|
||||||
Function LinuxToWinAttr (const FN : RawByteString; Const Info : Statx) : Longint;
|
Function LinuxToWinAttr (const FN : RawByteString; Const Info : TStatx) : Longint;
|
||||||
Var
|
Var
|
||||||
LinkInfo : Stat;
|
LinkInfo : Stat;
|
||||||
nm : RawByteString;
|
nm : RawByteString;
|
||||||
@ -928,16 +928,16 @@ end;
|
|||||||
Function FindGetFileInfo(const s: RawByteString; var f: TAbstractSearchRec; var Name: RawByteString):boolean;
|
Function FindGetFileInfo(const s: RawByteString; var f: TAbstractSearchRec; var Name: RawByteString):boolean;
|
||||||
Var
|
Var
|
||||||
{$ifdef USE_STATX}
|
{$ifdef USE_STATX}
|
||||||
stx : linux.statx;
|
stx : linux.tstatx;
|
||||||
{$endif USE_STATX}
|
{$endif USE_STATX}
|
||||||
st : baseunix.stat;
|
st : baseunix.stat;
|
||||||
WinAttr : longint;
|
WinAttr : longint;
|
||||||
begin
|
begin
|
||||||
{$ifdef USE_STATX}
|
{$ifdef USE_STATX}
|
||||||
if Assigned(f.FindHandle) and ( (PUnixFindData(F.FindHandle)^.searchattr and faSymlink) > 0) then
|
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
|
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
|
if FindGetFileInfo then
|
||||||
begin
|
begin
|
||||||
WinAttr:=LinuxToWinAttr(s,stx);
|
WinAttr:=LinuxToWinAttr(s,stx);
|
||||||
@ -1080,12 +1080,12 @@ Function FileGetDate (Handle : Longint) : Int64;
|
|||||||
Var
|
Var
|
||||||
Info : Stat;
|
Info : Stat;
|
||||||
{$ifdef USE_STATX}
|
{$ifdef USE_STATX}
|
||||||
Infox : Statx;
|
Infox : TStatx;
|
||||||
{$endif USE_STATX}
|
{$endif USE_STATX}
|
||||||
begin
|
begin
|
||||||
Result:=-1;
|
Result:=-1;
|
||||||
{$ifdef USE_STATX}
|
{$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
|
Result:=Infox.stx_Mtime.tv_sec
|
||||||
else if fpgeterrno=ESysENOSYS then
|
else if fpgeterrno=ESysENOSYS then
|
||||||
{$endif USE_STATX}
|
{$endif USE_STATX}
|
||||||
@ -1108,7 +1108,7 @@ begin
|
|||||||
times[0].tv_nsec:=0;
|
times[0].tv_nsec:=0;
|
||||||
times[1].tv_sec:=Age;
|
times[1].tv_sec:=Age;
|
||||||
times[1].tv_nsec:=0;
|
times[1].tv_nsec:=0;
|
||||||
if fpfutimens(Handle,times) = -1 then
|
if futimens(Handle,times) = -1 then
|
||||||
Result:=fpgeterrno;
|
Result:=fpgeterrno;
|
||||||
{$else USE_FUTIMES}
|
{$else USE_FUTIMES}
|
||||||
FileSetDate:=-1;
|
FileSetDate:=-1;
|
||||||
@ -1181,7 +1181,7 @@ begin
|
|||||||
times[0].tv_nsec:=0;
|
times[0].tv_nsec:=0;
|
||||||
times[1].tv_sec:=Age;
|
times[1].tv_sec:=Age;
|
||||||
times[1].tv_nsec:=0;
|
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;
|
Result:=fpgeterrno;
|
||||||
if fpgeterrno=ESysENOSYS then
|
if fpgeterrno=ESysENOSYS then
|
||||||
{$endif USE_UTIMENSAT}
|
{$endif USE_UTIMENSAT}
|
||||||
|
@ -7,7 +7,7 @@ var
|
|||||||
res : cint;
|
res : cint;
|
||||||
f1,f2 : text;
|
f1,f2 : text;
|
||||||
err : word;
|
err : word;
|
||||||
mystatx1,mystatx2 : statx;
|
mystatx1,mystatx2 : tstatx;
|
||||||
times : tkernel_timespecs;
|
times : tkernel_timespecs;
|
||||||
st,major,minor : string;
|
st,major,minor : string;
|
||||||
i,p,e : longint;
|
i,p,e : longint;
|
||||||
@ -57,17 +57,17 @@ begin
|
|||||||
rewrite(f2);
|
rewrite(f2);
|
||||||
write(f2,'ccccc');
|
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
|
if res<>0 then
|
||||||
halt(1);
|
halt(1);
|
||||||
times[0].tv_sec:=mystatx1.stx_atime.tv_sec;
|
times[0].tv_sec:=mystatx1.stx_atime.tv_sec;
|
||||||
times[0].tv_nsec:=mystatx1.stx_atime.tv_nsec;
|
times[0].tv_nsec:=mystatx1.stx_atime.tv_nsec;
|
||||||
times[1].tv_sec:=mystatx1.stx_mtime.tv_sec;
|
times[1].tv_sec:=mystatx1.stx_mtime.tv_sec;
|
||||||
times[1].tv_nsec:=mystatx1.stx_mtime.tv_nsec;
|
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
|
if res<>0 then
|
||||||
halt(1);
|
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
|
if res<>0 then
|
||||||
halt(1);
|
halt(1);
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ uses
|
|||||||
|
|
||||||
var
|
var
|
||||||
un : utsname;
|
un : utsname;
|
||||||
mystatx : statx;
|
mystatx : tstatx;
|
||||||
res : cint;
|
res : cint;
|
||||||
f : text;
|
f : text;
|
||||||
st,major,minor : string;
|
st,major,minor : string;
|
||||||
@ -53,7 +53,7 @@ begin
|
|||||||
rewrite(f);
|
rewrite(f);
|
||||||
write(f,'ccccc');
|
write(f,'ccccc');
|
||||||
close(f);
|
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);
|
erase(f);
|
||||||
if res<>0 then
|
if res<>0 then
|
||||||
begin
|
begin
|
||||||
|
@ -7,7 +7,7 @@ var
|
|||||||
res : cint;
|
res : cint;
|
||||||
f1,f2 : text;
|
f1,f2 : text;
|
||||||
err : word;
|
err : word;
|
||||||
mystatx1,mystatx2 : statx;
|
mystatx1,mystatx2 : tstatx;
|
||||||
times : tkernel_timespecs;
|
times : tkernel_timespecs;
|
||||||
st,major,minor : string;
|
st,major,minor : string;
|
||||||
i,p,e : longint;
|
i,p,e : longint;
|
||||||
@ -59,17 +59,17 @@ begin
|
|||||||
write(f2,'ccccc');
|
write(f2,'ccccc');
|
||||||
close(f2);
|
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
|
if res<>0 then
|
||||||
halt(1);
|
halt(1);
|
||||||
times[0].tv_sec:=mystatx1.stx_atime.tv_sec;
|
times[0].tv_sec:=mystatx1.stx_atime.tv_sec;
|
||||||
times[0].tv_nsec:=mystatx1.stx_atime.tv_nsec;
|
times[0].tv_nsec:=mystatx1.stx_atime.tv_nsec;
|
||||||
times[1].tv_sec:=mystatx1.stx_mtime.tv_sec;
|
times[1].tv_sec:=mystatx1.stx_mtime.tv_sec;
|
||||||
times[1].tv_nsec:=mystatx1.stx_mtime.tv_nsec;
|
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
|
if res<>0 then
|
||||||
halt(1);
|
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
|
if res<>0 then
|
||||||
halt(1);
|
halt(1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user