Path from file descriptor

Using QNX 6.2, if I have an open file descriptor, is it
possible to resolve that back to the path used to open it?

Thanks in advance
William

William Morris <william@bangel.demon.co.uk> wrote:

Using QNX 6.2, if I have an open file descriptor, is it
possible to resolve that back to the path used to open it?

Thanks in advance
William

fstat()


Bill Caroselli – Q-TPS Consulting
1-(626) 824-7983
qtps@earthlink.net

Weijie Zhang <wzhang@qnx.com> wrote:

“Bill Caroselli” <> qtps@earthlink.net> > wrote in message
news:b3liu7$lki$> 3@inn.qnx.com> …
William Morris <> william@bangel.demon.co.uk> > wrote:
Using QNX 6.2, if I have an open file descriptor, is it
possible to resolve that back to the path used to open it?

Thanks in advance
William

fstat()

???

You beat me to it! :slight_smile:

I think this has been discussed before, and the answer is, “no, this is
not possible”. The usual discussion goes “what if the file
is now unlinked, or what if the file is a symlink or hardlink”…

Cheers,
-RK


Weijie

\

Bill Caroselli – Q-TPS Consulting
1-(626) 824-7983
qtps@earthlink.net


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.

“Bill Caroselli” <qtps@earthlink.net> wrote in message
news:b3liu7$lki$3@inn.qnx.com

William Morris <> william@bangel.demon.co.uk> > wrote:
Using QNX 6.2, if I have an open file descriptor, is it
possible to resolve that back to the path used to open it?

Thanks in advance
William

fstat()

???

Weijie


Bill Caroselli – Q-TPS Consulting
1-(626) 824-7983
qtps@earthlink.net

William Morris <william@bangel.demon.co.uk> wrote:

Using QNX 6.2, if I have an open file descriptor, is it
possible to resolve that back to the path used to open it?

iofdinfo()

Note however that it is at the discretion of the IO manager
handling the fd whether or not a name will be / can be returned.
Speaking for the file system, once the file is opened there
is no need to keep a name around, and it may not even have a name
(has been opened and unlinked, like a temporary file) or it may
have multiple names (hard links). By default the filesystem does
not store the name with each open fd, but will make a best-effort
attempt to reconstruct it for you out the the name cache (so
if it was a suitable candidate for caching and is still present,
you will get the name) - this is how QNX4 Fsys works too. From
6.2.1 there is an option “blk fdinfo=” which can control how
to behave, and “fdinfo=always” will waste the memory to store
the full pathname associated with each open fd solely to satisfy
the iofdinfo() call on systems that you think you need this (I
don’t, which is why it’s not the default :slight_smile: Try “use io-blk.so”.

John Garvey <jgarvey@qnx.com> wrote:

William Morris <> william@bangel.demon.co.uk> > wrote:
Using QNX 6.2, if I have an open file descriptor, is it
possible to resolve that back to the path used to open it?

iofdinfo()

Note however that it is at the discretion of the IO manager
handling the fd whether or not a name will be / can be returned.
Speaking for the file system, once the file is opened there
is no need to keep a name around, and it may not even have a name
(has been opened and unlinked, like a temporary file) or it may
have multiple names (hard links). By default the filesystem does
not store the name with each open fd, but will make a best-effort
attempt to reconstruct it for you out the the name cache (so
if it was a suitable candidate for caching and is still present,
you will get the name) - this is how QNX4 Fsys works too. From
6.2.1 there is an option “blk fdinfo=” which can control how
to behave, and “fdinfo=always” will waste the memory to store
the full pathname associated with each open fd solely to satisfy
the iofdinfo() call on systems that you think you need this (I
don’t, which is why it’s not the default > :slight_smile: > Try “use io-blk.so”.

Perfect. Thanks a lot. I will try that next week. Looking at the man
page, and that of related iofunc_fdinfo etc it seems that I am in
control; the fds I am interested in are open on my own resource
manager’s resources.

Thanks again

William Morris
william@bangel.demon.co.uk