TYPE PID = RECORD i: INTEGER; END; PGRP = PID;
A value of type PID is a process identifier. (PID is declared as a one-word record so that the compiler's type checker will help catch some programming errors.)
A value of type PGRP is a process group identifier. Process groups are
mainly used to multiplex terminals among several jobs, as described in
section 2.11, page .
TYPE File = REF;
A value of type File is a file handle (a reference to an open-file object;
see Section 2.5, page ).
TYPE PathName = Text.T;
A value of type PathName is a path name (see Section 2.6, page
).
TYPE Dir = REF;
A value of type Dir is a directory handle, which serves as a base for
looking up a relative path name, as described in Section 2.6,
page . Supplying NIL for the directory handle means to
use the working directory of the process instead, as described in Section
2.8, page
. Directory handles are created by the
OpenDir procedure (see page
).
TYPE User = REF;
A value of type User is a specification of a user (see page
).
TYPE FileAccess = (xOK, wOK, rOK); FileAccessMode = SET OF FileAccess; AccessClass = (Others, Group, Owner); AccessMode = ARRAY AccessClass OF BITS 3 FOR FileAccessMode;
An access mode is associated with each directory and file and is used when a path name is looked up by Open or another procedure to decide whether the access is valid. The access mode says who can do what to the file or directory to which it is attached. For a file, `what' means reading (rOK), writing (wOK), and executing as program object code (xOK). For a directory, `what' means reading (rOK), making new entries (wOK), and searching as part of translating a path name (xOK).
`Who' means one of three things: a process whose user name is the same as the owner field of the object (Owner); a process whose user name is a member of the user group associated with the object (Group); or any other process (Other). (Recall that the effective user name is used for access to local objects, but the real user name is used for access to remote objects.)
TYPE FileAttributes = (SaveTextAfterUse, SetGIDonExec, SetUIDonExec); FileState = SET OF FileAttributes;
A value of type FileState packages up some miscellaneous attributes that are specified when a file is created. SetUIDonExec means to set the effective user name of a process executing the file to the owner of the file. SetGIDonExec means to set the effective group ID of a process executing the file to the group of the owner of the file. SaveTextAfterUse tells the system to save the virtual memory backing file version of the program text portion of the file even when no process is executing the program.
Taos note: SetGIDonExec and SaveTextAfterUse are ignored.
TYPE FileMode = RECORD access: BITS 9 FOR AccessMode; fileState: BITS 3 FOR FileState; END;
A file mode combines an access mode and a set of file attributes into a single quantity.
PROCEDURE ConsFileMode( owner, group, others: FileAccessMode := FileAccessMode{}; fileState: FileState := FileState{}) : FileMode RAISES {};
ConsFileMode constructs a FileMode, substituting for the lack of record and array constructors in Modula-2+. Note that the order of the first three parameters is the opposite of the order in AccessClass. This makes the default values more useful.
CONST RW = FileAccessMode{wOK, rOK}; RWX = FileAccessMode{xOK, wOK, rOK}; VAR ReadWriteAll: FileMode; ReadWriteExecuteAll: FileMode; ReadWriteMe: FileMode; ReadWriteExecuteMe: FileMode;
These variables are initialized as follows:
PROCEDURE GetUMask(): AccessMode RAISES {};
GetUMask returns the value of the file access mode creation mask, traditionally called the umask, associated with the calling process. Whenever a file or directory is created, the mode parameter passed (to Open, MakeDir, or OSFriends.MakeDevice) is adjusted as follows:
The umask is set when a process is created (see the SetUMask procedure on
page ) and is not normally changed during the
execution of a process. (If necessary, it can be changed using
OSFriends.SetMyUMask; see Appendix A.1, page
.)