Re: Is it possible to determine the open file path based on the file descriptor?

From: Floyd, Paul <paulf2718_at_gmail.com>
Date: Mon, 06 Dec 2021 08:23:31 UTC
On 2021-12-05 19:54, Konstantin Belousov wrote:
> On Sun, Dec 05, 2021 at 09:53:23AM -0800, Yuri wrote:
>> On 7/8/20 10:53, Konstantin Belousov wrote:
>>> I think an immediately useful addition would be a sysctl or fcntl that
>>> return struct kinfo_file for single file descriptor.
[snip]
>>> https://reviews.freebsd.org/D33277

That looks really nice. It's possible to do this with sysctl CTL_KERN / 
VKI_KERN_PROC / KERN_PROC_FILEDESC but that gets info for all file 
descriptors, meaning that you then have to search for the one that you want.

https://github.com/paulfloyd/freebsd_valgrind/blob/freebsd/coregrind/m_libcfile.c#L121

(I'm not the author of that bit of code).


A+

Paul