[Bug 272120] touch(1) -r modifies file's birthtime
- In reply to: bugzilla-noreply_a_freebsd.org: "[Bug 272120] touch(1) -r modifies file's birthtime"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 20 Jun 2026 07:47:45 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272120
Simon <simon.tettmar@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |simon.tettmar@gmail.com
--- Comment #4 from Simon <simon.tettmar@gmail.com> ---
I agree with Mark Peek that this behaviour appears to be caused by setutimes()
in sys/kern/vfs_syscalls.c, which deliberately sets va_birthtime to the
requested mtime when the requested mtime is earlier than the current birthtime.
Therefore touch(1) is not explicitly changing birthtime; the change happens in
the VFS timestamp-setting path.
I cannot convince myself that having mtimes prior to birthtimes can ever be a
good thing and so if no one objects I will look at updating touch(1)
documentation to explain this behaviour.
Here is a simple test I conducted ( truncated output for clarity ):
$ touch newfile
$ stat -x newfile
File: "newfile"
Access: Sat Jun 20 08:24:46 2026
Modify: Sat Jun 20 08:24:46 2026
Change: Sat Jun 20 08:24:46 2026
Birth: Sat Jun 20 08:24:46 2026
$ touch -m -r /usr/bin/yes newfile
$ stat -x newfile
File: "newfile"
Access: Sat Jun 20 08:24:46 2026
Modify: Wed Feb 25 03:41:32 2026
Change: Sat Jun 20 08:25:42 2026
Birth: Wed Feb 25 03:41:32 2026
$ touch -m -t 202606011224.00 newfile
$ stat -x newfile
File: "newfile"
Access: Sat Jun 20 08:24:46 2026
Modify: Mon Jun 1 12:24:00 2026
Change: Sat Jun 20 08:31:01 2026
Birth: Wed Feb 25 03:41:32 2026
$ touch -m -t 202206011224.00 newfile
$ stat -x newfile
File: "newfile"
Access: Sat Jun 20 08:24:46 2026
Modify: Wed Jun 1 12:24:00 2022
Change: Sat Jun 20 08:31:17 2026
Birth: Wed Jun 1 12:24:00 2022
--
You are receiving this mail because:
You are the assignee for the bug.