Reload remote file to directory
Is it possible for a program to re-bind a file to a filesystem tree that has been deleted, but to which it still has an open file descriptor?
i.e. if the program has executed
int fd = open("/dir/myfile", O_RDONLY);
unlink("/dir/myfile");
is there something like
linkfd(fd, "myfile", "/otherdir/");
which will create /otherdir/myfile
both an entry in the same file used in /dir/myfile
?
I know it is possible to restore the contents of such a file with a deleted but still open file via /proc/<PID>/fd/<num>
, but this creates a new file with a different inode number. I want to know if the same file can be reattached so that it /otherdir/myfile
has the same inode number as the remote one /dir/myfile
.
source to share