mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-01 10:06:57 +03:00
Update.
2002-01-19 Ulrich Drepper <drepper@redhat.com> * 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.
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user