linux.tex 102 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323
  1. %
  2. % $Id$
  3. % This file is part of the FPC documentation.
  4. % Copyright (C) 1997, by Michael Van Canneyt
  5. %
  6. % The FPC documentation is free text; you can redistribute it and/or
  7. % modify it under the terms of the GNU Library General Public License as
  8. % published by the Free Software Foundation; either version 2 of the
  9. % License, or (at your option) any later version.
  10. %
  11. % The FPC Documentation is distributed in the hope that it will be useful,
  12. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. % Library General Public License for more details.
  15. %
  16. % You should have received a copy of the GNU Library General Public
  17. % License along with the FPC documentation; see the file COPYING.LIB. If not,
  18. % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. % Boston, MA 02111-1307, USA.
  20. %
  21. \chapter{The LINUX unit.}
  22. \label{ch:linux}
  23. \FPCexampledir{linuxex}
  24. This chapter describes the LINUX unit for Free Pascal. The unit was written
  25. by Micha\"el van Canneyt. It works only on the Linux operating system.
  26. This chapter is divided in 2 sections:
  27. \begin{itemize}
  28. \item The first section lists all constants, types and variables, as listed
  29. in the interface section of the LINUX unit.
  30. \item The second section describes all procedures and functions in the LINUX
  31. unit.
  32. \end{itemize}
  33. % Type, Variable and Constant declarations
  34. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  35. \section{Type, Variable and Constant declarations}
  36. %
  37. \subsection{Types}
  38. \label{sec:types}
  39. PGlob and TGlob are 2 types used in the \seef{Glob} function:
  40. \begin{verbatim}
  41. PGlob = ^TGlob;
  42. TGlob = record
  43. Name : PChar;
  44. Next : PGlob;
  45. end;
  46. \end{verbatim}
  47. The following types are used in the signal-processing procedures.
  48. \begin{verbatim}
  49. tfpreg = record
  50. significand: array[0..3] of word;
  51. exponent: word;
  52. end;
  53. pfpstate = ^tfpstate;
  54. tfpstate = record
  55. cw, sw, tag, ipoff, cssel, dataoff, datasel: cardinal;
  56. st: array[0..7] of tfpreg;
  57. status: cardinal;
  58. end;
  59. PSigContextRec = ^SigContextRec;
  60. SigContextRec = record
  61. gs, __gsh: word;
  62. fs, __fsh: word;
  63. es, __esh: word;
  64. ds, __dsh: word;
  65. edi: cardinal;
  66. esi: cardinal;
  67. ebp: cardinal;
  68. esp: cardinal;
  69. ebx: cardinal;
  70. edx: cardinal;
  71. ecx: cardinal;
  72. eax: cardinal;
  73. trapno: cardinal;
  74. err: cardinal;
  75. eip: cardinal;
  76. cs, __csh: word;
  77. eflags: cardinal;
  78. esp_at_signal: cardinal;
  79. ss, __ssh: word;
  80. fpstate: pfpstate;
  81. oldmask: cardinal;
  82. cr2: cardinal;
  83. end;
  84. \end{verbatim}
  85. The above records contain information about the processor state and process
  86. state at the moment a signal is sent to your program.
  87. The records below are used in catching signals.
  88. \begin{verbatim}
  89. TSigAction = procedure(Sig: Longint; SigContext: SigContextRec);cdecl;
  90. SignalHandler = Procedure ( Sig : Integer);cdecl;
  91. PSignalHandler = SignalHandler;
  92. SignalRestorer = Procedure;cdecl;
  93. PSignalrestorer = SignalRestorer;
  94. SigActionRec = packed record
  95. Handler : record
  96. case byte of
  97. 0: (Sh: SignalHandler);
  98. 1: (Sa: TSigAction);
  99. end;
  100. Sa_Mask : SigSet;
  101. Sa_Flags : Longint;
  102. Sa_restorer : SignalRestorer; { Obsolete - Don't use }
  103. end;
  104. PSigActionRec = ^SigActionRec;
  105. \end{verbatim}
  106. Stat is used to store information about a file. It is defined in the
  107. syscalls unit.
  108. \begin{verbatim}
  109. stat = record
  110. dev : word;
  111. pad1 : word;
  112. ino : longint;
  113. mode : word;
  114. nlink : word;
  115. uid : word;
  116. gid : word;
  117. rdev : word;
  118. pad2 : word;
  119. size : longint;
  120. blksze : Longint;
  121. blocks : Longint;
  122. atime : Longint;
  123. unused1 : longint;
  124. mtime : Longint;
  125. unused2 : longint;
  126. ctime : Longint;
  127. unused3 : longint;
  128. unused4 : longint;
  129. unused5 : longint;
  130. end;
  131. \end{verbatim}
  132. Statfs is used to store information about a filesystem. It is defined in
  133. the syscalls unit.
  134. \begin{verbatim}
  135. statfs = record
  136. fstype : longint;
  137. bsize : longint;
  138. blocks : longint;
  139. bfree : longint;
  140. bavail : longint;
  141. files : longint;
  142. ffree : longint;
  143. fsid : longint;
  144. namelen : longint;
  145. spare : array [0..6] of longint;
  146. end
  147. \end{verbatim}
  148. \var{Dir and PDir} are used in the \seef{OpenDir} and \seef{ReadDir}
  149. functions.
  150. \begin{verbatim}
  151. TDir =record
  152. fd : integer;
  153. loc : longint;
  154. size : integer;
  155. buf : pdirent;
  156. nextoff: longint;
  157. dd_max : integer;
  158. lock : pointer;
  159. end;
  160. PDir =^TDir;
  161. \end{verbatim}
  162. \var{Dirent, PDirent} are used in the \seef{ReadDir} function to return files in a directory.
  163. \begin{verbatim}
  164. PDirent = ^Dirent;
  165. Dirent = Record
  166. ino,
  167. off : longint;
  168. reclen : word;
  169. name : string[255]
  170. end;
  171. \end{verbatim}
  172. Termio and Termios are used with iotcl() calls for terminal handling.
  173. \begin{verbatim}
  174. Const NCCS = 19;
  175. NCC = 8;
  176. Type termio = record
  177. c_iflag, { input mode flags }
  178. c_oflag, { output mode flags }
  179. c_cflag, { control mode flags }
  180. c_lflag : Word; { local mode flags }
  181. c_line : Word; { line discipline - careful, only High byte in use}
  182. c_cc : array [0..NCC-1] of char; { control characters }
  183. end;
  184. termios = record
  185. c_iflag, { input mode flags }
  186. c_oflag, { output mode flags }
  187. c_cflag, { control mode flags }
  188. c_lflag : Cardinal; { local mode flags }
  189. c_line : char; { line discipline }
  190. c_cc : array [0..NCCS-1] of char; { control characters }
  191. end;
  192. \end{verbatim}
  193. \var{Utimbuf} is used in the \seef{Utime} call to set access and modificaton time
  194. of a file.
  195. \begin{verbatim}
  196. utimbuf = record
  197. actime,modtime : Longint;
  198. end;
  199. \end{verbatim}
  200. For the \seef{Select} call, the following 4 types are needed:
  201. \begin{verbatim}
  202. FDSet = Array [0..31] of longint;
  203. PFDSet = ^FDSet;
  204. TimeVal = Record
  205. sec,usec : Longint;
  206. end;
  207. PTimeVal = ^TimeVal;
  208. \end{verbatim}
  209. The \seep{Uname} function uses the \var{utsname} to return information about
  210. the current kernel :
  211. \begin{verbatim}
  212. utsname =record
  213. sysname,nodename,release,
  214. version,machine,domainname : Array[0..64] of char;
  215. end;
  216. \end{verbatim}
  217. Its elements are null-terminated C style strings, you cannot access them
  218. directly !
  219. %
  220. \subsection{Variables}
  221. \var{Linuxerror} is the variable in which the procedures in the linux unit
  222. report errors.
  223. \begin{verbatim}
  224. LinuxError : Longint;
  225. \end{verbatim}
  226. \var{StdErr} Is a \var{Text} variable, corresponding to Standard Error or
  227. diagnostic output. It is connected to file descriptor 2. It can be freely
  228. used, and will be closed on exit.
  229. \begin{verbatim}
  230. StdErr : Text;
  231. \end{verbatim}
  232. %
  233. \subsection{Constants}
  234. Constants for setting/getting process priorities :
  235. \begin{verbatim}
  236. Prio_Process = 0;
  237. Prio_PGrp = 1;
  238. Prio_User = 2;
  239. \end{verbatim}
  240. For testing access rights:
  241. \begin{verbatim}
  242. R_OK = 4;
  243. W_OK = 2;
  244. X_OK = 1;
  245. F_OK = 0;
  246. \end{verbatim}
  247. For signal handling functions :
  248. \begin{verbatim}
  249. SA_NOCLDSTOP = 1;
  250. SA_SHIRQ = $04000000;
  251. SA_STACK = $08000000;
  252. SA_RESTART = $10000000;
  253. SA_INTERRUPT = $20000000;
  254. SA_NOMASK = $40000000;
  255. SA_ONESHOT = $80000000;
  256. SIG_BLOCK = 0;
  257. SIG_UNBLOCK = 1;
  258. SIG_SETMASK = 2;
  259. SIG_DFL = 0 ;
  260. SIG_IGN = 1 ;
  261. SIG_ERR = -1;
  262. SIGHUP = 1;
  263. SIGINT = 2;
  264. SIGQUIT = 3;
  265. SIGILL = 4;
  266. SIGTRAP = 5;
  267. SIGABRT = 6;
  268. SIGIOT = 6;
  269. SIGBUS = 7;
  270. SIGFPE = 8;
  271. SIGKILL = 9;
  272. SIGUSR1 = 10;
  273. SIGSEGV = 11;
  274. SIGUSR2 = 12;
  275. SIGPIPE = 13;
  276. SIGALRM = 14;
  277. SIGTERM = 15;
  278. SIGSTKFLT = 16;
  279. SIGCHLD = 17;
  280. SIGCONT = 18;
  281. SIGSTOP = 19;
  282. SIGTSTP = 20;
  283. SIGTTIN = 21;
  284. SIGTTOU = 22;
  285. SIGURG = 23;
  286. SIGXCPU = 24;
  287. SIGXFSZ = 25;
  288. SIGVTALRM = 26;
  289. SIGPROF = 27;
  290. SIGWINCH = 28;
  291. SIGIO = 29;
  292. SIGPOLL = SIGIO;
  293. SIGPWR = 30;
  294. SIGUNUSED = 31;
  295. \end{verbatim}
  296. For file control mechanism :
  297. \begin{verbatim}
  298. F_GetFd = 1;
  299. F_SetFd = 2;
  300. F_GetFl = 3;
  301. F_SetFl = 4;
  302. F_GetLk = 5;
  303. F_SetLk = 6;
  304. F_SetLkW = 7;
  305. F_GetOwn = 8;
  306. F_SetOwn = 9;
  307. \end{verbatim}
  308. For Terminal handling :
  309. \begin{verbatim}
  310. TCGETS = $5401 ;
  311. TCSETS = $5402 ;
  312. TCSETSW = $5403 ;
  313. TCSETSF = $5404 ;
  314. TCGETA = $5405 ;
  315. TCSETA = $5406 ;
  316. TCSETAW = $5407 ;
  317. TCSETAF = $5408 ;
  318. TCSBRK = $5409 ;
  319. TCXONC = $540A ;
  320. TCFLSH = $540B ;
  321. TIOCEXCL = $540C ;
  322. TIOCNXCL = $540D ;
  323. TIOCSCTTY = $540E ;
  324. TIOCGPGRP = $540F ;
  325. TIOCSPGRP = $5410 ;
  326. TIOCOUTQ = $5411 ;
  327. TIOCSTI = $5412 ;
  328. TIOCGWINSZ = $5413 ;
  329. TIOCSWINSZ = $5414 ;
  330. TIOCMGET = $5415 ;
  331. TIOCMBIS = $5416 ;
  332. TIOCMBIC = $5417 ;
  333. TIOCMSET = $5418 ;
  334. TIOCGSOFTCAR = $5419 ;
  335. TIOCSSOFTCAR = $541A ;
  336. FIONREAD = $541B ;
  337. TIOCINQ = FIONREAD;
  338. TIOCLINUX = $541C ;
  339. TIOCCONS = $541D ;
  340. TIOCGSERIAL = $541E ;
  341. TIOCSSERIAL = $541F ;
  342. TIOCPKT = $5420 ;
  343. FIONBIO = $5421 ;
  344. TIOCNOTTY = $5422 ;
  345. TIOCSETD = $5423 ;
  346. TIOCGETD = $5424 ;
  347. TCSBRKP = $5425 ;
  348. TIOCTTYGSTRUCT = $5426 ;
  349. FIONCLEX = $5450 ;
  350. FIOCLEX = $5451 ;
  351. FIOASYNC = $5452 ;
  352. TIOCSERCONFIG = $5453 ;
  353. TIOCSERGWILD = $5454 ;
  354. TIOCSERSWILD = $5455 ;
  355. TIOCGLCKTRMIOS = $5456 ;
  356. TIOCSLCKTRMIOS = $5457 ;
  357. TIOCSERGSTRUCT = $5458 ;
  358. TIOCSERGETLSR = $5459 ;
  359. TIOCSERGETMULTI = $545A ;
  360. TIOCSERSETMULTI = $545B ;
  361. TIOCMIWAIT = $545C ;
  362. TIOCGICOUNT = $545D ;
  363. TIOCPKT_DATA = 0;
  364. TIOCPKT_FLUSHREAD = 1;
  365. TIOCPKT_FLUSHWRITE = 2;
  366. TIOCPKT_STOP = 4;
  367. TIOCPKT_START = 8;
  368. TIOCPKT_NOSTOP = 16;
  369. TIOCPKT_DOSTOP = 32;
  370. \end{verbatim}
  371. Other than that, all constants for setting the speed and control flags of a
  372. terminal line, as described in the \seem{termios}{2} man
  373. page, are defined in the linux unit. It would take too much place to list
  374. them here.
  375. To check the \var{mode} field of a \var{stat} record, you ca use the
  376. following constants :
  377. \begin{verbatim}
  378. { Constants to check stat.mode }
  379. STAT_IFMT = $f000; {00170000}
  380. STAT_IFSOCK = $c000; {0140000}
  381. STAT_IFLNK = $a000; {0120000}
  382. STAT_IFREG = $8000; {0100000}
  383. STAT_IFBLK = $6000; {0060000}
  384. STAT_IFDIR = $4000; {0040000}
  385. STAT_IFCHR = $2000; {0020000}
  386. STAT_IFIFO = $1000; {0010000}
  387. STAT_ISUID = $0800; {0004000}
  388. STAT_ISGID = $0400; {0002000}
  389. STAT_ISVTX = $0200; {0001000}
  390. { Constants to check permissions }
  391. STAT_IRWXO = $7;
  392. STAT_IROTH = $4;
  393. STAT_IWOTH = $2;
  394. STAT_IXOTH = $1;
  395. STAT_IRWXG = STAT_IRWXO shl 3;
  396. STAT_IRGRP = STAT_IROTH shl 3;
  397. STAT_IWGRP = STAT_IWOTH shl 3;
  398. STAT_IXGRP = STAT_IXOTH shl 3;
  399. STAT_IRWXU = STAT_IRWXO shl 6;
  400. STAT_IRUSR = STAT_IROTH shl 6;
  401. STAT_IWUSR = STAT_IWOTH shl 6;
  402. STAT_IXUSR = STAT_IXOTH shl 6;
  403. \end{verbatim}
  404. You can test the type of a filesystem returned by a \seef{FSStat} call with
  405. the following constants:
  406. \begin{verbatim}
  407. fs_old_ext2 = $ef51;
  408. fs_ext2 = $ef53;
  409. fs_ext = $137d;
  410. fs_iso = $9660;
  411. fs_minix = $137f;
  412. fs_minix_30 = $138f;
  413. fs_minux_V2 = $2468;
  414. fs_msdos = $4d44;
  415. fs_nfs = $6969;
  416. fs_proc = $9fa0;
  417. fs_xia = $012FD16D;
  418. \end{verbatim}
  419. the \seef{FLock} call uses the following mode constants :
  420. \begin{verbatim}
  421. LOCK_SH = 1;
  422. LOCK_EX = 2;
  423. LOCK_UN = 8;
  424. LOCK_NB = 4;
  425. \end{verbatim}
  426. The \seef{MMap} function uses the following constants to specify access to
  427. mapped memory:
  428. \begin{verbatim}
  429. PROT_READ = $1; { page can be read }
  430. PROT_WRITE = $2; { page can be written }
  431. PROT_EXEC = $4; { page can be executed }
  432. PROT_NONE = $0; { page can not be accessed }
  433. \end{verbatim}
  434. and the following constants to specify the type of mapping.
  435. \begin{verbatim}
  436. MAP_SHARED = $1; { Share changes }
  437. MAP_PRIVATE = $2; { Changes are private }
  438. MAP_TYPE = $f; { Mask for type of mapping }
  439. MAP_FIXED = $10; { Interpret addr exactly }
  440. MAP_ANONYMOUS = $20; { don't use a file }
  441. \end{verbatim}
  442. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  443. % Functions and procedures
  444. \section{Functions and procedures}
  445. \begin{function}{Access}
  446. \Declaration
  447. Function Access (Path : Pathstr; Mode : integer) : Boolean;
  448. \Description
  449. Tests user's access rights on the specified file. Mode is a mask existing of
  450. one or more of
  451. \begin{description}
  452. \item[R\_OK] User has read rights.
  453. \item[W\_OK] User has write rights.
  454. \item[X\_OK] User has execute rights.
  455. \item[F\_OK] User has search rights in the directory where the file is.
  456. \end{description}
  457. The test is done with the real user ID, instead of the effective user ID.
  458. If access is denied, or an error occurred, false is returned.
  459. \Errors
  460. \var{LinuxError} is used to report errors:
  461. \begin{description}
  462. \item[sys\_eaccess] The requested access is denied, either to the file or one
  463. of the directories in its path.
  464. \item[sys\_einval] \var{Mode} was incorrect.
  465. \item[sys\_enoent] A directory component in \var{Path} doesn't exist or is a
  466. dangling symbolic link.
  467. \item[sys\_enotdir] A directory component in \var{Path} is not a directory.
  468. \item[sys\_enomem] Insufficient kernel memory.
  469. \item[sys\_eloop] \var{Path} has a circular symbolic link.
  470. \end{description}
  471. \SeeAlso
  472. \seef{Chown}, \seef{Chmod}, \seem{Access}{2}
  473. \end{function}
  474. \FPCexample{ex26}
  475. \begin{function}{Alarm}
  476. \Declaration
  477. Function Alarm(Sec : longint) : Longint;
  478. \Description
  479. Alarm schedules an alarm signal to be delivered to your process in \var{Sec}
  480. seconds. When \var{Sec} seconds have elapsed, Linux will send a \var{SIGALRM}
  481. signal to the current process. If \var{Sec} is zero, then no new alarm will
  482. be set. Whatever the value of \var{Sec}, any previous alarm is cancelled.
  483. The function returns the number of seconds till the previously scheduled
  484. alarm was due to be delivered, or zero if there was none.
  485. \Errors{None}
  486. \end{function}
  487. \FPCexample{ex59}
  488. \begin{function}{AssignPipe}
  489. \Declaration
  490. Function AssignPipe(var pipe\_in,pipe\_out:longint):boolean;
  491. Function AssignPipe(var pipe\_in,pipe\_out:text):boolean;
  492. Function AssignPipe(var pipe\_in,pipe\_out:file):boolean;
  493. \Description
  494. \var{AssignePipe} creates a pipe, i.e. two file objects, one for input,
  495. one for output. What is written to \var{Pipe\_out}, can be read from
  496. \var{Pipe\_in}.
  497. This call is overloaded. The in and out pipe can take three forms:
  498. an typed or untyped file, a text file or a file descriptor.
  499. If a text file is passed then reading and writing from/to the pipe
  500. can be done through the usual \var{Readln(Pipe\_in,...)} and
  501. \var{Writeln (Pipe\_out,...)} procedures.
  502. The function returns \var{True} if everything went succesfully,
  503. \var{False} otherwise.
  504. \Errors
  505. In case the function fails and returns \var{False}, \var{LinuxError}
  506. is used to report errors:
  507. \begin{description}
  508. \item[sys\_emfile] Too many file descriptors for this process.
  509. \item[sys\_enfile] The system file table is full.
  510. \end{description}
  511. \SeeAlso
  512. \seep{POpen}, \seef{MkFifo}, \seem{pipe}{2}
  513. \end{function}
  514. \FPCexample{ex36}
  515. \begin{function}{AssignStream}
  516. \Declaration
  517. Function AssignStream(Var StreamIn,Streamout:text;
  518. Const Prog:String) : longint;
  519. Function AssignStream(var StreamIn, StreamOut, StreamErr: Text;
  520. const prog: String): LongInt;
  521. \Description
  522. \var{AssignStream} creates a 2 or 3 pipes, i.e. two (or three) file objects, one for
  523. input, one for output,(and one for standard error) the other ends of these
  524. pipes are connected to standard input and output (and standard error) of
  525. \var{Prog}. \var{Prog} is the name of a program (including path) with options,
  526. which will be executed.
  527. What is written to \var{StreamOut}, will go to the standard input of
  528. \var{Prog}. Whatever is written by \var{Prog} to it's standard output
  529. can be read from \var{StreamIn}.
  530. Whatever is written by \var{Prog} to it's standard error read from
  531. \var{StreamErr}, if present.
  532. Reading and writing happens through the usual \var{Readln(StreamIn,...)} and
  533. \var{Writeln (StreamOut,...)} procedures.
  534. {\em Remark:} You should {\em not} use \var{Reset} or \var{Rewrite} on a
  535. file opened with \var{POpen}. This will close the file before re-opening
  536. it again, thereby closing the connection with the program.
  537. The function returns the process ID of the spawned process, or -1 in case of
  538. error.
  539. \Errors
  540. In case of error (return value -1) \var{LinuxError} is used to report
  541. errors:
  542. \begin{description}
  543. \item[sys\_emfile] Too many file descriptors for this process.
  544. \item[sys\_enfile] The system file table is full.
  545. \end{description}
  546. Other errors include the ones by the fork and exec programs
  547. \SeeAlso
  548. \seef{AssignPipe}, \seep{POpen},\seem{pipe}{2}
  549. \end{function}
  550. \FPCexample{ex38}
  551. \begin{function}{BaseName}
  552. \Declaration
  553. Function BaseName (Const Path;Const Suf : Pathstr) : Pathstr;
  554. \Description
  555. Returns the filename part of \var{Path}, stripping off \var{Suf} if it
  556. exists.
  557. The filename part is the whole name if \var{Path} contains no slash,
  558. or the part of \var{Path} after the last slash.
  559. The last character of the result is not a slash, unless the directory is the
  560. root directory.
  561. \Errors
  562. None.
  563. \SeeAlso
  564. \seef{DirName}, \seef{FExpand}, \seem{Basename}{1}
  565. \end{function}
  566. \FPCexample{ex48}
  567. \begin{procedure}{CFMakeRaw}
  568. \Declaration
  569. Procedure CFMakeRaw (var Tios:TermIOS);
  570. \Description
  571. \var{CFMakeRaw}
  572. Sets the flags in the \var{Termios} structure \var{Tios} to a state so that
  573. the terminal will function in Raw Mode.
  574. \Errors
  575. None.
  576. \SeeAlso
  577. \seep{CFSetOSpeed}, \seep{CFSetISpeed}, \seem{termios}{2}
  578. \end{procedure}
  579. For an example, see \seef{TCGetAttr}.
  580. \begin{procedure}{CFSetISpeed}
  581. \Declaration
  582. Procedure CFSetISpeed (var Tios:TermIOS;Speed:Longint);
  583. \Description
  584. \var{CFSetISpeed}
  585. Sets the input baudrate in the \var{TermIOS} structure \var{Tios} to
  586. \var{Speed}.
  587. \Errors
  588. None.
  589. \SeeAlso
  590. \seep{CFSetOSpeed}, \seep{CFMakeRaw}, \seem{termios}{2}
  591. \end{procedure}
  592. \begin{procedure}{CFSetOSpeed}
  593. \Declaration
  594. Procedure CFSetOSpeed (var Tios:TermIOS;Speed:Longint);
  595. \Description
  596. \var{CFSetOSpeed}
  597. Sets the output baudrate in the \var{Termios} structure \var{Tios} to
  598. \var{Speed}.
  599. \Errors
  600. None.
  601. \SeeAlso
  602. \seep{CFSetISpeed}, \seep{CFMakeRaw}, \seem{termios}{2}
  603. \end{procedure}
  604. \begin{function}{Chown}
  605. \Declaration
  606. Function Chown (Path : Pathstr;NewUid,NewGid : Longint) : Boolean;
  607. \Description
  608. \var{Chown} sets the User ID and Group ID of the file in \var{Path} to \var{NewUid,
  609. NewGid}.
  610. The function returns \var{True} if the call was succesfull, \var{False} if the call
  611. failed.
  612. \Errors
  613. Errors are returned in \var{LinuxError}.
  614. \begin{description}
  615. \item[sys\_eperm] The effective UID doesn't match the ownership of the file,
  616. and is not zero. Owner or group were not specified correctly.
  617. \item[sys\_eaccess] One of the directories in \var{Path} has no
  618. search (=execute) permission.
  619. \item[sys\_enoent] A directory entry in \var{Path} does
  620. not exist or is a symbolic link pointing to a non-existent directory.
  621. \item[sys\_enotdir] A directory entry in \var{OldPath} or \var{NewPath} is
  622. nor a directory.
  623. \item[sys\_enomem] Insufficient kernel memory.
  624. \item[sys\_erofs] The file is on a read-only filesystem.
  625. \item[sys\_eloop] \var{Path} has a reference to a circular
  626. symbolic link, i.e. a symbolic link, whose expansion points to itself.
  627. \end{description}
  628. \SeeAlso
  629. \seef{Chmod}, \seef{Access}, \seem{Chown}(2)
  630. \end{function}
  631. \FPCexample{ex24}
  632. \begin{function}{Chmod}
  633. \Declaration
  634. Function Chmod (Path : Pathstr;NewMode : Longint) : Boolean;
  635. \Description
  636. \var{Chmod}
  637. Sets the Mode bits of the file in \var{Path} to \var{NewMode}. Newmode can be
  638. specified by 'or'-ing the following:
  639. \begin{description}
  640. \item[S\_ISUID] Set user ID on execution.
  641. \item[S\_ISGID] Set Group ID on execution.
  642. \item[S\_ISVTX] Set sticky bit.
  643. \item[S\_IRUSR] Read by owner.
  644. \item[S\_IWUSR] Write by owner.
  645. \item[S\_IXUSR] Execute by owner.
  646. \item[S\_IRGRP] Read by group.
  647. \item[S\_IWGRP] Write by group.
  648. \item[S\_IXGRP] Execute by group.
  649. \item[S\_IROTH] Read by others.
  650. \item[S\_IWOTH] Write by others.
  651. \item[S\_IXOTH] Execute by others.
  652. \item[S\_IRWXO] Read, write, execute by others.
  653. \item[S\_IRWXG] Read, write, execute by groups.
  654. \item[S\_IRWXU] Read, write, execute by user.
  655. \end{description}
  656. \Errors
  657. Errors are returned in \var{LinuxError}.
  658. \begin{description}
  659. \item[sys\_eperm] The effective UID doesn't match the ownership of the file,
  660. and is not zero. Owner or group were not specified correctly.
  661. \item[sys\_eaccess] One of the directories in \var{Path} has no
  662. search (=execute) permission.
  663. \item[sys\_enoent] A directory entry in \var{Path} does
  664. not exist or is a symbolic link pointing to a non-existent directory.
  665. \item[sys\_enotdir] A directory entry in \var{OldPath} or \var{NewPath} is
  666. nor a directory.
  667. \item[sys\_enomem] Insufficient kernel memory.
  668. \item[sys\_erofs] The file is on a read-only filesystem.
  669. \item[sys\_eloop] \var{Path} has a reference to a circular
  670. symbolic link, i.e. a symbolic link, whose expansion points to itself.
  671. \end{description}
  672. \SeeAlso
  673. \seef{Chown}, \seef{Access}, \seem{Chmod}(2), \seef{Octal}
  674. \end{function}
  675. \FPCexample{ex23}
  676. \begin{function}{Clone}
  677. \Declaration
  678. TCloneFunc=function(args:pointer):longint;cdecl;
  679. Clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint;
  680. \Description
  681. Clone creates a child process which is a copy of the parent process, just
  682. like \seef{Fork} does. In difference with \var{Fork}, however, the child
  683. process shares some parts of it's execution context with its parent, so it
  684. is suitable for the implementation of threads: many instances of a program
  685. that share the same memory.
  686. When the child process is created, it starts executing the function
  687. \var{Func}, and passes it \var{Args}. The return value of \var{Func} is
  688. either the explicit return value of the function, or the exit code of
  689. the child process.
  690. The \var{sp} pointer points to the memory reserved as stack space for the
  691. child process. This address should be the top of the memory block to be used
  692. as stack.
  693. The \var{Flags} determine the behaviour of the \var{Clone} call. The low
  694. byte of the Flags contains the number of the signal that will be sent to
  695. the parent when the child dies.
  696. This may be bitwise OR'ed with the following constants:
  697. \begin{description}
  698. \item[CLONE\_VM] Parent and child share the same memory space, including
  699. memory (un)mapped with subsequent \var{mmap} calls.
  700. \item[CLONE\_FS] Parent and child have the same view of the filesystem;
  701. the \var{chroot}, \var{chdir} and \var{umask} calls affect both processes.
  702. \item[CLONE\_FILES] the file descriptor table of parent and child is shared.
  703. \item[CLONE\_SIGHAND] the parent and child share the same table of signal
  704. handlers. The signal masks are different, though.
  705. \item[CLONE\_PID] PArent and child have the same process ID.
  706. \end{description}
  707. Clone returns the process ID in the parent process, and -1 if an error
  708. occurred.
  709. \Errors
  710. On error, -1 is returned to the parent, and no child is created.
  711. \begin{description}
  712. \item [sys\_eagain] Too many processes are running.
  713. \item [sys\_enomem] Not enough memory to create child process.
  714. \end{description}
  715. \SeeAlso
  716. \seef{Fork}, \seem{clone}{2}
  717. \end{function}
  718. \FPCexample{ex14}
  719. \begin{function}{CloseDir}
  720. \Declaration
  721. Function CloseDir (p:pdir) : integer;
  722. \Description
  723. \var{CloseDir} closes the directory pointed to by \var{p}.
  724. It returns zero if the directory was closed succesfully, -1 otherwise.
  725. \Errors
  726. Errors are returned in LinuxError.
  727. \SeeAlso
  728. \seef{OpenDir}, \seef{ReadDir}, \seep{SeekDir}, \seef{TellDir},
  729. \seem{closedir}{3}
  730. \end{function}
  731. For an example, see \seef{OpenDir}.
  732. \begin{function}{CreateShellArgV}
  733. \Declaration
  734. function CreateShellArgV(const prog:string):ppchar;
  735. function CreateShellArgV(const prog:Ansistring):ppchar;
  736. \Description
  737. \var{CreateShellArgV} creates an array of 3 \var{PChar} pointers that can
  738. be used as arguments to \var{ExecVE} the first elements in the array
  739. will contain \var{/bin/sh}, the second will contain \var{-c}, and the third
  740. will contain \var{prog}.
  741. The function returns a pointer to this array, of type \var{PPChar}.
  742. \Errors
  743. None.
  744. \SeeAlso
  745. \seef{Shell}
  746. \end{function}
  747. \FPCexample{ex61}
  748. \begin{function}{DirName}
  749. \Declaration
  750. Function DirName (Const Path : Pathstr) : Pathstr;
  751. \Description
  752. Returns the directory part of \var{Path}.
  753. The directory is the part of \var{Path} before the last slash,
  754. or empty if there is no slash.
  755. The last character of the result is not a slash, unless the directory is the
  756. root directory.
  757. \Errors
  758. None.
  759. \SeeAlso
  760. \seef{BaseName}, \seef{FExpand}, \seem{Dirname}{1}
  761. \end{function}
  762. \FPCexample{ex47}
  763. \begin{function}{Dup}
  764. \Declaration
  765. Function Dup(oldfile:longint;var newfile:longint):Boolean;
  766. Function Dup(var oldfile,newfile:text):Boolean;
  767. Function Dup(var oldfile,newfile:file):Boolean;
  768. \Description
  769. Makes \var{NewFile} an exact copy of \var{OldFile}, after having flushed the
  770. buffer of \var{OldFile} in case it is a Text file or untyped file.
  771. Due to the buffering mechanism of Pascal, this has not the same functionality
  772. as the \seem{dup}{2} call in C. The internal Pascal buffers are not the same
  773. after this call, but when the buffers are flushed (e.g. after output),
  774. the output is sent to the same file.
  775. Doing an lseek will, however, work as in C, i.e. doing a lseek will change
  776. the fileposition in both files.
  777. The function returns \var{False} in case of an error, \var{True} if
  778. successful.
  779. \Errors
  780. In case of errors, \var{Linuxerror} is used to report errors.
  781. \begin{description}
  782. \item[sys\_ebadf] \var{OldFile} hasn't been assigned.
  783. \item[sys\_emfile] Maximum number of open files for the process is reached.
  784. \end{description}
  785. \SeeAlso
  786. \seef{Dup2}, \seem{Dup}{2}
  787. \end{function}
  788. \FPCexample{ex31}
  789. \begin{function}{Dup2}
  790. \Declaration
  791. Function Dup2(oldfile,newfile:longint):Boolean;
  792. Function Dup2(var oldfile,newfile:text):Boolean;
  793. Function Dup2(var oldfile,newfile:file):Boolean;
  794. \Description
  795. Makes \var{NewFile} an exact copy of \var{OldFile}, after having flushed the
  796. buffer of \var{OldFile} in the case of text or untyped files.
  797. \var{NewFile} can be an assigned file. If \var{newfile} was open, it is
  798. closed first. Due to the buffering mechanism of Pascal, this has not
  799. the same functionality as the \seem{dup2}{2} call in C. The internal Pascal
  800. buffers are not the same after this call, but when the buffers are flushed
  801. (e.g. after output), the output is sent to the same file.
  802. Doing an lseek will, however, work as in C, i.e. doing a lseek will change the
  803. fileposition in both files.
  804. The function returns \var{True} if succesful, false otherwise.
  805. \Errors
  806. In case of error, \var{Linuxerror} is used to report errors.
  807. \begin{description}
  808. \item[sys\_ebadf] \var{OldFile} hasn't been assigned.
  809. \item[sys\_emfile] Maximum number of open files for the process is reached.
  810. \end{description}
  811. \SeeAlso
  812. \seef{Dup}, \seem{Dup2}{2}
  813. \end{function}
  814. \FPCexample{ex32}
  815. \begin{procedure}{EpochToLocal}
  816. \Declaration
  817. Procedure EpochToLocal (Epoch : Longint; var Year,Month,Day,Hour,Minute,Second : Word);
  818. \Description
  819. Converts the epoch time (=Number of seconds since 00:00:00 , January 1,
  820. 1970, corrected for your time zone ) to local date and time.
  821. This function takes into account the timzeone settings of your system.
  822. \Errors
  823. None
  824. \SeeAlso
  825. \seef{GetEpochTime}, \seef{LocalToEpoch}, \seep{GetTime},\seep{GetDate}
  826. \end{procedure}
  827. \FPCexample{ex3}
  828. \begin{procedure}{Execl}
  829. \Declaration
  830. Procedure Execl (Path : pathstr);
  831. \Description
  832. Replaces the currently running program with the program, specified in
  833. \var{path}. Path is split into a command and it's options.
  834. The executable in \var{path} is NOT searched in the path.
  835. The current environment is passed to the program.
  836. On success, \var{execl} does not return.
  837. \Errors
  838. Errors are reported in \var{LinuxError}:
  839. \begin{description}
  840. \item[sys\_eacces] File is not a regular file, or has no execute permission.
  841. A compononent of the path has no search permission.
  842. \item[sys\_eperm] The file system is mounted \textit{noexec}.
  843. \item[sys\_e2big] Argument list too big.
  844. \item[sys\_enoexec] The magic number in the file is incorrect.
  845. \item[sys\_enoent] The file does not exist.
  846. \item[sys\_enomem] Not enough memory for kernel, or to split command line.
  847. \item[sys\_enotdir] A component of the path is not a directory.
  848. \item[sys\_eloop] The path contains a circular reference (via symlinks).
  849. \end{description}
  850. \SeeAlso
  851. \seep{Execve}, \seep{Execv}, \seep{Execvp}, \seep{Execle},
  852. \seep{Execlp}, \seef {Fork}, \seem{execvp}{3}
  853. \end{procedure}
  854. \FPCexample{ex10}
  855. \begin{procedure}{Execle}
  856. \Declaration
  857. Procedure Execle (Path : pathstr, Ep : ppchar);
  858. \Description
  859. Replaces the currently running program with the program, specified in
  860. \var{path}. Path is split into a command and it's options.
  861. The executable in \var{path} is searched in the path, if it isn't
  862. an absolute filename.
  863. The environment in \var{ep} is passed to the program.
  864. On success, \var{execle} does not return.
  865. \Errors
  866. Errors are reported in \var{LinuxError}:
  867. \begin{description}
  868. \item[sys\_eacces] File is not a regular file, or has no execute permission.
  869. A compononent of the path has no search permission.
  870. \item[sys\_eperm] The file system is mounted \textit{noexec}.
  871. \item[sys\_e2big] Argument list too big.
  872. \item[sys\_enoexec] The magic number in the file is incorrect.
  873. \item[sys\_enoent] The file does not exist.
  874. \item[sys\_enomem] Not enough memory for kernel, or to split command line.
  875. \item[sys\_enotdir] A component of the path is not a directory.
  876. \item[sys\_eloop] The path contains a circular reference (via symlinks).
  877. \end{description}
  878. \SeeAlso
  879. \seep{Execve}, \seep{Execv}, \seep{Execvp},
  880. \seep{Execl}, \seep{Execlp}, \seef {Fork}, \seem{execvp}{3}
  881. \end{procedure}
  882. \FPCexample{ex11}
  883. \begin{procedure}{Execlp}
  884. \Declaration
  885. Procedure Execlp (Path : pathstr);
  886. \Description
  887. Replaces the currently running program with the program, specified in
  888. \var{path}. Path is split into a command and it's options.
  889. The executable in \var{path} is searched in the path, if it isn't
  890. an absolute filename.
  891. The current environment is passed to the program.
  892. On success, \var{execlp} does not return.
  893. \Errors
  894. Errors are reported in \var{LinuxError}:
  895. \begin{description}
  896. \item[sys\_eacces] File is not a regular file, or has no execute permission.
  897. A compononent of the path has no search permission.
  898. \item[sys\_eperm] The file system is mounted \textit{noexec}.
  899. \item[sys\_e2big] Argument list too big.
  900. \item[sys\_enoexec] The magic number in the file is incorrect.
  901. \item[sys\_enoent] The file does not exist.
  902. \item[sys\_enomem] Not enough memory for kernel, or to split command line.
  903. \item[sys\_enotdir] A component of the path is not a directory.
  904. \item[sys\_eloop] The path contains a circular reference (via symlinks).
  905. \end{description}
  906. \SeeAlso
  907. \seep{Execve}, \seep{Execv}, \seep{Execvp}, \seep{Execle},
  908. \seep{Execl}, \seef {Fork}, \seem{execvp}{3}
  909. \end{procedure}
  910. \FPCexample{ex12}
  911. \begin{procedure}{Execv}
  912. \Declaration
  913. Procedure Execv (Path : pathstr; args : ppchar);
  914. \Description
  915. Replaces the currently running program with the program, specified in
  916. \var{path}.
  917. It gives the program the options in \var{args}.
  918. This is a pointer to an array of pointers to null-terminated
  919. strings. The last pointer in this array should be nil.
  920. The current environment is passed to the program.
  921. On success, \var{execv} does not return.
  922. \Errors
  923. Errors are reported in \var{LinuxError}:
  924. \begin{description}
  925. \item[sys\_eacces] File is not a regular file, or has no execute permission.
  926. A compononent of the path has no search permission.
  927. \item[sys\_eperm] The file system is mounted \textit{noexec}.
  928. \item[sys\_e2big] Argument list too big.
  929. \item[sys\_enoexec] The magic number in the file is incorrect.
  930. \item[sys\_enoent] The file does not exist.
  931. \item[sys\_enomem] Not enough memory for kernel.
  932. \item[sys\_enotdir] A component of the path is not a directory.
  933. \item[sys\_eloop] The path contains a circular reference (via symlinks).
  934. \end{description}
  935. \SeeAlso
  936. \seep{Execve}, \seep{Execvp}, \seep{Execle},
  937. \seep{Execl}, \seep{Execlp}, \seef {Fork}, \seem{execv}{3}
  938. \end{procedure}
  939. \FPCexample{ex8}
  940. \begin{procedure}{Execve}
  941. \Declaration
  942. Procedure Execve(Path:pchar;args:ppchar;ep:ppchar);
  943. Procedure Execve (Path : pathstr; args,ep : ppchar);
  944. \Description
  945. Replaces the currently running program with the program, specified in
  946. \var{path}.
  947. It gives the program the options in \var{args}, and the environment in
  948. \var{ep}. They are pointers to an array of pointers to null-terminated
  949. strings. The last pointer in this array should be nil.
  950. On success, \var{execve} does not return.
  951. \Errors
  952. Errors are reported in \var{LinuxError}:
  953. \begin{description}
  954. \item[eacces] File is not a regular file, or has no execute permission.
  955. A compononent of the path has no search permission.
  956. \item[sys\_ eperm] The file system is mounted \textit{noexec}.
  957. \item[sys\_ e2big] Argument list too big.
  958. \item[sys\_ enoexec] The magic number in the file is incorrect.
  959. \item[sys\_ enoent] The file does not exist.
  960. \item[sys\_ enomem] Not enough memory for kernel.
  961. \item[sys\_ enotdir] A component of the path is not a directory.
  962. \item[sys\_ eloop] The path contains a circular reference (via symlinks).
  963. \end{description}
  964. \SeeAlso
  965. \seep{Execve}, \seep{Execv}, \seep{Execvp} \seep{Execle},
  966. \seep{Execl}, \seep{Execlp}, \seef {Fork}, \seem{execve}{2}
  967. \end{procedure}
  968. \FPCexample{ex7}
  969. \begin{procedure}{Execvp}
  970. \Declaration
  971. Procedure Execvp (Path : pathstr; args : ppchar);
  972. \Description
  973. Replaces the currently running program with the program, specified in
  974. \var{path}. The executable in \var{path} is searched in the path, if it isn't
  975. an absolute filename.
  976. It gives the program the options in \var{args}. This is a pointer to an array of pointers to null-terminated
  977. strings. The last pointer in this array should be nil.
  978. The current environment is passed to the program.
  979. On success, \var{execvp} does not return.
  980. \Errors
  981. Errors are reported in \var{LinuxError}:
  982. \begin{description}
  983. \item[sys\_eacces] File is not a regular file, or has no execute permission.
  984. A compononent of the path has no search permission.
  985. \item[sys\_eperm] The file system is mounted \textit{noexec}.
  986. \item[sys\_e2big] Argument list too big.
  987. \item[sys\_enoexec] The magic number in the file is incorrect.
  988. \item[sys\_enoent] The file does not exist.
  989. \item[sys\_enomem] Not enough memory for kernel.
  990. \item[sys\_enotdir] A component of the path is not a directory.
  991. \item[sys\_eloop] The path contains a circular reference (via symlinks).
  992. \end{description}
  993. \SeeAlso
  994. \seep{Execve}, \seep{Execv}, \seep{Execle},
  995. \seep{Execl}, \seep{Execlp}, \seef {Fork}, \seem{execvp}{3}
  996. \end{procedure}
  997. \FPCexample{ex9}
  998. \begin{procedurel}{FD\_ZERO}{FDZero}
  999. \Declaration
  1000. Procedure FD\_ZERO (var fds:fdSet);
  1001. \Description
  1002. \var{FD\_ZERO} clears all the filedescriptors in the file descriptor
  1003. set \var{fds}.
  1004. \Errors
  1005. None.
  1006. \SeeAlso
  1007. \seef{Select},
  1008. \seef{SelectText},
  1009. \seef{GetFS},
  1010. \seepl{FD\_Clr}{FDClr},
  1011. \seepl{FD\_Set}{FDSet},
  1012. \seefl{FD\_IsSet}{FDIsSet}
  1013. \end{procedurel}
  1014. For an example, see \seef{Select}.
  1015. \begin{procedurel}{FD\_Clr}{FDClr}
  1016. \Declaration
  1017. Procedure FD\_Clr (fd:longint;var fds:fdSet);
  1018. \Description
  1019. \var{FD\_Clr} clears file descriptor \var{fd} in filedescriptor s
  1020. et \var{fds}.
  1021. \Errors
  1022. None.
  1023. \SeeAlso
  1024. \seef{Select},
  1025. \seef{SelectText},
  1026. \seef{GetFS},
  1027. \seepl{FD\_ZERO}{FDZero},
  1028. \seepl{FD\_Set}{FDSet},
  1029. \seefl{FD\_IsSet}{FDIsSet}
  1030. \end{procedurel}
  1031. For an example, see \seef{Select}.
  1032. \begin{functionl}{FD\_IsSet}{FDIsSet}
  1033. \Declaration
  1034. Function FD\_IsSet (fd:longint;var fds:fdSet) : boolean;
  1035. \Description
  1036. \var{FD\_Set} Checks whether file descriptor \var{fd} in filedescriptor set \var{fds}
  1037. is set.
  1038. \Errors
  1039. None.
  1040. \SeeAlso
  1041. \seef{Select}, \seef{SelectText}, \seef{GetFS},
  1042. \seepl{FD\_ZERO}{FDZero},
  1043. \seepl{FD\_Clr}{FDClr},
  1044. \seepl{FD\_Set}{FDSet}
  1045. \end{functionl}
  1046. For an example, see \seef{Select}.
  1047. \begin{procedurel}{FD\_Set}{FDSet}
  1048. \Declaration
  1049. Procedure FD\_Set (fd:longint;var fds:fdSet);
  1050. \Description
  1051. \var{FD\_Set} sets file descriptor \var{fd} in filedescriptor set \var{fds}.
  1052. \Errors
  1053. None.
  1054. \SeeAlso
  1055. \seef{Select}, \seef{SelectText}, \seef{GetFS},\seepl{FD\_ZERO}{FDZero},
  1056. \seepl{FD\_Clr}{FDClr}, \seefl{FD\_IsSet}{FDIsSet}
  1057. \end{procedurel}
  1058. For an example, see \seef{Select}.
  1059. \begin{function}{fdClose}
  1060. \Declaration
  1061. Function fdClose (fd:longint) : boolean;
  1062. \Description
  1063. \var{fdClose} closes a file with file descriptor \var{Fd}. The function
  1064. returns \var{True} if the file was closed successfully, \var{False}
  1065. otherwise.
  1066. \Errors
  1067. Errors are returned in LinuxError
  1068. \SeeAlso
  1069. \seef{fdOpen}, \seef{fdRead}, \seef{fdWrite},\seef{fdTruncate},
  1070. \seef{fdFlush}, seef{FdSeek}
  1071. \end{function}
  1072. For an example, see \seef{fdOpen}.
  1073. \begin{function}{fdFlush}
  1074. \Declaration
  1075. Function fdFlush (fd:Longint) : boolean;
  1076. \Description
  1077. \var{fdflush} flushes the Linux kernel file buffer, so the file is actually
  1078. written to disk. This is NOT the same as the internal buffer, maintained by
  1079. Free Pascal.
  1080. The function returns \var{True} if the call was successful, \var{false} if
  1081. an error occurred.
  1082. \Errors
  1083. Errors are returned in LinuxError.
  1084. \SeeAlso
  1085. \seef{fdOpen}, \seef{fdClose}, \seef{fdRead},\seef{fdWrite},
  1086. \seef{fdTruncate}, \seef{fdSeek}
  1087. \end{function}
  1088. For an example, see \seef{fdRead}.
  1089. \begin{function}{fdOpen}
  1090. \Declaration
  1091. Function fdOpen(PathName:String;flags:longint):longint;
  1092. Function fdOpen(PathName:Pchar ;flags:longint):longint;
  1093. Function fdOpen(PathName:String;flags,mode:longint):longint;
  1094. Function fdOpen(PathName:Pchar ;flags,mode:longint):longint;
  1095. \Description
  1096. \var{fdOpen} opens a file in \var{PathName} with flags \var{flags}
  1097. One of the following:
  1098. \begin{description}
  1099. \item [Open\_RdOnly] File is opened Read-only.
  1100. \item [Open\_WrOnly] File is opened Write-only.
  1101. \item [Open\_RdWr] File is opened Read-Write.
  1102. \end{description}
  1103. The flags may be\var{OR}-ed with one of the following constants:
  1104. \begin{description}
  1105. \item [Open\_Accmode] File is opened
  1106. \item [Open\_Creat] File is created if it doesn't exist.
  1107. \item [Open\_Excl] If the file is opened with \var{Open\_Creat} and it
  1108. already exists, the call wil fail.
  1109. \item [Open\_NoCtty] If the file is a terminal device, it will NOT become
  1110. the process' controlling terminal.
  1111. \item [Open\_Trunc] If the file exists, it will be truncated.
  1112. \item [Open\_Append] the file is opened in append mode. {\em Before each
  1113. write}, the file pointer is positioned at the end of the file.
  1114. \item [Open\_NonBlock] The file is opened in non-blocking mode. No operation
  1115. on the file descriptor will cause the calling process to wait till.
  1116. \item [Open\_NDelay] Idem as \var{Open\_NonBlock}
  1117. \item [Open\_Sync] The file is opened for synchronous IO. Any write
  1118. operation on the file will not return untill the data is physically written
  1119. to disk.
  1120. \item [Open\_NoFollow] if the file is a symbolic link, the open fails.
  1121. (\linux 2.1.126 and higher only)
  1122. \item [Open\_Directory] if the file is not a directory, the open fails.
  1123. (\linux 2.1.126 and higher only)
  1124. \end{description}
  1125. \var{PathName} can be of type \var{PChar} or \var{String}.
  1126. The optional \var{mode} argument specifies the permissions to set when opening
  1127. the file. This is modified by the umask setting. The real permissions are
  1128. \var{Mode and not umask}.
  1129. The return value of the function is the filedescriptor, or a negative
  1130. value if there was an error.
  1131. \Errors
  1132. Errors are returned in LinuxError
  1133. \SeeAlso
  1134. \seef{fdClose}, \seef{fdRead}, \seef{fdWrite},\seef{fdTruncate},
  1135. \seef{fdFlush}, \seef{fdSeek}
  1136. \end{function}
  1137. \FPCexample{ex19}
  1138. \begin{function}{fdRead}
  1139. \Declaration
  1140. Function fdRead (fd:longint;var buf;size:longint) : longint;
  1141. \Description
  1142. \var{fdRead} reads at most \var{size} bytes from the file descriptor
  1143. \var{fd}, and stores them in \var{buf}.
  1144. The function returns the number of bytes actually read, or -1 if
  1145. an error occurred.
  1146. No checking on the length of \var{buf} is done.
  1147. \Errors
  1148. Errors are returned in LinuxError.
  1149. \SeeAlso
  1150. \seef{fdOpen}, \seef{fdClose}, \seef{fdWrite},\seef{fdTruncate},
  1151. \seef{fdFlush}, \seef{fdSeek}
  1152. \end{function}
  1153. \FPCexample{ex20}
  1154. \begin{function}{fdSeek}
  1155. \Declaration
  1156. Function fdSeek (fd,Pos,SeekType:longint) : longint;
  1157. \Description
  1158. \var{fdSeek} sets the current fileposition of file \var{fd} to
  1159. \var{Pos}, starting from \var{SeekType}, which can be one of the following:
  1160. \begin{description}
  1161. \item [Seek\_Set] \ \var{Pos} is the absolute position in the file.
  1162. \item [Seek\_Cur] \ \var{Pos} is relative to the current position.
  1163. \item [Seek\_end] \ \var{Pos} is relative to the end of the file.
  1164. \end{description}
  1165. The function returns the new fileposition, or -1 of an error occurred.
  1166. \Errors
  1167. Errors are returned in LinuxError.
  1168. \SeeAlso
  1169. \seef{fdOpen}, \seef{fdWrite}, \seef{fdClose},
  1170. \seef{fdRead},\seef{fdTruncate},
  1171. \seef{fdFlush}
  1172. \end{function}
  1173. For an example, see \seef{fdOpen}.
  1174. \begin{function}{fdTruncate}
  1175. \Declaration
  1176. Function fdTruncate (fd,size:longint) : boolean;
  1177. \Description
  1178. \var{fdTruncate} sets the length of a file in \var{fd} on \var{size}
  1179. bytes, where \var{size} must be less than or equal to the current length of
  1180. the file in \var{fd}.
  1181. The function returns \var{True} if the call was successful, \var{false} if
  1182. an error occurred.
  1183. \Errors
  1184. Errors are returned in LinuxError.
  1185. \SeeAlso
  1186. \seef{fdOpen}, \seef{fdClose}, \seef{fdRead},\seef{fdWrite},\seef{fdFlush},
  1187. \seef{fdSeek}
  1188. \end{function}
  1189. \begin{function}{fdWrite}
  1190. \Declaration
  1191. Function fdWrite (fd:longint;var buf;size:longint) : longint;
  1192. \Description
  1193. \var{fdWrite} writes at most \var{size} bytes from \var{buf} to
  1194. file descriptor \var{fd}.
  1195. The function returns the number of bytes actually written, or -1 if an error
  1196. occurred.
  1197. \Errors
  1198. Errors are returned in LinuxError.
  1199. \SeeAlso
  1200. \seef{fdOpen}, \seef{fdClose}, \seef{fdRead},\seef{fdTruncate},
  1201. \seef{fdSeek}, \seef{fdFlush}
  1202. \end{function}
  1203. \begin{function}{FExpand}
  1204. \Declaration
  1205. Function FExpand (Const Path: Pathstr) : pathstr;
  1206. \Description
  1207. Expands \var {Path} to a full path, starting from root,
  1208. eliminating directory references such as . and .. from the result.
  1209. \Errors
  1210. None
  1211. \SeeAlso
  1212. \seef{BaseName},\seef{DirName}
  1213. \end{function}
  1214. \FPCexample{ex45}
  1215. \begin{function}{FLock}
  1216. \Declaration
  1217. Function Flock (fd,mode : longint) : boolean;
  1218. Function Flock (var T : text;mode : longint) : boolean;
  1219. Function Flock (var F : File;mode : longint) : boolean;
  1220. \Description
  1221. \var{FLock} implements file locking. it sets or removes a lock on the file
  1222. \var{F}. F can be of type \var{Text} or \var{File}, or it can be a \linux
  1223. filedescriptor (a longint)
  1224. \var{Mode} can be one of the following constants :
  1225. \begin{description}
  1226. \item [LOCK\_SH] \ sets a shared lock.
  1227. \item [LOCK\_EX] \ sets an exclusive lock.
  1228. \item [LOCK\_UN] \ unlocks the file.
  1229. \item [LOCK\_NB] \ This can be OR-ed together with the other.
  1230. If this is done the application doesn't block when locking.
  1231. \end{description}
  1232. The function returns \var{True} if successful, \var{False} otherwise.
  1233. \Errors
  1234. If an error occurs, it is reported in \var{LinuxError}.
  1235. \SeeAlso
  1236. \seef{Fcntl}, \seem{flock}{2}
  1237. \end{function}
  1238. \begin{function}{FNMatch}
  1239. \Declaration
  1240. Function FNMatch(const Pattern,Name:string):Boolean;
  1241. \Description
  1242. \var{FNMatch} returns \var{True} if the filename in \var{Name}
  1243. matches the wildcard pattern in \var{Pattern}, \var{False} otherwise.
  1244. \var{Pattern} can contain the wildcards \var{*} (match zero or more
  1245. arbitrary characters) or \var{?} (match a single character).
  1246. \Errors
  1247. None.
  1248. \SeeAlso
  1249. \seef{FSearch}, \seef{FExpand}
  1250. \end{function}
  1251. \FPCexample{ex69}
  1252. \begin{function}{FSearch}
  1253. \Declaration
  1254. Function FSearch (Path : pathstr;DirList : string) : Pathstr;
  1255. \Description
  1256. Searches in \var{DirList}, a colon separated list of directories,
  1257. for a file named \var{Path}. It then returns a path to the found file.
  1258. \Errors
  1259. An empty string if no such file was found.
  1260. \SeeAlso
  1261. \seef{BaseName}, \seef{DirName}, \seef{FExpand}, \seef{FNMatch}
  1262. \end{function}
  1263. \FPCexample{ex46}
  1264. \begin{procedurel}{FSplit}{LFsplit}
  1265. \Declaration
  1266. Procedure FSplit(const Path:PathStr; \\
  1267. Var Dir:DirStr;Var Name:NameStr;Var Ext:ExtStr);
  1268. \Description
  1269. \var{FSplit} splits a full file name into 3 parts : A \var{Path}, a
  1270. \var{Name} and an extension (in \var{ext}).
  1271. The extension is taken to be all letters after the last dot (.).
  1272. \Errors
  1273. None.
  1274. \SeeAlso
  1275. \seef{FSearch}
  1276. \end{procedurel}
  1277. \FPCexample{ex67}
  1278. \begin{function}{FSStat}
  1279. \Declaration
  1280. Function FSStat (Path : Pathstr; Var Info : statfs) : Boolean;
  1281. Function FSStat (Fd:longint;Var Info:stat) : Boolean;
  1282. \Description
  1283. Return in \var{Info} information about the filesystem on which the file
  1284. \var{Path} resides, or on which the file with file descriptor \var{fd}
  1285. resides.
  1286. Info is of type \var{statfs}. The function returns \var{True} if the call
  1287. was succesfull, \var{False} if the call failed.
  1288. \Errors
  1289. \var{LinuxError} is used to report errors.
  1290. \begin{description}
  1291. \item[sys\_enotdir] A component of \var{Path} is not a directory.
  1292. \item[sys\_einval] Invalid character in \var{Path}.
  1293. \item[sys\_enoent] \var{Path} does not exist.
  1294. \item[sys\_eaccess] Search permission is denied for component in
  1295. \var{Path}.
  1296. \item[sys\_eloop] A circular symbolic link was encountered in \var{Path}.
  1297. \item[sys\_eio] An error occurred while reading from the filesystem.
  1298. \end{description}
  1299. \SeeAlso
  1300. \seef{FStat}, \seef{LStat}, \seem{statfs}{2}
  1301. \end{function}
  1302. \FPCexample{ex30}
  1303. \begin{function}{FStat}
  1304. \Declaration
  1305. Function FStat(Path:Pathstr;Var Info:stat):Boolean;
  1306. Function FStat(Fd:longint;Var Info:stat):Boolean;
  1307. Function FStat(var F:Text;Var Info:stat):Boolean;
  1308. Function FStat(var F:File;Var Info:stat):Boolean;
  1309. \Description
  1310. \var{FStat} gets information about the file specified in one of the
  1311. following:
  1312. \begin{description}
  1313. \item [Path] a file on the filesystem.
  1314. \item [Fd] a valid file descriptor.
  1315. \item [F] an opened text file or untyped file.
  1316. \end{description}
  1317. and stores it in \var{Info}, which is of type \var{stat}.
  1318. The function returns \var{True} if the call was succesfull,
  1319. \var{False} if the call failed.
  1320. \Errors
  1321. \var{LinuxError} is used to report errors.
  1322. \begin{description}
  1323. \item[sys\_enoent] \var{Path} does not exist.
  1324. \end{description}
  1325. \SeeAlso
  1326. \seef{FSStat}, \seef{LStat}, \seem{stat}{2}
  1327. \end{function}
  1328. \FPCexample{ex28}
  1329. \begin{function}{Fcntl}
  1330. \Declaration
  1331. Function Fcntl(Fd:longint;Cmd:Integer):integer;
  1332. Function Fcntl(var Fd:Text;Cmd:Integer):integer;
  1333. \Description
  1334. Read a file's attributes. \var{Fd} is an assigned file, or a valid file
  1335. descriptor.
  1336. \var{Cmd} speciefies what to do, and is one of the following:
  1337. \begin{description}
  1338. \item[F\_GetFd] Read the close\_on\_exec flag. If the low-order bit is 0, then
  1339. the file will remain open across execve calls.
  1340. \item[F\_GetFl] Read the descriptor's flags.
  1341. \item[F\_GetOwn] Get the Process ID of the owner of a socket.
  1342. \end{description}
  1343. \Errors
  1344. \var{LinuxError} is used to report errors.
  1345. \begin{description}
  1346. \item[sys\_ebadf] \var{Fd} has a bad file descriptor.
  1347. \end{description}
  1348. \SeeAlso
  1349. \seep{Fcntl}, \seem{Fcntl}{2}
  1350. \end{function}
  1351. \begin{procedure}{Fcntl}
  1352. \Declaration
  1353. Procedure Fcntl (Fd : text, Cmd : Integer; Arg : longint);
  1354. Procedure Fcntl (Fd:longint;Cmd:longint;Arg:Longint);
  1355. \Description
  1356. Read or Set a file's attributes. \var{Fd} is an assigned file or a
  1357. valid file descriptor.
  1358. \var{Cmd} speciefies what to do, and is one of the following:
  1359. \begin{description}
  1360. \item[F\_SetFd] Set the close\_on\_exec flag of \var{Fd}. (only the least
  1361. siginificant bit is used).
  1362. \item[F\_GetLk] Return the \var{flock} record that prevents this process from
  1363. obtaining the lock, or set the \var{l\_type} field of the lock of there is no
  1364. obstruction. Arg is a pointer to a flock record.
  1365. \item[F\_SetLk] Set the lock or clear it (depending on \var{l\_type} in the
  1366. \var{flock} structure). if the lock is held by another process, an error
  1367. occurs.
  1368. \item[F\_GetLkw] Same as for \textbf{F\_Setlk}, but wait until the lock is
  1369. released.
  1370. \item[F\_SetOwn] Set the Process or process group that owns a socket.
  1371. \end{description}
  1372. \Errors
  1373. \var{LinuxError} is used to report errors.
  1374. \begin{description}
  1375. \item[sys\_ebadf] \var{Fd} has a bad file descriptor.
  1376. \item[sys\_eagain or sys\_eaccess] For \textbf{F\_SetLk}, if the lock is
  1377. held by another process.
  1378. \end{description}
  1379. \SeeAlso
  1380. \seef{Fcntl}, \seem{Fcntl}{2}, seef{FLock}
  1381. \end{procedure}
  1382. \begin{function}{Fork}
  1383. \Declaration
  1384. Function Fork : Longint;
  1385. \Description
  1386. Fork creates a child process which is a copy of the parent process.
  1387. Fork returns the process ID in the parent process, and zero in the child's
  1388. process. (you can get the parent's PID with \seef{GetPPid}).
  1389. \Errors
  1390. On error, -1 is returned to the parent, and no child is created.
  1391. \begin{description}
  1392. \item [sys\_eagain] Not enough memory to create child process.
  1393. \end{description}
  1394. \SeeAlso
  1395. \seep{Execve}, \seef{Clone}, \seem{fork}{2}
  1396. \end{function}
  1397. \begin{function}{FRename}
  1398. \Declaration
  1399. Function FReName (OldName,NewName : Pchar) : Boolean;
  1400. Function FReName (OldName,NewName : String) : Boolean;
  1401. \Description
  1402. \var{FRename} renames the file \var{OldName} to \var{NewName}. \var{NewName}
  1403. can be in a different directory than \var{OldName}, but it cannot be on
  1404. another partition (device). Any existing file on the new location will be replaced.
  1405. If the operation fails, then the \var{OldName} file will be preserved.
  1406. The function returns \var{True} on succes, \var{False} on failure.
  1407. \Errors
  1408. On error, errors are reported in \var{LinuxError}. Possible errors include:
  1409. \begin{description}
  1410. \item[sys\_eisdir] \var{NewName} exists and is a directory, but \var{OldName}
  1411. is not a directory.
  1412. \item[sys\_exdev] \var{NewName} and \var{OldName} are on different devices.
  1413. \item[sys\_enotempty or sys\_eexist] \var{NewName} is an existing, non-empty
  1414. directory.
  1415. \item[sys\_ebusy] \var{OldName} or \var{NewName} is a directory and is in
  1416. use by another process.
  1417. \item[sys\_einval] \var{NewName} is part of \var{OldName}.
  1418. \item[sys\_emlink] \var{OldPath} or \var{NewPath} already have tha maximum
  1419. amount of links pointing to them.
  1420. \item[sys\_enotdir] part of \var{OldName} or \var{NewName} is not
  1421. directory.
  1422. \item[sys\_efault] For the \var{pchar} case: One of the pointers points to
  1423. an invalid address.
  1424. \item[sys\_eaccess] access is denied when attempting to move the file.
  1425. \item[sys\_enametoolong] Either \var{OldName} or \var{NewName} is too long.
  1426. \item[sys\_enoent] a directory component in \var{OldName} or \var{NewName}
  1427. didn't exist.
  1428. \item[sys\_enomem] not enough kernel memory.
  1429. \item[sys\_erofs] \var{NewName} or \var{OldName} is on a read-only file
  1430. system.
  1431. \item[sys\_eloop] too many symbolic links were encountered trying to expand
  1432. \var{OldName} or \var{NewName}
  1433. \item[sys\_enospc] the filesystem has no room for the new directory entry.
  1434. \end{description}
  1435. \SeeAlso
  1436. \seef{UnLink}
  1437. \end{function}
  1438. \begin{procedure}{GetDate}
  1439. \Declaration
  1440. Procedure GetDate (Var Year, Month, Day : Word) ;
  1441. \Description
  1442. Returns the current date.
  1443. \Errors
  1444. None
  1445. \SeeAlso
  1446. \seef{GetEpochTime}, \seep{GetTime}, \seep{GetDateTime}, \seep{EpochToLocal}
  1447. \end{procedure}
  1448. \FPCexample{ex6}
  1449. \begin{procedure}{GetDateTime}
  1450. \Declaration
  1451. Procedure GetDateTime(Var Year,Month,Day,hour,minute,second:Word);
  1452. \Description
  1453. Returns the current date and time. The time is corrected for the local time
  1454. zone. This procedure is equivalent to the \seep{GetDate} and \var{GetTime}
  1455. calls.
  1456. \Errors
  1457. None
  1458. \SeeAlso
  1459. \seef{GetEpochTime}, \seep{GetTime}, \seep{EpochToLocal}, \seep{GetDate}
  1460. \end{procedure}
  1461. \FPCexample{ex60}
  1462. \begin{function}{GetDomainName}
  1463. \Declaration
  1464. Function GetDomainName : String;
  1465. \Description
  1466. Get the domain name of the machine on which the process is running.
  1467. An empty string is returned if the domain is not set.
  1468. \Errors
  1469. None.
  1470. \SeeAlso
  1471. \seef{GetHostName},seem{Getdomainname}{2}
  1472. \end{function}
  1473. \FPCexample{ex39}
  1474. \begin{function}{GetEGid}
  1475. \Declaration
  1476. Function GetEGid : Longint;
  1477. \Description
  1478. Get the effective group ID of the currently running process.
  1479. \Errors
  1480. None.
  1481. \SeeAlso
  1482. \seef{GetGid}, \seem{getegid}{2}
  1483. \end{function}
  1484. \FPCexample{ex18}
  1485. \begin{function}{GetEUid}
  1486. \Declaration
  1487. Function GetEUid : Longint;
  1488. \Description
  1489. Get the effective user ID of the currently running process.
  1490. \Errors
  1491. None.
  1492. \SeeAlso
  1493. \seef{GetEUid}, \seem{geteuid}{2}
  1494. \end{function}
  1495. \FPCexample{ex17}
  1496. \begin{function}{GetEnv}
  1497. \Declaration
  1498. Function GetEnv (P : String) : PChar;
  1499. \Description
  1500. Returns the value of the environment variable in \var{P}. If the variable is
  1501. not defined, nil is returned. The value of the environment variable may be
  1502. the empty string.
  1503. A PChar is returned to accomodate for strings longer than 255 bytes,
  1504. \var{TERMCAP} and \var{LS\_COLORS}, for instance.
  1505. \Errors
  1506. None.
  1507. \SeeAlso
  1508. \seem{sh}{1}, \seem{csh}{1}
  1509. \end{function}
  1510. \FPCexample{ex41}
  1511. \begin{function}{GetEpochTime}
  1512. \Declaration
  1513. Function GetEpochTime : longint;
  1514. \Description
  1515. returns the number of seconds since 00:00:00 gmt, january 1, 1970.
  1516. it is adjusted to the local time zone, but not to DST.
  1517. \Errors
  1518. no errors
  1519. \SeeAlso
  1520. \seep{EpochToLocal}, \seep{GetTime}, \seem{time}{2}
  1521. \end{function}
  1522. \FPCexample{ex1}
  1523. \begin{function}{GetFS}
  1524. \Declaration
  1525. Function GetFS (Var F : Any File Type) : Longint;
  1526. \Description
  1527. \var{GetFS} returns the file selector that the kernel provided for your
  1528. file. In principle you don' need this file selector. Only for some calls
  1529. it is needed, such as the \seef{Select} call or so.
  1530. \Errors
  1531. In case the file was not opened, then -1 is returned.
  1532. \SeeAlso
  1533. \seef{Select}
  1534. \end{function}
  1535. \FPCexample{ex34}
  1536. \begin{function}{GetGid}
  1537. \Declaration
  1538. Function GetGid : Longint;
  1539. \Description
  1540. Get the real group ID of the currently running process.
  1541. \Errors
  1542. None.
  1543. \SeeAlso
  1544. \seef{GetEGid}, \seem{getgid}{2}
  1545. \end{function}
  1546. \FPCexample{ex18}
  1547. \begin{function}{GetHostName}
  1548. \Declaration
  1549. Function GetHostName : String;
  1550. \Description
  1551. Get the hostname of the machine on which the process is running.
  1552. An empty string is returned if hostname is not set.
  1553. \Errors
  1554. None.
  1555. \SeeAlso
  1556. \seef{GetDomainName},seem{Gethostname}{2}
  1557. \end{function}
  1558. \FPCexample{ex40}
  1559. \begin{procedure}{GetLocalTimezone}
  1560. \Declaration
  1561. procedure GetLocalTimezone(timer:longint;var leap\_correct,leap\_hit:longint);
  1562. procedure GetLocalTimezone(timer:longint);
  1563. \Description
  1564. \var{GetLocalTimeZone} returns the local timezone information. It also
  1565. initializes the \var{TZSeconds} variable, which is used to correct the epoch time
  1566. to local time.
  1567. There should never be any need to call this function directly. It is called by the
  1568. initialization routines of the Linux unit.
  1569. \SeeAlso
  1570. \seef{GetTimezoneFile}, \seep{ReadTimezoneFile}
  1571. \end{procedure}
  1572. \begin{function}{GetPid}
  1573. \Declaration
  1574. Function GetPid : Longint;
  1575. \Description
  1576. Get the Process ID of the currently running process.
  1577. \Errors
  1578. None.
  1579. \SeeAlso
  1580. \seef{GetPPid}, \seem{getpid}{2}
  1581. \end{function}
  1582. \FPCexample{ex16}
  1583. \begin{function}{GetPPid}
  1584. \Declaration
  1585. Function GetPPid : Longint;
  1586. \Description
  1587. Get the Process ID of the parent process.
  1588. \Errors
  1589. None.
  1590. \SeeAlso
  1591. \seef{GetPid}, \seem{getppid}{2}
  1592. \end{function}
  1593. \FPCexample{ex16}
  1594. \begin{function}{GetPriority}
  1595. \Declaration
  1596. Function GetPriority (Which,Who : Integer) : Integer;
  1597. \Description
  1598. GetPriority returns the priority with which a process is running.
  1599. Which process(es) is determined by the \var{Which} and \var{Who} variables.
  1600. \var{Which} can be one of the pre-defined \var{Prio\_Process, Prio\_PGrp,
  1601. Prio\_User}, in which case \var{Who} is the process ID, Process group ID or
  1602. User ID, respectively.
  1603. \Errors
  1604. Error checking must be done on LinuxError, since a priority can be negative.
  1605. \begin{description}
  1606. \item[sys\_esrch] No process found using \var{which} and \var{who}.
  1607. \item[sys\_einval] \var{Which} was not one of \var{Prio\_Process, Prio\_Grp
  1608. or Prio\_User}.
  1609. \end{description}
  1610. \SeeAlso
  1611. \seef{SetPriority}, \seep{Nice}, \seem{Getpriority}{2}
  1612. \end{function}
  1613. For an example, see \seep{Nice}.
  1614. \begin{procedure}{GetTime}
  1615. \Declaration
  1616. procedure GetTime(var hour,min,sec,msec,usec:word);
  1617. procedure GetTime(var hour,min,sec,sec100:word);
  1618. procedure GetTime(var hour,min,sec:word);
  1619. \Description
  1620. Returns the current time of the day, adjusted to local time.
  1621. Upon return, the parameters are filled with
  1622. \begin{description}
  1623. \item[hour] Hours since 00:00 today.
  1624. \item[min] minutes in current hour.
  1625. \item[sec] seconds in current minute.
  1626. \item[sec100] hundreds of seconds in current second.
  1627. \item[msec] milliseconds in current second.
  1628. \item[usec] microseconds in current second.
  1629. \end{description}
  1630. \Errors
  1631. None
  1632. \SeeAlso
  1633. \seef{GetEpochTime}, \seep{GetDate}, \seep{GetDateTime}, \seep{EpochToLocal}
  1634. \end{procedure}
  1635. \FPCexample{ex5}
  1636. \begin{procedure}{GetTimeOfDay}
  1637. \Declaration
  1638. Procedure GetTimeOfDay(var tv:timeval);
  1639. \Description
  1640. \var{GetTimeOfDay} returns the number of seconds since 00:00, January 1
  1641. 1970, GMT in a \var{timeval} record. This time NOT corrected any way,
  1642. not taking into account timezones, daylight savings time and so on.
  1643. It is simply a wrapper to the kernel system call. To get the local time,
  1644. \seep{GetTime}.
  1645. \Errors
  1646. None.
  1647. \SeeAlso
  1648. \seep{GetTime}, \seef{GetTimeOfDay}
  1649. \end{procedure}
  1650. \begin{function}{GetTimeOfDay}
  1651. \Declaration
  1652. Function GetTimeOfDay:longint;
  1653. \Description
  1654. \var{GetTimeOfDay} returns the number of seconds since 00:00, January 1
  1655. 1970, GMT. This time NOT corrected any way, not taking into account
  1656. timezones, daylight savings time and so on.
  1657. It is simply a wrapper to the kernel system call. To get the local time,
  1658. \seep{GetTime}.
  1659. \Errors
  1660. None.
  1661. \SeeAlso
  1662. \seep{GetTimeOfDay}, \seep{GetTime}
  1663. \end{function}
  1664. \begin{function}{GetTimezoneFile}
  1665. \Declaration
  1666. function GetTimezoneFile:string;
  1667. \Description
  1668. \var{GetTimezoneFile} returns the location of the current timezone file.
  1669. The location of file is determined as follows:
  1670. \begin{enumerate}
  1671. \item If \file{/etc/timezone} exists, it is read, and the contents of this
  1672. file is returned. This should work on Debian systems.
  1673. \item If \file{/usr/lib/zoneinfo/localtime} exists, then it is returned.
  1674. (this file is a symlink to the timezone file on SuSE systems)
  1675. \item If \file{/etc/localtime} exists, then it is returned.
  1676. (this file is a symlink to the timezone file on RedHat systems)
  1677. \end{enumerate}
  1678. \Errors
  1679. If no file was found, an empty string is returned.
  1680. \SeeAlso
  1681. \seep{ReadTimezoneFile}
  1682. \end{function}
  1683. \begin{function}{GetUid}
  1684. \Declaration
  1685. Function GetUid : Longint;
  1686. \Description
  1687. Get the real user ID of the currently running process.
  1688. \Errors
  1689. None.
  1690. \SeeAlso
  1691. \seef{GetEUid}, \seem{getuid}{2}
  1692. \end{function}
  1693. \FPCexample{ex17}
  1694. \begin{function}{Glob}
  1695. \Declaration
  1696. Function Glob (Const Path : Pathstr) : PGlob;
  1697. \Description
  1698. Glob returns a pointer to a glob structure which contains all filenames which
  1699. exist and match the pattern in \var{Path}.
  1700. The pattern can contain wildcard characters, which have their
  1701. usual meaning.
  1702. \Errors
  1703. Returns nil on error, and \var{LinuxError} is set.
  1704. \begin{description}
  1705. \item[sys\_enomem] No memory on heap for glob structure.
  1706. \item[others] As returned by the opendir call, and sys\_readdir.
  1707. \end{description}
  1708. \SeeAlso
  1709. \seep{GlobFree}, \seem{Glob}{3}
  1710. \end{function}
  1711. \FPCexample{ex49}
  1712. \begin{procedure}{GlobFree}
  1713. \Declaration
  1714. Procedure GlobFree (Var P : Pglob);
  1715. \Description
  1716. Releases the memory, occupied by a pglob structure. \var{P} is set to nil.
  1717. \Errors
  1718. None
  1719. \SeeAlso
  1720. \seef{Glob}
  1721. \end{procedure}
  1722. For an example, see \seef{Glob}.
  1723. \begin{procedure}{IOCtl}
  1724. \Declaration
  1725. Procedure IOCtl (Handle,Ndx: Longint; Data: Pointer);
  1726. \Description
  1727. This is a general interface to the Unix/ \linux ioctl call.
  1728. It performs various operations on the filedescriptor \var{Handle}.
  1729. \var{Ndx} describes the operation to perform.
  1730. \var{Data} points to data needed for the \var{Ndx} function.
  1731. The structure of this data is function-dependent, so we don't elaborate on
  1732. this here.
  1733. For more information on this, see various manual pages under linux.
  1734. \Errors
  1735. Errors are reported in LinuxError. They are very dependent on the used
  1736. function, that's why we don't list them here
  1737. \SeeAlso
  1738. \seem{ioctl}{2}
  1739. \end{procedure}
  1740. \FPCexample{ex54}
  1741. \begin{function}{IOperm}
  1742. \Declaration
  1743. Function IOperm (From,Num : Cadinal; Value : Longint) : boolean;
  1744. \Description
  1745. \var{IOperm}
  1746. sets permissions on \var{Num} ports starting with port \var{From} to
  1747. \var{Value}. The function returns \var{True} if the call was successfull,
  1748. \var{False} otherwise.
  1749. {\em Remark:}
  1750. \begin{itemize}
  1751. \item This works ONLY as root.
  1752. \item Only the first \var{0x03ff} ports can be set.
  1753. \item When doing a \seef{Fork}, the permissions are reset. When doing a
  1754. \seep{Execve} they are kept.
  1755. \end{itemize}
  1756. \Errors
  1757. Errors are returned in \var{LinuxError}
  1758. \SeeAlso
  1759. \seem{ioperm}{2}
  1760. \end{function}
  1761. \begin{function}{IsATTY}
  1762. \Declaration
  1763. Function IsATTY (var f) : Boolean;
  1764. \Description
  1765. Check if the filehandle described by \var{f} is a terminal.
  1766. f can be of type
  1767. \begin{enumerate}
  1768. \item \var{longint} for file handles;
  1769. \item \var{Text} for \var{text} variables such as \var{input} etc.
  1770. \end{enumerate}
  1771. Returns \var{True} if \var{f} is a terminal, \var{False} otherwise.
  1772. \Errors
  1773. No errors are reported
  1774. \SeeAlso
  1775. \seep{IOCtl},\seef{TTYName}
  1776. \end{function}
  1777. \begin{functionl}{S\_ISBLK}{ISBLK}
  1778. \Declaration
  1779. Function S\_ISBLK (m:integer) : boolean;
  1780. \Description
  1781. \var{S\_ISBLK} checks the file mode \var{m} to see whether the file is a
  1782. block device file. If so it returns \var{True}.
  1783. \Errors
  1784. \seef{FStat},
  1785. \seefl{S\_ISLNK}{ISLNK},
  1786. \seefl{S\_ISREG}{ISREG},
  1787. \seefl{S\_ISDIR}{ISDIR},
  1788. \seefl{S\_ISCHR}{ISCHR},
  1789. \seefl{S\_ISFIFO}{ISFIFO},
  1790. \seefl{S\_ISSOCK}{ISSOCK}
  1791. \SeeAlso
  1792. ISLNK.
  1793. \end{functionl}
  1794. \begin{functionl}{S\_ISCHR}{ISCHR}
  1795. \Declaration
  1796. Function S\_ISCHR (m:integer) : boolean;
  1797. \Description
  1798. \var{S\_ISCHR} checks the file mode \var{m} to see whether the file is a
  1799. character device file. If so it returns \var{True}.
  1800. \Errors
  1801. \seef{FStat},
  1802. \seefl{S\_ISLNK}{ISLNK},
  1803. \seefl{S\_ISREG}{ISREG},
  1804. \seefl{S\_ISDIR}{ISDIR},
  1805. \seefl{S\_ISBLK}{ISBLK},
  1806. \seefl{S\_ISFIFO}{ISFIFO},
  1807. \seefl{S\_ISSOCK}{ISSOCK}
  1808. \SeeAlso
  1809. ISLNK.
  1810. \end{functionl}
  1811. \begin{functionl}{S\_ISDIR}{ISDIR}
  1812. \Declaration
  1813. Function S\_ISDIR (m:integer) : boolean;
  1814. \Description
  1815. \var{S\_ISDIR} checks the file mode \var{m} to see whether the file is a
  1816. directory. If so it returns \var{True}
  1817. \Errors
  1818. \seef{FStat},
  1819. \seefl{S\_ISLNK}{ISLNK},
  1820. \seefl{S\_ISREG}{ISREG},
  1821. \seefl{S\_ISCHR}{ISCHR},
  1822. \seefl{S\_ISBLK}{ISBLK},
  1823. \seefl{S\_ISFIFO}{ISFIFO},
  1824. \seefl{S\_ISSOCK}{ISSOCK}
  1825. \SeeAlso
  1826. ISLNK.
  1827. \end{functionl}
  1828. \begin{functionl}{S\_ISFIFO}{ISFIFO}
  1829. \Declaration
  1830. Function S\_ISFIFO (m:integer) : boolean;
  1831. \Description
  1832. \var{S\_ISFIFO} checks the file mode \var{m} to see whether the file is a
  1833. fifo (a named pipe). If so it returns \var{True}.
  1834. \Errors
  1835. \seef{FStat},
  1836. \seefl{S\_ISLNK}{ISLNK},
  1837. \seefl{S\_ISREG}{ISREG},
  1838. \seefl{S\_ISDIR}{ISDIR},
  1839. \seefl{S\_ISCHR}{ISCHR},
  1840. \seefl{S\_ISBLK}{ISBLK},
  1841. \seefl{S\_ISSOCK}{ISSOCK}
  1842. \SeeAlso
  1843. ISLNK.
  1844. \end{functionl}
  1845. \begin{functionl}{S\_ISLNK}{ISLNK}
  1846. \Declaration
  1847. Function S\_ISLNK (m:integer) : boolean;
  1848. \Description
  1849. \var{S\_ISLNK} checks the file mode \var{m} to see whether the file is a
  1850. symbolic link. If so it returns \var{True}
  1851. \Errors
  1852. \seef{FStat},
  1853. \seefl{S\_ISREG}{ISREG},
  1854. \seefl{S\_ISDIR}{ISDIR},
  1855. \seefl{S\_ISCHR}{ISCHR},
  1856. \seefl{S\_ISBLK}{ISBLK},
  1857. \seefl{S\_ISFIFO}{ISFIFO},
  1858. \seefl{S\_ISSOCK}{ISSOCK}
  1859. \SeeAlso
  1860. \end{functionl}
  1861. \FPCexample{ex53}
  1862. \begin{functionl}{S\_ISREG}{ISREG}
  1863. \Declaration
  1864. Function S\_ISREG (m:integer) : boolean;
  1865. \Description
  1866. \var{S\_ISREG} checks the file mode \var{m} to see whether the file is a
  1867. regular file. If so it returns \var{True}
  1868. \Errors
  1869. \seef{FStat},
  1870. \seefl{S\_ISLNK}{ISLNK},
  1871. \seefl{S\_ISDIR}{ISDIR},
  1872. \seefl{S\_ISCHR}{ISCHR},
  1873. \seefl{S\_ISBLK}{ISBLK},
  1874. \seefl{S\_ISFIFO}{ISFIFO},
  1875. \seefl{S\_ISSOCK}{ISSOCK}
  1876. \SeeAlso
  1877. ISLNK.
  1878. \end{functionl}
  1879. \begin{functionl}{S\_ISSOCK}{ISSOCK}
  1880. \Declaration
  1881. Function S\_ISSOCK (m:integer) : boolean;
  1882. \Description
  1883. \var{S\_ISSOCK} checks the file mode \var{m} to see whether the file is a
  1884. socket. If so it returns \var{True}.
  1885. \Errors
  1886. \seef{FStat},
  1887. \seefl{S\_ISLNK}{ISLNK},
  1888. \seefl{S\_ISREG}{ISREG},
  1889. \seefl{S\_ISDIR}{ISDIR},
  1890. \seefl{S\_ISCHR}{ISCHR},
  1891. \seefl{S\_ISBLK}{ISBLK},
  1892. \seefl{S\_ISFIFO}{ISFIFO}
  1893. \SeeAlso
  1894. ISLNK.
  1895. \end{functionl}
  1896. \begin{function}{Kill}
  1897. \Declaration
  1898. Function Kill (Pid : Longint; Sig : Integer) : Integer;
  1899. \Description
  1900. Send a signal \var{Sig} to a process or process group. If \var{Pid}>0 then
  1901. the signal is sent to \var{Pid}, if it equals -1, then the signal is sent to
  1902. all processes except process 1. If \var{Pid}<-1 then the signal is sent to
  1903. process group -Pid.
  1904. The return value is zero, except in case three, where the return value is the
  1905. number of processes to which the signal was sent.
  1906. \Errors
  1907. \var{LinuxError} is used to report errors:
  1908. \begin{description}
  1909. \item[sys\_einval] An invalid signal is sent.
  1910. \item[sys\_esrch] The \var{Pid} or process group don't exist.
  1911. \item[sys\_eperm] The effective userid of the current process doesn't math
  1912. the one of process \var{Pid}.
  1913. \end{description}
  1914. \SeeAlso
  1915. \seep{SigAction}, \seef{Signal}, \seem{Kill}{2}
  1916. \end{function}
  1917. \begin{function}{LStat}
  1918. \Declaration
  1919. Function LStat (Path : Pathstr; Var Info : stat) : Boolean;
  1920. \Description
  1921. \var{LStat} gets information about the link specified in \var{Path}, and stores it in
  1922. \var{Info}, which is of type \var{stat}. Contrary to \var{FStat}, it stores
  1923. information about the link, not about the file the link points to.
  1924. The function returns \var{True} if the call was succesfull, \var{False} if the call
  1925. failed.
  1926. \Errors
  1927. \var{LinuxError} is used to report errors.
  1928. \begin{description}
  1929. \item[sys\_enoent] \var{Path} does not exist.
  1930. \end{description}
  1931. \SeeAlso
  1932. \seef{FStat}, \seef{FSStat}, \seem{stat}{2}
  1933. \end{function}
  1934. \FPCexample{ex29}
  1935. \begin{function}{Link}
  1936. \Declaration
  1937. Function Link (OldPath,NewPath : pathstr) : Boolean;
  1938. \Description
  1939. \var{Link} makes \var{NewPath} point to the same file als \var{OldPath}. The two files
  1940. then have the same inode number. This is known as a 'hard' link.
  1941. The function returns \var{True} if the call was succesfull, \var{False} if the call
  1942. failed.
  1943. \Errors
  1944. Errors are returned in \var{LinuxError}.
  1945. \begin{description}
  1946. \item[sys\_exdev] \var {OldPath} and \var {NewPath} are not on the same
  1947. filesystem.
  1948. \item[sys\_eperm] The filesystem containing oldpath and newpath doesn't
  1949. support linking files.
  1950. \item[sys\_eaccess] Write access for the directory containing \var{Newpath}
  1951. is disallowed, or one of the directories in \var{OldPath} or {NewPath} has no
  1952. search (=execute) permission.
  1953. \item[sys\_enoent] A directory entry in \var{OldPath} or \var{NewPath} does
  1954. not exist or is a symbolic link pointing to a non-existent directory.
  1955. \item[sys\_enotdir] A directory entry in \var{OldPath} or \var{NewPath} is
  1956. nor a directory.
  1957. \item[sys\_enomem] Insufficient kernel memory.
  1958. \item[sys\_erofs] The files are on a read-only filesystem.
  1959. \item[sys\_eexist] \var{NewPath} already exists.
  1960. \item[sys\_emlink] \var{OldPath} has reached maximal link count.
  1961. \item[sys\_eloop] \var{OldPath} or \var{NewPath} has a reference to a circular
  1962. symbolic link, i.e. a symbolic link, whose expansion points to itself.
  1963. \item[sys\_enospc] The device containing \var{NewPath} has no room for anothe
  1964. entry.
  1965. \item[sys\_eperm] \var{OldPath} points to . or .. of a directory.
  1966. \end{description}
  1967. \SeeAlso
  1968. \seef{SymLink}, \seef{UnLink}, \seem{Link}{2}
  1969. \end{function}
  1970. \FPCexample{ex21}
  1971. \begin{function}{LocalToEpoch}
  1972. \Declaration
  1973. Function LocalToEpoch (Year,Month,Day,Hour,Minute,Second : Word) : longint;
  1974. \Description
  1975. Converts the Local time to epoch time (=Number of seconds since 00:00:00 , January 1,
  1976. 1970 ).
  1977. \Errors
  1978. None
  1979. \SeeAlso
  1980. \seef{GetEpochTime}, \seep{EpochToLocal}, \seep{GetTime},\seep{GetDate}
  1981. \end{function}
  1982. \FPCexample{ex4}
  1983. \begin{function}{MkFifo}
  1984. \Declaration
  1985. Function MkFifo (PathName: String; Mode : Longint) : Boolean;
  1986. \Description
  1987. \var{MkFifo} creates named a named pipe in the filesystem, with name
  1988. \var{PathName} and mode {Mode}.
  1989. \Errors
  1990. \var{LinuxError} is used to report errors:
  1991. \begin{description}
  1992. \item[sys\_emfile] Too many file descriptors for this process.
  1993. \item[sys\_enfile] The system file table is full.
  1994. \end{description}
  1995. \SeeAlso
  1996. \seep{POpen}, \seef{MkFifo}, \seem{mkfifo}{4}
  1997. \end{function}
  1998. \begin{function}{MMap}
  1999. \Declaration
  2000. Function MMap(const m:tmmapargs):longint;
  2001. \Description
  2002. \var{MMap} maps or unmaps files or devices into memory. The different fields
  2003. of the argument \var{m} determine what and how the \var{mmap} maps this:
  2004. \begin{description}
  2005. \item[address] Address where to mmap the device. This address is a hint,
  2006. and may not be followed.
  2007. \item[size] Size (in bytes) of area to be mapped.
  2008. \item[prot] Protection of mapped memory. This is a OR-ed combination of the
  2009. following constants:
  2010. \begin{description}
  2011. \item[PROT\_EXEC] The memory can be executed.
  2012. \item[PROT\_READ] The memory can be read.
  2013. \item[PROT\_WRITE] The memory can be written.
  2014. \item[PROT\_NONE] The memory can not be accessed.
  2015. \end{description}
  2016. \item[flags] Contains some options for the mmap call. It is an OR-ed
  2017. combination of the following constants:
  2018. \begin{description}
  2019. \item[MAP\_FIXED] Do not map at another address than the given address. If the
  2020. address cannot be used, \var{MMap} will fail.
  2021. \item[MAP\_SHARED] Share this map with other processes that map this object.
  2022. \item[MAP\_PRIVATE] Create a private map with copy-on-write semantics.
  2023. \item[MAP\_ANONYMOUS] \var{fd} does not have to be a file descriptor.
  2024. \end{description}
  2025. One of the options \var{MAP\_SHARED} and \var{MAP\_PRIVATE} must be present,
  2026. but not both at the same time.
  2027. \item[fd] File descriptor from which to map.
  2028. \item[offset] Offset to be used in file descriptor fd.
  2029. \end{description}
  2030. The function returns a pointer to the mapped memory, or a -1 in case of en
  2031. error.
  2032. \Errors
  2033. On error, -1 is returned and LinuxError is set to the error code:
  2034. \begin{description}
  2035. \item[Sys\_EBADF] \var{fd} is not a valid file descriptor and
  2036. \var{MAP\_ANONYMOUS} was not specified.
  2037. \item[Sys\_EACCES] \var{MAP\_PRIVATE} was specified, but fd is not open for
  2038. reading. Or \var{MAP\_SHARED} was asked and \var{PROT\_WRITE} is set, fd
  2039. is not open for writing
  2040. \item[Sys\_EINVAL] One of the record fields \var{Start}, \var{length} or
  2041. \var{offset} is invalid.
  2042. \item[Sys\_ETXTBUSY] \var{MAP\_DENYWRITE} was set but the object specified
  2043. by fd is open for writing.
  2044. \item[Sys\_EAGAIN] \var{fd} is locked, or too much memory is locked.
  2045. \item[Sys\_ENOMEM] Not enough memory for this operation.
  2046. \end{description}
  2047. \SeeAlso
  2048. \seef{MUnMap}, \seem{mmap}{2}
  2049. \end{function}
  2050. \FPCexample{ex66}
  2051. \begin{function}{MUnMap}
  2052. \Declaration
  2053. function MUnMap (P : Pointer; Size : Longint) : Boolean;
  2054. \Description
  2055. \var{MUnMap} unmaps the memory block of size \var{Size}, pointed to by
  2056. \var{P}, which was previously allocated with \seef{MMap}.
  2057. The function returns \var{True} if successful, \var{False} otherwise.
  2058. \Errors
  2059. In case of error the function returns \var{False} and \var{LinuxError}
  2060. is set to an error value. See \seef{MMap} for possible error values.
  2061. \SeeAlso
  2062. \seef{MMap}, \seem{munmap}{2}
  2063. \end{function}
  2064. For an example, see \seef{MMap}.
  2065. \begin{procedure}{Nice}
  2066. \Declaration
  2067. Procedure Nice ( N : Integer);
  2068. \Description
  2069. Nice adds \var{-N} to the priority of the running process. The lower the
  2070. priority numerically, the less the process is favored.
  2071. Only the superuser can specify a negative \var{N}, i.e. increase the rate at
  2072. which the process is run.
  2073. \Errors
  2074. Errors are returned in \var{LinuxError}
  2075. \begin{description}
  2076. \item [sys\_eperm] A non-superuser tried to specify a negative \var{N}, i.e.
  2077. do a priority increase.
  2078. \end{description}
  2079. \SeeAlso
  2080. \seef{GetPriority}, \seef{SetPriority}, \seem{Nice}{2}
  2081. \end{procedure}
  2082. \FPCexample{ex15}
  2083. \begin{function}{Octal}
  2084. \Declaration
  2085. Function Octal(l:longint):longint;
  2086. \Description
  2087. \var{Octal} will convert a number specified as an octal number to it's
  2088. decimal value.
  2089. This is useful for the \seef{Chmod} call, where permissions are specified
  2090. as octal numbers.
  2091. \Errors
  2092. No checking is performed whether the given number is a correct Octal number.
  2093. e.g. specifying \var{998} is possible; the result will be wrong in that
  2094. case.
  2095. \SeeAlso
  2096. \seef{Chmod}.
  2097. \end{function}
  2098. \FPCexample{ex68}
  2099. \begin{function}{OpenDir}
  2100. \Declaration
  2101. Function OpenDir (f:pchar) : pdir;
  2102. Function OpenDir (f:string) : pdir;
  2103. \Description
  2104. \var{OpenDir} opens the directory \var{f}, and returns a \var{pdir}
  2105. pointer to a \var{Dir} record, which can be used to read the directory
  2106. structure. If the directory cannot be opened, \var{nil} is returned.
  2107. \Errors
  2108. Errors are returned in LinuxError.
  2109. \SeeAlso
  2110. \seef{CloseDir}, \seef{ReadDir}, \seep{SeekDir}, \seef{TellDir},
  2111. \seem{opendir}{3}
  2112. \end{function}
  2113. \FPCexample{ex35}
  2114. \begin{procedure}{pause}
  2115. \Declaration
  2116. Procedure Pause;
  2117. \Description
  2118. \var{Pause} puts the process to sleep and waits until the application
  2119. receives a signal. If a signal handler is installed for the received
  2120. sigal, the handler will be called and after that pause will return
  2121. control to the process.
  2122. \Errors
  2123. None.
  2124. \end{procedure}
  2125. For an example, see \seef{Alarm}.
  2126. \begin{function}{PClose}
  2127. \Declaration
  2128. Function PClose (Var F : FileType) : longint;
  2129. \Description
  2130. \var{PClose} closes a file opened with \var{POpen}. It waits for the
  2131. command to complete, and then returns the exit status of the command.
  2132. \Errors
  2133. \var{LinuxError} is used to report errors. If it is different from zero,
  2134. the exit status is not valid.
  2135. \SeeAlso
  2136. \seep{POpen}
  2137. \end{function}
  2138. For an example, see \seep{POpen}
  2139. \begin{procedure}{POpen}
  2140. \Declaration
  2141. Procedure POpen (Var F : FileType; Cmd : pathstr; rw : char);
  2142. \Description
  2143. Popen runs the command specified in \var{Cmd},
  2144. and redirects the standard in or output of the
  2145. command to the other end of the pipe \var{F}. The parameter \var{rw}
  2146. indicates the direction of the pipe. If it is set to \var{'W'}, then F can
  2147. be used to write data, which will then be read by the command from stdinput.
  2148. If it is set to \var{'R'}, then the standard output of the command can be
  2149. read from \var{F}. \var{F} should be reset or rewritten prior to using it.
  2150. \var{F} can be of type \var{Text} or \var{File}.
  2151. A file opened with \var {POpen} can be closed with \var{Close}, but also
  2152. with \seef{PClose}. The result is the same, but \var{PClose} returns the
  2153. exit status of the command \var{Cmd}.
  2154. \Errors
  2155. Errors are reported in \var{LinuxError} and are essentially those of the
  2156. Execve, Dup and AssignPipe commands.
  2157. \SeeAlso
  2158. \seef{AssignPipe}, \seem{popen}{3}, \seef{PClose}
  2159. \end{procedure}
  2160. \FPCexample{ex37}
  2161. \begin{function}{ReadDir}
  2162. \Declaration
  2163. Function ReadDir (p:pdir) : pdirent;
  2164. \Description
  2165. \var{ReadDir} reads the next entry in the directory pointed to by \var{p}.
  2166. It returns a \var{pdirent} pointer to a structure describing the entry.
  2167. If the next entry can't be read, \var{Nil} is returned.
  2168. \Errors
  2169. Errors are returned in LinuxError.
  2170. \SeeAlso
  2171. \seef{CloseDir}, \seef{OpenDir}, \seep{SeekDir}, \seef{TellDir},
  2172. \seem{readdir}{3}
  2173. \end{function}
  2174. For an example, see \seef{OpenDir}.
  2175. \begin{function}{ReadLink}
  2176. \Declaration
  2177. Function ReadLink(name,linkname:pchar;maxlen:longint):longint;
  2178. Function ReadLink(name:pathstr):pathstr;
  2179. \Description
  2180. \var{ReadLink} returns the file the symbolic link \var{name} is pointing
  2181. to. The first form of this function accepts a buffer \var{linkname} of
  2182. length \var{maxlen} where the filename will be stored. It returns the
  2183. actual number of characters stored in the buffer.
  2184. The second form of the function returns simply the name of the file.
  2185. \Errors
  2186. On error, the first form of the function returns -1; the second one returns
  2187. an empty string. \var{LinuxError} is set to report errors:
  2188. \begin{description}
  2189. \item[SYS\_ENOTDIR] A part of the path in \var{Name} is not a directory.
  2190. \item[SYS\_EINVAL] maxlen is not positive, or the file is not a symbolic link.
  2191. \item[SYS\_ENAMETOOLONG] A pathname, or a component of a pathname, was too
  2192. long.
  2193. \item[SYS\_ENOENT] the link \var{name} does not exist.
  2194. \item[SYS\_EACCES] No permission to search a directory in the path
  2195. \item[SYS\_ELOOP] Too many symbolic links were encountered in trans­
  2196. lating the pathname.
  2197. \item[SYS\_EIO] An I/O error occurred while reading from the file
  2198. system.
  2199. \item[SYS\_EFAULT] The buffer is not part of the the process's memory space.
  2200. \item[SYS\_ENOMEM] Not enough kernel memory was available.
  2201. \end{description}
  2202. \SeeAlso
  2203. \seef{SymLink}
  2204. \end{function}
  2205. \FPCexample{ex62}
  2206. \begin{procedure}{ReadPort}
  2207. \Declaration
  2208. Procedure ReadPort (Port : Longint; Var Value : Byte);
  2209. Procedure ReadPort (Port : Longint; Var Value : Word);
  2210. Procedure ReadPort (Port : Longint; Var Value : Longint);
  2211. \Description
  2212. \var{ReadPort} reads one Byte, Word or Longint from port \var{Port} into
  2213. \var{Value}.
  2214. Note that you need permission to read a port. This permission can be set by
  2215. the root user with the \seef{IOperm} call.
  2216. \Errors
  2217. In case of an error (not enough permissions read this port), runtime 216
  2218. ({\em Access Violation}) will occur.
  2219. \SeeAlso
  2220. \seef{IOperm}, \seep{ReadPortB}, \seep{ReadPortW}, \seep{ReadPortL},\seep{WritePort},
  2221. \seep{WritePortB}, \seep{WritePortL}, \seep{WritePortW}
  2222. \end{procedure}
  2223. \begin{procedure}{ReadPortB}
  2224. \Declaration
  2225. Procedure ReadPortB (Port : Longint; Var Buf; Count: longint);
  2226. Function ReadPortB (Port : Longint): Byte;
  2227. \Description
  2228. The procedural form of \var{ReadPortB} reads \var{Count} bytes from port
  2229. \var{Port} and stores them in \var{Buf}. There must be enough memory
  2230. allocated at \var{Buf} to store \var{Count} bytes.
  2231. The functional form of \var{ReadPortB} reads 1 byte from port \var{B}
  2232. and returns the byte that was read.
  2233. Note that you need permission to read a port. This permission can be set by
  2234. the root user with the \seef{IOperm} call.
  2235. \Errors
  2236. In case of an error (not enough permissions read this port), runtime 216
  2237. ({\em Access Violation}) will occur.
  2238. \SeeAlso
  2239. \seef{IOperm}, \seep{ReadPort}, \seep{ReadPortW}, \seep{ReadPortL},\seep{WritePort},
  2240. \seep{WritePortB}, \seep{WritePortL}, \seep{WritePortW}
  2241. \end{procedure}
  2242. \begin{procedure}{ReadPortL}
  2243. \Declaration
  2244. function ReadPortL (Port : Longint): LongInt;
  2245. Procedure ReadPortL (Port : Longint; Var Buf; Count: longint);
  2246. \Description
  2247. The procedural form of \var{ReadPortL} reads \var{Count} longints from port
  2248. \var{Port} and stores them in \var{Buf}. There must be enough memory
  2249. allocated at \var{Buf} to store \var{Count} Longints.
  2250. The functional form of \var{ReadPortB} reads 1 longint from port \var{B}
  2251. and returns the longint that was read.
  2252. Note that you need permission to read a port. This permission can be set by
  2253. the root user with the \seef{IOperm} call.
  2254. \Errors
  2255. In case of an error (not enough permissions read this port), runtime 216
  2256. ({\em Access Violation}) will occur.
  2257. \SeeAlso
  2258. \seef{IOperm}, \seep{ReadPort}, \seep{ReadPortW}, \seep{ReadPortB},\seep{WritePort},
  2259. \seep{WritePortB}, \seep{WritePortL}, \seep{WritePortW}
  2260. \end{procedure}
  2261. \begin{procedure}{ReadPortW}
  2262. \Declaration
  2263. Procedure ReadPortW (Port : Longint; Var Buf; Count: longint);
  2264. function ReadPortW (Port : Longint): Word;
  2265. \Description
  2266. The procedural form of \var{ReadPortB} reads \var{Count} words from port
  2267. \var{Port} and stores them in \var{Buf}. There must be enough memory
  2268. allocated at \var{Buf} to store \var{Count} words.
  2269. The functional form of \var{ReadPortB} reads 1 word from port \var{B}
  2270. and returns the word that was read.
  2271. Note that you need permission to read a port. This permission can be set by
  2272. the root user with the \seef{IOperm} call.
  2273. \Errors
  2274. In case of an error (not enough permissions read this port), runtime 216
  2275. ({\em Access Violation}) will occur.
  2276. \SeeAlso
  2277. \seef{IOperm}, \seep{ReadPort}, \seep{ReadPortB}, \seep{ReadPortL},\seep{WritePort},
  2278. \seep{WritePortB}, \seep{WritePortL}, \seep{WritePortW}
  2279. \end{procedure}
  2280. \begin{procedure}{ReadTimezoneFile}
  2281. \Declaration
  2282. procedure ReadTimezoneFile(fn:string);
  2283. \Description
  2284. \var{ReadTimeZoneFile} reads the timezone file \var{fn} and initializes
  2285. the local time routines based on the information found there.
  2286. There should be no need to call this function. The initialization routines
  2287. of the \file{linux} unit call this routine at unit startup.
  2288. \Errors
  2289. None.
  2290. \SeeAlso
  2291. \seef{GetTimezoneFile}, \seep{GetLocalTimezone}
  2292. \end{procedure}
  2293. \begin{procedure}{SeekDir}
  2294. \Declaration
  2295. Procedure SeekDir (p:pdir;off:longint);
  2296. \Description
  2297. \var{SeekDir} sets the directory pointer to the \var{off}-th entry in the
  2298. directory structure pointed to by \var{p}.
  2299. \Errors
  2300. Errors are returned in LinuxError.
  2301. \SeeAlso
  2302. \seef{CloseDir}, \seef{ReadDir}, \seef{OpenDir}, \seef{TellDir},
  2303. \seem{seekdir}{3}
  2304. \end{procedure}
  2305. For an example, see \seef{OpenDir}.
  2306. \begin{function}{Select}
  2307. \Declaration
  2308. Function Select (N : Longint; \\ var readfds,writefds,exceptfds : PFDset;
  2309. Var Timeout) : Longint;
  2310. \Description
  2311. \var{Select} checks one of the file descriptors in the \var{FDSets} to see if its
  2312. status changed.
  2313. \var{readfds, writefds} and \var{exceptfds} are pointers to arrays of 256
  2314. bits. If you want a file descriptor to be checked, you set the
  2315. corresponding element in the array to 1. The other elements in the array
  2316. must be set to zero. Three arrays are passed : The entries in \var{readfds}
  2317. are checked to see if characters become available for reading. The entries
  2318. in \var{writefds} are checked to see if it is OK to write to them, while
  2319. entries in \var{exceptfds} are cheked to see if an exception occorred on
  2320. them.
  2321. You can use the functions \seepl{FD\_ZERO}{FDZero}, \seepl{FD\_Clr}{FDClr},
  2322. \seepl{FD\_Set}{FDSet}, \seefl{FD\_IsSet}{FDIsSet} to manipulate the individual elements of a set.
  2323. The pointers can be nil.
  2324. \var{N} is the largest index of a nonzero entry plus 1. (= the largest
  2325. file-descriptor + 1).
  2326. \var{TimeOut} can be used to set a time limit.
  2327. If \var{TimeOut} can be two types :
  2328. \begin{enumerate}
  2329. \item \var{TimeOut} is of type \var{PTime} and contains a
  2330. zero time, the call returns immediately. If \var{TimeOut} is \var{Nil}, the
  2331. kernel will wait forever, or until a status changed.
  2332. \item \var{TimeOut} is of type \var{Longint}. If it is -1, this has the same
  2333. effect as a \var{Timeout} of type \var{PTime} which is \var{Nil}.
  2334. Otherwise, \var{TimeOut} contains a time in milliseconds.
  2335. \end{enumerate}
  2336. When the TimeOut is reached, or one of the file descriptors has changed,
  2337. the \var{Select} call returns. On return, it will have modified the entries
  2338. in the array which have actually changed, and it returns the number of
  2339. entries that have been changed. If the timout was reached, and no decsriptor
  2340. changed, zero is returned; The arrays of indexes are undefined after that.
  2341. On error, -1 is returned.
  2342. \Errors
  2343. On error, the function returns -1, and Errors are reported in LinuxError :
  2344. \begin{description}
  2345. \item[SYS\_EBADF\ ] An invalid descriptot was specified in one of the sets.
  2346. \item[SYS\_EINTR\ ] A non blocked signal was caught.
  2347. \item[SYS\_EINVAL\ ] \var{N} is negative or too big.
  2348. \item[SYS\_ENOMEM\ ] \var{Select} was unable to allocate memory for its
  2349. internal tables.
  2350. \end{description}
  2351. \SeeAlso
  2352. \seef{SelectText}, \seef{GetFS},
  2353. \seepl{FD\_ZERO}{FDZero},
  2354. \seepl{FD\_Clr}{FDClr},
  2355. \seepl{FD\_Set}{FDSet},
  2356. \seefl{FD\_IsSet}{FDIsSet}
  2357. \end{function}
  2358. \FPCexample{ex33}
  2359. \begin{function}{SelectText}
  2360. \Declaration
  2361. Function SelectText ( var T : Text; TimeOut :PTime) : Longint;
  2362. \Description
  2363. \var{SelectText} executes the \seef{Select} call on a file of type
  2364. \var{Text}. You can specify a timeout in \var{TimeOut}. The SelectText call
  2365. determines itself whether it should check for read or write, depending on
  2366. how the file was opened : With \var{Reset} it is checked for reading, with
  2367. \var{Rewrite} and \var{Append} it is checked for writing.
  2368. \Errors
  2369. See \seef{Select}. \var{SYS\_EBADF} can also mean that the file wasn't
  2370. opened.
  2371. \SeeAlso
  2372. \seef{Select}, \seef{GetFS}
  2373. \end{function}
  2374. \begin{function}{SetPriority}
  2375. \Declaration
  2376. Function SetPriority (Which,Who,Prio : Integer) : Integer;
  2377. \Description
  2378. SetPriority sets the priority with which a process is running.
  2379. Which process(es) is determined by the \var{Which} and \var{Who} variables.
  2380. \var{Which} can be one of the pre-defined \var{Prio\_Process, Prio\_PGrp,
  2381. Prio\_User}, in which case \var{Who} is the process ID, Process group ID or
  2382. User ID, respectively.
  2383. \var{Prio} is a value in the range -20 to 20.
  2384. \Errors
  2385. Error checking must be done on LinuxError, since a priority can be negative.
  2386. \begin{description}
  2387. \item[sys\_esrch] No process found using \var{which} and \var{who}.
  2388. \item[sys\_einval] \var{Which} was not one of \var{Prio\_Process, Prio\_Grp
  2389. or Prio\_User}.
  2390. \item[sys\_eperm] A process was found, but neither its effective or real
  2391. user ID match the effective user ID of the caller.
  2392. \item [sys\_eacces] A non-superuser tried to a priority increase.
  2393. \end{description}
  2394. \SeeAlso
  2395. \seef{GetPriority}, \seep{Nice}, \seem{Setpriority}{2}
  2396. \end{function}
  2397. For an example, see \seep{Nice}.
  2398. \begin{function}{Shell}
  2399. \Declaration
  2400. Function Shell (Command : String) : Longint;
  2401. \Description
  2402. \var{Shell} invokes the bash shell (\file{/bin/sh}), and feeds it the
  2403. command \var{Command} (using the \var{-c} option). The function then waits
  2404. for the command to complete, and then returns the exit
  2405. status of the command, or 127 if it could not complete the \seef{Fork}
  2406. or \seep{Execve} calls.
  2407. \Errors
  2408. Errors are reported in LinuxError.
  2409. \SeeAlso
  2410. \seep{POpen}, \seef{Fork}, \seep{Execve}, \seem{system}{3}
  2411. \end{function}
  2412. \FPCexample{ex56}
  2413. \begin{procedure}{SigAction}
  2414. \Declaration
  2415. Procedure SigAction (Signum : Integer; Var Act,OldAct : PSigActionRec);
  2416. \Description
  2417. Changes the action to take upon receipt of a signal. \var{Act} and
  2418. \var{Oldact} are pointers to a \var{SigActionRec} record.
  2419. \var{SigNum} specifies the signal, and can be any signal except
  2420. \textbf{SIGKILL} or \textbf{SIGSTOP}.
  2421. If \var{Act} is non-nil, then the new action for signal \var{SigNum} is taken
  2422. from it. If \var{OldAct} is non-nil, the old action is stored there.
  2423. \var{Sa\_Handler} may be \var{SIG\_DFL} for the default action or
  2424. \var{SIG\_IGN} to ignore the signal.
  2425. \var{Sa\_Mask} Specifies which signals should be ignord during the execution
  2426. of the signal handler.
  2427. \var{Sa\_Flags} Speciefies a series of flags which modify the behaviour of
  2428. the signal handler. You can 'or' none or more of the following :
  2429. \begin{description}
  2430. \item[SA\_NOCLDSTOP] If signum is \textbf{SIGCHLD} do not receive
  2431. notification when child processes stop.
  2432. \item[SA\_ONESHOT or SA\_RESETHAND] Restore the signal action to the default
  2433. state once the signal handler has been called.
  2434. \item[SA\_RESTART] For compatibility with BSD signals.
  2435. \item[SA\_NOMASK or SA\_NODEFER] Do not prevent the signal from being received
  2436. from within its own signal handler.
  2437. \end{description}
  2438. \Errors
  2439. \var{LinuxError} is used to report errors.
  2440. \begin{description}
  2441. \item[sys\_einval] an invalid signal was specified, or it was
  2442. \textbf{SIGKILL} or \textbf{SIGSTOP}.
  2443. \item[sys\_efault] \var{Act,OldAct} point outside this process address space
  2444. \item[sys\_eintr] System call was interrupted.
  2445. \end{description}
  2446. \SeeAlso
  2447. \seep{SigProcMask}, \seef{SigPending}, \seep{SigSuspend}, \seef{Kill},
  2448. \seem{Sigaction}{2}
  2449. \end{procedure}
  2450. \FPCexample{ex57}
  2451. \begin{function}{SigPending}
  2452. \Declaration
  2453. Function SigPending : SigSet;
  2454. \Description
  2455. Sigpending allows the examination of pending signals (which have been raised
  2456. while blocked.) The signal mask of pending signals is returned.
  2457. \Errors
  2458. None
  2459. \SeeAlso
  2460. \seep{SigAction}, \seep{SigProcMask}, \seep{SigSuspend}, \seef{Signal},
  2461. \seef{Kill}, \seem{Sigpending}{2}
  2462. \end{function}
  2463. \begin{procedure}{SigProcMask}
  2464. \Declaration
  2465. Procedure SigProcMask (How : Integer; SSet,OldSSet : PSigSet);
  2466. \Description
  2467. Changes the list of currently blocked signals. The behaviour of the call
  2468. depends on \var{How} :
  2469. \begin{description}
  2470. \item[SIG\_BLOCK] The set of blocked signals is the union of the current set
  2471. and the \var{SSet} argument.
  2472. \item[SIG\_UNBLOCK] The signals in \var{SSet} are removed from the set of
  2473. currently blocked signals.
  2474. \item[SIG\_SETMASK] The list of blocked signals is set so \var{SSet}.
  2475. \end{description}
  2476. If \var{OldSSet} is non-nil, then the old set is stored in it.
  2477. \Errors
  2478. \var{LinuxError} is used to report errors.
  2479. \begin{description}
  2480. \item[sys\_efault] \var{SSet} or \var{OldSSet} point to an adress outside
  2481. the range of the process.
  2482. \item[sys\_eintr] System call was interrupted.
  2483. \end{description}
  2484. \SeeAlso
  2485. \seep{SigAction}, \seef{SigPending}, \seep{SigSuspend}, \seef{Kill},
  2486. \seem{Sigprocmask}{2}
  2487. \end{procedure}
  2488. \begin{procedure}{SigRaise}
  2489. \Declaration
  2490. Procedure SigRaise(Sig:integer);
  2491. \Description
  2492. \var{SigRaise} sends a \var{Sig} signal to the current process.
  2493. \Errors
  2494. None.
  2495. \SeeAlso
  2496. \seef{Kill}, \seef{GetPid}
  2497. \end{procedure}
  2498. \FPCexample{ex65}
  2499. \begin{procedure}{SigSuspend}
  2500. \Declaration
  2501. Procedure SigSuspend (Mask : SigSet);
  2502. \Description
  2503. SigSuspend temporarily replaces the signal mask for the process with the one
  2504. given in \var{Mask}, and then suspends the process until a signal is received.
  2505. \Errors
  2506. None
  2507. \SeeAlso
  2508. \seep{SigAction}, \seep{SigProcMask}, \seef{SigPending}, \seef{Signal},
  2509. \seef{Kill}, \seem{SigSuspend}{2}
  2510. \end{procedure}
  2511. \begin{function}{Signal}
  2512. \Declaration
  2513. Function Signal (SigNum : Integer; Handler : SignalHandler) : SignalHandler;
  2514. \Description
  2515. Signal installs a new signal handler for signal \var{SigNum}. This call has
  2516. the same functionality as the \textbf{SigAction} call.
  2517. The return value for Signal is the old signal handler, or nil on error.
  2518. \Errors
  2519. \var {LinuxError} is used to report errors :
  2520. \begin{description}
  2521. \item[SIG\_ERR] An error occurred.
  2522. \end{description}
  2523. \SeeAlso
  2524. \seep{SigAction},\seef{Kill}, \seem{Signal}{2}
  2525. \end{function}
  2526. \FPCexample{ex58}
  2527. \begin{function}{StringToPPchar}
  2528. \Declaration
  2529. Function StringToPPChar(Var S:STring):ppchar;
  2530. \Description
  2531. \var{StringToPPChar} splits the string \var{S} in words, replacing any
  2532. whitespace with zero characters. It returns a pointer to an array of pchars
  2533. that point to the first letters of the words in S. This array is terminated
  2534. by a \var{Nil} pointer.
  2535. The function does {\em not} add a zero character to the end of the string
  2536. unless it ends on whitespace.
  2537. The function reserves memory on the heap to store the array of \var{PChar};
  2538. The caller is responsible for freeing this memory.
  2539. This function can be called to create arguments for the various \var{Exec}
  2540. calls.
  2541. \Errors
  2542. None.
  2543. \SeeAlso
  2544. \seef{CreateShellArgV}, \seep{Execve}, \seep{Execv}
  2545. \end{function}
  2546. \FPCexample{ex70}
  2547. \begin{function}{SymLink}
  2548. \Declaration
  2549. Function SymLink (OldPath,NewPath : pathstr) : Boolean;
  2550. \Description
  2551. \var{SymLink} makes \var{Newpath} point to the file in \var{OldPath}, which doesn't
  2552. necessarily exist. The two files DO NOT have the same inode number.
  2553. This is known as a 'soft' link.
  2554. The permissions of the link are irrelevant, as they are not used when
  2555. following the link. Ownership of the file is only checked in case of removal
  2556. or renaming of the link.
  2557. The function returns \var{True} if the call was succesfull, \var{False} if the call
  2558. failed.
  2559. \Errors
  2560. Errors are returned in \var{LinuxError}.
  2561. \begin{description}
  2562. \item[sys\_eperm] The filesystem containing oldpath and newpath doesn't
  2563. support linking files.
  2564. \item[sys\_eaccess] Write access for the directory containing \var{Newpath}
  2565. is disallowed, or one of the directories in \var{OldPath} or {NewPath} has no
  2566. search (=execute) permission.
  2567. \item[sys\_enoent] A directory entry in \var{OldPath} or \var{NewPath} does
  2568. not exist or is a symbolic link pointing to a non-existent directory.
  2569. \item[sys\_enotdir] A directory entry in \var{OldPath} or \var{NewPath} is
  2570. nor a directory.
  2571. \item[sys\_enomem] Insufficient kernel memory.
  2572. \item[sys\_erofs] The files are on a read-only filesystem.
  2573. \item[sys\_eexist] \var{NewPath} already exists.
  2574. \item[sys\_eloop] \var{OldPath} or \var{NewPath} has a reference to a circular
  2575. symbolic link, i.e. a symbolic link, whose expansion points to itself.
  2576. \item[sys\_enospc] The device containing \var{NewPath} has no room for anothe
  2577. entry.
  2578. \end{description}
  2579. \SeeAlso
  2580. \seef{Link}, \seef{UnLink}, \seef{ReadLink}, \seem{Symlink}{2}
  2581. \end{function}
  2582. \FPCexample{ex22}
  2583. \begin{function}{SysInfo}
  2584. \Declaration
  2585. Function SysInfo(var Info:TSysinfo):Boolean;
  2586. \Description
  2587. \var{SysInfo} returns system information in \var{Info}. Returned information
  2588. in \var{Info} includes:
  2589. \begin{description}
  2590. \item[uptime] Number of seconds since boot.
  2591. \item[loads] 1, 5 and 15 minute load averages.
  2592. \item[totalram] total amount of main memory.
  2593. \item[freeram] amount of free memory.
  2594. \item[sharedram] amount of shared memory
  2595. \item[bufferram] amount of memory used by buffers.
  2596. \item[totalswap] total amount of swapspace.
  2597. \item[freeswap] amount of free swapspace.
  2598. \item[procs] number of current processes.
  2599. \end{description}
  2600. \Errors
  2601. None.
  2602. \SeeAlso
  2603. \seep{Uname}
  2604. \end{function}
  2605. \FPCexample{ex64}
  2606. \begin{function}{TCDrain}
  2607. \Declaration
  2608. Function TCDrain (Fd:longint) : Boolean;
  2609. \Description
  2610. \var{TCDrain}
  2611. waits until all data to file descriptor \var{Fd} is transmitted.
  2612. The function returns \var{True} if the call was succesfull, \var{False}
  2613. otherwise.
  2614. \Errors
  2615. Errors are reported in LinuxError
  2616. \SeeAlso
  2617. \seem{termios}{2}
  2618. \end{function}
  2619. \begin{function}{TCFlow}
  2620. \Declaration
  2621. Function TCFlow (Fd,Act:longint) : Boolean;
  2622. \Description
  2623. \var{TCFlow}
  2624. suspends/resumes transmission or reception of data to or from the file
  2625. descriptor \var{Fd}, depending
  2626. on the action \var {Act}. This can be one of the following pre-defined
  2627. values:
  2628. \begin{description}
  2629. \item [TCOOFF\ ] suspend reception/transmission,
  2630. \item [TCOON\ ] resume reception/transmission,
  2631. \item [TCIOFF\ ] transmit a stop character to stop input from the terminal,
  2632. \item [TCION\ ] transmit start to resume input from the terminal.
  2633. \end{description}
  2634. The function returns \var{True} if the call was succesfull, \var{False}
  2635. otherwise.
  2636. \Errors
  2637. Errors are reported in LinuxError.
  2638. \SeeAlso
  2639. \seem{termios}{2}
  2640. \end{function}
  2641. \begin{function}{TCFlush}
  2642. \Declaration
  2643. Function TCFlush (Fd,QSel:longint) : Boolean;
  2644. \Description
  2645. \var{TCFlush}
  2646. discards all data sent or received to/from file descriptor \var{fd}.
  2647. \var{QSel} indicates which queue
  2648. should be discard. It can be one of the following pre-defined values :
  2649. \begin{description}
  2650. \item [TCIFLUSH\ ] input,
  2651. \item [TCOFLUSH\ ] output,
  2652. \item [TCIOFLUSH\ ] both input and output.
  2653. \end{description}
  2654. The function returns \var{True} if the call was succesfull, \var{False}
  2655. otherwise.
  2656. \Errors
  2657. Errors are reported in LinuxError.
  2658. \SeeAlso
  2659. \seem{termios}{2}
  2660. \end{function}
  2661. \begin{function}{TCGetAttr}
  2662. \Declaration
  2663. Function TCGetAttr (fd:longint;var tios:TermIOS) : Boolean;
  2664. \Description
  2665. \var{TCGetAttr}
  2666. gets the terminal parameters from the terminal referred to by the file
  2667. descriptor \var{fd} and returns them in a \var{TermIOS} structure \var{tios}.
  2668. The function returns \var{True} if the call was succesfull, \var{False}
  2669. otherwise.
  2670. \Errors
  2671. Errors are reported in LinuxError
  2672. \SeeAlso
  2673. \seef{TCSetAttr}, \seem{termios}{2}
  2674. \end{function}
  2675. \FPCexample{ex55}
  2676. \begin{function}{TCGetPGrp}
  2677. \Declaration
  2678. Function TCGetPGrp (Fd:longint;var Id:longint) : boolean;
  2679. \Description
  2680. \var{TCGetPGrp}
  2681. returns the process group ID of a foreground process group in \var{Id}
  2682. The function returns \var{True} if the call was succesfull, \var{False}
  2683. otherwise
  2684. \Errors
  2685. Errors are reported in LinuxError
  2686. \SeeAlso
  2687. \seem{termios}{2}
  2688. \end{function}
  2689. \begin{function}{TCSendBreak}
  2690. \Declaration
  2691. Function TCSendBreak (Fd,Duration:longint) : Boolean;
  2692. \Description
  2693. \var{TCSendBreak}
  2694. Sends zero-valued bits on an asynchrone serial connection decsribed by
  2695. file-descriptor \var{Fd}, for duration \var{Duration}.
  2696. The function returns \var{True} if the action was performed successfully,
  2697. \var{False} otherwise.
  2698. \Errors
  2699. Errors are reported in LinuxError.
  2700. \SeeAlso
  2701. \seem{termios}{2}
  2702. \end{function}
  2703. \begin{function}{TCSetAttr}
  2704. \Declaration
  2705. Function TCSetAttr (Fd:longint;OptAct:longint;var Tios:TermIOS) : Boolean;
  2706. \Description
  2707. \var{TCSetAttr}
  2708. Sets the terminal parameters you specify in a \var{TermIOS} structure
  2709. \var{Tios} for the terminal
  2710. referred to by the file descriptor \var{Fd}. \var{OptAct} specifies an
  2711. optional action when the set need to be done,
  2712. this could be one of the following pre-defined values:
  2713. \begin{description}
  2714. \item [TCSANOW\ ] set immediately.
  2715. \item [TCSADRAIN\ ] wait for output.
  2716. \item [TCSAFLUSH\ ] wait for output and discard all input not yet read.
  2717. \end{description}
  2718. The function Returns \var{True} if the call was succesfull, \var{False}
  2719. otherwise.
  2720. \Errors
  2721. Errors are reported in LinuxError.
  2722. \SeeAlso
  2723. \seef{TCGetAttr}, \seem{termios}{2}
  2724. \end{function}
  2725. For an example, see \seef{TCGetAttr}.
  2726. \begin{function}{TCSetPGrp}
  2727. \Declaration
  2728. Function TCSetPGrp (Fd,Id:longint) : boolean;
  2729. \Description
  2730. \var{TCSetPGrp} Sets the Process Group Id to \var{Id}.
  2731. The function returns \var{True} if the call was successful, \var{False}
  2732. otherwise.
  2733. \Errors
  2734. Errors are returned in LinuxError.
  2735. \SeeAlso
  2736. \seef{TCGetPGrp}, \seem{termios}{2}
  2737. \end{function}
  2738. For an example, see \seef{TCGetPGrp}.
  2739. \begin{function}{TTYName}
  2740. \Declaration
  2741. Function TTYName (var f) : String;
  2742. \Description
  2743. Returns the name of the terminal pointed to by \var{f}. \var{f}
  2744. must be a terminal. \var{f} can be of type:
  2745. \begin{enumerate}
  2746. \item \var{longint} for file handles;
  2747. \item \var{Text} for \var{text} variables such as \var{input} etc.
  2748. \end{enumerate}
  2749. \Errors
  2750. Returns an empty string in case of an error. \var{Linuxerror} may be set
  2751. to indicate what error occurred, but this is uncertain.
  2752. \SeeAlso
  2753. \seef{IsATTY},\seep{IOCtl}
  2754. \end{function}
  2755. \begin{function}{TellDir}
  2756. \Declaration
  2757. Function TellDir (p:pdir) : longint;
  2758. \Description
  2759. \var{TellDir} returns the current location in the directory structure
  2760. pointed to by \var{p}. It returns -1 on failure.
  2761. \Errors
  2762. Errors are returned in LinuxError.
  2763. \SeeAlso
  2764. \seef{CloseDir}, \seef{ReadDir}, \seep{SeekDir}, \seef{OpenDir},
  2765. \seem{telldir}{3}
  2766. \end{function}
  2767. For an example, see \seef{OpenDir}.
  2768. \begin{function}{Umask}
  2769. \Declaration
  2770. Function Umask (Mask : Integer) : Integer;
  2771. \Description
  2772. Change the file creation mask for the current user to \var{Mask}. The
  2773. current mask is returned.
  2774. \Errors
  2775. None
  2776. \SeeAlso
  2777. \seef{Chmod}, \seem{Umask}{2}
  2778. \end{function}
  2779. \FPCexample{ex27}
  2780. \begin{procedure}{Uname}
  2781. \Declaration
  2782. Procedure Uname (var unamerec:utsname);
  2783. \Description
  2784. \var{Uname} gets the name and configuration of the current \linux kernel,
  2785. and returns it in \var{unamerec}.
  2786. \Errors
  2787. \var{LinuxError} is used to report errors.
  2788. \SeeAlso
  2789. \seef{GetHostName}, \seef{GetDomainName}, \seem{uname}{2}
  2790. \end{procedure}
  2791. \begin{function}{UnLink}
  2792. \Declaration
  2793. Function UnLink (Var Path) : Boolean;
  2794. \Description
  2795. \var{UnLink} decreases the link count on file \var{Path}. \var{Path} can be
  2796. of type \var{PathStr} or \var{PChar}. If the link count is zero, the
  2797. file is removed from the disk.
  2798. The function returns \var{True} if the call was succesfull, \var{False} if the call
  2799. failed.
  2800. \Errors
  2801. Errors are returned in \var{LinuxError}.
  2802. \begin{description}
  2803. \item[sys\_eaccess] You have no write access right in the directory
  2804. containing \var{Path}, or you have no search permission in one of the
  2805. directory components of \var{Path}.
  2806. \item[sys\_eperm] The directory containing pathname has the sticky-bit
  2807. set and the process's effective uid is neither the uid of the
  2808. file to be deleted nor that of the directory containing it.
  2809. \item[sys\_enoent] A component of the path doesn't exist.
  2810. \item[sys\_enotdir] A directory component of the path is not a directory.
  2811. \item[sys\_eisdir] \var{Path} refers to a directory.
  2812. \item[sys\_enomem] Insufficient kernel memory.
  2813. \item[sys\_erofs] \var{Path} is on a read-only filesystem.
  2814. \end{description}
  2815. \SeeAlso
  2816. \seef{Link}, \seef{SymLink}, \seem{Unlink}{2}
  2817. \end{function}
  2818. For an example, see \seef{Link}.
  2819. \begin{function}{Utime}
  2820. \Declaration
  2821. Function Utime (path : pathstr; utim : utimbuf) : Boolean;
  2822. \Description
  2823. \var{Utime} sets the access and modification times of a file.
  2824. the \var{utimbuf} record contains 2 fields, \var{actime}, and \var{modtime},
  2825. both of type Longint. They should be filled with an epoch-like time,
  2826. specifying, respectively, the last access time, and the last modification
  2827. time.
  2828. For some filesystem (most notably, FAT), these times are the same.
  2829. \Errors
  2830. Errors are returned in \var{LinuxError}.
  2831. \begin{description}
  2832. \item[sys\_eaccess] One of the directories in \var{Path} has no
  2833. search (=execute) permission.
  2834. \item[sys\_enoent] A directory entry in \var{Path} does
  2835. not exist or is a symbolic link pointing to a non-existent directory.
  2836. \end{description}
  2837. Other errors may occur, but aren't documented.
  2838. \SeeAlso
  2839. \seef{GetEpochTime}, \seef{Chown}, \seef{Access}, \seem{utime}(2)
  2840. \end{function}
  2841. \FPCexample{ex25}
  2842. \begin{function}{WaitPid}
  2843. \Declaration
  2844. Function WaitPid (Pid : longint; Status : pointer; Options : Integer) : Longint;
  2845. \Description
  2846. \var{WaitPid} waits for a child process with process ID \var{Pid} to exit. The
  2847. value of \var{Pid} can be one of the following:
  2848. \begin{description}
  2849. \item[Pid < -1] Causes \var{WaitPid} to wait for any child process whose
  2850. process group ID equals the absolute value of \var{pid}.
  2851. \item[Pid = -1] Causes \var{WaitPid} to wait for any child process.
  2852. \item[Pid = 0] Causes \var{WaitPid} to wait for any child process whose
  2853. process group ID equals the one of the calling
  2854. process.
  2855. \item[Pid > 0] Causes \var{WaitPid} to wait for the child whose process ID
  2856. equals the value of \var{Pid}.
  2857. \end{description}
  2858. The \var{Options} parameter can be used to specify further how \var{WaitPid}
  2859. behaves:
  2860. \begin{description}
  2861. \item [WNOHANG] Causes \var{Waitpid} to return immediately if no child has
  2862. exited.
  2863. \item [WUNTRACED] Causes \var{WaitPid} to return also for children which are
  2864. stopped, but whose status has not yet been reported.
  2865. \end{description}
  2866. Upon return, it returns the exit status of the process, or -1 in case of
  2867. failure.
  2868. \Errors
  2869. Errors are returned in LinuxError.
  2870. \SeeAlso
  2871. \seef{Fork}, \seep{Execve}, \seem{waitpid}{2}
  2872. \end{function}
  2873. For an example, see \seef{Fork}.
  2874. \begin{procedure}{WritePort}
  2875. \Declaration
  2876. Procedure WritePort (Port : Longint; Value : Byte);
  2877. Procedure WritePort (Port : Longint; Value : Word);
  2878. Procedure WritePort (Port : Longint; Value : Longint);
  2879. \Description
  2880. \var{WritePort} writes \var{Value} -- 1 byte, Word or longint --
  2881. to port \var{Port}.
  2882. Note: You need permission to write to a port. This permission can be set with root
  2883. permission with the \var{IOperm} call.
  2884. \Errors
  2885. In case of an error (not enough permissions to write to this port), runtime 216
  2886. ({\em Access Violation}) will occur.
  2887. \SeeAlso
  2888. \seef{IOperm}, \seep{WritePortB}, \seep{WritePortL}, \seep{WritePortW},
  2889. \seep{ReadPortB}, \seep{ReadPortL}, \seep{ReadPortW}
  2890. \end{procedure}
  2891. \begin{procedure}{WritePortB}
  2892. \Declaration
  2893. Procedure WritePortB (Port : Longint; Value : Byte);
  2894. Procedure WritePortB (Port : Longint; Var Buf; Count: longint);
  2895. \Description
  2896. The first form of \var{WritePortB} writes 1 byte to port \var{Port}.
  2897. The second form writes \var{Count} bytes from \var{Buf} to port \var{Port}.
  2898. Note: You need permission to write to a port. This permission can be set with root
  2899. permission with the \var{IOperm} call.
  2900. \Errors
  2901. In case of an error (not enough permissions to write to this port), runtime 216
  2902. ({\em Access Violation}) will occur.
  2903. \SeeAlso
  2904. \seef{IOperm}, \seep{WritePort}, \seep{WritePortL}, \seep{WritePortW},
  2905. \seep{ReadPortB}, \seep{ReadPortL}, \seep{ReadPortW}
  2906. \end{procedure}
  2907. \begin{procedure}{WritePortL}
  2908. \Declaration
  2909. Procedure WritePortL (Port : Longint; Value : Longint);
  2910. Procedure WritePortL (Port : Longint; Var Buf; Count: longint);
  2911. \Description
  2912. The first form of \var{WritePortB} writes 1 byte to port \var{Port}.
  2913. The second form writes \var{Count} bytes from \var{Buf} to port \var{Port}.
  2914. Note: You need permission to write to a port. This permission can be set with root
  2915. permission with the \var{IOperm} call.
  2916. \Errors
  2917. In case of an error (not enough permissions to write to this port), runtime 216
  2918. ({\em Access Violation}) will occur.
  2919. \SeeAlso
  2920. \seef{IOperm}, \seep{WritePort}, \seep{WritePortB}, \seep{WritePortW},
  2921. \seep{ReadPortB}, \seep{ReadPortL}, \seep{ReadPortW}
  2922. \end{procedure}
  2923. \begin{procedure}{WritePortW}
  2924. \Declaration
  2925. Procedure WritePortW (Port : Longint; Var Buf; Count: longint);
  2926. Procedure WritePortW (Port : Longint; Value : Word);
  2927. \Description
  2928. The first form of \var{WritePortB} writes 1 byte to port \var{Port}.
  2929. The second form writes \var{Count} bytes from \var{Buf} to port \var{Port}.
  2930. Note: You need permission to write to a port. This permission can be set with root
  2931. permission with the \var{IOperm} call.
  2932. \Errors
  2933. In case of an error (not enough permissions to write to this port), runtime 216
  2934. ({\em Access Violation}) will occur.
  2935. \SeeAlso
  2936. \seef{IOperm}, \seep{WritePort}, \seep{WritePortL}, \seep{WritePortB},
  2937. \seep{ReadPortB}, \seep{ReadPortL}, \seep{ReadPortW}
  2938. \end{procedure}