12
12
You should have received a copy of the GNU General Public License
13
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
18
#include <drizzled/internal/my_sys.h>
19
#include <drizzled/error.h>
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#include "mysys_priv.h"
17
#include "mysys_err.h"
29
22
Read a chunk of bytes from a file with retry's if needed
40
33
N number of bytes read.
43
size_t my_read(int Filedes, unsigned char *Buffer, size_t Count, myf MyFlags)
36
size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags)
45
38
size_t readbytes, save_count;
39
DBUG_ENTER("my_read");
40
DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %lu MyFlags: %d",
41
Filedes, (long) Buffer, (ulong) Count, MyFlags));
50
46
errno= 0; /* Linux doesn't reset this */
51
47
if ((readbytes= read(Filedes, Buffer, Count)) != Count)
53
errno= errno ? errno : -1;
49
my_errno= errno ? errno : -1;
50
DBUG_PRINT("warning",("Read only %d bytes off %lu from %d, errno: %d",
51
(int) readbytes, (ulong) Count, Filedes,
54
53
if ((readbytes == 0 || (int) readbytes == -1) && errno == EINTR)
55
DBUG_PRINT("debug", ("my_read() was interrupted and returned %ld",
56
57
continue; /* Interrupted */
58
59
if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
60
61
if (readbytes == (size_t) -1)
61
62
my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG),
63
my_filename(Filedes),my_errno);
63
64
else if (MyFlags & (MY_NABP | MY_FNABP))
64
65
my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG),
66
my_filename(Filedes),my_errno);
67
68
if (readbytes == (size_t) -1 ||
68
69
((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO)))
69
return(MY_FILE_ERROR); /* Return with error */
70
DBUG_RETURN(MY_FILE_ERROR); /* Return with error */
70
71
if (readbytes != (size_t) -1 && (MyFlags & MY_FULL_IO))
72
73
Buffer+= readbytes;