wrote:
> On Wednesday, January 30, 2013 9:35:48 AM UTC-5, Rutles - China Blue Suede Schubert wrote:
>> Not in C nor POSIX. Also inode and device numbers can
>> change after an unmount and remount. You should be asking
>> yourself why do you need this.
> Why? Just curious, that's all. I like knowing whether things are
> symmetrical or not, and this does not appear to be symmetrical.
As others have noted, this isn't really a C question, but, no,
it isn't symmetrical.
(snip)
> Yeah. I can use an FD, but was trying to use the inode.
I am not sure how much this is still applicable, given all the different
types of file systems available on current unix-like systems.
The reason that find is used is because it is not symmetrical.
Directory entries point to i-nodes, but there is no back pointer.
(Especially as more than one directory entry can point to the
same i-node.) The only way to find the name(s) of such files
is to search through all the directory entries on the disk and
compare the i-node value, which is what find does.
(You can also look inside the file and see if you recognize the
data.)
Even more, there doesn't have to be even one.
A common unix convention for temporary files is to open the file,
and then immediately delete (unlink) it. That removes the directory
entry, but the actual files stays around until close.
Not all file systems can implement the above, which has complications
for their use with unix. One that it complicates is NFS.
-- glen