In Linux, a file can remain accessible to a process even if it no longer has a visible path in the filesystem. This occurs when a file is unlinked (deleted) while still open or when its path becomes inaccessible due to mount shadowing. This document explains how CRIU detects and reconstructs these “invisible” files.
The most common case is when an application opens a file and then immediately deletes it:
int fd = open("/tmp/secret", O_RDWR);
unlink("/tmp/secret");
The file data persists in the kernel as long as the file descriptor remains open, but it no longer exists in the filesystem directory structure.
On virtual filesystems like /proc, if a process dies, its entries (e.g., /proc/$PID/cmdline) disappear. However, if another process still has an open file descriptor to one of these entries, the file remains alive but “nameless.”
If a process opens a file in /mnt/data and then a new filesystem is mounted over /mnt, the original file becomes inaccessible via its path.
CRIU uses the /proc/$pid/fd/ and /proc/$pid/fdinfo/ interfaces to identify open files and their expected paths.
If a file has a link count of zero (st_nlink == 0), it is truly deleted.
--ghost-fiemap option to only capture the data blocks, significantly reducing image size.If a file has a positive link count but its expected path is missing or points to a different file, it means the specific name used to open the file was deleted, but other hard links still exist.
linkat() with the AT_EMPTY_PATH flag to create a temporary name for the file on the same filesystem. This allows it to be re-opened via a path during restoration.--link-remap flag.For deleted /proc entries, CRIU cannot use ghost files or linkat(). Instead:
/proc entry referred to./proc/$PID/... entry of this helper..nfsXXX) and handles them via the link-remap mechanism.linkat() may fail on OverlayFS if the file resides on a read-only lower layer, CRIU automatically falls back to the ghost file strategy in these cases.devpts (like PTYs) are managed by the kernel and are restored using specific PTY master/slave allocation logic rather than file-based reconstruction.--ghost-limit option.st_rdev) match.