unxsysc.inc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. function fpNice(N:cint):cint;
  2. {
  3. Set process priority. A positive N means a lower priority.
  4. A negative N decreases priority.
  5. Doesn't exist in BSD. Linux emu uses setpriority in a construct as below:
  6. }
  7. begin
  8. fpNice:=fpSetPriority(Prio_Process,0,N);
  9. end;
  10. Function fpGetPriority(Which,Who:cint):cint;
  11. {
  12. Get Priority of process, process group, or user.
  13. Which : selects what kind of priority is used.
  14. can be one of the following predefined Constants :
  15. Prio_User.
  16. Prio_PGrp.
  17. Prio_Process.
  18. Who : depending on which, this is , respectively :
  19. Uid
  20. Pid
  21. Process Group id
  22. Errors are reported in linuxerror _only_. (priority can be negative)
  23. }
  24. begin
  25. if (which<prio_process) or (which>prio_user) then
  26. begin
  27. { We can save an interrupt here }
  28. fpgetpriority:=0;
  29. linuxerror:=ESysEinval;
  30. end
  31. else
  32. begin
  33. fpGetPriority:=do_syscall(syscall_nr_GetPriority,which,who);
  34. end;
  35. end;
  36. Function fpSetPriority(Which,Who,What:cint):cint;
  37. {
  38. Set Priority of process, process group, or user.
  39. Which : selects what kind of priority is used.
  40. can be one of the following predefined Constants :
  41. Prio_User.
  42. Prio_PGrp.
  43. Prio_Process.
  44. Who : depending on value of which, this is, respectively :
  45. Uid
  46. Pid
  47. Process Group id
  48. what : A number between -20 and 20. -20 is most favorable, 20 least.
  49. 0 is the default.
  50. }
  51. begin
  52. if ((which<prio_process) or (which>prio_user)) or ((what<-20) or (what>20)) then
  53. fpseterrno(ESyseinval) { We can save an interrupt here }
  54. else
  55. begin
  56. fpSetPriority:=do_syscall(Syscall_nr_Setpriority,which,who,what);
  57. end;
  58. end;
  59. Function fpLstat(path:pchar;Info:pstat):cint;
  60. {
  61. Get all information on a link (the link itself), and return it in info.
  62. }
  63. begin
  64. fpLStat:=do_syscall(syscall_nr_lstat,TSysParam(path),TSysParam(info));
  65. end;
  66. Function fpLstat(Filename: PathStr;Info:pstat):cint;
  67. {
  68. Get all information on a link (the link itself), and return it in info.
  69. }
  70. begin
  71. FileName:=FileName+#0;
  72. fpLStat:=do_syscall(syscall_nr_lstat,TSysParam(@filename[1]),TSysParam(info));
  73. end;
  74. Function fpSymlink(oldname,newname:pchar):cint;
  75. {
  76. We need this for erase
  77. }
  78. begin
  79. fpsymlink:=do_syscall(syscall_nr_symlink,TSysParam(oldname),TSysParam(newname));
  80. end;
  81. Function fpReadLink(name,linkname:pchar;maxlen:cint):cint;
  82. begin
  83. fpreadlink:=do_syscall(syscall_nr_readlink, TSysParam(name),TSysParam(linkname),maxlen);
  84. end;
  85. Function fpReadLink(Name:pathstr):pathstr;
  86. {
  87. Read a link (where it points to)
  88. }
  89. var
  90. LinkName : pathstr;
  91. i : cint;
  92. begin
  93. Name:=Name+#0;
  94. i:=fpReadLink(@Name[1],@LinkName[1],high(linkname));
  95. if i>0 then
  96. begin
  97. linkname[0]:=chr(i);
  98. fpReadLink:=LinkName;
  99. end
  100. else
  101. fpReadLink:='';
  102. end;