| 168 | */ |
| 169 | |
| 170 | size_t my_pwrite(File Filedes, const uchar *Buffer, size_t Count, |
| 171 | my_off_t offset, myf MyFlags) |
| 172 | { |
| 173 | size_t writtenbytes; |
| 174 | size_t sum_written= 0; |
| 175 | uint errors= 0; |
| 176 | const size_t initial_count= Count; |
| 177 | |
| 178 | DBUG_ENTER("my_pwrite"); |
| 179 | DBUG_PRINT("my",("fd: %d Seek: %llu Buffer: %p Count: %lu MyFlags: %d", |
| 180 | Filedes, offset, Buffer, (ulong)Count, MyFlags)); |
| 181 | |
| 182 | for (;;) |
| 183 | { |
| 184 | errno= 0; |
| 185 | #if !defined (HAVE_PREAD) && !defined (_WIN32) |
| 186 | int error; |
| 187 | writtenbytes= (size_t) -1; |
| 188 | mysql_mutex_lock(&my_file_info[Filedes].mutex); |
| 189 | error= (lseek(Filedes, offset, MY_SEEK_SET) != (my_off_t) -1 && |
| 190 | (writtenbytes= write(Filedes, Buffer, Count)) == Count); |
| 191 | mysql_mutex_unlock(&my_file_info[Filedes].mutex); |
| 192 | if (error) |
| 193 | break; |
| 194 | #elif defined (_WIN32) |
| 195 | writtenbytes= my_win_pwrite(Filedes, Buffer, Count, offset); |
| 196 | #else |
| 197 | writtenbytes= pwrite(Filedes, Buffer, Count, offset); |
| 198 | #endif |
| 199 | if(writtenbytes == Count) |
| 200 | { |
| 201 | sum_written+= writtenbytes; |
| 202 | break; |
| 203 | } |
| 204 | my_errno= errno; |
| 205 | if (writtenbytes != (size_t) -1) |
| 206 | { |
| 207 | sum_written+= writtenbytes; |
| 208 | Buffer+= writtenbytes; |
| 209 | Count-= writtenbytes; |
| 210 | offset+= writtenbytes; |
| 211 | } |
| 212 | DBUG_PRINT("error",("Write only %u bytes", (uint) writtenbytes)); |
| 213 | #ifndef NO_BACKGROUND |
| 214 | |
| 215 | if (my_thread_var->abort) |
| 216 | MyFlags&= ~ MY_WAIT_IF_FULL; /* End if aborted by user */ |
| 217 | |
| 218 | if ((my_errno == ENOSPC || my_errno == EDQUOT) && |
| 219 | (MyFlags & MY_WAIT_IF_FULL)) |
| 220 | { |
| 221 | wait_for_free_space(my_filename(Filedes), errors); |
| 222 | errors++; |
| 223 | continue; |
| 224 | } |
| 225 | if (writtenbytes != 0 && writtenbytes != (size_t) -1) |
| 226 | continue; |
| 227 | else if (my_errno == EINTR) |
no test coverage detected