[Bug 197695] Fix broken KERN_PROC_FILEDESC sysctl

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Feb 19 05:04:11 UTC 2015


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197695

--- Comment #4 from Niall Douglas <s_bugzilla at nedprod.com> ---
It turns out that I was wrong about there being no method of retrieving a
canonical path for an open file descriptor on FreeBSD. There in fact is, and it
is called KERN_PROC_FILEDESC.

Unfortunately, KERN_PROC_FILEDESC is broken for regular files, but not
directories where it works perfectly - even tracking renames and deletions with
ease. The attached test case and its output shows the broken behaviour:

1. Files opened with O_CREAT never get a path. Creating the file, closing it
and opening it again gets the file descriptor its path.

2. As soon as the process does its first rename() all the paths for all the
regular file descriptors get reset to null, but not directory file descriptors.

3. Directory file descriptors work correctly.


This was tested on FreeBSD 10.1 with ZFS on root. Other filing systems may
vary.

Niall

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list