NULL struct to futimes does not return current date/time on GNU/Hurd
Thomas Schwinge
tschwinge@gnu.org
Sat Sep 23 10:49:00 GMT 2006
Hello!
On Tue, Sep 19, 2006 at 01:13:48PM -0400, Barry deFreese wrote:
> Applications that pass a NULL timeval struct to futimes (such as
> coreutils touch), futimes is supposed to set the current date/time
> which does not work properly.
I'd either suggest the following (ugly) fix:
#v+
--- futimes.c.orig 2006-09-23 01:11:56.000000000 +0200
+++ futimes.c.ugly.glibc 2006-09-23 12:42:29.000000000 +0200
@@ -28,7 +28,7 @@
int
__futimes (int fd, const struct timeval tvp[2])
{
- struct timeval timevals[2];
+ struct timeval __attribute__ ((__may_alias__)) timevals[2];
error_t err;
if (tvp == NULL)
#v-
... or rather rewrite that function:
#v+
--- futimes.c.orig 2006-09-23 01:11:56.000000000 +0200
+++ futimes.c.rewrite.glibc 2006-09-23 12:43:26.000000000 +0200
@@ -28,20 +28,20 @@
int
__futimes (int fd, const struct timeval tvp[2])
{
- struct timeval timevals[2];
error_t err;
+ time_value_t new_atime, new_mtime;
if (tvp == NULL)
- {
/* 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;
+ new_atime.microseconds = new_mtime.microseconds = -1;
+ else
+ {
+ new_atime = *(time_value_t *) &tvp[0];
+ new_mtime = *(time_value_t *) &tvp[1];
}
- 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, new_atime, new_mtime));
return err ? __hurd_dfail (fd, err) : 0;
}
weak_alias (__futimes, futimes)
#v-
Roland, what do you prefer? Based on that I will then send in patches
also for the other *utimes.c files, which have similar problems, as the
code looks like.
Regards,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20060923/6921bb36/attachment.sig>
More information about the Libc-alpha
mailing list