Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 05 Mar 2024 00:16:25 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 272120] touch(1) -r modifies file's birthtime
Message-ID:  <bug-272120-227-Eco5byfkEM@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-272120-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-272120-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D272120

Mark Peek <mp@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mp@FreeBSD.org

--- Comment #2 from Mark Peek <mp@FreeBSD.org> ---
I looked into this a little bit and here is what I discovered. Running "tou=
ch
-m" uses utimensat(2) and passes in just the modification date. This system
call then calls an internal setutimes()
https://github.com/freebsd/freebsd-src/blob/main/sys/kern/vfs_syscalls.c#L3=
211.

In 2002 this change was added:

=20=20=20
https://github.com/freebsd/freebsd-src/commit/fb36a3d8472e3b7c446b5501635ec=
34eb1ebaa00

    Change utimes to set the file creation time (for filesystems that
    support creation times such as UFS2) to the value of the
    modification time if the value of the modification time is older
    than the current creation time. See utimes(2) for further details.

If a birthtime is not passed into setutimes() and the birthtime is younger =
than
the modification time, then the birthtime is set to the modification time. =
The
utimensat(2) man page documents this behavior.

This makes a little bit of sense given a modification time usually should n=
ot
be older than the birthtime of the file. But the utimes man page does talk
about the need for a new system call allowing for setting access, modificat=
ion,
*and* birthtime so that might be an alternative.

Options:
1. Document this behavior in the touch(1) man page.
2. Add a new system call to allow setting all three times and modify touch(=
1)
to use it.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-272120-227-Eco5byfkEM>