summaryrefslogtreecommitdiff
path: root/man/2/sys-fd2path
diff options
context:
space:
mode:
Diffstat (limited to 'man/2/sys-fd2path')
-rw-r--r--man/2/sys-fd2path46
1 files changed, 46 insertions, 0 deletions
diff --git a/man/2/sys-fd2path b/man/2/sys-fd2path
new file mode 100644
index 00000000..4890e0fb
--- /dev/null
+++ b/man/2/sys-fd2path
@@ -0,0 +1,46 @@
+.TH FD2PATH 2
+.SH NAME
+fd2path \- return file name associated with file descriptor
+.SH SYNOPSIS
+.EX
+include "sys.m";
+sys := load Sys Sys->PATH;
+
+fd2path(fd: ref FD): string;
+.EE
+.SH DESCRIPTION
+As described in
+.IR intro (2),
+the kernel stores a rooted path name with every open file or directory;
+typically, it is the name used in the original access of the file.
+.B Fd2path
+returns the path name associated with open file descriptor
+.IR fd .
+(It returns nil if an error occurs.)
+.PP
+Changes to the underlying name space do not update the path name
+stored with the file descriptor.
+Therefore,
+the path returned by
+.B fd2path
+may no longer refer to the same file (or indeed any file)
+after some component directory or file in the path has been removed, renamed
+or rebound.
+.PP
+As an example,
+.IR workdir (2)
+is implemented by opening
+.B .
+and executing
+.B fd2path
+on the resulting file descriptor.
+.SH SEE ALSO
+.IR bind (1),
+.IR ns (1),
+.IR sys-bind (2),
+.IR sys-intro (2),
+.IR workdir (2),
+.IR prog (3)
+.SH DIAGNOSTICS
+.B Fd2path
+returns nil on error and sets the system error string.