• C
    linux-user: Pass through nanosecond timestamp components for stat syscalls · 5f992db6
    Chen-Yu Tsai 提交于
    Since Linux 2.6 the stat syscalls have mostly supported nanosecond
    components for each of the file-related timestamps.
    
    QEMU user mode emulation currently does not pass through the nanosecond
    portion of the timestamp, even when the host system fills in the value.
    This results in a mismatch when run on subsecond resolution filesystems
    such as ext4 or XFS.
    
    An example of this leading to inconsistency is cross-debootstraping a
    full desktop root filesystem of Debian Buster. Recent versions of
    fontconfig store the full timestamp (instead of just the second portion)
    of the directory in its per-directory cache file, and checks this against
    the directory to see if the cache is up-to-date. With QEMU user mode
    emulation, the timestamp stored is incorrect, and upon booting the rootfs
    natively, fontconfig discovers the mismatch, and proceeds to rebuild the
    cache on the comparatively slow machine (low-power ARM vs x86). This
    stalls the first attempt to open whatever application that incorporates
    fontconfig.
    
    This patch renames the "unused" padding trailing each timestamp element
    to its nanosecond counterpart name if such an element exists in the
    kernel sources for the given platform. Not all do. Then have the syscall
    wrapper fill in the nanosecond portion if the host supports it, as
    specified by the _POSIX_C_SOURCE and _XOPEN_SOURCE feature macros.
    
    Recent versions of glibc only use stat64 and newfstatat syscalls on
    32-bit and 64-bit platforms respectively. The changes in this patch
    were tested by directly calling the stat, stat64 and newfstatat syscalls
    directly, in addition to the glibc wrapper, on arm and aarch64 little
    endian targets.
    Reviewed-by: NLaurent Vivier <laurent@vivier.eu>
    Signed-off-by: NChen-Yu Tsai <wens@csie.org>
    Message-Id: <20190522162147.26303-1-wens@kernel.org>
    Signed-off-by: NLaurent Vivier <laurent@vivier.eu>
    5f992db6
syscall.c 372.3 KB