[Bug 198570] Add fnctl(F_GETPATH) support to FreeBSD
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Fri Mar 13 20:58:54 UTC 2015
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198570
Bug ID: 198570
Summary: Add fnctl(F_GETPATH) support to FreeBSD
Product: Base System
Version: 11.0-CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Some People
Priority: ---
Component: kern
Assignee: freebsd-bugs at FreeBSD.org
Reporter: s_bugzilla at nedprod.com
Related: #197695 (Fix broken KERN_PROC_FILEDESC sysctl), #197778 (Implement the
AT_EMPTY_PATH race free Linux extension).
The lack of a facility to fetch the current path of an open file descriptor
prevents race free filesystem code. For example, right now there is no reliable
way of opening a fd to the containing directory of an open file handle, and
therefore there is no way of unlinking, renaming or hard linking a file which
has been relocated by a third party since it was opened.
Ideally FreeBSD ought to provide direct fd file operations (#197778), but even
with a full suite of those there remains one occasion when you really must have
the full path for an open fd: when you are symlinking from somewhere to
wherever that fd references on the filing system.
What is annoying is that this is straightforward on Windows especially, and
with a bit of work on Linux. On OS X F_GETPATH is unstable with respect to hard
links, so it returns any of the hard links to a fd, and it's somewhat random
which you get.
Would there be any appetite for FreeBSD to gain a F_GETPATH fnctl?
char buffer[4096];
int len;
if(-1==(len=fnctl(fd, F_GETPATH, buffer, sizeof(buffer))))
errno might be EBADF, EOVERFLOW;
buffer[0...len] contains the zero terminated path of the hard link originally
opened as the fd which is a null string if that hard link has been deleted.
This would bring to FreeBSD semantic equivalence to Linux and Windows. And not
replicate the broken F_GETPATH in OS X.
Niall
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list