PTENTER(10.2)
NAME
ptenter, ptclose, ptclone, ptpath − path name cache
SYNOPSIS
Pthashsyspt;
Path∗ptenter(Pthash ∗pt, Path ∗dir, char ∗name);
voidptclose(Pthash ∗pt);
voidptclone(Chan ∗c, int l, int id);
intptpath(Path ∗path, char ∗buf, int size);
DESCRIPTION
A path name cache is a value of type Pthash. It maintains a tree of path names, in which a value of type Path corresponds to one element of a path name. Paths are retrieved by the fd and ns files of prog(3).
The global variable syspt is the name cache for files implemented by the local host. Similar caches are maintained for each remote host by mnt(3).
For a given Chan c the currently associated path name is c->path.
Ptenter returns the path in pt for directory entry name in a given directory dir. If name is “..”, the result is the path of dir’s parent.
Ptpath deposits in array buf of size bytes the full path name associated with path (by working back up the path tree). If the path is not rooted at a device name (ie, #x), it is prefixed with slash (‘/’). Ptpath returns the number of bytes it has stored in buf.
Ptclone updates c->path to represent the name resulting from opening the clone file of a network device. Id is the conversation index (directory number) that contains the ctl file that was opened. If l is zero, the parent directory dir of the new path dir/id/ctl is the parent of the current path of c; otherwise dir is the parent of c’s current parent. The resulting path is associated with channel c.
Ptclose empties the name cache pt, freeing all path elements in it (but it does not free pt itself).
The entries in each Pthash instance are managed internally by a simple garbage collector.
DIAGNOSTICS
Ptpath will call error(10.2) if the buffer is too small or it runs short of memory.
SOURCE
/os/port/ns.c
/emu/ns.c
SEE ALSO
Plan 9 — June 09, 2000