criu

Invisible and Nameless Files

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.

How Files Lose Their Paths

1. Unlinked while Open

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.

2. Virtual Filesystem Deletion

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.”

3. Mount Shadowing (Overmounts)

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’s Detection and Reconstruction Strategies

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.

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.

Virtual File Remap (The PID Helper)

For deleted /proc entries, CRIU cannot use ghost files or linkat(). Instead:

  1. It records the PID of the original process that the /proc entry referred to.
  2. During restoration, it creates a temporary TASK_HELPER process with that specific PID.
  3. The restored application opens the /proc/$PID/... entry of this helper.
  4. The helper is terminated once all restoration tasks are complete.

Filesystem-Specific Handling

Technical Details

See also