Library for checking fd in Linux

I am looking for a library for checking if the file descriptor is open (by serial port name eg. /dev/ttyS0) in Linux.
I need it because the exclusive mode is not working correctly (library: serialport - Rust).
What do you recommend?

I found but it is not working correctly.

File descriptors (integers locally assigned to a process) only exist while a file is open.
Could you elaborate on what isn't working correctly?
IIRC many linux distros have a ModemManager daemon which may hold an fd to /dev/tty* devices.
My reading revealed that requesting exclusivity was the only step required to work around this

I found procfs.
I going to use it.