-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_darwin.go
More file actions
184 lines (172 loc) · 4.88 KB
/
errors_darwin.go
File metadata and controls
184 lines (172 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// ©Hayabusa Cloud Co., Ltd. 2026. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
//go:build darwin
package uring
import (
"errors"
"syscall"
"code.hybscloud.com/iofd"
"code.hybscloud.com/iox"
)
// Common errors for semantic consistency across the ecosystem (Darwin stub).
// Aliased to iofd so message identity matches the Linux build.
var (
ErrInvalidParam = iofd.ErrInvalidParam
ErrInterrupted = iofd.ErrInterrupted
ErrNoMemory = iofd.ErrNoMemory
ErrPermission = iofd.ErrPermission
)
// Error definitions for uring operations.
var (
ErrInProgress = errors.New("uring: operation in progress")
ErrFaultParams = errors.New("uring: fault in parameters")
ErrProcessFileLimit = errors.New("uring: process file descriptor limit")
ErrSystemFileLimit = errors.New("uring: system file descriptor limit")
ErrNoDevice = errors.New("uring: no such device")
ErrNotSupported = errors.New("uring: operation not supported")
ErrBusy = errors.New("uring: resource busy")
ErrClosed = errors.New("uring: ring closed")
ErrCQOverflow = errors.New("uring: completion queue overflow")
ErrExists = errors.New("uring: already exists")
ErrNameTooLong = errors.New("uring: name too long")
ErrNotFound = errors.New("uring: not found")
ErrCanceled = errors.New("uring: operation canceled")
ErrTimedOut = errors.New("uring: operation timed out")
ErrConnectionRefused = errors.New("uring: connection refused")
ErrConnectionReset = errors.New("uring: connection reset")
ErrNotConnected = errors.New("uring: not connected")
ErrAlreadyConnected = errors.New("uring: already connected")
ErrAddressInUse = errors.New("uring: address in use")
ErrNetworkUnreachable = errors.New("uring: network unreachable")
ErrHostUnreachable = errors.New("uring: host unreachable")
ErrBrokenPipe = errors.New("uring: broken pipe")
ErrNoBufferSpace = errors.New("uring: no buffer space available")
)
// Darwin errno constants
const (
EPERM = 1
EINTR = 4
ENODEV = 19
EINVAL = 22
EAGAIN = 35
EWOULDBLOCK = EAGAIN
EINPROGRESS = 36
EALREADY = 37
ENOTSOCK = 38
EDESTADDRREQ = 39
EMSGSIZE = 40
EPROTOTYPE = 41
ENOPROTOOPT = 42
EPROTONOSUPPORT = 43
EOPNOTSUPP = 45
EAFNOSUPPORT = 47
EADDRINUSE = 48
EADDRNOTAVAIL = 49
ENETDOWN = 50
ENETUNREACH = 51
ENETRESET = 52
ECONNABORTED = 53
ECONNRESET = 54
ENOBUFS = 55
EISCONN = 56
ENOTCONN = 57
ESHUTDOWN = 58
ETIMEDOUT = 60
ECONNREFUSED = 61
EHOSTDOWN = 64
EHOSTUNREACH = 65
ENOMEM = 12
EACCES = 13
EFAULT = 14
EBUSY = 16
EEXIST = 17
ENAMETOOLONG = 63
EMFILE = 24
ENFILE = 23
ENOSYS = 78
ENOTSUP = 45
EPIPE = 32
ECANCELED = 89
)
// errFromErrno converts a zcall errno to a semantic error.
func errFromErrno(errno uintptr) error {
if errno == 0 {
return nil
}
switch errno {
case EINTR:
return ErrInterrupted
case EAGAIN:
return iox.ErrWouldBlock
case EINPROGRESS, EALREADY:
return ErrInProgress
case EFAULT:
return ErrFaultParams
case EINVAL:
return ErrInvalidParam
case EMFILE:
return ErrProcessFileLimit
case ENFILE:
return ErrSystemFileLimit
case ENODEV:
return ErrNoDevice
case ENOMEM:
return ErrNoMemory
case EACCES, EPERM:
return ErrPermission
case ENOSYS, ENOTSUP:
return ErrNotSupported
case EBUSY:
return ErrBusy
case EEXIST:
return ErrExists
case ENAMETOOLONG:
return ErrNameTooLong
case ECANCELED:
return ErrCanceled
case ETIMEDOUT:
return ErrTimedOut
case ECONNREFUSED:
return ErrConnectionRefused
case ECONNRESET, ECONNABORTED:
return ErrConnectionReset
case ENOTCONN:
return ErrNotConnected
case EISCONN:
return ErrAlreadyConnected
case EADDRINUSE:
return ErrAddressInUse
case ENETUNREACH:
return ErrNetworkUnreachable
case EHOSTUNREACH, EHOSTDOWN:
return ErrHostUnreachable
case EPIPE:
return ErrBrokenPipe
case ENOBUFS:
return ErrNoBufferSpace
default:
return syscall.Errno(errno)
}
}
// CompletionError decodes a CQE result into the package error model.
// Non-negative results are successful byte counts or operation values.
// Negative results are kernel -errno values.
func CompletionError(res int32) error {
if res >= 0 {
return nil
}
return errFromErrno(uintptr(-int64(res)))
}
// Err decodes c.Res as a completion error.
func (c *CQEView) Err() error {
return CompletionError(c.Res)
}
// Err decodes c.Res as a completion error.
func (c *DirectCQE) Err() error {
return CompletionError(c.Res)
}
// Err decodes c.Res as a completion error.
func (c *ExtCQE) Err() error {
return CompletionError(c.Res)
}