Hi (and happy new year).

I've had this idea ever since someone asked about this situation on this
forum a few months ago:

Considering that you have a long running process writing stuff into a large
file, and you accidentally delete that file.
You can still access the file's content through /proc/<pid>/fd/<fd> and
that's basically the suggestion he was given ("cp /proc... new file"),
but the limitations of this solution are:

1. It will loose any changes made to the deleted file after the copy.
2. It creates another copy of the data (could be a problem if there isn't
enough space on any partition).

My solution (available in http://sourceforge.net/projects/fdlink) is to
enable the user to link back the deleted file to a new name on the same
filesystem as the deleted file.

The solution involves as small kernel module and a simple program which
calls ioctl(2) on the special device created by that module.

The idea is that if someone finds themselves in that situation they should
be able to install that module and use it without having to reboot the
system (and thus loosing the whole point of it).

I have a couple of enhancement that I'm waiting to find time to implement:

1. Update the symlink content under fd/<fd> to point to the new file name.
2. Implement this as a system call and offer this to be included in 2.6

The module was tested under Debian 2.6.18 and later on x86_64.

Any comments/suggestions/contributions are welcome.

Cheers,

--Amos

Reply via email to