Line 22:
Line 22:
First of all, CRIU should detect this situation to take place. Modulo some [[filesystems pecularities]], this is done like this.
First of all, CRIU should detect this situation to take place. Modulo some [[filesystems pecularities]], this is done like this.
−
First, we [[dumping files|get the files]] from the target process via unix socket. Then for each of them get the file's name via /proc by calling <core>readlink</code> on the /proc/self/fd/$fd path. It's important to note, that we readlink ''self'' FD to get the file's name we can work with. Next we <code>fstat()</code> the respective self file descriptor.
+
First, we [[dumping files|get the files]] from the target process via unix socket. Then for each of them get the file's name via /proc by calling <code>readlink</code> on the /proc/self/fd/$fd path. It's important to note, that we readlink ''self'' FD to get the file's name we can work with. Next we <code>fstat()</code> the respective self file descriptor.
If the <code>st_nlink</code> field is zero, then the file is fully deleted from the system. Since no filesystems allow to create a name back for such files, we have no other choice other than get the file itself into images. So we generate a so called ''ghost file'' in the image directory and copy the file contents into it.
If the <code>st_nlink</code> field is zero, then the file is fully deleted from the system. Since no filesystems allow to create a name back for such files, we have no other choice other than get the file itself into images. So we generate a so called ''ghost file'' in the image directory and copy the file contents into it.