tags:

views:

146

answers:

1

I have a file that was deleted, but is still held open my a program. I found the inode number using lsof. How can I create a hard link back to that inode?

Any code helps, but Perl would be handy.

+3  A: 

Copy from /proc/pid/fd/file descriptor

Use lsof to find the pid and the file descriptor.

moonshadow
I just ran my own little test, and this does work, but I don't understand why! Those are symlinks to the actual file, and a symlink accesses the file through its filename, does it not?
Thomas
You cannot hard link to the entry in /proc, because hard links have to be on the same filesystem (i.e. your link would have to be in /proc). Copying should be fine.
mark4o
mark: noted, thanks. Thomas: they're not real symlinks, they just look like them. Google for proc_register_dynamic for more info.
moonshadow