57 lines · 1.2 KB · Text
RawDownload
.TH FD2PATH 2.SH NAMEfd2path \- return file name associated with file descriptor.SH SYNOPSIS.B #include <u.h>.br.B #include <libc.h>.PP.Bint fd2path(int fd, char *buf, int nbuf).SH DESCRIPTIONAs 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 Fd2pathreturns the path name associated with open file descriptor.IR fd .Up to.I nbufbytes of the name are stored in.IR buf ;if the name is too long, it will be silently truncated at a UTF-8character boundary.The name is always null-terminated.The return value of.I fd2pathwill be zero unless an error occurs..PPChanges to the underlying name space do not update the path namestored with the file descriptor.Therefore,the path returned by.I fd2pathmay no longer refer to the same file (or indeed any file)after some component directory or file in the path has been removed, renamedor rebound..PPAs an example,.IR getwd (2)is implemented by opening.B .and executing.I fd2pathon 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 DIAGNOSTICSSets.IR errstr .