16 #include "myisam_priv.h"
17 #include <drizzled/error.h>
21 using namespace drizzled;
23 #define MY_WAIT_FOR_USER_TO_FIX_PANIC 60
24 #define MY_WAIT_GIVE_USER_A_MESSAGE 10
47 size_t my_pread(
int Filedes,
unsigned char *Buffer,
size_t Count, internal::my_off_t offset,
55 if ((error= ((readbytes= pread(Filedes, Buffer, Count, offset)) != Count)))
56 errno= errno ? errno : -1;
57 if (error || readbytes != Count)
59 if ((readbytes == 0 || readbytes == (
size_t) -1) && errno == EINTR)
63 if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
65 if (readbytes == (
size_t) -1)
66 my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG),
"unknown", errno);
67 else if (MyFlags & (MY_NABP | MY_FNABP))
68 my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG),
"unknown", errno);
70 if (readbytes == (
size_t) -1 || (MyFlags & (MY_FNABP | MY_NABP)))
71 return(MY_FILE_ERROR);
73 if (MyFlags & (MY_NABP | MY_FNABP))
101 size_t my_pwrite(
int Filedes,
const unsigned char *Buffer,
size_t Count,
102 internal::my_off_t offset, myf MyFlags)
104 size_t writenbytes, written;
111 if ((writenbytes= pwrite(Filedes, Buffer, Count,offset)) == Count)
114 if (writenbytes != (
size_t) -1)
116 written+=writenbytes;
121 #ifndef NO_BACKGROUND
122 if ((errno == ENOSPC || errno == EDQUOT) &&
123 (MyFlags & MY_WAIT_IF_FULL))
125 if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE))
126 my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH),
127 "unknown", errno, MY_WAIT_FOR_USER_TO_FIX_PANIC);
128 sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC);
131 if ((writenbytes && writenbytes != (
size_t) -1) || errno == EINTR)
134 if (MyFlags & (MY_NABP | MY_FNABP))
136 if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
138 my_error(EE_WRITE, MYF(ME_BELL | ME_WAITTANG),
"unknown", errno);
140 return(MY_FILE_ERROR);
145 if (MyFlags & (MY_NABP | MY_FNABP))
147 return(writenbytes+written);