* [PATCH] Fix futimes (was Re: utimes()) [not found] ` <20030731134306.GA19853@tigers-lfs.nsw.bigpond.net.au> @ 2003-07-31 14:04 ` Jakub Jelinek 2003-07-31 14:27 ` Andreas Schwab 0 siblings, 1 reply; 3+ messages in thread From: Jakub Jelinek @ 2003-07-31 14:04 UTC (permalink / raw) To: Ulrich Drepper, Roland McGrath, Greg Schafer; +Cc: Glibc hackers On Thu, Jul 31, 2003 at 11:43:06PM +1000, Greg Schafer wrote: > Thanks, that fixed it. > > There is similar code in sysdeps/unix/sysv/linux/futimes.c and > sysdeps/posix/utimes.c that may also be affected. futimes.c seems to be indeed broken the same way (sorry, missed it). But sysdeps/posix/utimes.c is not: times->actime = tvp[0].tv_sec + tvp[0].tv_usec / 1000000; times->modtime = tvp[1].tv_sec + tvp[1].tv_usec / 1000000; The question is what is utimes/futimes supposed to do if tv_usec > 999999. I couldn't find anything in POSIX about it, so I don't know which one of: tvp[0].tv_sec + (tvp[0].tv_usec >= 500000) tvp[0].tv_sec + tvp[0].tv_usec / 1000000 tvp[0].tv_sec + (tvp[0].tv_usec + 500000) / 1000000 is needed (but then, it should probably used everywhere, not one way in some *utimes.c implementations and differently in others. 2003-07-31 Jakub Jelinek <jakub@redhat.com> * sysdeps/unix/sysv/linux/futimes.c (__utimes): Add parens so that actime and modtime are computed properly. --- libc/sysdeps/unix/sysv/linux/futimes.c.jj 2003-07-16 06:10:01.000000000 -0400 +++ libc/sysdeps/unix/sysv/linux/futimes.c 2003-07-31 09:54:53.000000000 -0400 @@ -1,4 +1,4 @@ -/* futimes -- change access and modification times of open file. Stub version. +/* futimes -- change access and modification times of open file. Linux version. Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -58,8 +58,8 @@ __futimes (int fd, const struct timeval if (tvp != NULL) { times = &buf; - buf.actime = tvp[0].tv_sec + tvp[0].tv_usec >= 500000; - buf.modtime = tvp[1].tv_sec + tvp[1].tv_usec >= 500000; + buf.actime = tvp[0].tv_sec + (tvp[0].tv_usec >= 500000); + buf.modtime = tvp[1].tv_sec + (tvp[1].tv_usec >= 500000); } else times = NULL; Jakub ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix futimes (was Re: utimes()) 2003-07-31 14:04 ` [PATCH] Fix futimes (was Re: utimes()) Jakub Jelinek @ 2003-07-31 14:27 ` Andreas Schwab 2003-07-31 14:38 ` [PATCH] Fix utimes and futimes (take 2) Jakub Jelinek 0 siblings, 1 reply; 3+ messages in thread From: Andreas Schwab @ 2003-07-31 14:27 UTC (permalink / raw) To: Jakub Jelinek; +Cc: Glibc hackers Jakub Jelinek <jakub@redhat.com> writes: |> The question is what is utimes/futimes supposed to do if |> tv_usec > 999999. I can't find any requirement that the argument must be normalized, so IMHO utimes should cope. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Fix utimes and futimes (take 2) 2003-07-31 14:27 ` Andreas Schwab @ 2003-07-31 14:38 ` Jakub Jelinek 0 siblings, 0 replies; 3+ messages in thread From: Jakub Jelinek @ 2003-07-31 14:38 UTC (permalink / raw) To: Andreas Schwab; +Cc: Glibc hackers On Thu, Jul 31, 2003 at 04:27:12PM +0200, Andreas Schwab wrote: > Jakub Jelinek <jakub@redhat.com> writes: > > |> The question is what is utimes/futimes supposed to do if > |> tv_usec > 999999. > > I can't find any requirement that the argument must be normalized, so > IMHO utimes should cope. 2003-07-31 Jakub Jelinek <jakub@redhat.com> * sysdeps/unix/sysv/linux/utimes.c (__utimes): Fix actime and modtime computation. * sysdeps/unix/sysv/linux/futimes.c (__futimes): Likewise. * sysdeps/posix/utimes.c (__utimes): Likewise. --- libc/sysdeps/unix/sysv/linux/utimes.c.jj 2003-07-14 17:15:43.000000000 -0400 +++ libc/sysdeps/unix/sysv/linux/utimes.c 2003-07-31 08:43:08.000000000 -0400 @@ -47,8 +47,8 @@ __utimes (const char *file, const struct if (tvp != NULL) { times = &buf; - buf.actime = tvp[0].tv_sec + tvp[0].tv_usec >= 500000; - buf.modtime = tvp[1].tv_sec + tvp[1].tv_usec >= 500000; + buf.actime = tvp[0].tv_sec + (tvp[0].tv_usec + 500000) / 1000000; + buf.modtime = tvp[1].tv_sec + (tvp[1].tv_usec + 500000) / 1000000; } else times = NULL; --- libc/sysdeps/unix/sysv/linux/futimes.c.jj 2003-07-16 06:10:01.000000000 -0400 +++ libc/sysdeps/unix/sysv/linux/futimes.c 2003-07-31 09:54:53.000000000 -0400 @@ -1,4 +1,4 @@ -/* futimes -- change access and modification times of open file. Stub version. +/* futimes -- change access and modification times of open file. Linux version. Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -58,8 +58,8 @@ __futimes (int fd, const struct timeval if (tvp != NULL) { times = &buf; - buf.actime = tvp[0].tv_sec + tvp[0].tv_usec >= 500000; - buf.modtime = tvp[1].tv_sec + tvp[1].tv_usec >= 500000; + buf.actime = tvp[0].tv_sec + (tvp[0].tv_usec + 500000) / 1000000; + buf.modtime = tvp[1].tv_sec + (tvp[1].tv_usec + 500000) / 1000000; } else times = NULL; --- libc/sysdeps/posix/utimes.c.jj 2001-07-06 00:56:01.000000000 -0400 +++ libc/sysdeps/posix/utimes.c 2003-07-31 10:32:18.000000000 -0400 @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1997, 2000, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -31,8 +31,8 @@ __utimes (const char *file, const struct if (tvp) { times = &buf; - times->actime = tvp[0].tv_sec + tvp[0].tv_usec / 1000000; - times->modtime = tvp[1].tv_sec + tvp[1].tv_usec / 1000000; + buf.actime = tvp[0].tv_sec + (tvp[0].tv_usec + 500000) / 1000000; + buf.modtime = tvp[1].tv_sec + (tvp[1].tv_usec + 500000) / 1000000; } else times = NULL; Jakub ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-07-31 14:38 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20030731122612.GA620@tigers-lfs.nsw.bigpond.net.au> [not found] ` <20030731124735.GD20507@sunsite.ms.mff.cuni.cz> [not found] ` <20030731134306.GA19853@tigers-lfs.nsw.bigpond.net.au> 2003-07-31 14:04 ` [PATCH] Fix futimes (was Re: utimes()) Jakub Jelinek 2003-07-31 14:27 ` Andreas Schwab 2003-07-31 14:38 ` [PATCH] Fix utimes and futimes (take 2) Jakub Jelinek
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).