Bug 260241 - [feature request] Provide a sysctl or fcntl that would return the list of paths for a given file descriptor
Summary: [feature request] Provide a sysctl or fcntl that would return the list of pat...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-05 17:52 UTC by Yuri Victorovich
Modified: 2021-12-11 18:01 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer freebsd_triage 2021-12-05 17:52:52 UTC
At least two projects are blocked on FreeBSD due to inability of such lookup:

1. sysutils/watchman
2. The USD project: https://github.com/PixarAnimationStudios/USD/blob/release/pxr/base/arch/fileSystem.cpp#L470


This was discussed in hackers@ around July 2021.

It would be beneficial if sysctl or fcntl would be able to return a list of file paths for a given file descriptor.
This list of paths can be empty when the file is deleted, or it can have multiple paths when the file is hard-linked.


Yuri
Comment 1 Damjan Jovanovic 2021-12-05 18:39:01 UTC
Wine's file change notifications would also benefit from this (https://source.winehq.org/patches/data/221384).

In that patch I've used sysctl with CTL_KERN + KERN_PROC + KERN_PROC_FILEDESC + pid, but frequent linear searches for each file descriptor are going to be slow.