Bug#388785: libc0.3: Passing a NULL struct to futimes does not return the current date/time on GNU/Hurd
Package: libc0.3
Version: 2.3.6.ds1-4
Severity: important
Tags: patch
Newer coreutils' touch uses futimes() to set the current date/time.
This fails badly on the Hurd right now:
mbanck@beethoven:~/tmp$ touch foo
mbanck@beethoven:~/tmp$ ls -l foo
-rw-r--r-- 1 mbanck mbanck 0 Sep 22 16:18 foo
mbanck@beethoven:~/tmp$ ./bin/touch foo
mbanck@beethoven:~/tmp$ ls -l foo
-rw-r--r-- 1 mbanck mbanck 0 Jan 1 1970 foo
I have attached a proposed patch by Alfred M. Szmidt and Barry deFreese.
Michael
--- futimes.org 2006-09-19 13:00:49.000000000 +0000
+++ futimes.c 2006-09-19 13:05:13.000000000 +0000
@@ -28,20 +28,28 @@
int
__futimes (int fd, const struct timeval tvp[2])
{
- struct timeval timevals[2];
error_t err;
-
+
if (tvp == NULL)
{
+ volatile struct timeval timevals[2];
/* Setting the number of microseconds to `-1' tells the
underlying filesystems to use the current time. */
timevals[1].tv_usec = timevals[0].tv_usec = (time_t)-1;
- tvp = timevals;
+
+ err = HURD_DPORT_USE (fd, __file_utimes (port,
+ *(time_value_t *) &timevals[0],
+ *(time_value_t *) &timevals[1]));
+
}
+ else
+ {
- err = HURD_DPORT_USE (fd, __file_utimes (port,
- *(time_value_t *) &tvp[0],
- *(time_value_t *) &tvp[1]));
+ err = HURD_DPORT_USE (fd, __file_utimes (port,
+ *(time_value_t *) &tvp[0],
+ *(time_value_t *) &tvp[1]));
+
+ }
return err ? __hurd_dfail (fd, err) : 0;
}
weak_alias (__futimes, futimes)
Reply to: