Skip to content

path_filestat_set_times uses monotonic time for ATIM_NOW/MTIM_NOW instead of realtime #6149

@artemyarulin

Description

@artemyarulin

When calling utimensat(..., UTIME_NOW) or futimens(..., UTIME_NOW), WASIX sets file timestamps using the monotonic clock rather than realtime. That makes mtime look like “seconds since boot” (near the Unix epoch) instead of the current calendar time. This breaks tools that rely on correct mtimes (e.g., touch, build systems, backups, zip archive, db)

#include <sys/stat.h>
#include <time.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

int main(void)
{
    int fd = open("t", O_CREAT | O_TRUNC | O_WRONLY, 0644);
    close(fd);
    struct timespec ts[2] = { {0, UTIME_NOW}, {0, UTIME_NOW} };
    utimensat(AT_FDCWD, "t", ts, 0);
    struct stat st;
    stat("t", &st);
    // BUG: mtime should be realtime (calendar time). Instead it is monotonic (since boot)
    // Expected 2026-02-01..., but we got Unix epoch based (e.g., 1970-01-01)
    printf("mtime=%lld now=%lld\n", (long long)st.st_mtime, (long long)time(NULL));
    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions