Skip to content

FileMetadata.createdAtMillis does not return the file creationTime on unix. #1755

@MohammadKHC

Description

@MohammadKHC

stat.ctime refers to change time, not creation time.

In fact, POSIX does not provide a way to retrieve the creation time.
However, since Linux 4.11, there is a new statx system call, which provides
stx_btime as the creation (birth) time.

The JVM’s UnixFileAttributes.creationTime() already checks whether the birth
time is available and, if it is, returns it. Otherwise, it falls back to
mtime, not ctime.

See:
https://github.com/openjdk/jdk/blob/master/src/java.base/unix/classes/sun/nio/fs/UnixFileAttributes.java#L176

Note: It seems like macOS already provides a true file creation time via st_birthtimespec
in the original stat struct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions