Link to a specific inode

2019-04-25 16:46发布

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.

2条回答
可以哭但决不认输i
2楼-- · 2019-04-25 17:38

Copy from /proc/pid/fd/file descriptor

Use lsof to find the pid and the file descriptor.

查看更多
手持菜刀,她持情操
3楼-- · 2019-04-25 17:44

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.

查看更多
登录 后发表回答