public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>,
	Roland McGrath <roland@redhat.com>,
	Greg Schafer <gschafer@zip.com.au>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Fix futimes (was Re: utimes())
Date: Thu, 31 Jul 2003 14:04:00 -0000	[thread overview]
Message-ID: <20030731140430.GG20507@sunsite.ms.mff.cuni.cz> (raw)
In-Reply-To: <20030731134306.GA19853@tigers-lfs.nsw.bigpond.net.au>

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

       reply	other threads:[~2003-07-31 14:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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     ` Jakub Jelinek [this message]
2003-07-31 14:27       ` Andreas Schwab
2003-07-31 14:38         ` [PATCH] Fix utimes and futimes (take 2) Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030731140430.GG20507@sunsite.ms.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=gschafer@zip.com.au \
    --cc=libc-hacker@sources.redhat.com \
    --cc=roland@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).