~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_open.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 01:03:01 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913010301-tcvvezipx1124acy
Added calls to the dtrace delete begin/end probes.

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 "config.h"
17
 
 
18
 
#include "drizzled/internal/my_sys.h"
19
 
#include "drizzled/error.h"
20
 
 
21
 
#include <fcntl.h>
22
 
 
23
 
#include <cerrno>
24
 
#include <cstdlib>
25
 
#include <cstring>
26
 
 
27
 
 
28
 
namespace drizzled
29
 
{
30
 
namespace internal
31
 
{
 
16
#include "mysys/mysys_priv.h"
 
17
#include "mysys/mysys_err.h"
 
18
#include "my_dir.h"
 
19
 
 
20
#include <errno.h>
 
21
#include <stdlib.h>
 
22
#include <string.h>
32
23
 
33
24
/*
34
25
  Open a file
40
31
      MyFlags   Special flags
41
32
 
42
33
  RETURN VALUE
43
 
    int descriptor
 
34
    File descriptor
44
35
*/
45
36
 
46
 
int my_open(const char *FileName, int Flags, myf MyFlags)
 
37
File my_open(const char *FileName, int Flags, myf MyFlags)
47
38
                                /* Path-name of file */
48
39
                                /* Read | write .. */
49
40
                                /* Special flags */
50
41
{
51
 
  int fd;
 
42
  File fd;
52
43
 
53
44
#if !defined(NO_OPEN_3)
54
45
  fd = open(FileName, Flags, my_umask); /* Normal unix */
70
61
 
71
62
*/
72
63
 
73
 
int my_close(int fd, myf MyFlags)
 
64
int my_close(File fd, myf MyFlags)
74
65
{
75
66
  int err;
76
67
 
81
72
 
82
73
  if (err)
83
74
  {
84
 
    errno=errno;
 
75
    my_errno=errno;
85
76
    if (MyFlags & (MY_FAE | MY_WME))
86
77
      my_error(EE_BADCLOSE, MYF(ME_BELL+ME_WAITTANG), "unknown", errno);
87
78
  }
 
79
  my_file_opened--;
88
80
 
89
81
  return(err);
90
82
} /* my_close */
107
99
 
108
100
*/
109
101
 
110
 
int my_register_filename(int fd, const char *FileName, uint32_t error_message_number, myf MyFlags)
 
102
File my_register_filename(File fd, const char *FileName, uint32_t error_message_number, myf MyFlags)
111
103
{
112
104
  if ((int) fd >= 0)
113
105
  {
 
106
    my_file_opened++;
 
107
    my_file_total_opened++;
 
108
 
114
109
    return fd;
115
110
  }
116
111
  else
117
 
    errno= errno;
 
112
    my_errno= errno;
118
113
 
119
114
  if (MyFlags & (MY_FFNF | MY_FAE | MY_WME))
120
115
  {
121
 
    if (errno == EMFILE)
 
116
    if (my_errno == EMFILE)
122
117
      error_message_number= EE_OUT_OF_FILERESOURCES;
123
118
    my_error(error_message_number, MYF(ME_BELL+ME_WAITTANG),
124
 
             FileName, errno);
 
119
             FileName, my_errno);
125
120
  }
126
121
  return -1;
127
122
}
128
 
 
129
 
} /* namespace internal */
130
 
} /* namespace drizzled */