Skip to content

Handling of negative tv_secs values #917

@sunfishcode

Description

@sunfishcode

Linux uses unsigned types for stat fields like st_mtime which are actually signed. Values with the most significant bit indicate negative time offsets from the epoch, which is to say, dates before 1970. Currently rustix just re-exports the kernel's stat struct, so it inherits this problem of using unsigned types for things that hold signed data.

rustix should change to using its own type for stat. That's also a chance to make st_mode be a Mode, st_uid be a Uid, and so on, and maybe even have things like st_mtime/st_mtime_nsec be a Timespec.

While here, macOS has a bug with negative timestamps, details here, and rustix should consider applying a similar fix.

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