2
% $Id: linux.tex,v 1.3 2002/08/30 06:37:15 michael Exp $
3
% This file is part of the FPC documentation.
4
% Copyright (C) 1997, by Michael Van Canneyt
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.
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.
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.
21
\chapter{The LINUX unit.}
24
\FPCexampledir{linuxex}
25
This chapter describes the LINUX unit for Free Pascal. The unit was written
26
by Micha\"el van Canneyt. It works only on the Linux operating system.
27
This chapter is divided in 3 sections:
29
\item The first section lists all constants, types and variables, as listed
30
in the interface section of the LINUX unit.
31
\item The second section gives and overview of all available functions,
33
\item The third section describes all procedures and functions in the LINUX
37
% Type, Variable and Constant declarations
38
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39
\section{Type, Variable and Constant declarations}
44
PGlob and TGlob are 2 types used in the \seef{Glob} function:
52
The following types are used in the signal-processing procedures.
55
significand: array[0..3] of word;
61
cw, sw, tag, ipoff, cssel, dataoff, datasel: cardinal;
62
st: array[0..7] of tfpreg;
66
PSigContextRec = ^SigContextRec;
67
SigContextRec = record
85
esp_at_signal: cardinal;
92
The above records contain information about the processor state and process
93
state at the moment a signal is sent to your program.
95
The records below are used in catching signals.
97
TSigAction = procedure(Sig: Longint; SigContext: SigContextRec);cdecl;
98
SignalHandler = Procedure ( Sig : Integer);cdecl;
100
PSignalHandler = SignalHandler;
101
SignalRestorer = Procedure;cdecl;
102
PSignalrestorer = SignalRestorer;
103
SigActionRec = packed record
106
0: (Sh: SignalHandler);
111
Sa_restorer : SignalRestorer; { Obsolete - Don't use }
113
PSigActionRec = ^SigActionRec;
115
Stat is used to store information about a file. It is defined in the
141
Statfs is used to store information about a filesystem. It is defined in
154
spare : array [0..6] of longint;
157
\var{Dir and PDir} are used in the \seef{OpenDir} and \seef{ReadDir}
171
\var{Dirent, PDirent} are used in the \seef{ReadDir} function to return files in a directory.
181
Termio and Termios are used with iotcl() calls for terminal handling.
187
c_iflag, { input mode flags }
188
c_oflag, { output mode flags }
189
c_cflag, { control mode flags }
190
c_lflag : Word; { local mode flags }
191
c_line : Word; { line discipline - careful, only High byte in use}
192
c_cc : array [0..NCC-1] of char; { control characters }
195
c_iflag, { input mode flags }
196
c_oflag, { output mode flags }
197
c_cflag, { control mode flags }
198
c_lflag : Cardinal; { local mode flags }
199
c_line : char; { line discipline }
200
c_cc : array [0..NCCS-1] of char; { control characters }
203
\var{Utimbuf} is used in the \seef{Utime} call to set access and modificaton time
207
actime,modtime : Longint;
210
For the \seef{Select} call, the following 4 types are needed:
212
FDSet = Array [0..31] of longint;
219
The \var{timespec} record is needed in the \seef{NanoSleep} function:
221
timespec = packed record
222
tv_sec,tv_nsec:longint;
226
The \seep{Uname} function uses the \var{utsname} to return information about
230
sysname,nodename,release,
231
version,machine,domainname : Array[0..64] of char;
234
Its elements are null-terminated C style strings, you cannot access them
238
\subsection{Variables}
239
\var{Linuxerror} is the variable in which the procedures in the linux unit
242
LinuxError : Longint;
244
\var{StdErr} Is a \var{Text} variable, corresponding to Standard Error or
245
diagnostic output. It is connected to file descriptor 2. It can be freely
246
used, and will be closed on exit.
252
\subsection{Constants}
253
Constants for setting/getting process priorities :
259
For testing access rights:
266
For signal handling functions :
269
SA_SHIRQ = $04000000;
270
SA_STACK = $08000000;
271
SA_RESTART = $10000000;
272
SA_INTERRUPT = $20000000;
273
SA_NOMASK = $40000000;
274
SA_ONESHOT = $80000000;
317
For file control mechanism :
329
For Terminal handling :
355
TIOCGSOFTCAR = $5419 ;
356
TIOCSSOFTCAR = $541A ;
361
TIOCGSERIAL = $541E ;
362
TIOCSSERIAL = $541F ;
369
TIOCTTYGSTRUCT = $5426 ;
373
TIOCSERCONFIG = $5453 ;
374
TIOCSERGWILD = $5454 ;
375
TIOCSERSWILD = $5455 ;
376
TIOCGLCKTRMIOS = $5456 ;
377
TIOCSLCKTRMIOS = $5457 ;
378
TIOCSERGSTRUCT = $5458 ;
379
TIOCSERGETLSR = $5459 ;
380
TIOCSERGETMULTI = $545A ;
381
TIOCSERSETMULTI = $545B ;
383
TIOCGICOUNT = $545D ;
385
TIOCPKT_FLUSHREAD = 1;
386
TIOCPKT_FLUSHWRITE = 2;
392
Other than that, all constants for setting the speed and control flags of a
393
terminal line, as described in the \seem{termios}{2} man
394
page, are defined in the linux unit. It would take too much place to list
396
To check the \var{mode} field of a \var{stat} record, you ca use the
397
following constants :
399
{ Constants to check stat.mode }
400
STAT_IFMT = $f000; {00170000}
401
STAT_IFSOCK = $c000; {0140000}
402
STAT_IFLNK = $a000; {0120000}
403
STAT_IFREG = $8000; {0100000}
404
STAT_IFBLK = $6000; {0060000}
405
STAT_IFDIR = $4000; {0040000}
406
STAT_IFCHR = $2000; {0020000}
407
STAT_IFIFO = $1000; {0010000}
408
STAT_ISUID = $0800; {0004000}
409
STAT_ISGID = $0400; {0002000}
410
STAT_ISVTX = $0200; {0001000}
411
{ Constants to check permissions }
416
STAT_IRWXG = STAT_IRWXO shl 3;
417
STAT_IRGRP = STAT_IROTH shl 3;
418
STAT_IWGRP = STAT_IWOTH shl 3;
419
STAT_IXGRP = STAT_IXOTH shl 3;
420
STAT_IRWXU = STAT_IRWXO shl 6;
421
STAT_IRUSR = STAT_IROTH shl 6;
422
STAT_IWUSR = STAT_IWOTH shl 6;
423
STAT_IXUSR = STAT_IXOTH shl 6;
425
You can test the type of a filesystem returned by a \seef{FSStat} call with
426
the following constants:
440
the \seef{FLock} call uses the following mode constants :
447
The \seef{MMap} function uses the following constants to specify access to
450
PROT_READ = $1; { page can be read }
451
PROT_WRITE = $2; { page can be written }
452
PROT_EXEC = $4; { page can be executed }
453
PROT_NONE = $0; { page can not be accessed }
455
and the following constants to specify the type of mapping.
457
MAP_SHARED = $1; { Share changes }
458
MAP_PRIVATE = $2; { Changes are private }
459
MAP_TYPE = $f; { Mask for type of mapping }
460
MAP_FIXED = $10; { Interpret addr exactly }
461
MAP_ANONYMOUS = $20; { don't use a file }
464
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
465
% Functions and procedures by category
466
\section{Function list by category}
467
What follows is a listing of the available functions, grouped by category.
468
For each function there is a reference to the page where you can find the
470
\subsection{File Input/Output routines}
471
Functions for handling file input/output.
473
\funcref{Dup}{Duplicate a file handle}
474
\funcref{Dup2}{Copy one file handle to another}
475
\procref{Fcntl}{General file control}
476
\funcref{fdClose}{Close file descriptor}
477
\funcref{fdFlush}{Flush file descriptor}
478
\funcref{fdOpen}{Open new file descriptor}
479
\funcref{fdRead}{Read from file descriptor}
480
\funcref{fdSeek}{Position in file}
481
\funcref{fdTruncate}{Truncate file}
482
\funcref{fdWrite}{Write to file descriptor}
483
\funcref{GetFS}{Get file descriptor of pascal file}
484
\funcref{Select}{Wait for input from file descriptor}
485
\funcref{SelectText}{Wait for input from pascal file}
488
\subsection{General File handling routines}
489
Functions for handling files on disk.
491
\funcref{Access}{Check access rights on file}
492
\funcref{BaseName}{Return name part of file}
493
\funcref{Chown}{Change owner of file}
494
\funcref{Chmod}{Change access rights on file}
495
\funcref{DirName}{Return directory part of file}
496
\procrefl{FSplit}{LFsplit}{Split filename in parts}
497
\funcref{FExpand}{Return full-grown filename}
498
\funcref{FLock}{Set lock on a file}
499
\funcref{FNMatch}{Match filename to searchpattern}
500
\funcref{FSearch}{Search for a file in a path}
501
\funcref{FSStat}{Return filesystem information}
502
\funcref{FStat}{Return file information}
503
\funcref{FRename}{Rename file}
504
\funcref{LStat}{Return information on a link}
505
\funcref{Link}{Create a link}
506
\funcref{ReadLink}{Read contents of a symbolic link}
507
\funcref{SymLink}{Create a symbolic link}
508
\funcref{Umask}{Set the file creation mask}
509
\funcref{UnLink}{Remove a file}
510
\funcref{Utime}{Change file timestamps}
513
\subsection{Pipes, FIFOs and streams }
514
Functions for creating and managing pipes.
516
\funcref{AssignPipe}{Create a pipe}
517
\funcref{AssignStream}{Create pipes to program's input and output}
518
\funcref{MkFifo}{Make a fifo}
519
\funcref{PClose}{Close a pipe}
520
\procref{POpen}{Open a pipe for to program's input or output}
523
\subsection{Directory handling routines}
524
Functions for reading and searching directories.
526
\funcref{CloseDir}{Close directory handle}
527
\funcref{Glob}{Return files matching a search expression}
528
\procref{GlobFree}{Free result of Glob}
529
\funcref{OpenDir}{Open directory for reading}
530
\funcref{ReadDir}{Read directory entry}
531
\procref{SeekDir}{Seek directory}
532
\funcref{TellDir}{Seek directory}
535
\subsection{Process handling}
536
Functions for managing processes and programs.
538
\funcref{Clone}{Create a thread}
539
\procref{Execl}{Execute process with command-line list}
540
\procref{Execle}{Execute process with command-line list and environment}
541
\procref{Execlp}{Search in path and execute process with command list}
542
\procref{Execv}{Execute process}
543
\procref{Execve}{Execute process with environment}
544
\procref{Execvp}{Search in path and execute process}
545
\funcref{Fork}{Spawn child process}
546
\funcref{GetEGid}{Get effective group id}
547
\funcref{GetEnv}{Get environment variable}
548
\funcref{GetEUid}{Get effective user id}
549
\funcref{GetGid}{Get group id}
550
\funcref{GetPid}{Get process id}
551
\funcref{GetPPid}{Get parent process id}
552
\funcref{GetPriority}{Get process priority}
553
\funcref{GetUid}{Get user id}
554
\procref{Nice}{Change priority of process}
555
\funcref{SetPriority}{Change priority of process}
556
\funcref{Shell}{Execute shell command}
557
\funcref{WaitPid}{Wait for child process to terminate}
561
Functions for managing and responding to signals.
563
\funcref{Alarm}{Send alarm signal to self}
564
\funcref{Kill}{Send arbitrary signal to process}
565
\procref{pause}{Wait for signal to arrive}
566
\procref{SigAction}{Set signal action}
567
\funcref{Signal}{Set signal action}
568
\funcref{SigPending}{See if signals are waiting}
569
\procref{SigProcMask}{Set signal processing mask}
570
\procref{SigRaise}{Send signal to self}
571
\procref{SigSuspend}{Sets signal mask and waits for signal}
572
\funcref{NanoSleep}{Waits for a specific amount of time}
575
\subsection{System information}
576
Functions for retrieving system information such as date and time.
578
\procref{GetDate}{Return system date}
579
\procref{GetDateTime}{Return system date and time}
580
\funcref{GetDomainName}{Return system domain name}
581
\funcref{GetEpochTime}{Return epoch time}
582
\funcref{GetHostName}{Return system host name}
583
\procref{GetLocalTimezone}{Return system timezone}
584
\procref{GetTime}{Return system time}
585
\funcref{GetTimeOfDay}{Return system time}
586
\funcref{GetTimezoneFile}{Return name of timezone file}
587
\procref{ReadTimezoneFile}{Read timezone file contents}
588
\funcref{SysInfo}{Return general system information}
589
\procref{Uname}{Return system information}
592
\subsection{Terminal functions}
593
Functions for controlling the terminal to which the process is connected.
596
\procref{CFMakeRaw}{Set terminal to raw mode}
597
\procref{CFSetISpeed}{Set terminal reading speed}
598
\procref{CFSetOSpeed}{Set terminal writing speed}
599
\procref{IOCtl}{General IO control call}
600
\funcref{IsATTY}{See if filedescriptor is a terminal}
601
\funcref{TCDrain}{Wait till all output was written}
602
\funcref{TCFlow}{Suspend transmission or receipt of data}
603
\funcref{TCFlush}{Discard data written to terminal}
604
\funcref{TCGetAttr}{Get terminal attributes}
605
\funcref{TCGetPGrp}{Return PID of foreground process}
606
\funcref{TCSendBreak}{Send data for specific time}
607
\funcref{TCSetAttr}{Set terminal attributes}
608
\funcref{TCSetPGrp}{Set foreground process}
609
\funcref{TTYName}{Name of tty file}
612
\subsection{Port input/output}
613
Functions for reading and writing to the hardware ports.
615
\funcref{IOperm}{Set permissions for port access}
616
\procref{ReadPort}{Read data from port}
617
\procref{ReadPortB}{Read 1 byte from port}
618
\procref{ReadPortL}{Read 4 bytes from port}
619
\procref{ReadPortW}{Read 2 bytes from port}
620
\procref{WritePort}{Write data to port}
621
\procref{WritePortB}{Write 1 byte to port}
622
\procref{WritePortL}{Write 4 bytes to port}
623
\procref{WritePortW}{Write 2 bytes to port}
626
\subsection{Utility routines}
627
Auxiliary functions that are useful in connection with the other functions.
629
\funcref{CreateShellArgV}{Create an array of pchars from string}
630
\procref{EpochToLocal}{Convert epoch time to local time}
631
\procrefl{FD\_Clr}{FDClr}{Clear item of select filedescriptors}
632
\funcrefl{FD\_IsSet}{FDIsSet}{Check item of select filedescriptors}
633
\procrefl{FD\_Set}{FDSet}{Set item of select filedescriptors}
634
\procrefl{FD\_ZERO}{FDZero}{Clear all items in select filedecriptors}
635
\funcref{LocalToEpoch}{Convert local time to epoch time}
636
\funcref{MMap}{Map a file into memory}
637
\funcref{MUnMap}{Unmap previously mapped memory file}
638
\funcref{Octal}{Convert octal to digital}
639
\funcrefl{S\_ISBLK}{ISBLK}{Check file mode for block device}
640
\funcrefl{S\_ISCHR}{ISCHR}{Check file mode for character device}
641
\funcrefl{S\_ISDIR}{ISDIR}{Check file mode for directory}
642
\funcrefl{S\_ISFIFO}{ISFIFO}{Check file mode for FIFO}
643
\funcrefl{S\_ISLNK}{ISLNK}{Check file mode for symboloc link}
644
\funcrefl{S\_ISREG}{ISREG}{Check file mode for regular file}
645
\funcrefl{S\_ISSOCK}{ISSOCK}{Check file mode for socket}
646
\funcref{StringToPPchar}{Create an array of pchars from string}
649
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
650
% Functions and procedures
651
\section{Functions and procedures}
653
\begin{function}{Access}
655
Function Access (Path : Pathstr; Mode : integer) : Boolean;
657
Tests user's access rights on the specified file. Mode is a mask existing of
660
\item[R\_OK] User has read rights.
661
\item[W\_OK] User has write rights.
662
\item[X\_OK] User has execute rights.
663
\item[F\_OK] User has search rights in the directory where the file is.
665
The test is done with the real user ID, instead of the effective user ID.
666
If access is denied, or an error occurred, false is returned.
668
\var{LinuxError} is used to report errors:
670
\item[sys\_eaccess] The requested access is denied, either to the file or one
671
of the directories in its path.
672
\item[sys\_einval] \var{Mode} was incorrect.
673
\item[sys\_enoent] A directory component in \var{Path} doesn't exist or is a
674
dangling symbolic link.
675
\item[sys\_enotdir] A directory component in \var{Path} is not a directory.
676
\item[sys\_enomem] Insufficient kernel memory.
677
\item[sys\_eloop] \var{Path} has a circular symbolic link.
681
\seef{Chown}, \seef{Chmod}, \seem{Access}{2}
688
\begin{function}{Alarm}
690
Function Alarm(Sec : longint) : Longint;
692
Alarm schedules an alarm signal to be delivered to your process in \var{Sec}
693
seconds. When \var{Sec} seconds have elapsed, Linux will send a \var{SIGALRM}
694
signal to the current process. If \var{Sec} is zero, then no new alarm will
695
be set. Whatever the value of \var{Sec}, any previous alarm is cancelled.
697
The function returns the number of seconds till the previously scheduled
698
alarm was due to be delivered, or zero if there was none.
706
\begin{function}{AssignPipe}
708
Function AssignPipe(var pipe\_in,pipe\_out:longint):boolean;
709
Function AssignPipe(var pipe\_in,pipe\_out:text):boolean;
710
Function AssignPipe(var pipe\_in,pipe\_out:file):boolean;
712
\var{AssignePipe} creates a pipe, i.e. two file objects, one for input,
713
one for output. What is written to \var{Pipe\_out}, can be read from
716
This call is overloaded. The in and out pipe can take three forms:
717
an typed or untyped file, a text file or a file descriptor.
719
If a text file is passed then reading and writing from/to the pipe
720
can be done through the usual \var{Readln(Pipe\_in,...)} and
721
\var{Writeln (Pipe\_out,...)} procedures.
723
The function returns \var{True} if everything went succesfully,
724
\var{False} otherwise.
726
In case the function fails and returns \var{False}, \var{LinuxError}
727
is used to report errors:
729
\item[sys\_emfile] Too many file descriptors for this process.
730
\item[sys\_enfile] The system file table is full.
733
\seep{POpen}, \seef{MkFifo}, \seem{pipe}{2}
740
\begin{function}{AssignStream}
742
Function AssignStream(Var StreamIn,Streamout:text;
743
Const Prog:String) : longint;
744
Function AssignStream(var StreamIn, StreamOut, StreamErr: Text;
745
const prog: String): LongInt;
747
\var{AssignStream} creates a 2 or 3 pipes, i.e. two (or three) file objects, one for
748
input, one for output,(and one for standard error) the other ends of these
749
pipes are connected to standard input and output (and standard error) of
750
\var{Prog}. \var{Prog} is the name of a program (including path) with options,
751
which will be executed.
753
What is written to \var{StreamOut}, will go to the standard input of
754
\var{Prog}. Whatever is written by \var{Prog} to it's standard output
755
can be read from \var{StreamIn}.
756
Whatever is written by \var{Prog} to it's standard error read from
757
\var{StreamErr}, if present.
759
Reading and writing happens through the usual \var{Readln(StreamIn,...)} and
760
\var{Writeln (StreamOut,...)} procedures.
762
{\em Remark:} You should {\em not} use \var{Reset} or \var{Rewrite} on a
763
file opened with \var{POpen}. This will close the file before re-opening
764
it again, thereby closing the connection with the program.
766
The function returns the process ID of the spawned process, or -1 in case of
770
In case of error (return value -1) \var{LinuxError} is used to report
773
\item[sys\_emfile] Too many file descriptors for this process.
774
\item[sys\_enfile] The system file table is full.
776
Other errors include the ones by the fork and exec programs
778
\seef{AssignPipe}, \seep{POpen},\seem{pipe}{2}
785
\begin{function}{BaseName}
787
Function BaseName (Const Path;Const Suf : Pathstr) : Pathstr;
789
Returns the filename part of \var{Path}, stripping off \var{Suf} if it
791
The filename part is the whole name if \var{Path} contains no slash,
792
or the part of \var{Path} after the last slash.
793
The last character of the result is not a slash, unless the directory is the
799
\seef{DirName}, \seef{FExpand}, \seem{Basename}{1}
804
\begin{procedure}{CFMakeRaw}
806
Procedure CFMakeRaw (var Tios:TermIOS);
809
Sets the flags in the \var{Termios} structure \var{Tios} to a state so that
810
the terminal will function in Raw Mode.
815
\seep{CFSetOSpeed}, \seep{CFSetISpeed}, \seem{termios}{2}
817
For an example, see \seef{TCGetAttr}.
819
\begin{procedure}{CFSetISpeed}
821
Procedure CFSetISpeed (var Tios:TermIOS;Speed:Longint);
824
Sets the input baudrate in the \var{TermIOS} structure \var{Tios} to
830
\seep{CFSetOSpeed}, \seep{CFMakeRaw}, \seem{termios}{2}
833
\begin{procedure}{CFSetOSpeed}
835
Procedure CFSetOSpeed (var Tios:TermIOS;Speed:Longint);
838
Sets the output baudrate in the \var{Termios} structure \var{Tios} to
844
\seep{CFSetISpeed}, \seep{CFMakeRaw}, \seem{termios}{2}
847
\begin{function}{Chown}
849
Function Chown (Path : Pathstr;NewUid,NewGid : Longint) : Boolean;
851
\var{Chown} sets the User ID and Group ID of the file in \var{Path} to \var{NewUid,
853
The function returns \var{True} if the call was succesfull, \var{False} if the call
856
Errors are returned in \var{LinuxError}.
858
\item[sys\_eperm] The effective UID doesn't match the ownership of the file,
859
and is not zero. Owner or group were not specified correctly.
860
\item[sys\_eaccess] One of the directories in \var{Path} has no
861
search (=execute) permission.
862
\item[sys\_enoent] A directory entry in \var{Path} does
863
not exist or is a symbolic link pointing to a non-existent directory.
864
\item[sys\_enotdir] A directory entry in \var{OldPath} or \var{NewPath} is
866
\item[sys\_enomem] Insufficient kernel memory.
867
\item[sys\_erofs] The file is on a read-only filesystem.
868
\item[sys\_eloop] \var{Path} has a reference to a circular
869
symbolic link, i.e. a symbolic link, whose expansion points to itself.
872
\seef{Chmod}, \seef{Access}, \seem{Chown}(2)
877
\begin{function}{Chmod}
879
Function Chmod (Path : Pathstr;NewMode : Longint) : Boolean;
882
Sets the Mode bits of the file in \var{Path} to \var{NewMode}. Newmode can be
883
specified by 'or'-ing the following:
885
\item[S\_ISUID] Set user ID on execution.
886
\item[S\_ISGID] Set Group ID on execution.
887
\item[S\_ISVTX] Set sticky bit.
888
\item[S\_IRUSR] Read by owner.
889
\item[S\_IWUSR] Write by owner.
890
\item[S\_IXUSR] Execute by owner.
891
\item[S\_IRGRP] Read by group.
892
\item[S\_IWGRP] Write by group.
893
\item[S\_IXGRP] Execute by group.
894
\item[S\_IROTH] Read by others.
895
\item[S\_IWOTH] Write by others.
896
\item[S\_IXOTH] Execute by others.
897
\item[S\_IRWXO] Read, write, execute by others.
898
\item[S\_IRWXG] Read, write, execute by groups.
899
\item[S\_IRWXU] Read, write, execute by user.
903
Errors are returned in \var{LinuxError}.
905
\item[sys\_eperm] The effective UID doesn't match the ownership of the file,
906
and is not zero. Owner or group were not specified correctly.
907
\item[sys\_eaccess] One of the directories in \var{Path} has no
908
search (=execute) permission.
909
\item[sys\_enoent] A directory entry in \var{Path} does
910
not exist or is a symbolic link pointing to a non-existent directory.
911
\item[sys\_enotdir] A directory entry in \var{OldPath} or \var{NewPath} is
913
\item[sys\_enomem] Insufficient kernel memory.
914
\item[sys\_erofs] The file is on a read-only filesystem.
915
\item[sys\_eloop] \var{Path} has a reference to a circular
916
symbolic link, i.e. a symbolic link, whose expansion points to itself.
920
\seef{Chown}, \seef{Access}, \seem{Chmod}(2), \seef{Octal}
925
\begin{function}{Clone}
927
TCloneFunc=function(args:pointer):longint;cdecl;
928
Clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint;
930
Clone creates a child process which is a copy of the parent process, just
931
like \seef{Fork} does. In difference with \var{Fork}, however, the child
932
process shares some parts of it's execution context with its parent, so it
933
is suitable for the implementation of threads: many instances of a program
934
that share the same memory.
936
When the child process is created, it starts executing the function
937
\var{Func}, and passes it \var{Args}. The return value of \var{Func} is
938
either the explicit return value of the function, or the exit code of
941
The \var{sp} pointer points to the memory reserved as stack space for the
942
child process. This address should be the top of the memory block to be used
945
The \var{Flags} determine the behaviour of the \var{Clone} call. The low
946
byte of the Flags contains the number of the signal that will be sent to
947
the parent when the child dies.
948
This may be bitwise OR'ed with the following constants:
950
\item[CLONE\_VM] Parent and child share the same memory space, including
951
memory (un)mapped with subsequent \var{mmap} calls.
952
\item[CLONE\_FS] Parent and child have the same view of the filesystem;
953
the \var{chroot}, \var{chdir} and \var{umask} calls affect both processes.
954
\item[CLONE\_FILES] the file descriptor table of parent and child is shared.
955
\item[CLONE\_SIGHAND] the parent and child share the same table of signal
956
handlers. The signal masks are different, though.
957
\item[CLONE\_PID] PArent and child have the same process ID.
960
Clone returns the process ID in the parent process, and -1 if an error
963
On error, -1 is returned to the parent, and no child is created.
965
\item [sys\_eagain] Too many processes are running.
966
\item [sys\_enomem] Not enough memory to create child process.
969
\seef{Fork}, \seem{clone}{2}
974
\begin{function}{CloseDir}
976
Function CloseDir (p:pdir) : integer;
978
\var{CloseDir} closes the directory pointed to by \var{p}.
979
It returns zero if the directory was closed succesfully, -1 otherwise.
981
Errors are returned in LinuxError.
983
\seef{OpenDir}, \seef{ReadDir}, \seep{SeekDir}, \seef{TellDir},
986
For an example, see \seef{OpenDir}.
988
\begin{function}{CreateShellArgV}
990
function CreateShellArgV(const prog:string):ppchar;
991
function CreateShellArgV(const prog:Ansistring):ppchar;
993
\var{CreateShellArgV} creates an array of 3 \var{PChar} pointers that can
994
be used as arguments to \var{ExecVE} the first elements in the array
995
will contain \var{/bin/sh}, the second will contain \var{-c}, and the third
996
will contain \var{prog}.
998
The function returns a pointer to this array, of type \var{PPChar}.
1007
\begin{function}{DirName}
1009
Function DirName (Const Path : Pathstr) : Pathstr;
1011
Returns the directory part of \var{Path}.
1012
The directory is the part of \var{Path} before the last slash,
1013
or empty if there is no slash.
1014
The last character of the result is not a slash, unless the directory is the
1020
\seef{BaseName}, \seef{FExpand}, \seem{Dirname}{1}
1026
\begin{function}{Dup}
1028
Function Dup(oldfile:longint;var newfile:longint):Boolean;
1029
Function Dup(var oldfile,newfile:text):Boolean;
1030
Function Dup(var oldfile,newfile:file):Boolean;
1032
Makes \var{NewFile} an exact copy of \var{OldFile}, after having flushed the
1033
buffer of \var{OldFile} in case it is a Text file or untyped file.
1034
Due to the buffering mechanism of Pascal, this has not the same functionality
1035
as the \seem{dup}{2} call in C. The internal Pascal buffers are not the same
1036
after this call, but when the buffers are flushed (e.g. after output),
1037
the output is sent to the same file.
1038
Doing an lseek will, however, work as in C, i.e. doing a lseek will change
1039
the fileposition in both files.
1041
The function returns \var{False} in case of an error, \var{True} if
1044
In case of errors, \var{Linuxerror} is used to report errors.
1046
\item[sys\_ebadf] \var{OldFile} hasn't been assigned.
1047
\item[sys\_emfile] Maximum number of open files for the process is reached.
1050
\seef{Dup2}, \seem{Dup}{2}
1057
\begin{function}{Dup2}
1059
Function Dup2(oldfile,newfile:longint):Boolean;
1060
Function Dup2(var oldfile,newfile:text):Boolean;
1061
Function Dup2(var oldfile,newfile:file):Boolean;
1063
Makes \var{NewFile} an exact copy of \var{OldFile}, after having flushed the
1064
buffer of \var{OldFile} in the case of text or untyped files.
1066
\var{NewFile} can be an assigned file. If \var{newfile} was open, it is
1067
closed first. Due to the buffering mechanism of Pascal, this has not
1068
the same functionality as the \seem{dup2}{2} call in C. The internal Pascal
1069
buffers are not the same after this call, but when the buffers are flushed
1070
(e.g. after output), the output is sent to the same file.
1071
Doing an lseek will, however, work as in C, i.e. doing a lseek will change the
1072
fileposition in both files.
1074
The function returns \var{True} if succesful, false otherwise.
1076
In case of error, \var{Linuxerror} is used to report errors.
1078
\item[sys\_ebadf] \var{OldFile} hasn't been assigned.
1079
\item[sys\_emfile] Maximum number of open files for the process is reached.
1082
\seef{Dup}, \seem{Dup2}{2}
1089
\begin{procedure}{EpochToLocal}
1091
Procedure EpochToLocal (Epoch : Longint; var Year,Month,Day,Hour,Minute,Second : Word);
1093
Converts the epoch time (=Number of seconds since 00:00:00 , January 1,
1094
1970, corrected for your time zone ) to local date and time.
1096
This function takes into account the timzeone settings of your system.
1100
\seef{GetEpochTime}, \seef{LocalToEpoch}, \seep{GetTime},\seep{GetDate}
1105
\begin{procedure}{Execl}
1107
Procedure Execl (Path : pathstr);
1109
Replaces the currently running program with the program, specified in
1110
\var{path}. Path is split into a command and it's options.
1111
The executable in \var{path} is NOT searched in the path.
1112
The current environment is passed to the program.
1113
On success, \var{execl} does not return.
1116
Errors are reported in \var{LinuxError}:
1118
\item[sys\_eacces] File is not a regular file, or has no execute permission.
1119
A compononent of the path has no search permission.
1120
\item[sys\_eperm] The file system is mounted \textit{noexec}.
1121
\item[sys\_e2big] Argument list too big.
1122
\item[sys\_enoexec] The magic number in the file is incorrect.
1123
\item[sys\_enoent] The file does not exist.
1124
\item[sys\_enomem] Not enough memory for kernel, or to split command line.
1125
\item[sys\_enotdir] A component of the path is not a directory.
1126
\item[sys\_eloop] The path contains a circular reference (via symlinks).
1129
\seep{Execve}, \seep{Execv}, \seep{Execvp}, \seep{Execle},
1130
\seep{Execlp}, \seef {Fork}, \seem{execvp}{3}
1135
\begin{procedure}{Execle}
1137
Procedure Execle (Path : pathstr, Ep : ppchar);
1139
Replaces the currently running program with the program, specified in
1140
\var{path}. Path is split into a command and it's options.
1141
The executable in \var{path} is searched in the path, if it isn't
1142
an absolute filename.
1143
The environment in \var{ep} is passed to the program.
1144
On success, \var{execle} does not return.
1147
Errors are reported in \var{LinuxError}:
1149
\item[sys\_eacces] File is not a regular file, or has no execute permission.
1150
A compononent of the path has no search permission.
1151
\item[sys\_eperm] The file system is mounted \textit{noexec}.
1152
\item[sys\_e2big] Argument list too big.
1153
\item[sys\_enoexec] The magic number in the file is incorrect.
1154
\item[sys\_enoent] The file does not exist.
1155
\item[sys\_enomem] Not enough memory for kernel, or to split command line.
1156
\item[sys\_enotdir] A component of the path is not a directory.
1157
\item[sys\_eloop] The path contains a circular reference (via symlinks).
1160
\seep{Execve}, \seep{Execv}, \seep{Execvp},
1161
\seep{Execl}, \seep{Execlp}, \seef {Fork}, \seem{execvp}{3}
1166
\begin{procedure}{Execlp}
1168
Procedure Execlp (Path : pathstr);
1170
Replaces the currently running program with the program, specified in
1171
\var{path}. Path is split into a command and it's options.
1172
The executable in \var{path} is searched in the path, if it isn't
1173
an absolute filename.
1174
The current environment is passed to the program.
1175
On success, \var{execlp} does not return.
1178
Errors are reported in \var{LinuxError}:
1180
\item[sys\_eacces] File is not a regular file, or has no execute permission.
1181
A compononent of the path has no search permission.
1182
\item[sys\_eperm] The file system is mounted \textit{noexec}.
1183
\item[sys\_e2big] Argument list too big.
1184
\item[sys\_enoexec] The magic number in the file is incorrect.
1185
\item[sys\_enoent] The file does not exist.
1186
\item[sys\_enomem] Not enough memory for kernel, or to split command line.
1187
\item[sys\_enotdir] A component of the path is not a directory.
1188
\item[sys\_eloop] The path contains a circular reference (via symlinks).
1191
\seep{Execve}, \seep{Execv}, \seep{Execvp}, \seep{Execle},
1192
\seep{Execl}, \seef {Fork}, \seem{execvp}{3}
1197
\begin{procedure}{Execv}
1199
Procedure Execv (Path : pathstr; args : ppchar);
1201
Replaces the currently running program with the program, specified in
1203
It gives the program the options in \var{args}.
1204
This is a pointer to an array of pointers to null-terminated
1205
strings. The last pointer in this array should be nil.
1206
The current environment is passed to the program.
1207
On success, \var{execv} does not return.
1210
Errors are reported in \var{LinuxError}:
1212
\item[sys\_eacces] File is not a regular file, or has no execute permission.
1213
A compononent of the path has no search permission.
1214
\item[sys\_eperm] The file system is mounted \textit{noexec}.
1215
\item[sys\_e2big] Argument list too big.
1216
\item[sys\_enoexec] The magic number in the file is incorrect.
1217
\item[sys\_enoent] The file does not exist.
1218
\item[sys\_enomem] Not enough memory for kernel.
1219
\item[sys\_enotdir] A component of the path is not a directory.
1220
\item[sys\_eloop] The path contains a circular reference (via symlinks).
1223
\seep{Execve}, \seep{Execvp}, \seep{Execle},
1224
\seep{Execl}, \seep{Execlp}, \seef {Fork}, \seem{execv}{3}
1230
\begin{procedure}{Execve}
1232
Procedure Execve(Path:pchar;args:ppchar;ep:ppchar);
1233
Procedure Execve (Path : pathstr; args,ep : ppchar);
1235
Replaces the currently running program with the program, specified in
1237
It gives the program the options in \var{args}, and the environment in
1238
\var{ep}. They are pointers to an array of pointers to null-terminated
1239
strings. The last pointer in this array should be nil.
1240
On success, \var{execve} does not return.
1242
Errors are reported in \var{LinuxError}:
1244
\item[eacces] File is not a regular file, or has no execute permission.
1245
A compononent of the path has no search permission.
1246
\item[sys\_ eperm] The file system is mounted \textit{noexec}.
1247
\item[sys\_ e2big] Argument list too big.
1248
\item[sys\_ enoexec] The magic number in the file is incorrect.
1249
\item[sys\_ enoent] The file does not exist.
1250
\item[sys\_ enomem] Not enough memory for kernel.
1251
\item[sys\_ enotdir] A component of the path is not a directory.
1252
\item[sys\_ eloop] The path contains a circular reference (via symlinks).
1255
\seep{Execve}, \seep{Execv}, \seep{Execvp} \seep{Execle},
1256
\seep{Execl}, \seep{Execlp}, \seef {Fork}, \seem{execve}{2}
1261
\begin{procedure}{Execvp}
1263
Procedure Execvp (Path : pathstr; args : ppchar);
1265
Replaces the currently running program with the program, specified in
1266
\var{path}. The executable in \var{path} is searched in the path, if it isn't
1267
an absolute filename.
1268
It gives the program the options in \var{args}. This is a pointer to an array of pointers to null-terminated
1269
strings. The last pointer in this array should be nil.
1270
The current environment is passed to the program.
1271
On success, \var{execvp} does not return.
1274
Errors are reported in \var{LinuxError}:
1276
\item[sys\_eacces] File is not a regular file, or has no execute permission.
1277
A compononent of the path has no search permission.
1278
\item[sys\_eperm] The file system is mounted \textit{noexec}.
1279
\item[sys\_e2big] Argument list too big.
1280
\item[sys\_enoexec] The magic number in the file is incorrect.
1281
\item[sys\_enoent] The file does not exist.
1282
\item[sys\_enomem] Not enough memory for kernel.
1283
\item[sys\_enotdir] A component of the path is not a directory.
1284
\item[sys\_eloop] The path contains a circular reference (via symlinks).
1287
\seep{Execve}, \seep{Execv}, \seep{Execle},
1288
\seep{Execl}, \seep{Execlp}, \seef {Fork}, \seem{execvp}{3}
1294
\begin{procedurel}{FD\_ZERO}{FDZero}
1296
Procedure FD\_ZERO (var fds:fdSet);
1298
\var{FD\_ZERO} clears all the filedescriptors in the file descriptor
1306
\seepl{FD\_Clr}{FDClr},
1307
\seepl{FD\_Set}{FDSet},
1308
\seefl{FD\_IsSet}{FDIsSet}
1311
For an example, see \seef{Select}.
1313
\begin{procedurel}{FD\_Clr}{FDClr}
1315
Procedure FD\_Clr (fd:longint;var fds:fdSet);
1317
\var{FD\_Clr} clears file descriptor \var{fd} in filedescriptor s
1325
\seepl{FD\_ZERO}{FDZero},
1326
\seepl{FD\_Set}{FDSet},
1327
\seefl{FD\_IsSet}{FDIsSet}
1330
For an example, see \seef{Select}.
1332
\begin{functionl}{FD\_IsSet}{FDIsSet}
1334
Function FD\_IsSet (fd:longint;var fds:fdSet) : boolean;
1336
\var{FD\_Set} Checks whether file descriptor \var{fd} in filedescriptor set \var{fds}
1341
\seef{Select}, \seef{SelectText}, \seef{GetFS},
1342
\seepl{FD\_ZERO}{FDZero},
1343
\seepl{FD\_Clr}{FDClr},
1344
\seepl{FD\_Set}{FDSet}
1347
For an example, see \seef{Select}.
1349
\begin{procedurel}{FD\_Set}{FDSet}
1351
Procedure FD\_Set (fd:longint;var fds:fdSet);
1353
\var{FD\_Set} sets file descriptor \var{fd} in filedescriptor set \var{fds}.
1357
\seef{Select}, \seef{SelectText}, \seef{GetFS},\seepl{FD\_ZERO}{FDZero},
1358
\seepl{FD\_Clr}{FDClr}, \seefl{FD\_IsSet}{FDIsSet}
1361
For an example, see \seef{Select}.
1363
\begin{function}{fdClose}
1365
Function fdClose (fd:longint) : boolean;
1367
\var{fdClose} closes a file with file descriptor \var{Fd}. The function
1368
returns \var{True} if the file was closed successfully, \var{False}
1372
Errors are returned in LinuxError
1374
\seef{fdOpen}, \seef{fdRead}, \seef{fdWrite},\seef{fdTruncate},
1375
\seef{fdFlush}, seef{FdSeek}
1377
For an example, see \seef{fdOpen}.
1379
\begin{function}{fdFlush}
1381
Function fdFlush (fd:Longint) : boolean;
1383
\var{fdflush} flushes the Linux kernel file buffer, so the file is actually
1384
written to disk. This is NOT the same as the internal buffer, maintained by
1386
The function returns \var{True} if the call was successful, \var{false} if
1389
Errors are returned in LinuxError.
1391
\seef{fdOpen}, \seef{fdClose}, \seef{fdRead},\seef{fdWrite},
1392
\seef{fdTruncate}, \seef{fdSeek}
1394
For an example, see \seef{fdRead}.
1396
\begin{function}{fdOpen}
1398
Function fdOpen(PathName:String;flags:longint):longint;
1399
Function fdOpen(PathName:Pchar ;flags:longint):longint;
1400
Function fdOpen(PathName:String;flags,mode:longint):longint;
1401
Function fdOpen(PathName:Pchar ;flags,mode:longint):longint;
1403
\var{fdOpen} opens a file in \var{PathName} with flags \var{flags}
1404
One of the following:
1406
\item [Open\_RdOnly] File is opened Read-only.
1407
\item [Open\_WrOnly] File is opened Write-only.
1408
\item [Open\_RdWr] File is opened Read-Write.
1410
The flags may be\var{OR}-ed with one of the following constants:
1412
\item [Open\_Accmode] File is opened
1413
\item [Open\_Creat] File is created if it doesn't exist.
1414
\item [Open\_Excl] If the file is opened with \var{Open\_Creat} and it
1415
already exists, the call wil fail.
1416
\item [Open\_NoCtty] If the file is a terminal device, it will NOT become
1417
the process' controlling terminal.
1418
\item [Open\_Trunc] If the file exists, it will be truncated.
1419
\item [Open\_Append] the file is opened in append mode. {\em Before each
1420
write}, the file pointer is positioned at the end of the file.
1421
\item [Open\_NonBlock] The file is opened in non-blocking mode. No operation
1422
on the file descriptor will cause the calling process to wait till.
1423
\item [Open\_NDelay] Idem as \var{Open\_NonBlock}
1424
\item [Open\_Sync] The file is opened for synchronous IO. Any write
1425
operation on the file will not return untill the data is physically written
1427
\item [Open\_NoFollow] if the file is a symbolic link, the open fails.
1428
(\linux 2.1.126 and higher only)
1429
\item [Open\_Directory] if the file is not a directory, the open fails.
1430
(\linux 2.1.126 and higher only)
1432
\var{PathName} can be of type \var{PChar} or \var{String}.
1433
The optional \var{mode} argument specifies the permissions to set when opening
1434
the file. This is modified by the umask setting. The real permissions are
1435
\var{Mode and not umask}.
1436
The return value of the function is the filedescriptor, or a negative
1437
value if there was an error.
1440
Errors are returned in LinuxError
1442
\seef{fdClose}, \seef{fdRead}, \seef{fdWrite},\seef{fdTruncate},
1443
\seef{fdFlush}, \seef{fdSeek}
1448
\begin{function}{fdRead}
1450
Function fdRead (fd:longint;var buf;size:longint) : longint;
1452
\var{fdRead} reads at most \var{size} bytes from the file descriptor
1453
\var{fd}, and stores them in \var{buf}.
1454
The function returns the number of bytes actually read, or -1 if
1456
No checking on the length of \var{buf} is done.
1459
Errors are returned in LinuxError.
1461
\seef{fdOpen}, \seef{fdClose}, \seef{fdWrite},\seef{fdTruncate},
1462
\seef{fdFlush}, \seef{fdSeek}
1467
\begin{function}{fdSeek}
1469
Function fdSeek (fd,Pos,SeekType:longint) : longint;
1471
\var{fdSeek} sets the current fileposition of file \var{fd} to
1472
\var{Pos}, starting from \var{SeekType}, which can be one of the following:
1474
\item [Seek\_Set] \ \var{Pos} is the absolute position in the file.
1475
\item [Seek\_Cur] \ \var{Pos} is relative to the current position.
1476
\item [Seek\_end] \ \var{Pos} is relative to the end of the file.
1478
The function returns the new fileposition, or -1 of an error occurred.
1481
Errors are returned in LinuxError.
1483
\seef{fdOpen}, \seef{fdWrite}, \seef{fdClose},
1484
\seef{fdRead},\seef{fdTruncate},
1487
For an example, see \seef{fdOpen}.
1489
\begin{function}{fdTruncate}
1491
Function fdTruncate (fd,size:longint) : boolean;
1493
\var{fdTruncate} sets the length of a file in \var{fd} on \var{size}
1494
bytes, where \var{size} must be less than or equal to the current length of
1495
the file in \var{fd}.
1496
The function returns \var{True} if the call was successful, \var{false} if
1499
Errors are returned in LinuxError.
1501
\seef{fdOpen}, \seef{fdClose}, \seef{fdRead},\seef{fdWrite},\seef{fdFlush},
1505
\begin{function}{fdWrite}
1507
Function fdWrite (fd:longint;var buf;size:longint) : longint;
1509
\var{fdWrite} writes at most \var{size} bytes from \var{buf} to
1510
file descriptor \var{fd}.
1511
The function returns the number of bytes actually written, or -1 if an error
1515
Errors are returned in LinuxError.
1517
\seef{fdOpen}, \seef{fdClose}, \seef{fdRead},\seef{fdTruncate},
1518
\seef{fdSeek}, \seef{fdFlush}
1521
\begin{function}{FExpand}
1523
Function FExpand (Const Path: Pathstr) : pathstr;
1525
Expands \var {Path} to a full path, starting from root,
1526
eliminating directory references such as . and .. from the result.
1531
\seef{BaseName},\seef{DirName}
1536
\begin{function}{FLock}
1538
Function Flock (fd,mode : longint) : boolean;
1539
Function Flock (var T : text;mode : longint) : boolean;
1540
Function Flock (var F : File;mode : longint) : boolean;
1542
\var{FLock} implements file locking. it sets or removes a lock on the file
1543
\var{F}. F can be of type \var{Text} or \var{File}, or it can be a \linux
1544
filedescriptor (a longint)
1545
\var{Mode} can be one of the following constants :
1547
\item [LOCK\_SH] \ sets a shared lock.
1548
\item [LOCK\_EX] \ sets an exclusive lock.
1549
\item [LOCK\_UN] \ unlocks the file.
1550
\item [LOCK\_NB] \ This can be OR-ed together with the other.
1551
If this is done the application doesn't block when locking.
1554
The function returns \var{True} if successful, \var{False} otherwise.
1556
If an error occurs, it is reported in \var{LinuxError}.
1558
\seef{Fcntl}, \seem{flock}{2}
1561
\begin{function}{FNMatch}
1563
Function FNMatch(const Pattern,Name:string):Boolean;
1565
\var{FNMatch} returns \var{True} if the filename in \var{Name}
1566
matches the wildcard pattern in \var{Pattern}, \var{False} otherwise.
1568
\var{Pattern} can contain the wildcards \var{*} (match zero or more
1569
arbitrary characters) or \var{?} (match a single character).
1573
\seef{FSearch}, \seef{FExpand}
1578
\begin{function}{FSearch}
1580
Function FSearch (Path : pathstr;DirList : string) : Pathstr;
1582
Searches in \var{DirList}, a colon separated list of directories,
1583
for a file named \var{Path}. It then returns a path to the found file.
1585
An empty string if no such file was found.
1587
\seef{BaseName}, \seef{DirName}, \seef{FExpand}, \seef{FNMatch}
1592
\begin{procedurel}{FSplit}{LFsplit}
1594
Procedure FSplit(const Path:PathStr; \\
1595
Var Dir:DirStr;Var Name:NameStr;Var Ext:ExtStr);
1597
\var{FSplit} splits a full file name into 3 parts : A \var{Path}, a
1598
\var{Name} and an extension (in \var{ext}).
1599
The extension is taken to be all letters after the last dot (.).
1608
\begin{function}{FSStat}
1610
Function FSStat (Path : Pathstr; Var Info : statfs) : Boolean;
1611
Function FSStat (Fd:longint;Var Info:stat) : Boolean;
1613
Return in \var{Info} information about the filesystem on which the file
1614
\var{Path} resides, or on which the file with file descriptor \var{fd}
1616
Info is of type \var{statfs}. The function returns \var{True} if the call
1617
was succesfull, \var{False} if the call failed.
1619
\var{LinuxError} is used to report errors.
1621
\item[sys\_enotdir] A component of \var{Path} is not a directory.
1622
\item[sys\_einval] Invalid character in \var{Path}.
1623
\item[sys\_enoent] \var{Path} does not exist.
1624
\item[sys\_eaccess] Search permission is denied for component in
1626
\item[sys\_eloop] A circular symbolic link was encountered in \var{Path}.
1627
\item[sys\_eio] An error occurred while reading from the filesystem.
1631
\seef{FStat}, \seef{LStat}, \seem{statfs}{2}
1637
\begin{function}{FStat}
1639
Function FStat(Path:Pathstr;Var Info:stat):Boolean;
1640
Function FStat(Fd:longint;Var Info:stat):Boolean;
1641
Function FStat(var F:Text;Var Info:stat):Boolean;
1642
Function FStat(var F:File;Var Info:stat):Boolean;
1644
\var{FStat} gets information about the file specified in one of the
1647
\item [Path] a file on the filesystem.
1648
\item [Fd] a valid file descriptor.
1649
\item [F] an opened text file or untyped file.
1651
and stores it in \var{Info}, which is of type \var{stat}.
1652
The function returns \var{True} if the call was succesfull,
1653
\var{False} if the call failed.
1656
\var{LinuxError} is used to report errors.
1658
\item[sys\_enoent] \var{Path} does not exist.
1661
\seef{FSStat}, \seef{LStat}, \seem{stat}{2}
1666
\begin{function}{Fcntl}
1668
Function Fcntl(Fd:longint;Cmd:Integer):integer;
1669
Function Fcntl(var Fd:Text;Cmd:Integer):integer;
1671
Read a file's attributes. \var{Fd} is an assigned file, or a valid file
1673
\var{Cmd} speciefies what to do, and is one of the following:
1675
\item[F\_GetFd] Read the close\_on\_exec flag. If the low-order bit is 0, then
1676
the file will remain open across execve calls.
1677
\item[F\_GetFl] Read the descriptor's flags.
1678
\item[F\_GetOwn] Get the Process ID of the owner of a socket.
1682
\var{LinuxError} is used to report errors.
1684
\item[sys\_ebadf] \var{Fd} has a bad file descriptor.
1688
\seep{Fcntl}, \seem{Fcntl}{2}
1691
\begin{procedure}{Fcntl}
1693
Procedure Fcntl (Fd : text, Cmd : Integer; Arg : longint);
1694
Procedure Fcntl (Fd:longint;Cmd:longint;Arg:Longint);
1696
Read or Set a file's attributes. \var{Fd} is an assigned file or a
1697
valid file descriptor.
1698
\var{Cmd} speciefies what to do, and is one of the following:
1700
\item[F\_SetFd] Set the close\_on\_exec flag of \var{Fd}. (only the least
1701
siginificant bit is used).
1702
\item[F\_GetLk] Return the \var{flock} record that prevents this process from
1703
obtaining the lock, or set the \var{l\_type} field of the lock of there is no
1704
obstruction. Arg is a pointer to a flock record.
1705
\item[F\_SetLk] Set the lock or clear it (depending on \var{l\_type} in the
1706
\var{flock} structure). if the lock is held by another process, an error
1708
\item[F\_GetLkw] Same as for \textbf{F\_Setlk}, but wait until the lock is
1710
\item[F\_SetOwn] Set the Process or process group that owns a socket.
1715
\var{LinuxError} is used to report errors.
1717
\item[sys\_ebadf] \var{Fd} has a bad file descriptor.
1718
\item[sys\_eagain or sys\_eaccess] For \textbf{F\_SetLk}, if the lock is
1719
held by another process.
1723
\seef{Fcntl}, \seem{Fcntl}{2}, seef{FLock}
1726
\begin{function}{Fork}
1728
Function Fork : Longint;
1730
Fork creates a child process which is a copy of the parent process.
1731
Fork returns the process ID in the parent process, and zero in the child's
1732
process. (you can get the parent's PID with \seef{GetPPid}).
1735
On error, -1 is returned to the parent, and no child is created.
1737
\item [sys\_eagain] Not enough memory to create child process.
1740
\seep{Execve}, \seef{Clone}, \seem{fork}{2}
1743
\begin{function}{FRename}
1745
Function FReName (OldName,NewName : Pchar) : Boolean;
1746
Function FReName (OldName,NewName : String) : Boolean;
1748
\var{FRename} renames the file \var{OldName} to \var{NewName}. \var{NewName}
1749
can be in a different directory than \var{OldName}, but it cannot be on
1750
another partition (device). Any existing file on the new location will be replaced.
1752
If the operation fails, then the \var{OldName} file will be preserved.
1754
The function returns \var{True} on succes, \var{False} on failure.
1756
On error, errors are reported in \var{LinuxError}. Possible errors include:
1758
\item[sys\_eisdir] \var{NewName} exists and is a directory, but \var{OldName}
1760
\item[sys\_exdev] \var{NewName} and \var{OldName} are on different devices.
1761
\item[sys\_enotempty or sys\_eexist] \var{NewName} is an existing, non-empty
1763
\item[sys\_ebusy] \var{OldName} or \var{NewName} is a directory and is in
1764
use by another process.
1765
\item[sys\_einval] \var{NewName} is part of \var{OldName}.
1766
\item[sys\_emlink] \var{OldPath} or \var{NewPath} already have tha maximum
1767
amount of links pointing to them.
1768
\item[sys\_enotdir] part of \var{OldName} or \var{NewName} is not
1770
\item[sys\_efault] For the \var{pchar} case: One of the pointers points to
1772
\item[sys\_eaccess] access is denied when attempting to move the file.
1773
\item[sys\_enametoolong] Either \var{OldName} or \var{NewName} is too long.
1774
\item[sys\_enoent] a directory component in \var{OldName} or \var{NewName}
1776
\item[sys\_enomem] not enough kernel memory.
1777
\item[sys\_erofs] \var{NewName} or \var{OldName} is on a read-only file
1779
\item[sys\_eloop] too many symbolic links were encountered trying to expand
1780
\var{OldName} or \var{NewName}
1781
\item[sys\_enospc] the filesystem has no room for the new directory entry.
1788
\begin{procedure}{GetDate}
1790
Procedure GetDate (Var Year, Month, Day : Word) ;
1792
Returns the current date.
1796
\seef{GetEpochTime}, \seep{GetTime}, \seep{GetDateTime}, \seep{EpochToLocal}
1801
\begin{procedure}{GetDateTime}
1803
Procedure GetDateTime(Var Year,Month,Day,hour,minute,second:Word);
1805
Returns the current date and time. The time is corrected for the local time
1806
zone. This procedure is equivalent to the \seep{GetDate} and \var{GetTime}
1811
\seef{GetEpochTime}, \seep{GetTime}, \seep{EpochToLocal}, \seep{GetDate}
1816
\begin{function}{GetDomainName}
1818
Function GetDomainName : String;
1820
Get the domain name of the machine on which the process is running.
1821
An empty string is returned if the domain is not set.
1826
\seef{GetHostName},seem{Getdomainname}{2}
1831
\begin{function}{GetEGid}
1833
Function GetEGid : Longint;
1835
Get the effective group ID of the currently running process.
1839
\seef{GetGid}, \seem{getegid}{2}
1844
\begin{function}{GetEUid}
1846
Function GetEUid : Longint;
1848
Get the effective user ID of the currently running process.
1852
\seef{GetEUid}, \seem{geteuid}{2}
1857
\begin{function}{GetEnv}
1859
Function GetEnv (P : String) : PChar;
1861
Returns the value of the environment variable in \var{P}. If the variable is
1862
not defined, nil is returned. The value of the environment variable may be
1864
A PChar is returned to accomodate for strings longer than 255 bytes,
1865
\var{TERMCAP} and \var{LS\_COLORS}, for instance.
1870
\seem{sh}{1}, \seem{csh}{1}
1875
\begin{function}{GetEpochTime}
1877
Function GetEpochTime : longint;
1879
returns the number of seconds since 00:00:00 gmt, january 1, 1970.
1880
it is adjusted to the local time zone, but not to DST.
1885
\seep{EpochToLocal}, \seep{GetTime}, \seem{time}{2}
1890
\begin{function}{GetFS}
1892
Function GetFS (Var F : Any File Type) : Longint;
1894
\var{GetFS} returns the file selector that the kernel provided for your
1895
file. In principle you don' need this file selector. Only for some calls
1896
it is needed, such as the \seef{Select} call or so.
1898
In case the file was not opened, then -1 is returned.
1905
\begin{function}{GetGid}
1907
Function GetGid : Longint;
1909
Get the real group ID of the currently running process.
1913
\seef{GetEGid}, \seem{getgid}{2}
1918
\begin{function}{GetHostName}
1920
Function GetHostName : String;
1922
Get the hostname of the machine on which the process is running.
1923
An empty string is returned if hostname is not set.
1928
\seef{GetDomainName},seem{Gethostname}{2}
1933
\begin{procedure}{GetLocalTimezone}
1935
procedure GetLocalTimezone(timer:longint;var leap\_correct,leap\_hit:longint);
1936
procedure GetLocalTimezone(timer:longint);
1938
\var{GetLocalTimeZone} returns the local timezone information. It also
1939
initializes the \var{TZSeconds} variable, which is used to correct the epoch time
1942
There should never be any need to call this function directly. It is called by the
1943
initialization routines of the Linux unit.
1945
\seef{GetTimezoneFile}, \seep{ReadTimezoneFile}
1948
\begin{function}{GetPid}
1950
Function GetPid : Longint;
1952
Get the Process ID of the currently running process.
1956
\seef{GetPPid}, \seem{getpid}{2}
1961
\begin{function}{GetPPid}
1963
Function GetPPid : Longint;
1965
Get the Process ID of the parent process.
1969
\seef{GetPid}, \seem{getppid}{2}
1974
\begin{function}{GetPriority}
1976
Function GetPriority (Which,Who : Integer) : Integer;
1978
GetPriority returns the priority with which a process is running.
1979
Which process(es) is determined by the \var{Which} and \var{Who} variables.
1980
\var{Which} can be one of the pre-defined \var{Prio\_Process, Prio\_PGrp,
1981
Prio\_User}, in which case \var{Who} is the process ID, Process group ID or
1982
User ID, respectively.
1986
Error checking must be done on LinuxError, since a priority can be negative.
1988
\item[sys\_esrch] No process found using \var{which} and \var{who}.
1989
\item[sys\_einval] \var{Which} was not one of \var{Prio\_Process, Prio\_Grp
1994
\seef{SetPriority}, \seep{Nice}, \seem{Getpriority}{2}
1996
For an example, see \seep{Nice}.
1998
\begin{procedure}{GetTime}
2000
procedure GetTime(var hour,min,sec,msec,usec:word);
2001
procedure GetTime(var hour,min,sec,sec100:word);
2002
procedure GetTime(var hour,min,sec:word);
2004
Returns the current time of the day, adjusted to local time.
2005
Upon return, the parameters are filled with
2007
\item[hour] Hours since 00:00 today.
2008
\item[min] minutes in current hour.
2009
\item[sec] seconds in current minute.
2010
\item[sec100] hundreds of seconds in current second.
2011
\item[msec] milliseconds in current second.
2012
\item[usec] microseconds in current second.
2017
\seef{GetEpochTime}, \seep{GetDate}, \seep{GetDateTime}, \seep{EpochToLocal}
2022
\begin{procedure}{GetTimeOfDay}
2024
Procedure GetTimeOfDay(var tv:timeval);
2026
\var{GetTimeOfDay} returns the number of seconds since 00:00, January 1
2027
1970, GMT in a \var{timeval} record. This time NOT corrected any way,
2028
not taking into account timezones, daylight savings time and so on.
2030
It is simply a wrapper to the kernel system call. To get the local time,
2035
\seep{GetTime}, \seef{GetTimeOfDay}
2038
\begin{function}{GetTimeOfDay}
2040
Function GetTimeOfDay:longint;
2042
\var{GetTimeOfDay} returns the number of seconds since 00:00, January 1
2043
1970, GMT. This time NOT corrected any way, not taking into account
2044
timezones, daylight savings time and so on.
2046
It is simply a wrapper to the kernel system call. To get the local time,
2051
\seep{GetTimeOfDay}, \seep{GetTime}
2054
\begin{function}{GetTimezoneFile}
2056
function GetTimezoneFile:string;
2058
\var{GetTimezoneFile} returns the location of the current timezone file.
2059
The location of file is determined as follows:
2061
\item If \file{/etc/timezone} exists, it is read, and the contents of this
2062
file is returned. This should work on Debian systems.
2063
\item If \file{/usr/lib/zoneinfo/localtime} exists, then it is returned.
2064
(this file is a symlink to the timezone file on SuSE systems)
2065
\item If \file{/etc/localtime} exists, then it is returned.
2066
(this file is a symlink to the timezone file on RedHat systems)
2069
If no file was found, an empty string is returned.
2071
\seep{ReadTimezoneFile}
2074
\begin{function}{GetUid}
2076
Function GetUid : Longint;
2078
Get the real user ID of the currently running process.
2082
\seef{GetEUid}, \seem{getuid}{2}
2087
\begin{function}{Glob}
2089
Function Glob (Const Path : Pathstr) : PGlob;
2091
Glob returns a pointer to a glob structure which contains all filenames which
2092
exist and match the pattern in \var{Path}.
2093
The pattern can contain wildcard characters, which have their
2097
Returns nil on error, and \var{LinuxError} is set.
2099
\item[sys\_enomem] No memory on heap for glob structure.
2100
\item[others] As returned by the opendir call, and sys\_readdir.
2104
\seep{GlobFree}, \seem{Glob}{3}
2109
\begin{procedure}{GlobFree}
2111
Procedure GlobFree (Var P : Pglob);
2113
Releases the memory, occupied by a pglob structure. \var{P} is set to nil.
2119
For an example, see \seef{Glob}.
2121
\begin{procedure}{IOCtl}
2123
Procedure IOCtl (Handle,Ndx: Longint; Data: Pointer);
2125
This is a general interface to the Unix/ \linux ioctl call.
2126
It performs various operations on the filedescriptor \var{Handle}.
2127
\var{Ndx} describes the operation to perform.
2128
\var{Data} points to data needed for the \var{Ndx} function.
2129
The structure of this data is function-dependent, so we don't elaborate on
2131
For more information on this, see various manual pages under linux.
2135
Errors are reported in LinuxError. They are very dependent on the used
2136
function, that's why we don't list them here
2144
\begin{function}{IOperm}
2146
Function IOperm (From,Num : Cadinal; Value : Longint) : boolean;
2149
sets permissions on \var{Num} ports starting with port \var{From} to
2150
\var{Value}. The function returns \var{True} if the call was successfull,
2151
\var{False} otherwise.
2154
\item This works ONLY as root.
2155
\item Only the first \var{0x03ff} ports can be set.
2156
\item When doing a \seef{Fork}, the permissions are reset. When doing a
2157
\seep{Execve} they are kept.
2161
Errors are returned in \var{LinuxError}
2166
\begin{function}{IsATTY}
2168
Function IsATTY (var f) : Boolean;
2170
Check if the filehandle described by \var{f} is a terminal.
2173
\item \var{longint} for file handles;
2174
\item \var{Text} for \var{text} variables such as \var{input} etc.
2176
Returns \var{True} if \var{f} is a terminal, \var{False} otherwise.
2179
No errors are reported
2181
\seep{IOCtl},\seef{TTYName}
2183
\begin{functionl}{S\_ISBLK}{ISBLK}
2185
Function S\_ISBLK (m:integer) : boolean;
2187
\var{S\_ISBLK} checks the file mode \var{m} to see whether the file is a
2188
block device file. If so it returns \var{True}.
2192
\seefl{S\_ISLNK}{ISLNK},
2193
\seefl{S\_ISREG}{ISREG},
2194
\seefl{S\_ISDIR}{ISDIR},
2195
\seefl{S\_ISCHR}{ISCHR},
2196
\seefl{S\_ISFIFO}{ISFIFO},
2197
\seefl{S\_ISSOCK}{ISSOCK}
2202
\begin{functionl}{S\_ISCHR}{ISCHR}
2204
Function S\_ISCHR (m:integer) : boolean;
2206
\var{S\_ISCHR} checks the file mode \var{m} to see whether the file is a
2207
character device file. If so it returns \var{True}.
2211
\seefl{S\_ISLNK}{ISLNK},
2212
\seefl{S\_ISREG}{ISREG},
2213
\seefl{S\_ISDIR}{ISDIR},
2214
\seefl{S\_ISBLK}{ISBLK},
2215
\seefl{S\_ISFIFO}{ISFIFO},
2216
\seefl{S\_ISSOCK}{ISSOCK}
2221
\begin{functionl}{S\_ISDIR}{ISDIR}
2223
Function S\_ISDIR (m:integer) : boolean;
2225
\var{S\_ISDIR} checks the file mode \var{m} to see whether the file is a
2226
directory. If so it returns \var{True}
2230
\seefl{S\_ISLNK}{ISLNK},
2231
\seefl{S\_ISREG}{ISREG},
2232
\seefl{S\_ISCHR}{ISCHR},
2233
\seefl{S\_ISBLK}{ISBLK},
2234
\seefl{S\_ISFIFO}{ISFIFO},
2235
\seefl{S\_ISSOCK}{ISSOCK}
2240
\begin{functionl}{S\_ISFIFO}{ISFIFO}
2242
Function S\_ISFIFO (m:integer) : boolean;
2244
\var{S\_ISFIFO} checks the file mode \var{m} to see whether the file is a
2245
fifo (a named pipe). If so it returns \var{True}.
2249
\seefl{S\_ISLNK}{ISLNK},
2250
\seefl{S\_ISREG}{ISREG},
2251
\seefl{S\_ISDIR}{ISDIR},
2252
\seefl{S\_ISCHR}{ISCHR},
2253
\seefl{S\_ISBLK}{ISBLK},
2254
\seefl{S\_ISSOCK}{ISSOCK}
2260
\begin{functionl}{S\_ISLNK}{ISLNK}
2262
Function S\_ISLNK (m:integer) : boolean;
2264
\var{S\_ISLNK} checks the file mode \var{m} to see whether the file is a
2265
symbolic link. If so it returns \var{True}
2269
\seefl{S\_ISREG}{ISREG},
2270
\seefl{S\_ISDIR}{ISDIR},
2271
\seefl{S\_ISCHR}{ISCHR},
2272
\seefl{S\_ISBLK}{ISBLK},
2273
\seefl{S\_ISFIFO}{ISFIFO},
2274
\seefl{S\_ISSOCK}{ISSOCK}
2282
\begin{functionl}{S\_ISREG}{ISREG}
2284
Function S\_ISREG (m:integer) : boolean;
2286
\var{S\_ISREG} checks the file mode \var{m} to see whether the file is a
2287
regular file. If so it returns \var{True}
2291
\seefl{S\_ISLNK}{ISLNK},
2292
\seefl{S\_ISDIR}{ISDIR},
2293
\seefl{S\_ISCHR}{ISCHR},
2294
\seefl{S\_ISBLK}{ISBLK},
2295
\seefl{S\_ISFIFO}{ISFIFO},
2296
\seefl{S\_ISSOCK}{ISSOCK}
2301
\begin{functionl}{S\_ISSOCK}{ISSOCK}
2303
Function S\_ISSOCK (m:integer) : boolean;
2305
\var{S\_ISSOCK} checks the file mode \var{m} to see whether the file is a
2306
socket. If so it returns \var{True}.
2310
\seefl{S\_ISLNK}{ISLNK},
2311
\seefl{S\_ISREG}{ISREG},
2312
\seefl{S\_ISDIR}{ISDIR},
2313
\seefl{S\_ISCHR}{ISCHR},
2314
\seefl{S\_ISBLK}{ISBLK},
2315
\seefl{S\_ISFIFO}{ISFIFO}
2321
\begin{function}{Kill}
2323
Function Kill (Pid : Longint; Sig : Integer) : Integer;
2325
Send a signal \var{Sig} to a process or process group. If \var{Pid}>0 then
2326
the signal is sent to \var{Pid}, if it equals -1, then the signal is sent to
2327
all processes except process 1. If \var{Pid}<-1 then the signal is sent to
2329
The return value is zero, except in case three, where the return value is the
2330
number of processes to which the signal was sent.
2333
\var{LinuxError} is used to report errors:
2335
\item[sys\_einval] An invalid signal is sent.
2336
\item[sys\_esrch] The \var{Pid} or process group don't exist.
2337
\item[sys\_eperm] The effective userid of the current process doesn't math
2338
the one of process \var{Pid}.
2342
\seep{SigAction}, \seef{Signal}, \seem{Kill}{2}
2345
\begin{function}{LStat}
2347
Function LStat (Path : Pathstr; Var Info : stat) : Boolean;
2349
\var{LStat} gets information about the link specified in \var{Path}, and stores it in
2350
\var{Info}, which is of type \var{stat}. Contrary to \var{FStat}, it stores
2351
information about the link, not about the file the link points to.
2352
The function returns \var{True} if the call was succesfull, \var{False} if the call
2356
\var{LinuxError} is used to report errors.
2358
\item[sys\_enoent] \var{Path} does not exist.
2362
\seef{FStat}, \seef{FSStat}, \seem{stat}{2}
2367
\begin{function}{Link}
2369
Function Link (OldPath,NewPath : pathstr) : Boolean;
2371
\var{Link} makes \var{NewPath} point to the same file als \var{OldPath}. The two files
2372
then have the same inode number. This is known as a 'hard' link.
2373
The function returns \var{True} if the call was succesfull, \var{False} if the call
2377
Errors are returned in \var{LinuxError}.
2379
\item[sys\_exdev] \var {OldPath} and \var {NewPath} are not on the same
2381
\item[sys\_eperm] The filesystem containing oldpath and newpath doesn't
2382
support linking files.
2383
\item[sys\_eaccess] Write access for the directory containing \var{Newpath}
2384
is disallowed, or one of the directories in \var{OldPath} or {NewPath} has no
2385
search (=execute) permission.
2386
\item[sys\_enoent] A directory entry in \var{OldPath} or \var{NewPath} does
2387
not exist or is a symbolic link pointing to a non-existent directory.
2388
\item[sys\_enotdir] A directory entry in \var{OldPath} or \var{NewPath} is
2390
\item[sys\_enomem] Insufficient kernel memory.
2391
\item[sys\_erofs] The files are on a read-only filesystem.
2392
\item[sys\_eexist] \var{NewPath} already exists.
2393
\item[sys\_emlink] \var{OldPath} has reached maximal link count.
2394
\item[sys\_eloop] \var{OldPath} or \var{NewPath} has a reference to a circular
2395
symbolic link, i.e. a symbolic link, whose expansion points to itself.
2396
\item[sys\_enospc] The device containing \var{NewPath} has no room for anothe
2398
\item[sys\_eperm] \var{OldPath} points to . or .. of a directory.
2402
\seef{SymLink}, \seef{UnLink}, \seem{Link}{2}
2407
\begin{function}{LocalToEpoch}
2409
Function LocalToEpoch (Year,Month,Day,Hour,Minute,Second : Word) : longint;
2411
Converts the Local time to epoch time (=Number of seconds since 00:00:00 , January 1,
2417
\seef{GetEpochTime}, \seep{EpochToLocal}, \seep{GetTime},\seep{GetDate}
2422
\begin{function}{MkFifo}
2424
Function MkFifo (PathName: String; Mode : Longint) : Boolean;
2426
\var{MkFifo} creates named a named pipe in the filesystem, with name
2427
\var{PathName} and mode {Mode}.
2430
\var{LinuxError} is used to report errors:
2432
\item[sys\_emfile] Too many file descriptors for this process.
2433
\item[sys\_enfile] The system file table is full.
2437
\seep{POpen}, \seef{MkFifo}, \seem{mkfifo}{4}
2440
\begin{function}{MMap}
2442
Function MMap(const m:tmmapargs):longint;
2444
\var{MMap} maps or unmaps files or devices into memory. The different fields
2445
of the argument \var{m} determine what and how the \var{mmap} maps this:
2447
\item[address] Address where to mmap the device. This address is a hint,
2448
and may not be followed.
2449
\item[size] Size (in bytes) of area to be mapped.
2450
\item[prot] Protection of mapped memory. This is a OR-ed combination of the
2451
following constants:
2453
\item[PROT\_EXEC] The memory can be executed.
2454
\item[PROT\_READ] The memory can be read.
2455
\item[PROT\_WRITE] The memory can be written.
2456
\item[PROT\_NONE] The memory can not be accessed.
2458
\item[flags] Contains some options for the mmap call. It is an OR-ed
2459
combination of the following constants:
2461
\item[MAP\_FIXED] Do not map at another address than the given address. If the
2462
address cannot be used, \var{MMap} will fail.
2463
\item[MAP\_SHARED] Share this map with other processes that map this object.
2464
\item[MAP\_PRIVATE] Create a private map with copy-on-write semantics.
2465
\item[MAP\_ANONYMOUS] \var{fd} does not have to be a file descriptor.
2467
One of the options \var{MAP\_SHARED} and \var{MAP\_PRIVATE} must be present,
2468
but not both at the same time.
2469
\item[fd] File descriptor from which to map.
2470
\item[offset] Offset to be used in file descriptor fd.
2473
The function returns a pointer to the mapped memory, or a -1 in case of en
2476
On error, -1 is returned and LinuxError is set to the error code:
2478
\item[Sys\_EBADF] \var{fd} is not a valid file descriptor and
2479
\var{MAP\_ANONYMOUS} was not specified.
2480
\item[Sys\_EACCES] \var{MAP\_PRIVATE} was specified, but fd is not open for
2481
reading. Or \var{MAP\_SHARED} was asked and \var{PROT\_WRITE} is set, fd
2482
is not open for writing
2483
\item[Sys\_EINVAL] One of the record fields \var{Start}, \var{length} or
2484
\var{offset} is invalid.
2485
\item[Sys\_ETXTBUSY] \var{MAP\_DENYWRITE} was set but the object specified
2486
by fd is open for writing.
2487
\item[Sys\_EAGAIN] \var{fd} is locked, or too much memory is locked.
2488
\item[Sys\_ENOMEM] Not enough memory for this operation.
2491
\seef{MUnMap}, \seem{mmap}{2}
2496
\begin{function}{MUnMap}
2498
function MUnMap (P : Pointer; Size : Longint) : Boolean;
2500
\var{MUnMap} unmaps the memory block of size \var{Size}, pointed to by
2501
\var{P}, which was previously allocated with \seef{MMap}.
2503
The function returns \var{True} if successful, \var{False} otherwise.
2505
In case of error the function returns \var{False} and \var{LinuxError}
2506
is set to an error value. See \seef{MMap} for possible error values.
2508
\seef{MMap}, \seem{munmap}{2}
2511
For an example, see \seef{MMap}.
2513
\begin{function}{NanoSleep}
2515
Function NanoSleep(const req : timespec;var rem : timespec) : longint;
2517
\var{NanoSleep} suspends the process till a time period as specified
2518
in \var{req} has passed. Then the function returns. If the
2519
call was interrupted (e.g. by some signal) then the function may
2520
return earlier, and \var{rem} will contain the remaining time till the
2521
end of the intended period. In this case the return value will be
2522
-1, and \var{LinuxError} will be set to \var{EINTR}
2524
If the function returns without error, the return value is zero.
2526
If the call was interrupted, -1 is returned, and \var{LinuxError} is set
2527
to \var{EINTR}. If invalid time values were specified, then -1 is returned
2528
and \var{LinuxError} is set to \var{EINVAL}.
2530
\seep{Pause}, \seef{Alarm}
2535
\begin{procedure}{Nice}
2537
Procedure Nice ( N : Integer);
2539
\var{Nice} adds \var{-N} to the priority of the running process. The lower the
2540
priority numerically, the less the process is favored.
2541
Only the superuser can specify a negative \var{N}, i.e. increase the rate at
2542
which the process is run.
2545
Errors are returned in \var{LinuxError}
2547
\item [sys\_eperm] A non-superuser tried to specify a negative \var{N}, i.e.
2548
do a priority increase.
2552
\seef{GetPriority}, \seef{SetPriority}, \seem{Nice}{2}
2557
\begin{function}{Octal}
2559
Function Octal(l:longint):longint;
2561
\var{Octal} will convert a number specified as an octal number to it's
2564
This is useful for the \seef{Chmod} call, where permissions are specified
2567
No checking is performed whether the given number is a correct Octal number.
2568
e.g. specifying \var{998} is possible; the result will be wrong in that
2576
\begin{function}{OpenDir}
2578
Function OpenDir (f:pchar) : pdir;
2579
Function OpenDir (f:string) : pdir;
2581
\var{OpenDir} opens the directory \var{f}, and returns a \var{pdir}
2582
pointer to a \var{Dir} record, which can be used to read the directory
2583
structure. If the directory cannot be opened, \var{nil} is returned.
2585
Errors are returned in LinuxError.
2587
\seef{CloseDir}, \seef{ReadDir}, \seep{SeekDir}, \seef{TellDir},
2595
\begin{procedure}{pause}
2599
\var{Pause} puts the process to sleep and waits until the application
2600
receives a signal. If a signal handler is installed for the received
2601
sigal, the handler will be called and after that pause will return
2602
control to the process.
2607
For an example, see \seef{Alarm}.
2610
\begin{function}{PClose}
2612
Function PClose (Var F : FileType) : longint;
2614
\var{PClose} closes a file opened with \var{POpen}. It waits for the
2615
command to complete, and then returns the exit status of the command.
2618
\var{LinuxError} is used to report errors. If it is different from zero,
2619
the exit status is not valid.
2623
For an example, see \seep{POpen}
2625
\begin{procedure}{POpen}
2627
Procedure POpen (Var F : FileType; Cmd : pathstr; rw : char);
2629
Popen runs the command specified in \var{Cmd},
2630
and redirects the standard in or output of the
2631
command to the other end of the pipe \var{F}. The parameter \var{rw}
2632
indicates the direction of the pipe. If it is set to \var{'W'}, then F can
2633
be used to write data, which will then be read by the command from stdinput.
2634
If it is set to \var{'R'}, then the standard output of the command can be
2635
read from \var{F}. \var{F} should be reset or rewritten prior to using it.
2636
\var{F} can be of type \var{Text} or \var{File}.
2637
A file opened with \var {POpen} can be closed with \var{Close}, but also
2638
with \seef{PClose}. The result is the same, but \var{PClose} returns the
2639
exit status of the command \var{Cmd}.
2641
Errors are reported in \var{LinuxError} and are essentially those of the
2642
Execve, Dup and AssignPipe commands.
2645
\seef{AssignPipe}, \seem{popen}{3}, \seef{PClose}
2650
\begin{function}{ReadDir}
2652
Function ReadDir (p:pdir) : pdirent;
2654
\var{ReadDir} reads the next entry in the directory pointed to by \var{p}.
2655
It returns a \var{pdirent} pointer to a structure describing the entry.
2656
If the next entry can't be read, \var{Nil} is returned.
2659
Errors are returned in LinuxError.
2661
\seef{CloseDir}, \seef{OpenDir}, \seep{SeekDir}, \seef{TellDir},
2665
For an example, see \seef{OpenDir}.
2667
\begin{function}{ReadLink}
2669
Function ReadLink(name,linkname:pchar;maxlen:longint):longint;
2670
Function ReadLink(name:pathstr):pathstr;
2672
\var{ReadLink} returns the file the symbolic link \var{name} is pointing
2673
to. The first form of this function accepts a buffer \var{linkname} of
2674
length \var{maxlen} where the filename will be stored. It returns the
2675
actual number of characters stored in the buffer.
2677
The second form of the function returns simply the name of the file.
2679
On error, the first form of the function returns -1; the second one returns
2680
an empty string. \var{LinuxError} is set to report errors:
2682
\item[SYS\_ENOTDIR] A part of the path in \var{Name} is not a directory.
2683
\item[SYS\_EINVAL] maxlen is not positive, or the file is not a symbolic link.
2684
\item[SYS\_ENAMETOOLONG] A pathname, or a component of a pathname, was too
2686
\item[SYS\_ENOENT] the link \var{name} does not exist.
2687
\item[SYS\_EACCES] No permission to search a directory in the path
2688
\item[SYS\_ELOOP] Too many symbolic links were encountered in trans�
2689
lating the pathname.
2690
\item[SYS\_EIO] An I/O error occurred while reading from the file
2692
\item[SYS\_EFAULT] The buffer is not part of the the process's memory space.
2693
\item[SYS\_ENOMEM] Not enough kernel memory was available.
2701
\begin{procedure}{ReadPort}
2703
Procedure ReadPort (Port : Longint; Var Value : Byte);
2704
Procedure ReadPort (Port : Longint; Var Value : Word);
2705
Procedure ReadPort (Port : Longint; Var Value : Longint);
2707
\var{ReadPort} reads one Byte, Word or Longint from port \var{Port} into
2710
Note that you need permission to read a port. This permission can be set by
2711
the root user with the \seef{IOperm} call.
2713
In case of an error (not enough permissions read this port), runtime 216
2714
({\em Access Violation}) will occur.
2717
\seef{IOperm}, \seep{ReadPortB}, \seep{ReadPortW}, \seep{ReadPortL},\seep{WritePort},
2718
\seep{WritePortB}, \seep{WritePortL}, \seep{WritePortW}
2721
\begin{procedure}{ReadPortB}
2723
Procedure ReadPortB (Port : Longint; Var Buf; Count: longint);
2724
Function ReadPortB (Port : Longint): Byte;
2726
The procedural form of \var{ReadPortB} reads \var{Count} bytes from port
2727
\var{Port} and stores them in \var{Buf}. There must be enough memory
2728
allocated at \var{Buf} to store \var{Count} bytes.
2730
The functional form of \var{ReadPortB} reads 1 byte from port \var{B}
2731
and returns the byte that was read.
2733
Note that you need permission to read a port. This permission can be set by
2734
the root user with the \seef{IOperm} call.
2737
In case of an error (not enough permissions read this port), runtime 216
2738
({\em Access Violation}) will occur.
2741
\seef{IOperm}, \seep{ReadPort}, \seep{ReadPortW}, \seep{ReadPortL},\seep{WritePort},
2742
\seep{WritePortB}, \seep{WritePortL}, \seep{WritePortW}
2745
\begin{procedure}{ReadPortL}
2747
function ReadPortL (Port : Longint): LongInt;
2748
Procedure ReadPortL (Port : Longint; Var Buf; Count: longint);
2750
The procedural form of \var{ReadPortL} reads \var{Count} longints from port
2751
\var{Port} and stores them in \var{Buf}. There must be enough memory
2752
allocated at \var{Buf} to store \var{Count} Longints.
2754
The functional form of \var{ReadPortB} reads 1 longint from port \var{B}
2755
and returns the longint that was read.
2757
Note that you need permission to read a port. This permission can be set by
2758
the root user with the \seef{IOperm} call.
2760
In case of an error (not enough permissions read this port), runtime 216
2761
({\em Access Violation}) will occur.
2763
\seef{IOperm}, \seep{ReadPort}, \seep{ReadPortW}, \seep{ReadPortB},\seep{WritePort},
2764
\seep{WritePortB}, \seep{WritePortL}, \seep{WritePortW}
2767
\begin{procedure}{ReadPortW}
2769
Procedure ReadPortW (Port : Longint; Var Buf; Count: longint);
2770
function ReadPortW (Port : Longint): Word;
2772
The procedural form of \var{ReadPortB} reads \var{Count} words from port
2773
\var{Port} and stores them in \var{Buf}. There must be enough memory
2774
allocated at \var{Buf} to store \var{Count} words.
2776
The functional form of \var{ReadPortB} reads 1 word from port \var{B}
2777
and returns the word that was read.
2779
Note that you need permission to read a port. This permission can be set by
2780
the root user with the \seef{IOperm} call.
2782
In case of an error (not enough permissions read this port), runtime 216
2783
({\em Access Violation}) will occur.
2785
\seef{IOperm}, \seep{ReadPort}, \seep{ReadPortB}, \seep{ReadPortL},\seep{WritePort},
2786
\seep{WritePortB}, \seep{WritePortL}, \seep{WritePortW}
2790
\begin{procedure}{ReadTimezoneFile}
2792
procedure ReadTimezoneFile(fn:string);
2794
\var{ReadTimeZoneFile} reads the timezone file \var{fn} and initializes
2795
the local time routines based on the information found there.
2797
There should be no need to call this function. The initialization routines
2798
of the \file{linux} unit call this routine at unit startup.
2802
\seef{GetTimezoneFile}, \seep{GetLocalTimezone}
2806
\begin{procedure}{SeekDir}
2808
Procedure SeekDir (p:pdir;off:longint);
2810
\var{SeekDir} sets the directory pointer to the \var{off}-th entry in the
2811
directory structure pointed to by \var{p}.
2813
Errors are returned in LinuxError.
2815
\seef{CloseDir}, \seef{ReadDir}, \seef{OpenDir}, \seef{TellDir},
2818
For an example, see \seef{OpenDir}.
2820
\begin{function}{Select}
2822
Function Select (N : Longint; \\ var readfds,writefds,exceptfds : PFDset;
2823
Var Timeout) : Longint;
2825
\var{Select} checks one of the file descriptors in the \var{FDSets} to see if its
2827
\var{readfds, writefds} and \var{exceptfds} are pointers to arrays of 256
2828
bits. If you want a file descriptor to be checked, you set the
2829
corresponding element in the array to 1. The other elements in the array
2830
must be set to zero. Three arrays are passed : The entries in \var{readfds}
2831
are checked to see if characters become available for reading. The entries
2832
in \var{writefds} are checked to see if it is OK to write to them, while
2833
entries in \var{exceptfds} are cheked to see if an exception occorred on
2835
You can use the functions \seepl{FD\_ZERO}{FDZero}, \seepl{FD\_Clr}{FDClr},
2836
\seepl{FD\_Set}{FDSet}, \seefl{FD\_IsSet}{FDIsSet} to manipulate the individual elements of a set.
2837
The pointers can be nil.
2838
\var{N} is the largest index of a nonzero entry plus 1. (= the largest
2839
file-descriptor + 1).
2840
\var{TimeOut} can be used to set a time limit.
2841
If \var{TimeOut} can be two types :
2843
\item \var{TimeOut} is of type \var{PTime} and contains a
2844
zero time, the call returns immediately. If \var{TimeOut} is \var{Nil}, the
2845
kernel will wait forever, or until a status changed.
2846
\item \var{TimeOut} is of type \var{Longint}. If it is -1, this has the same
2847
effect as a \var{Timeout} of type \var{PTime} which is \var{Nil}.
2848
Otherwise, \var{TimeOut} contains a time in milliseconds.
2851
When the TimeOut is reached, or one of the file descriptors has changed,
2852
the \var{Select} call returns. On return, it will have modified the entries
2853
in the array which have actually changed, and it returns the number of
2854
entries that have been changed. If the timout was reached, and no decsriptor
2855
changed, zero is returned; The arrays of indexes are undefined after that.
2856
On error, -1 is returned.
2858
On error, the function returns -1, and Errors are reported in LinuxError :
2860
\item[SYS\_EBADF\ ] An invalid descriptot was specified in one of the sets.
2861
\item[SYS\_EINTR\ ] A non blocked signal was caught.
2862
\item[SYS\_EINVAL\ ] \var{N} is negative or too big.
2863
\item[SYS\_ENOMEM\ ] \var{Select} was unable to allocate memory for its
2867
\seef{SelectText}, \seef{GetFS},
2868
\seepl{FD\_ZERO}{FDZero},
2869
\seepl{FD\_Clr}{FDClr},
2870
\seepl{FD\_Set}{FDSet},
2871
\seefl{FD\_IsSet}{FDIsSet}
2876
\begin{function}{SelectText}
2878
Function SelectText ( var T : Text; TimeOut :PTime) : Longint;
2880
\var{SelectText} executes the \seef{Select} call on a file of type
2881
\var{Text}. You can specify a timeout in \var{TimeOut}. The SelectText call
2882
determines itself whether it should check for read or write, depending on
2883
how the file was opened : With \var{Reset} it is checked for reading, with
2884
\var{Rewrite} and \var{Append} it is checked for writing.
2886
See \seef{Select}. \var{SYS\_EBADF} can also mean that the file wasn't
2889
\seef{Select}, \seef{GetFS}
2892
\begin{function}{SetPriority}
2894
Function SetPriority (Which,Who,Prio : Integer) : Integer;
2896
SetPriority sets the priority with which a process is running.
2897
Which process(es) is determined by the \var{Which} and \var{Who} variables.
2898
\var{Which} can be one of the pre-defined \var{Prio\_Process, Prio\_PGrp,
2899
Prio\_User}, in which case \var{Who} is the process ID, Process group ID or
2900
User ID, respectively.
2901
\var{Prio} is a value in the range -20 to 20.
2905
Error checking must be done on LinuxError, since a priority can be negative.
2907
\item[sys\_esrch] No process found using \var{which} and \var{who}.
2908
\item[sys\_einval] \var{Which} was not one of \var{Prio\_Process, Prio\_Grp
2910
\item[sys\_eperm] A process was found, but neither its effective or real
2911
user ID match the effective user ID of the caller.
2912
\item [sys\_eacces] A non-superuser tried to a priority increase.
2916
\seef{GetPriority}, \seep{Nice}, \seem{Setpriority}{2}
2918
For an example, see \seep{Nice}.
2920
\begin{function}{Shell}
2922
Function Shell (Command : String) : Longint;
2924
\var{Shell} invokes the bash shell (\file{/bin/sh}), and feeds it the
2925
command \var{Command} (using the \var{-c} option). The function then waits
2926
for the command to complete, and then returns the exit
2927
status of the command, or 127 if it could not complete the \seef{Fork}
2928
or \seep{Execve} calls.
2931
Errors are reported in LinuxError.
2933
\seep{POpen}, \seef{Fork}, \seep{Execve}, \seem{system}{3}
2938
\begin{procedure}{SigAction}
2940
Procedure SigAction (Signum : Integer; Var Act,OldAct : PSigActionRec);
2942
Changes the action to take upon receipt of a signal. \var{Act} and
2943
\var{Oldact} are pointers to a \var{SigActionRec} record.
2944
\var{SigNum} specifies the signal, and can be any signal except
2945
\textbf{SIGKILL} or \textbf{SIGSTOP}.
2946
If \var{Act} is non-nil, then the new action for signal \var{SigNum} is taken
2947
from it. If \var{OldAct} is non-nil, the old action is stored there.
2948
\var{Sa\_Handler} may be \var{SIG\_DFL} for the default action or
2949
\var{SIG\_IGN} to ignore the signal.
2950
\var{Sa\_Mask} Specifies which signals should be ignord during the execution
2951
of the signal handler.
2952
\var{Sa\_Flags} Speciefies a series of flags which modify the behaviour of
2953
the signal handler. You can 'or' none or more of the following :
2955
\item[SA\_NOCLDSTOP] If signum is \textbf{SIGCHLD} do not receive
2956
notification when child processes stop.
2957
\item[SA\_ONESHOT or SA\_RESETHAND] Restore the signal action to the default
2958
state once the signal handler has been called.
2959
\item[SA\_RESTART] For compatibility with BSD signals.
2960
\item[SA\_NOMASK or SA\_NODEFER] Do not prevent the signal from being received
2961
from within its own signal handler.
2965
\var{LinuxError} is used to report errors.
2967
\item[sys\_einval] an invalid signal was specified, or it was
2968
\textbf{SIGKILL} or \textbf{SIGSTOP}.
2969
\item[sys\_efault] \var{Act,OldAct} point outside this process address space
2970
\item[sys\_eintr] System call was interrupted.
2975
\seep{SigProcMask}, \seef{SigPending}, \seep{SigSuspend}, \seef{Kill},
2982
\begin{function}{SigPending}
2984
Function SigPending : SigSet;
2986
Sigpending allows the examination of pending signals (which have been raised
2987
while blocked.) The signal mask of pending signals is returned.
2992
\seep{SigAction}, \seep{SigProcMask}, \seep{SigSuspend}, \seef{Signal},
2993
\seef{Kill}, \seem{Sigpending}{2}
2996
\begin{procedure}{SigProcMask}
2998
Procedure SigProcMask (How : Integer; SSet,OldSSet : PSigSet);
3000
Changes the list of currently blocked signals. The behaviour of the call
3001
depends on \var{How} :
3003
\item[SIG\_BLOCK] The set of blocked signals is the union of the current set
3004
and the \var{SSet} argument.
3005
\item[SIG\_UNBLOCK] The signals in \var{SSet} are removed from the set of
3006
currently blocked signals.
3007
\item[SIG\_SETMASK] The list of blocked signals is set so \var{SSet}.
3009
If \var{OldSSet} is non-nil, then the old set is stored in it.
3012
\var{LinuxError} is used to report errors.
3014
\item[sys\_efault] \var{SSet} or \var{OldSSet} point to an adress outside
3015
the range of the process.
3016
\item[sys\_eintr] System call was interrupted.
3020
\seep{SigAction}, \seef{SigPending}, \seep{SigSuspend}, \seef{Kill},
3021
\seem{Sigprocmask}{2}
3024
\begin{procedure}{SigRaise}
3026
Procedure SigRaise(Sig:integer);
3028
\var{SigRaise} sends a \var{Sig} signal to the current process.
3032
\seef{Kill}, \seef{GetPid}
3037
\begin{procedure}{SigSuspend}
3039
Procedure SigSuspend (Mask : SigSet);
3041
SigSuspend temporarily replaces the signal mask for the process with the one
3042
given in \var{Mask}, and then suspends the process until a signal is received.
3047
\seep{SigAction}, \seep{SigProcMask}, \seef{SigPending}, \seef{Signal},
3048
\seef{Kill}, \seem{SigSuspend}{2}
3051
\begin{function}{Signal}
3053
Function Signal (SigNum : Integer; Handler : SignalHandler) : SignalHandler;
3055
Signal installs a new signal handler for signal \var{SigNum}. This call has
3056
the same functionality as the \textbf{SigAction} call.
3057
The return value for Signal is the old signal handler, or nil on error.
3060
\var {LinuxError} is used to report errors :
3062
\item[SIG\_ERR] An error occurred.
3066
\seep{SigAction},\seef{Kill}, \seem{Signal}{2}
3071
\begin{function}{StringToPPchar}
3073
Function StringToPPChar(Var S:STring):ppchar;
3075
\var{StringToPPChar} splits the string \var{S} in words, replacing any
3076
whitespace with zero characters. It returns a pointer to an array of pchars
3077
that point to the first letters of the words in S. This array is terminated
3078
by a \var{Nil} pointer.
3080
The function does {\em not} add a zero character to the end of the string
3081
unless it ends on whitespace.
3083
The function reserves memory on the heap to store the array of \var{PChar};
3084
The caller is responsible for freeing this memory.
3086
This function can be called to create arguments for the various \var{Exec}
3091
\seef{CreateShellArgV}, \seep{Execve}, \seep{Execv}
3096
\begin{function}{SymLink}
3098
Function SymLink (OldPath,NewPath : pathstr) : Boolean;
3100
\var{SymLink} makes \var{Newpath} point to the file in \var{OldPath}, which doesn't
3101
necessarily exist. The two files DO NOT have the same inode number.
3102
This is known as a 'soft' link.
3103
The permissions of the link are irrelevant, as they are not used when
3104
following the link. Ownership of the file is only checked in case of removal
3105
or renaming of the link.
3106
The function returns \var{True} if the call was succesfull, \var{False} if the call
3110
Errors are returned in \var{LinuxError}.
3112
\item[sys\_eperm] The filesystem containing oldpath and newpath doesn't
3113
support linking files.
3114
\item[sys\_eaccess] Write access for the directory containing \var{Newpath}
3115
is disallowed, or one of the directories in \var{OldPath} or {NewPath} has no
3116
search (=execute) permission.
3117
\item[sys\_enoent] A directory entry in \var{OldPath} or \var{NewPath} does
3118
not exist or is a symbolic link pointing to a non-existent directory.
3119
\item[sys\_enotdir] A directory entry in \var{OldPath} or \var{NewPath} is
3121
\item[sys\_enomem] Insufficient kernel memory.
3122
\item[sys\_erofs] The files are on a read-only filesystem.
3123
\item[sys\_eexist] \var{NewPath} already exists.
3124
\item[sys\_eloop] \var{OldPath} or \var{NewPath} has a reference to a circular
3125
symbolic link, i.e. a symbolic link, whose expansion points to itself.
3126
\item[sys\_enospc] The device containing \var{NewPath} has no room for anothe
3130
\seef{Link}, \seef{UnLink}, \seef{ReadLink}, \seem{Symlink}{2}
3135
\begin{function}{SysInfo}
3137
Function SysInfo(var Info:TSysinfo):Boolean;
3139
\var{SysInfo} returns system information in \var{Info}. Returned information
3140
in \var{Info} includes:
3142
\item[uptime] Number of seconds since boot.
3143
\item[loads] 1, 5 and 15 minute load averages.
3144
\item[totalram] total amount of main memory.
3145
\item[freeram] amount of free memory.
3146
\item[sharedram] amount of shared memory
3147
\item[bufferram] amount of memory used by buffers.
3148
\item[totalswap] total amount of swapspace.
3149
\item[freeswap] amount of free swapspace.
3150
\item[procs] number of current processes.
3160
\begin{function}{TCDrain}
3162
Function TCDrain (Fd:longint) : Boolean;
3165
waits until all data to file descriptor \var{Fd} is transmitted.
3167
The function returns \var{True} if the call was succesfull, \var{False}
3171
Errors are reported in LinuxError
3176
\begin{function}{TCFlow}
3178
Function TCFlow (Fd,Act:longint) : Boolean;
3181
suspends/resumes transmission or reception of data to or from the file
3182
descriptor \var{Fd}, depending
3183
on the action \var {Act}. This can be one of the following pre-defined
3186
\item [TCOOFF\ ] suspend reception/transmission,
3187
\item [TCOON\ ] resume reception/transmission,
3188
\item [TCIOFF\ ] transmit a stop character to stop input from the terminal,
3189
\item [TCION\ ] transmit start to resume input from the terminal.
3191
The function returns \var{True} if the call was succesfull, \var{False}
3195
Errors are reported in LinuxError.
3200
\begin{function}{TCFlush}
3202
Function TCFlush (Fd,QSel:longint) : Boolean;
3205
discards all data sent or received to/from file descriptor \var{fd}.
3206
\var{QSel} indicates which queue
3207
should be discard. It can be one of the following pre-defined values :
3209
\item [TCIFLUSH\ ] input,
3210
\item [TCOFLUSH\ ] output,
3211
\item [TCIOFLUSH\ ] both input and output.
3213
The function returns \var{True} if the call was succesfull, \var{False}
3217
Errors are reported in LinuxError.
3222
\begin{function}{TCGetAttr}
3224
Function TCGetAttr (fd:longint;var tios:TermIOS) : Boolean;
3227
gets the terminal parameters from the terminal referred to by the file
3228
descriptor \var{fd} and returns them in a \var{TermIOS} structure \var{tios}.
3229
The function returns \var{True} if the call was succesfull, \var{False}
3233
Errors are reported in LinuxError
3235
\seef{TCSetAttr}, \seem{termios}{2}
3240
\begin{function}{TCGetPGrp}
3242
Function TCGetPGrp (Fd:longint;var Id:longint) : boolean;
3245
returns the process group ID of a foreground process group in \var{Id}
3246
The function returns \var{True} if the call was succesfull, \var{False}
3250
Errors are reported in LinuxError
3255
\begin{function}{TCSendBreak}
3257
Function TCSendBreak (Fd,Duration:longint) : Boolean;
3260
Sends zero-valued bits on an asynchrone serial connection decsribed by
3261
file-descriptor \var{Fd}, for duration \var{Duration}.
3262
The function returns \var{True} if the action was performed successfully,
3263
\var{False} otherwise.
3266
Errors are reported in LinuxError.
3271
\begin{function}{TCSetAttr}
3273
Function TCSetAttr (Fd:longint;OptAct:longint;var Tios:TermIOS) : Boolean;
3276
Sets the terminal parameters you specify in a \var{TermIOS} structure
3277
\var{Tios} for the terminal
3278
referred to by the file descriptor \var{Fd}. \var{OptAct} specifies an
3279
optional action when the set need to be done,
3280
this could be one of the following pre-defined values:
3282
\item [TCSANOW\ ] set immediately.
3283
\item [TCSADRAIN\ ] wait for output.
3284
\item [TCSAFLUSH\ ] wait for output and discard all input not yet read.
3286
The function Returns \var{True} if the call was succesfull, \var{False}
3290
Errors are reported in LinuxError.
3292
\seef{TCGetAttr}, \seem{termios}{2}
3294
For an example, see \seef{TCGetAttr}.
3296
\begin{function}{TCSetPGrp}
3298
Function TCSetPGrp (Fd,Id:longint) : boolean;
3300
\var{TCSetPGrp} Sets the Process Group Id to \var{Id}.
3301
The function returns \var{True} if the call was successful, \var{False}
3305
Errors are returned in LinuxError.
3307
\seef{TCGetPGrp}, \seem{termios}{2}
3309
For an example, see \seef{TCGetPGrp}.
3311
\begin{function}{TTYName}
3313
Function TTYName (var f) : String;
3315
Returns the name of the terminal pointed to by \var{f}. \var{f}
3316
must be a terminal. \var{f} can be of type:
3318
\item \var{longint} for file handles;
3319
\item \var{Text} for \var{text} variables such as \var{input} etc.
3323
Returns an empty string in case of an error. \var{Linuxerror} may be set
3324
to indicate what error occurred, but this is uncertain.
3326
\seef{IsATTY},\seep{IOCtl}
3329
\begin{function}{TellDir}
3331
Function TellDir (p:pdir) : longint;
3333
\var{TellDir} returns the current location in the directory structure
3334
pointed to by \var{p}. It returns -1 on failure.
3336
Errors are returned in LinuxError.
3338
\seef{CloseDir}, \seef{ReadDir}, \seep{SeekDir}, \seef{OpenDir},
3341
For an example, see \seef{OpenDir}.
3343
\begin{function}{Umask}
3345
Function Umask (Mask : Integer) : Integer;
3347
Change the file creation mask for the current user to \var{Mask}. The
3348
current mask is returned.
3353
\seef{Chmod}, \seem{Umask}{2}
3358
\begin{procedure}{Uname}
3360
Procedure Uname (var unamerec:utsname);
3362
\var{Uname} gets the name and configuration of the current \linux kernel,
3363
and returns it in \var{unamerec}.
3366
\var{LinuxError} is used to report errors.
3368
\seef{GetHostName}, \seef{GetDomainName}, \seem{uname}{2}
3371
\begin{function}{UnLink}
3373
Function UnLink (Var Path) : Boolean;
3375
\var{UnLink} decreases the link count on file \var{Path}. \var{Path} can be
3376
of type \var{PathStr} or \var{PChar}. If the link count is zero, the
3377
file is removed from the disk.
3378
The function returns \var{True} if the call was succesfull, \var{False} if the call
3382
Errors are returned in \var{LinuxError}.
3384
\item[sys\_eaccess] You have no write access right in the directory
3385
containing \var{Path}, or you have no search permission in one of the
3386
directory components of \var{Path}.
3387
\item[sys\_eperm] The directory containing pathname has the sticky-bit
3388
set and the process's effective uid is neither the uid of the
3389
file to be deleted nor that of the directory containing it.
3390
\item[sys\_enoent] A component of the path doesn't exist.
3391
\item[sys\_enotdir] A directory component of the path is not a directory.
3392
\item[sys\_eisdir] \var{Path} refers to a directory.
3393
\item[sys\_enomem] Insufficient kernel memory.
3394
\item[sys\_erofs] \var{Path} is on a read-only filesystem.
3398
\seef{Link}, \seef{SymLink}, \seem{Unlink}{2}
3400
For an example, see \seef{Link}.
3402
\begin{function}{Utime}
3404
Function Utime (path : pathstr; utim : utimbuf) : Boolean;
3406
\var{Utime} sets the access and modification times of a file.
3407
the \var{utimbuf} record contains 2 fields, \var{actime}, and \var{modtime},
3408
both of type Longint. They should be filled with an epoch-like time,
3409
specifying, respectively, the last access time, and the last modification
3411
For some filesystem (most notably, FAT), these times are the same.
3414
Errors are returned in \var{LinuxError}.
3416
\item[sys\_eaccess] One of the directories in \var{Path} has no
3417
search (=execute) permission.
3418
\item[sys\_enoent] A directory entry in \var{Path} does
3419
not exist or is a symbolic link pointing to a non-existent directory.
3421
Other errors may occur, but aren't documented.
3424
\seef{GetEpochTime}, \seef{Chown}, \seef{Access}, \seem{utime}(2)
3429
\begin{function}{WaitPid}
3431
Function WaitPid (Pid : longint; Status : pointer; Options : Longint) : Longint;
3433
\var{WaitPid} waits for a child process with process ID \var{Pid} to exit. The
3434
value of \var{Pid} can be one of the following:
3436
\item[Pid < -1] Causes \var{WaitPid} to wait for any child process whose
3437
process group ID equals the absolute value of \var{pid}.
3438
\item[Pid = -1] Causes \var{WaitPid} to wait for any child process.
3439
\item[Pid = 0] Causes \var{WaitPid} to wait for any child process whose
3440
process group ID equals the one of the calling
3442
\item[Pid > 0] Causes \var{WaitPid} to wait for the child whose process ID
3443
equals the value of \var{Pid}.
3445
The \var{Options} parameter can be used to specify further how \var{WaitPid}
3448
\item [WNOHANG] Causes \var{Waitpid} to return immediately if no child has
3450
\item [WUNTRACED] Causes \var{WaitPid} to return also for children which are
3451
stopped, but whose status has not yet been reported.
3452
\item[\_\_WCLONE] Causes \var{WaitPid} also to wait for threads created by
3453
the \seef{Clone} call.
3455
Upon return, it returns the exit status of the process, or -1 in case of
3459
Errors are returned in LinuxError.
3461
\seef{Fork}, \seep{Execve}, \seem{waitpid}{2}
3464
For an example, see \seef{Fork}.
3466
\begin{procedure}{WritePort}
3468
Procedure WritePort (Port : Longint; Value : Byte);
3469
Procedure WritePort (Port : Longint; Value : Word);
3470
Procedure WritePort (Port : Longint; Value : Longint);
3472
\var{WritePort} writes \var{Value} -- 1 byte, Word or longint --
3475
Note: You need permission to write to a port. This permission can be set with root
3476
permission with the \var{IOperm} call.
3478
In case of an error (not enough permissions to write to this port), runtime 216
3479
({\em Access Violation}) will occur.
3481
\seef{IOperm}, \seep{WritePortB}, \seep{WritePortL}, \seep{WritePortW},
3482
\seep{ReadPortB}, \seep{ReadPortL}, \seep{ReadPortW}
3486
\begin{procedure}{WritePortB}
3488
Procedure WritePortB (Port : Longint; Value : Byte);
3489
Procedure WritePortB (Port : Longint; Var Buf; Count: longint);
3491
The first form of \var{WritePortB} writes 1 byte to port \var{Port}.
3492
The second form writes \var{Count} bytes from \var{Buf} to port \var{Port}.
3494
Note: You need permission to write to a port. This permission can be set with root
3495
permission with the \var{IOperm} call.
3497
In case of an error (not enough permissions to write to this port), runtime 216
3498
({\em Access Violation}) will occur.
3500
\seef{IOperm}, \seep{WritePort}, \seep{WritePortL}, \seep{WritePortW},
3501
\seep{ReadPortB}, \seep{ReadPortL}, \seep{ReadPortW}
3505
\begin{procedure}{WritePortL}
3507
Procedure WritePortL (Port : Longint; Value : Longint);
3508
Procedure WritePortL (Port : Longint; Var Buf; Count: longint);
3510
The first form of \var{WritePortB} writes 1 byte to port \var{Port}.
3511
The second form writes \var{Count} bytes from \var{Buf} to port \var{Port}.
3513
Note: You need permission to write to a port. This permission can be set with root
3514
permission with the \var{IOperm} call.
3516
In case of an error (not enough permissions to write to this port), runtime 216
3517
({\em Access Violation}) will occur.
3519
\seef{IOperm}, \seep{WritePort}, \seep{WritePortB}, \seep{WritePortW},
3520
\seep{ReadPortB}, \seep{ReadPortL}, \seep{ReadPortW}
3524
\begin{procedure}{WritePortW}
3526
Procedure WritePortW (Port : Longint; Var Buf; Count: longint);
3527
Procedure WritePortW (Port : Longint; Value : Word);
3529
The first form of \var{WritePortB} writes 1 byte to port \var{Port}.
3530
The second form writes \var{Count} bytes from \var{Buf} to port \var{Port}.
3532
Note: You need permission to write to a port. This permission can be set with root
3533
permission with the \var{IOperm} call.
3535
In case of an error (not enough permissions to write to this port), runtime 216
3536
({\em Access Violation}) will occur.
3538
\seef{IOperm}, \seep{WritePort}, \seep{WritePortL}, \seep{WritePortB},
3539
\seep{ReadPortB}, \seep{ReadPortL}, \seep{ReadPortW}