~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/backend/port/win32/error.c

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * error.c
 
4
 *        Map win32 error codes to errno values
 
5
 *
 
6
 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
 
7
 *
 
8
 * IDENTIFICATION
 
9
 *        $PostgreSQL: pgsql/src/backend/port/win32/error.c,v 1.4 2004-12-31 22:00:37 pgsql Exp $
 
10
 *
 
11
 *-------------------------------------------------------------------------
 
12
 */
 
13
 
 
14
#include "postgres.h"
 
15
 
 
16
static struct
 
17
{
 
18
        DWORD           winerr;
 
19
        int                     doserr;
 
20
}       doserrors[] =
 
21
 
 
22
{
 
23
        {
 
24
                ERROR_INVALID_FUNCTION, EINVAL
 
25
        },
 
26
        {
 
27
                ERROR_FILE_NOT_FOUND, ENOENT
 
28
        },
 
29
        {
 
30
                ERROR_PATH_NOT_FOUND, ENOENT
 
31
        },
 
32
        {
 
33
                ERROR_TOO_MANY_OPEN_FILES, EMFILE
 
34
        },
 
35
        {
 
36
                ERROR_ACCESS_DENIED, EACCES
 
37
        },
 
38
        {
 
39
                ERROR_INVALID_HANDLE, EBADF
 
40
        },
 
41
        {
 
42
                ERROR_ARENA_TRASHED, ENOMEM
 
43
        },
 
44
        {
 
45
                ERROR_NOT_ENOUGH_MEMORY, ENOMEM
 
46
        },
 
47
        {
 
48
                ERROR_INVALID_BLOCK, ENOMEM
 
49
        },
 
50
        {
 
51
                ERROR_BAD_ENVIRONMENT, E2BIG
 
52
        },
 
53
        {
 
54
                ERROR_BAD_FORMAT, ENOEXEC
 
55
        },
 
56
        {
 
57
                ERROR_INVALID_ACCESS, EINVAL
 
58
        },
 
59
        {
 
60
                ERROR_INVALID_DATA, EINVAL
 
61
        },
 
62
        {
 
63
                ERROR_INVALID_DRIVE, ENOENT
 
64
        },
 
65
        {
 
66
                ERROR_CURRENT_DIRECTORY, EACCES
 
67
        },
 
68
        {
 
69
                ERROR_NOT_SAME_DEVICE, EXDEV
 
70
        },
 
71
        {
 
72
                ERROR_NO_MORE_FILES, ENOENT
 
73
        },
 
74
        {
 
75
                ERROR_LOCK_VIOLATION, EACCES
 
76
        },
 
77
        {
 
78
                ERROR_BAD_NETPATH, ENOENT
 
79
        },
 
80
        {
 
81
                ERROR_NETWORK_ACCESS_DENIED, EACCES
 
82
        },
 
83
        {
 
84
                ERROR_BAD_NET_NAME, ENOENT
 
85
        },
 
86
        {
 
87
                ERROR_FILE_EXISTS, EEXIST
 
88
        },
 
89
        {
 
90
                ERROR_CANNOT_MAKE, EACCES
 
91
        },
 
92
        {
 
93
                ERROR_FAIL_I24, EACCES
 
94
        },
 
95
        {
 
96
                ERROR_INVALID_PARAMETER, EINVAL
 
97
        },
 
98
        {
 
99
                ERROR_NO_PROC_SLOTS, EAGAIN
 
100
        },
 
101
        {
 
102
                ERROR_DRIVE_LOCKED, EACCES
 
103
        },
 
104
        {
 
105
                ERROR_BROKEN_PIPE, EPIPE
 
106
        },
 
107
        {
 
108
                ERROR_DISK_FULL, ENOSPC
 
109
        },
 
110
        {
 
111
                ERROR_INVALID_TARGET_HANDLE, EBADF
 
112
        },
 
113
        {
 
114
                ERROR_INVALID_HANDLE, EINVAL
 
115
        },
 
116
        {
 
117
                ERROR_WAIT_NO_CHILDREN, ECHILD
 
118
        },
 
119
        {
 
120
                ERROR_CHILD_NOT_COMPLETE, ECHILD
 
121
        },
 
122
        {
 
123
                ERROR_DIRECT_ACCESS_HANDLE, EBADF
 
124
        },
 
125
        {
 
126
                ERROR_NEGATIVE_SEEK, EINVAL
 
127
        },
 
128
        {
 
129
                ERROR_SEEK_ON_DEVICE, EACCES
 
130
        },
 
131
        {
 
132
                ERROR_DIR_NOT_EMPTY, ENOTEMPTY
 
133
        },
 
134
        {
 
135
                ERROR_NOT_LOCKED, EACCES
 
136
        },
 
137
        {
 
138
                ERROR_BAD_PATHNAME, ENOENT
 
139
        },
 
140
        {
 
141
                ERROR_MAX_THRDS_REACHED, EAGAIN
 
142
        },
 
143
        {
 
144
                ERROR_LOCK_FAILED, EACCES
 
145
        },
 
146
        {
 
147
                ERROR_ALREADY_EXISTS, EEXIST
 
148
        },
 
149
        {
 
150
                ERROR_FILENAME_EXCED_RANGE, ENOENT
 
151
        },
 
152
        {
 
153
                ERROR_NESTING_NOT_ALLOWED, EAGAIN
 
154
        },
 
155
        {
 
156
                ERROR_NOT_ENOUGH_QUOTA, ENOMEM
 
157
        }
 
158
};
 
159
 
 
160
void
 
161
_dosmaperr(unsigned long e)
 
162
{
 
163
        int                     i;
 
164
 
 
165
        if (e == 0)
 
166
        {
 
167
                errno = 0;
 
168
                return;
 
169
        }
 
170
 
 
171
        for (i = 0; i < sizeof(doserrors) / sizeof(doserrors[0]); i++)
 
172
        {
 
173
                if (doserrors[i].winerr == e)
 
174
                {
 
175
                        errno = doserrors[i].doserr;
 
176
                        ereport(DEBUG5,
 
177
                                        (errmsg_internal("Mapped win32 error code %i to %i",
 
178
                                                                         (int) e, errno)));
 
179
                        return;
 
180
                }
 
181
        }
 
182
 
 
183
        ereport(DEBUG4,
 
184
                        (errmsg_internal("Unknown win32 error code: %i",
 
185
                                                         (int) e)));
 
186
        errno = EINVAL;
 
187
        return;
 
188
}