BT> "Vish" == Vish Viswanathan writes:
Vish> Hi, I need to know a way of finding out the directory (full
Vish> path) from where a executable gets loaded programmatically.
BT> No way.
HWN> If you don't care about portability, you can look at where
HWN> /proc/self/exe is pointing to
JM> This is good (This is, after all, a Linux newsgroup), but what
JM> that gives you is an inode number. This seems to be correct in my
Ah, and on my system it gives you a filename. The basic answer here
is that what /proc/self/exe links to differs between the 2.0.x and
2.1.x kernels, so using it isn't even portable between different
versions of Linux. And different Unices have a different interface
under /proc, or possibly no /proc at all. Depending on this is a
*total* portability lose.
JM> However, I see no "direct" way to convert the inode number back to
JM> a filename. I think the "standard" way is something like: find /
JM> -inum X But that is obviously a "haystack" method.
Given a particular inode number, an arbitrary number of directory
entries on that filesystem can point to that inode. AFAIK there isn't
a good way to get from an inode number to the directory entries that
point to it, though.
/ \ "Dad was reading a book called
| David Maze | _Schroedinger's Kittens_. A*
| http://www.veryComputer.com/| -- Abra Mitchell