Page MenuHomeFreeBSD

Add futimens and utimensat system calls.

Authored by jilles on Jan 3 2015, 4:01 PM.



The core kernel part is patch file utimes.2008.4.diff from I updated the code for API changes, added the manual
page and added compatibility code for old kernels.

This diff does not contain man page .Dd updates, exact __FreeBSD_version
values and make sysent.

Test Plan

installworld and installkernel on VM.
Not in this diff: Fixed and ran NetBSD utimensat tests. Patched touch, cp and
All these using old kernel+new world and new kernel+new world.
The former gives expected failures only.

Diff Detail

rS FreeBSD src repository - subversion
No Linters Available
No Unit Test Coverage

Event Timeline

jilles retitled this revision from to Add futimens and utimensat system calls..
jilles updated this object.
jilles edited the test plan for this revision. (Show Details)

minor mdoc


missing comma

Seems reasonable to me; thanks for taking care of both audit and Capsicum aspects!


In 2012, you suggested to use the same values for the new constants as Linux (and now NetBSD) to ease the compatibility layer. OpenBSD uses different values though (orthogonal to the proposed in the patch).

Rebase to recent head, fix symlink.7 per pluknet@.

I can't build head on stable/9 anymore, so testing took more time.

Further notes:

  • The UTIME_* constant values in the current patch may be folded by a compiler into a (tv_nsec >= 0 && tv_nsec < 1000000000) test (OpenBSD's reason to use these). On the other hand, Linux/NetBSD's values may allow better error detection if someone erroneously decrements a 0 nanosecond value.
  • A new UTIME_* constant might allow setting birthtimes in future. An alternative would be adding a flags word to the syscall underlying futimens().
delphij added a reviewer: delphij.

Looks good to go.

This revision is now accepted and ready to land.Jan 20 2015, 10:11 PM
pluknet added a reviewer: pluknet.

I see no objection to commit the change in its current form.
See minor notes.


wrong indentation


I do not remember such precedents that we support older kernel (also utimensat).
As I understand this is done for portmgr purposes? So, just a remark.


Good catch -- there should be two tabs after 'int' to match surrounding code.


I think this is good: especially if we modify existing base system applications to use futimens(2) -- some users would do 'make installkernel installworld' instead of rebooting and installing world, while they should. I have been doing it for ZFS ioctl's for some while by the way.

The compatibility code is to stop breaking things too badly for people running an old kernel and a new world. It is not useful for running tests since it naturally pretends to support more than the kernel can deliver. It is probably best to remove it in 12-current or so.

Thanks for the review.

wollman added a reviewer: wollman.

Linux emulator support? I'm assuming it's already stubbed out (haven't looked) and just needs to be switched to the new internal interface.