简体   繁体   中英

Linux file descriptor from file name

As it is possible to get the file name from the file descriptor, I was wondering if there was a way to do the reverse.

There has to be a Linux command that does this since it doesn't seem like it would be that hard to do if there is already a fd-->fn function.

To make this a question: how can one get the file descriptor from something like /dev/urandom ?

See the command lsof to list all open files and their per-process file handle.

Of course if n processes have /dev/urandom open, then there will be at least n matches (a process can have more than one handle to the same file).

Memory mapped files may not have a file descriptor, but such files are still listed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM