~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/my_pread.c

  • Committer: Brian Aker
  • Date: 2008-07-06 06:01:07 UTC
  • Revision ID: brian@tangent.org-20080706060107-llyy4p2ar8auddp6
Removed critical rt include files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
#include "myisamdef.h"
17
 
#include <mysys/mysys_err.h>
 
17
#include "mysys_err.h"
18
18
#include <errno.h>
19
19
#include <unistd.h>
20
20
 
39
39
    #             Number of bytes read
40
40
*/
41
41
 
42
 
size_t my_pread(File Filedes, unsigned char *Buffer, size_t Count, my_off_t offset,
 
42
size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset,
43
43
                myf MyFlags)
44
44
{
45
45
  size_t readbytes;
46
46
  int error= 0;
 
47
  DBUG_ENTER("my_pread");
 
48
  DBUG_PRINT("my",("Fd: %d  Seek: %lu  Buffer: 0x%lx  Count: %u  MyFlags: %d",
 
49
                   Filedes, (ulong) offset, (long) Buffer, (uint) Count,
 
50
                   MyFlags));
47
51
  for (;;)
48
52
  {
49
53
    errno=0;                                    /* Linux doesn't reset this */
51
55
      my_errno= errno ? errno : -1;
52
56
    if (error || readbytes != Count)
53
57
    {
 
58
      DBUG_PRINT("warning",("Read only %d bytes off %u from %d, errno: %d",
 
59
                            (int) readbytes, (uint) Count,Filedes,my_errno));
54
60
      if ((readbytes == 0 || readbytes == (size_t) -1) && errno == EINTR)
55
61
      {
 
62
        DBUG_PRINT("debug", ("my_pread() was interrupted and returned %d",
 
63
                             (int) readbytes));
56
64
        continue;                              /* Interrupted */
57
65
      }
58
66
      if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
65
73
                   my_filename(Filedes),my_errno);
66
74
      }
67
75
      if (readbytes == (size_t) -1 || (MyFlags & (MY_FNABP | MY_NABP)))
68
 
        return(MY_FILE_ERROR);          /* Return with error */
 
76
        DBUG_RETURN(MY_FILE_ERROR);             /* Return with error */
69
77
    }
70
78
    if (MyFlags & (MY_NABP | MY_FNABP))
71
 
      return(0);                                /* Read went ok; Return 0 */
72
 
    return(readbytes);                  /* purecov: inspected */
 
79
      DBUG_RETURN(0);                           /* Read went ok; Return 0 */
 
80
    DBUG_RETURN(readbytes);                     /* purecov: inspected */
73
81
  }
74
82
} /* my_pread */
75
83
 
95
103
    #             Number of bytes read
96
104
*/
97
105
 
98
 
size_t my_pwrite(int Filedes, const unsigned char *Buffer, size_t Count,
 
106
size_t my_pwrite(int Filedes, const uchar *Buffer, size_t Count,
99
107
                 my_off_t offset, myf MyFlags)
100
108
{
101
109
  size_t writenbytes, written;
102
 
  uint32_t errors;
 
110
  uint errors;
 
111
  DBUG_ENTER("my_pwrite");
 
112
  DBUG_PRINT("my",("Fd: %d  Seek: %lu  Buffer: 0x%lx  Count: %u  MyFlags: %d",
 
113
                   Filedes, (ulong) offset, (long) Buffer, (uint) Count,
 
114
                   MyFlags));
103
115
  errors= 0;
104
116
  written= 0;
105
117
 
115
127
      Count-=writenbytes;
116
128
      offset+=writenbytes;
117
129
    }
 
130
    DBUG_PRINT("error",("Write only %u bytes", (uint) writenbytes));
118
131
#ifndef NO_BACKGROUND
119
132
    if (my_thread_var->abort)
120
133
      MyFlags&= ~ MY_WAIT_IF_FULL;              /* End if aborted by user */
124
137
      if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE))
125
138
        my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH),
126
139
                 my_filename(Filedes),my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
127
 
      sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC);
 
140
      VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
128
141
      continue;
129
142
    }
130
143
    if ((writenbytes && writenbytes != (size_t) -1) || my_errno == EINTR)
137
150
        my_error(EE_WRITE, MYF(ME_BELL | ME_WAITTANG),
138
151
                 my_filename(Filedes),my_errno);
139
152
      }
140
 
      return(MY_FILE_ERROR);            /* Error on read */
 
153
      DBUG_RETURN(MY_FILE_ERROR);               /* Error on read */
141
154
    }
142
155
    else
143
156
      break;                                    /* Return bytes written */
144
157
  }
 
158
  DBUG_EXECUTE_IF("check", my_seek(Filedes, -1, SEEK_SET, MYF(0)););
145
159
  if (MyFlags & (MY_NABP | MY_FNABP))
146
 
    return(0);                  /* Want only errors */
147
 
  return(writenbytes+written); /* purecov: inspected */
 
160
    DBUG_RETURN(0);                     /* Want only errors */
 
161
  DBUG_RETURN(writenbytes+written); /* purecov: inspected */
148
162
} /* my_pwrite */