os0file.c:

  Fix InnoDB bug: on HP-UX, with a 32-bit binary, InnoDB was only able to read or write <= 2 GB files; the reason was that InnoDB treated the return value of lseek() as a 32-bit integer; lseek was used on HP-UX-11 as a replacement for pread() and pwrite() because HAVE_BROKEN_PREAD was defined on that platform
parent f3fc9a2d
......@@ -6,6 +6,8 @@ The interface to the operating system file i/o primitives
Created 10/21/1995 Heikki Tuuri
*******************************************************/
#define HAVE_BROKEN_PREAD
#include "os0file.h"
#include "os0sync.h"
#include "os0thread.h"
......@@ -14,8 +16,6 @@ Created 10/21/1995 Heikki Tuuri
#include "fil0fil.h"
#include "buf0buf.h"
#undef HAVE_FDATASYNC
#ifdef POSIX_ASYNC_IO
/* We assume in this case that the OS has standard Posix aio (at least SunOS
2.6, HP-UX 11i and AIX 4.3 have) */
......@@ -1195,6 +1195,7 @@ os_file_pread(
return(n_bytes);
#else
{
off_t ret_offset;
ssize_t ret;
ulint i;
......@@ -1203,12 +1204,12 @@ os_file_pread(
os_mutex_enter(os_file_seek_mutexes[i]);
ret = lseek(file, offs, 0);
ret_offset = lseek(file, offs, SEEK_SET);
if (ret < 0) {
if (ret_offset < 0) {
os_mutex_exit(os_file_seek_mutexes[i]);
return(ret);
return(-1);
}
ret = read(file, buf, (ssize_t)n);
......@@ -1281,6 +1282,7 @@ os_file_pwrite(
return(ret);
#else
{
off_t ret_offset;
ulint i;
/* Protect the seek / write operation with a mutex */
......@@ -1288,12 +1290,12 @@ os_file_pwrite(
os_mutex_enter(os_file_seek_mutexes[i]);
ret = lseek(file, offs, 0);
ret_offset = lseek(file, offs, SEEK_SET);
if (ret < 0) {
if (ret_offset < 0) {
os_mutex_exit(os_file_seek_mutexes[i]);
return(ret);
return(-1);
}
ret = write(file, buf, (ssize_t)n);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment