~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/internal/my_sync.cc

  • Committer: Brian Aker
  • Date: 2010-02-07 01:33:54 UTC
  • Revision ID: brian@gaz-20100207013354-d2pg1n68u5c09pgo
Remove giant include header to its own file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include "mysys_priv.h"
17
 
#include "mysys_err.h"
 
16
#include "config.h"
 
17
#include "drizzled/internal/my_sys.h"
 
18
 
18
19
#include <errno.h>
 
20
#include <fcntl.h>
 
21
 
 
22
#include "drizzled/my_error.h"
 
23
 
 
24
namespace drizzled
 
25
{
 
26
namespace internal
 
27
{
19
28
 
20
29
/*
21
30
  Sync data in file to disk
40
49
    -1 error
41
50
*/
42
51
 
43
 
int my_sync(File fd, myf my_flags)
 
52
int my_sync(int fd, myf my_flags)
44
53
{
45
54
  int res;
46
55
 
57
66
#endif
58
67
#if defined(HAVE_FDATASYNC)
59
68
    res= fdatasync(fd);
60
 
#elif defined(HAVE_FSYNC)
 
69
#else
61
70
    res= fsync(fd);
62
 
#else
63
 
#error Cannot find a way to sync a file, durability in danger
64
 
    res= 0;                                     /* No sync (strange OS) */
65
71
#endif
66
72
  } while (res == -1 && errno == EINTR);
67
73
 
68
74
  if (res)
69
75
  {
70
76
    int er= errno;
71
 
    if (!(my_errno= er))
72
 
      my_errno= -1;                             /* Unknown error */
 
77
    if (!(errno= er))
 
78
      errno= -1;                             /* Unknown error */
73
79
    if ((my_flags & MY_IGNORE_BADFD) &&
74
80
        (er == EBADF || er == EINVAL || er == EROFS))
75
81
    {
76
82
      res= 0;
77
83
    }
78
84
    else if (my_flags & MY_WME)
79
 
      my_error(EE_SYNC, MYF(ME_BELL+ME_WAITTANG), my_filename(fd), my_errno);
 
85
      my_error(EE_SYNC, MYF(ME_BELL+ME_WAITTANG), "unknown", errno);
80
86
  }
81
87
  return(res);
82
88
} /* my_sync */
94
100
  RETURN
95
101
    0 if ok, !=0 if error
96
102
*/
97
 
int my_sync_dir(const char *dir_name __attribute__((unused)),
98
 
                myf my_flags __attribute__((unused)))
 
103
#ifdef NEED_EXPLICIT_SYNC_DIR
 
104
int my_sync_dir(const char *dir_name, myf my_flags)
99
105
{
100
 
#ifdef NEED_EXPLICIT_SYNC_DIR
101
 
  File dir_fd;
 
106
  int dir_fd;
102
107
  int res= 0;
103
108
  const char *correct_dir_name;
104
109
  /* Sometimes the path does not contain an explicit directory */
117
122
  else
118
123
    res= 1;
119
124
  return(res);
 
125
}
120
126
#else
 
127
int my_sync_dir(const char *, myf)
 
128
{
121
129
  return 0;
 
130
}
122
131
#endif
123
 
}
124
132
 
125
133
 
126
134
/*
134
142
  RETURN
135
143
    0 if ok, !=0 if error
136
144
*/
137
 
int my_sync_dir_by_file(const char *file_name __attribute__((unused)),
138
 
                        myf my_flags __attribute__((unused)))
 
145
#ifdef NEED_EXPLICIT_SYNC_DIR
 
146
int my_sync_dir_by_file(const char *file_name, myf my_flags)
139
147
{
140
 
#ifdef NEED_EXPLICIT_SYNC_DIR
141
148
  char dir_name[FN_REFLEN];
142
149
  size_t dir_name_length;
143
150
  dirname_part(dir_name, file_name, &dir_name_length);
144
151
  return my_sync_dir(dir_name, my_flags);
 
152
}
145
153
#else
 
154
int my_sync_dir_by_file(const char *, myf)
 
155
{
146
156
  return 0;
 
157
}
147
158
#endif
148
 
}
149
159
 
 
160
} /* namespace internal */
 
161
} /* namespace drizzled */