diff options
Diffstat (limited to 'static/plan9-4e/man2/fd2path.2')
| -rw-r--r-- | static/plan9-4e/man2/fd2path.2 | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/static/plan9-4e/man2/fd2path.2 b/static/plan9-4e/man2/fd2path.2 new file mode 100644 index 00000000..9876c132 --- /dev/null +++ b/static/plan9-4e/man2/fd2path.2 @@ -0,0 +1,57 @@ +.TH FD2PATH 2 +.SH NAME +fd2path \- return file name associated with file descriptor +.SH SYNOPSIS +.B #include <u.h> +.br +.B #include <libc.h> +.PP +.B +int fd2path(int fd, char *buf, int nbuf) +.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. +.I Fd2path +returns the path name associated with open file descriptor +.IR fd . +Up to +.I nbuf +bytes of the name are stored in +.IR buf ; +if the name is too long, it will be silently truncated at a UTF-8 +character boundary. +The name is always null-terminated. +The return value of +.I fd2path +will be zero unless 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 +.I 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 getwd (2) +is implemented by opening +.B . +and executing +.I fd2path +on the resulting file descriptor. +.SH SOURCE +.B /sys/src/libc/9syscall +.SH SEE ALSO +.IR bind (1), +.IR ns (1), +.IR bind (2), +.IR intro (2), +.IR getwd (2), +.IR proc (3) +.SH DIAGNOSTICS +Sets +.IR errstr . |
