• Gabriel Guimaraes's avatar
    Workaround for the OverlayFS bug present before Kernel 4.2 · dbaab31f
    Gabriel Guimaraes authored
    This is here only to support the Linux Kernel between versions
    3.18 and 4.2. After that, this workaround is not needed anymore,
    but it will work properly on both a kernel with and without the bug.
    
    The bug is that when a process has a file open in an OverlayFS directory,
    the information in /proc/<pid>/fd/<fd> and /proc/<pid>/fdinfo/<fd>
    is wrong, so we grab that information from the mountinfo table instead.
    
    This is done every time fill_fdlink is called.
    We first check to see if the mnt_id and st_dev numbers currently match
    some entry in the mountinfo table. If so, we already have the correct mnt_id
    and no fixup is needed.
    
    Then we proceed to see if there are any overlayFS mounted directories
    in the mountinfo table. If so, we concatenate the mountpoint with the
    name of the file, and stat the resulting path to check if we found the
    correct device id and node number. If that is the case, we update the
    mount id and link variables with the correct values.
    Signed-off-by: 's avatarGabriel Guimaraes <gabriellimaguimaraes@gmail.com>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
    dbaab31f
mnt.proto 875 Bytes