Jeff Ferland
Jeff Ferland

Reputation: 18312

Link to a specific inode

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.

Upvotes: 12

Views: 5507

Answers (2)

Poulpatine
Poulpatine

Reputation: 125

on EXT filesystem you can use debugfs command to recreate the link like :

debugfs -w /dev/mapper/vg0-root -R 'link <16> myfile'

Which will create a "file" named myfile and pointing to inode 16.

Upvotes: 3

moonshadow
moonshadow

Reputation: 89115

Copy from /proc/pid/fd/file descriptor

Use lsof to find the pid and the file descriptor.

Upvotes: 14

Related Questions