[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NULL struct to futimes does not return current date/time on GNU/Hurd
From: |
Thomas Schwinge |
Subject: |
Re: NULL struct to futimes does not return current date/time on GNU/Hurd |
Date: |
Sat, 23 Sep 2006 12:48:56 +0200 |
User-agent: |
Mutt/1.5.6+20040907i |
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
signature.asc
Description: Digital signature
- Re: NULL struct to futimes does not return current date/time on GNU/Hurd,
Thomas Schwinge <=