tutimensat.pp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. { %target=linux }
  2. uses
  3. ctypes,baseunix,linux;
  4. var
  5. un : utsname;
  6. res : cint;
  7. f1,f2 : text;
  8. err : word;
  9. mystatx1,mystatx2 : statx;
  10. times : tkernel_timespecs;
  11. st,major,minor : string;
  12. i,p,e : longint;
  13. major_release, minor_release : longint;
  14. begin
  15. fpuname(un);
  16. st:=un.release;
  17. for i:=1 to UTSNAME_LENGTH do
  18. if st[i]='.' then
  19. begin
  20. p:=i;
  21. major:=system.copy(st,1,p-1);
  22. system.val(major,major_release,err);
  23. if err<>0 then
  24. begin
  25. writeln('Unable to parse first part of linux version ',st,'(',major,') correctly');
  26. halt(2);
  27. end;
  28. break;
  29. end;
  30. for i:=p+1 to UTSNAME_LENGTH do
  31. if st[i]='.' then
  32. begin
  33. e:=i;
  34. minor:=system.copy(st,p+1,e-p-1);
  35. system.val(minor,minor_release,err);
  36. if err<>0 then
  37. begin
  38. writeln('Unable to second part of parse linux version ',st,'i(',minor,') correctly');
  39. halt(2);
  40. end;
  41. break;
  42. end;
  43. if (major_release<4) or ((major_release=4) and (minor_release<11)) then
  44. begin
  45. writeln('This version of Linux: ',st,' does not have fstatx syscall');
  46. halt(0);
  47. end
  48. else
  49. writeln('This linux version ',st,' should support statx syscall');
  50. assign(f1,'tutimensat1.txt');
  51. rewrite(f1);
  52. write(f1,'ccccc');
  53. close(f1);
  54. assign(f2,'tutimensat2.txt');
  55. rewrite(f2);
  56. write(f2,'ccccc');
  57. close(f2);
  58. res:=fpstatx(AT_FDCWD,'tutimensat1.txt',AT_SYMLINK_NOFOLLOW,STATX_ALL,mystatx1);
  59. if res<>0 then
  60. halt(1);
  61. times[0].tv_sec:=mystatx1.stx_atime.tv_sec;
  62. times[0].tv_nsec:=mystatx1.stx_atime.tv_nsec;
  63. times[1].tv_sec:=mystatx1.stx_mtime.tv_sec;
  64. times[1].tv_nsec:=mystatx1.stx_mtime.tv_nsec;
  65. res:=fputimensat(AT_FDCWD,'tutimensat2.txt',times,0);
  66. if res<>0 then
  67. halt(1);
  68. res:=fpstatx(AT_FDCWD,'tutimensat2.txt',AT_SYMLINK_NOFOLLOW,STATX_ALL,mystatx2);
  69. if res<>0 then
  70. halt(1);
  71. erase(f1);
  72. erase(f2);
  73. if (mystatx1.stx_atime.tv_sec<>mystatx2.stx_atime.tv_sec) or (mystatx1.stx_atime.tv_nsec<>mystatx2.stx_atime.tv_nsec) or
  74. (mystatx1.stx_mtime.tv_sec<>mystatx2.stx_mtime.tv_sec) or (mystatx1.stx_mtime.tv_nsec<>mystatx2.stx_mtime.tv_nsec) then
  75. halt(1);
  76. writeln('ok');
  77. end.