🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: muc.lists.freebsd.bugs
Article #871

[Bug 301356] utimes(2) with tv_sec = -1 (VNOVAL) should return -1 and set errno to EINVAL per POSIX

#871
From: 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
Technical Details
Message-ID: <bug-301356-227@https.bugs.freebsd.org/bugzilla/>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!sewer!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!sewer!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: bugzilla-noreply@freebsd.org
Newsgroups: muc.lists.freebsd.bugs
Subject: [Bug 301356] utimes(2) with tv_sec = -1 (VNOVAL) should return -1
 and set errno to EINVAL per POSIX
Date: Tue, 01 Dec 2026 14:50:28 +0000
Organization: Newsgate at muc.de e.V.
Approved: news-admin@muc.de
Distribution: world
Message-ID: <bug-301356-227@https.bugs.freebsd.org/bugzilla/>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2";
	logging-data="18411"; mail-complaints-to="news-admin@muc.de"
X-Original-To: bugs@mlmmj.nyi.freebsd.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
	t=1796136628;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:mime-version:mime-version:content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding;
	bh=uRItfIEhB/c5z16VN0igeZl9GiaoU3FP7CdVf3AzI9g=;
	b=mZfH4oAExoVBF9Ss1UgcOcrlERsgFuo6jquhf0FGT38JOBCUSbSczIbBIM/92rfqiaLa+v
	KeTIv3tZoh/laqQIT+zkROQyn4a2OtKVzWonFrKkmUgT7qApk+AgLbQtSdLPAS6aHG11yJ
	ClzbdLqdKb1/pyWdthfVGPLc74dozscT1OS8a3qIiVensOMDt59ZM5QDQkEM3eLu8T86G4
	eivMCN0O28k7fK4e4IS46lgfZoJlXEmYQjbaxrJbDf5chVU869FTaxmZ1Ihh4Y8pB5D5YG
	13vk6qXXL+T0KgKDiK/ALWaj/oiZW18S2J8FUmsq2Ytbf04DK6cT40C+0t55mQ==
X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f
Auto-Submitted: auto-generated
Precedence: list
X-Newsgate-Id: f02c70b8849f+
X-No-Archive: Yes