Bug#762677: libc0.3: Hurd futimens does not support UTIME_NOW
Package: libc0.3
Version: 2.19-11
Severity: normal
The futimens patch for the Hurd does not support UTIME_NOW or
UTIME_OMIT. POSIX says:
"If the tv_nsec field of a timespec structure has the special value
UTIME_NOW, the file's relevant timestamp shall be set to the greatest
value supported by the file system that is not greater than the
current time. If the tv_nsec field has the special value UTIME_OMIT,
the file's relevant timestamp shall not be changed. In either case,
the tv_sec field shall be ignored."
This is the cause of the current man-db build failure:
https://buildd.debian.org/status/fetch.php?pkg=man-db&arch=hurd-i386&ver=2.7.0.1-1&stamp=1411530073
Gnulib defines UTIME_NOW to (-1) if it is not defined by the system.
But, since futimens doesn't specifically support it, setting the mtime
to {0, UTIME_NOW} just results in a timestamp one nanosecond less than
the epoch, which is not very useful. The attached test program, when
run with a file name argument, should result in a file whose
modification time is set to the current time.
I'll see if I can modify Gnulib or failing that man-db to work around
this, but of course it would be better for futimens to be fixed.
Thanks,
--
Colin Watson [cjwatson@debian.org]
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define MUST(name, cond) \
do { \
if (!(cond)) { \
fprintf (stderr, name " failed\n"); \
abort (); \
} \
} while (0)
int main (int argc, char **argv)
{
int fd;
struct timespec times[2];
if (argc < 2) {
fprintf (stderr, "need file name\n");
exit (2);
}
fd = open (argv[1], O_RDWR | O_CREAT | O_TRUNC, 0666);
MUST ("open", fd >= 0);
times[0].tv_sec = 0;
times[0].tv_nsec = UTIME_NOW;
times[1].tv_sec = 0;
times[1].tv_nsec = UTIME_NOW;
MUST ("futimens", futimens (fd, times) == 0);
MUST ("close", close (fd) == 0);
return 0;
}
Reply to: