~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_sync.cc

Renamed namespace slot to namespace service.

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/mysys_priv.h"
 
17
#include "mysys/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), "unknown", my_errno);
86
80
  }
87
81
  return(res);
88
82
} /* my_sync */
103
97
#ifdef NEED_EXPLICIT_SYNC_DIR
104
98
int my_sync_dir(const char *dir_name, myf my_flags)
105
99
{
106
 
  int dir_fd;
 
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 */
157
151
}
158
152
#endif
159
153
 
160
 
} /* namespace internal */
161
 
} /* namespace drizzled */