~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_sync.c

  • Committer: Brian Aker
  • Date: 2008-07-20 05:41:52 UTC
  • Revision ID: brian@tangent.org-20080720054152-5laf6plsb0o7h6ss
Documentation cleanup

Show diffs side-by-side

added added

removed removed

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