🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: muc.lists.freebsd.bugs
1 messages
1 total messages Started by bugzilla-noreply Tue, 01 Dec 2026 14:50
[Bug 301356] utimes(2) with tv_sec = -1 (VNOVAL) should return -1 and set errno to EINVAL per POSIX
#871
Author: bugzilla-noreply
Date: Tue, 01 Dec 2026 14:50
58 lines
3484 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301356

            Bug ID: 301356
           Summary: utimes(2) with tv_sec = -1 (VNOVAL) should return -1
                    and set errno to EINVAL per POSIX
           Product: Base System
           Version: 15.2-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: kit-ty-kate@exn.st

Running the following code:
```
#include <sys/time.h>
#include <sys/stat.h>
#include <stdio.h>
int main() {
  struct timeval t[2];
  struct stat st;
  t[0].tv_sec = -1;
  t[0].tv_usec = 100;
  t[1].tv_sec = -1;
  t[1].tv_usec = 100;
  int ret = utimes("/tmp/abc", t);
  stat("/tmp/abc", &st);
  printf("%d, %ld %ld\n", ret, st.st_atime, st.st_mtime);
  return 0;
}
```
`/tmp/abc`'s mtime isn't modified and no error is raised.
However replace by `-2` or any other reasonable number, then mtime is modified
as expected.

POSIX (https://pubs.opengroup.org/onlinepubs/9799919799/functions/utimes.html)
says:
> [EINVAL]
>    A new file timestamp would be a value whose tv_sec component is not a value supported by the file system.

which is the case for -1 as it is internally equal to ENOVAL and thus
impossible to set, and so utimes should fail with -1 and set errno in that
case.

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

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads