From 284749da8bfa7720960381f6681157f6ab44547d Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 19 Jan 2002 17:51:34 +0000 Subject: Update. 2002-01-19 Ulrich Drepper * libio/fileops.c (_IO_file_underflow_mmap): Don't define as static. Set offset if read end wasn't the buffer end. (_IO_file_seekoff_mmap): New function. (_IO_file_xsgetn_mmap): New function. (_IO_file_jumps_mmap): Use the two new functions. * libio/wfileops.c (_IO_wfile_underflow_mmap): Handle end read buffer != end buffer. * libio/libioP.h: Declare _IO_file_seekoff_mmap and _IO_file_underflow_mmap. * libio/iofopen.c: Don't position file descriptor at end of file. * libio/tst-widetext.c: Improve error messages. * stdio-common/tst-rndseek.c: Likewise. --- libio/iofopen.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'libio/iofopen.c') diff --git a/libio/iofopen.c b/libio/iofopen.c index e4821cbf0e..e3b9838195 100644 --- a/libio/iofopen.c +++ b/libio/iofopen.c @@ -67,25 +67,12 @@ __fopen_maybe_mmap (fp) # endif if (p != MAP_FAILED) { - if ( -# ifdef _G_LSEEK64 - _G_LSEEK64 (fp->_fileno, st.st_size, SEEK_SET) -# else - __lseek (fp->_fileno, st.st_size, SEEK_SET) -# endif - != st.st_size) - { - /* We cannot search the file. Don't mmap then. */ - __munmap (p, st.st_size); - return fp; - } - /* OK, we managed to map the file. Set the buffer up and use a special jump table with simplified underflow functions which never tries to read anything from the file. */ _IO_setb (fp, p, (char *) p + st.st_size, 0); - _IO_setg (fp, p, p, (char *) p + st.st_size); + _IO_setg (fp, p, p, p); if (fp->_mode <= 0) _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_file_jumps_mmap; @@ -93,7 +80,7 @@ __fopen_maybe_mmap (fp) _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_wfile_jumps_mmap; fp->_wide_data->_wide_vtable = &_IO_wfile_jumps_mmap; - fp->_offset = st.st_size; + fp->_offset = 0; } } } -- cgit v1.2.3