include "sys.m"; sys:= load Sys Sys->PATH;
'..'
refers to the parent directory of the directory containing that element.
When a process presents a file name to Inferno, it is evaluated by the following algorithm:
/
means the root of the main hierarchy
#
means the separate root of a kernel device's file tree (see Section 3)
A program can use bind or mount so that whenever a specified file is reached during an evaluation, that evaluation continues instead from some other specified file. These calls create union directories, which are concatenations of ordinary directories that are searched sequentially until the desired element is found.
Using bind and mount to do namespace adjustment affects only the current namespace group.
Files are opened for input, output or input/output by open or create. These calls return reference to an abstract data type (adt) of type FD (file descriptor) that identifies the file to subsequent I/O calls, such as read and write.
Files are normally read or written in sequential order. The I/O position in the file is called the file offset and may be set arbitrarily using the seek system call.
File descriptors are garbage-collected as soon as they are no longer referenced. There is no close function.
However, it is safe to use an uninitialized (nil value) reference to a file descriptor (ref Sys->FD) as an argument to the functions of the Sys module. They return an error value (-1) and message "fd out of range or not open," but the program should not crash.
By convention, the first three integer values are used by application programs as follows:
0 | Standard input |
1 | Standard output |
2 | Standard error output |
Since this is only a convention, it is possible to close file descriptor 0, or even to replace it by a file open only for writing. However, programs must agree upon convention.
The set of processes that shares that table is called a file descriptor group. Files opened by one process in the group may be read from and written to by other processes in same the group. (See pctl - process control).
Directories may be opened and read much like regular files (see dirread - read directory). They contain an integral number of records, called directory entries. Each entry is a machine-independent representation of the information about an existing file in the directory including the name, ownership, permission, access dates, and similar information.
The entry corresponding to an arbitrary file can be retrieved by stat or fstat; wstat and fwstat write back entries, thus changing the properties of a file.
New files are made with create and deleted with remove (see open, create - open/create a file for reading or writing and remove - remove a file). As with regular files, attributes of directories can be manipulated by wstat, and fwstat. Directories may not be written directly.
Guaranteed synchronous writes are not available.
File locking from underlying file systems is not supported by Inferno. Processes can coordinate their file operations by other mechanisms.
Atomicity of I/O is guaranteed for I/O with byte counts smaller than the Styx message size; see read, write - transfer data from and to a file in Chapter 3.
A newly spawned thread shares the same program namespace as that of its creator thread. The set of global variables that is in scope to one thread is in scope to the other. Also, change made by one can be detected by the other. Since they are scheduled independently, a creator and a spawned thread should synchronize their actions to share data meaningfully.
Processes are also organized into process groups that represent the set of threads that a single kill request terminates (see prog - interface to running programs in Chapter 2).
A newly spawned thread inherits the following attributes:
When a pathname crosses from one server to another, the process identities are mapped by each server receiving a file request.
The uid and gid strings are assigned to the thread that is created when a user logs into Inferno and cannot be changed.