about summary refs log tree commit diff
path: root/libio/fileops.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-06-25 19:33:56 +0000
committerUlrich Drepper <drepper@redhat.com>2002-06-25 19:33:56 +0000
commitc42924899320727fd22d17c944a473bab0f55bb7 (patch)
tree4a54ddb8cac453ea5a36e4446559730325edf1ce /libio/fileops.c
parent51909ff7bf4563b53e6ffaf07a8e8e0af79d322f (diff)
downloadglibc-c42924899320727fd22d17c944a473bab0f55bb7.tar.gz
glibc-c42924899320727fd22d17c944a473bab0f55bb7.tar.xz
glibc-c42924899320727fd22d17c944a473bab0f55bb7.zip
Update.
	* libio/fileops.c (_IO_file_xsgetn_mmap): Always set EOF flag is
	not enough content is available.
	* libio/tst-eof.c: New file.
	* libio/Makefile (tests): Add tst-eof.

	* libio/fileops.c (_IO_file_underflow_mmap): Read a single byte to
	update atime.
	* libio/tst-atime.c: New file.
	* libio/Makefile (tests): Add tst-atime.
Diffstat (limited to 'libio/fileops.c')
-rw-r--r--libio/fileops.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/libio/fileops.c b/libio/fileops.c
index 42bba7aa21..20794955a8 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -608,6 +608,13 @@ _IO_file_underflow_mmap (_IO_FILE *fp)
 {
   if (fp->_IO_read_end < fp->_IO_buf_end)
     {
+      /* A stupid requirement in POSIX says that the first read on a
+	 stream must update the atime.  Just read a single byte.  We
+	 don't have to worry about repositioning the file descriptor
+	 since the following seek defines its position anyway.  */
+      char ignore[1];
+      read (fp->_fileno, ignore, 1);
+
       if (
 # ifdef _G_LSEEK64
 	  _G_LSEEK64 (fp->_fileno, fp->_IO_buf_end - fp->_IO_buf_base,
@@ -1262,12 +1269,10 @@ _IO_file_xsgetn_mmap (fp, data, n)
 	}
     }
 
-  if (have == 0)
-    {
-      if (s == (char *) data)
-	fp->_flags |= _IO_EOF_SEEN;
-    }
-  else
+  if (have < n)
+    fp->_flags |= _IO_EOF_SEEN;
+
+  if (have != 0)
     {
       have = MIN (have, n);
 #ifdef _LIBC