Skip to content

set_symlink_file_times doesn't change atime but causes it to become UTIME_NOW on Linux #106

@l-0-l

Description

@l-0-l

There is no specific function to change only the atime for links. It could be nice if set_times was public, as this may be the only function you need. But when using set_symlink_file_times you must first get the current link metadata, which is also inefficient, and then change both the mtime and the atime, providing the one you don't want to change from the metadata. Specific functions like set_file_atime provide a None to the relevant FileTime in set_times, which then converts it to an OS-specific UTIME_OMIT for the system call or whatever in Windows. Unlike in Windows implementation's set_file_handle_times corresponding function, though, which does accept Option<FileTime> and is public, in Linux using set_times sin't an option.

When I try to set atime only by providing mtime from the original link's metadata with set_symlink_file_times, the link's 'atime' becomes the current system time on Debian 12 x86-64 default ext4 filesystem. It works well for me the other way round, though, I am not sure why.

Proposed solutions:

  • Add specific set_symlink_file_atime and set_symlink_file_mtime to both Windows and Linux implementations.
  • Remove the set_symlink_file_times entirely and add a flag like follow_links to the normal file functions like set_file_atime.
  • Make set_times public, like the set_file_handle_times in Windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions