full diff: https://github.com/containerd/fifo/compare/a9fb20d87448d386e6d50b1f2e1fa70dcf0de43c...bda0ff6ed73c67bfb5e62bc9c697f146b7fd7f13
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -118,7 +118,7 @@ google.golang.org/genproto 694d95ba50e67b2e363f3483057d |
| 118 | 118 |
|
| 119 | 119 |
# containerd |
| 120 | 120 |
github.com/containerd/containerd 36cf5b690dcc00ff0f34ff7799209050c3d0c59a # v1.3.0 |
| 121 |
-github.com/containerd/fifo a9fb20d87448d386e6d50b1f2e1fa70dcf0de43c |
|
| 121 |
+github.com/containerd/fifo bda0ff6ed73c67bfb5e62bc9c697f146b7fd7f13 |
|
| 122 | 122 |
github.com/containerd/continuity f2a389ac0a02ce21c09edd7344677a601970f41c |
| 123 | 123 |
github.com/containerd/cgroups c4b9ac5c7601384c965b9646fc515884e091ebb9 |
| 124 | 124 |
github.com/containerd/console 0650fd9eeb50bab4fc99dceb9f2e14cf58f36e7f |
| 125 | 125 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,30 @@ |
| 0 |
+/* |
|
| 1 |
+ Copyright The containerd Authors. |
|
| 2 |
+ |
|
| 3 |
+ Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 4 |
+ you may not use this file except in compliance with the License. |
|
| 5 |
+ You may obtain a copy of the License at |
|
| 6 |
+ |
|
| 7 |
+ http://www.apache.org/licenses/LICENSE-2.0 |
|
| 8 |
+ |
|
| 9 |
+ Unless required by applicable law or agreed to in writing, software |
|
| 10 |
+ distributed under the License is distributed on an "AS IS" BASIS, |
|
| 11 |
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 12 |
+ See the License for the specific language governing permissions and |
|
| 13 |
+ limitations under the License. |
|
| 14 |
+*/ |
|
| 15 |
+ |
|
| 16 |
+package fifo |
|
| 17 |
+ |
|
| 18 |
+import ( |
|
| 19 |
+ "errors" |
|
| 20 |
+) |
|
| 21 |
+ |
|
| 22 |
+var ( |
|
| 23 |
+ ErrClosed = errors.New("fifo closed")
|
|
| 24 |
+ ErrCtrlClosed = errors.New("control of closed fifo")
|
|
| 25 |
+ ErrRdFrmWRONLY = errors.New("reading from write-only fifo")
|
|
| 26 |
+ ErrReadClosed = errors.New("reading from a closed fifo")
|
|
| 27 |
+ ErrWrToRDONLY = errors.New("writing to read-only fifo")
|
|
| 28 |
+ ErrWriteClosed = errors.New("writing to a closed fifo")
|
|
| 29 |
+) |
| ... | ... |
@@ -147,7 +147,7 @@ func OpenFifo(ctx context.Context, fn string, flag int, perm os.FileMode) (io.Re |
| 147 | 147 |
// Read from a fifo to a byte array. |
| 148 | 148 |
func (f *fifo) Read(b []byte) (int, error) {
|
| 149 | 149 |
if f.flag&syscall.O_WRONLY > 0 {
|
| 150 |
- return 0, errors.New("reading from write-only fifo")
|
|
| 150 |
+ return 0, ErrRdFrmWRONLY |
|
| 151 | 151 |
} |
| 152 | 152 |
select {
|
| 153 | 153 |
case <-f.opened: |
| ... | ... |
@@ -158,14 +158,14 @@ func (f *fifo) Read(b []byte) (int, error) {
|
| 158 | 158 |
case <-f.opened: |
| 159 | 159 |
return f.file.Read(b) |
| 160 | 160 |
case <-f.closed: |
| 161 |
- return 0, errors.New("reading from a closed fifo")
|
|
| 161 |
+ return 0, ErrReadClosed |
|
| 162 | 162 |
} |
| 163 | 163 |
} |
| 164 | 164 |
|
| 165 | 165 |
// Write from byte array to a fifo. |
| 166 | 166 |
func (f *fifo) Write(b []byte) (int, error) {
|
| 167 | 167 |
if f.flag&(syscall.O_WRONLY|syscall.O_RDWR) == 0 {
|
| 168 |
- return 0, errors.New("writing to read-only fifo")
|
|
| 168 |
+ return 0, ErrWrToRDONLY |
|
| 169 | 169 |
} |
| 170 | 170 |
select {
|
| 171 | 171 |
case <-f.opened: |
| ... | ... |
@@ -176,7 +176,7 @@ func (f *fifo) Write(b []byte) (int, error) {
|
| 176 | 176 |
case <-f.opened: |
| 177 | 177 |
return f.file.Write(b) |
| 178 | 178 |
case <-f.closed: |
| 179 |
- return 0, errors.New("writing to a closed fifo")
|
|
| 179 |
+ return 0, ErrWriteClosed |
|
| 180 | 180 |
} |
| 181 | 181 |
} |
| 182 | 182 |
|
| ... | ... |
@@ -20,8 +20,6 @@ package fifo |
| 20 | 20 |
|
| 21 | 21 |
import ( |
| 22 | 22 |
"syscall" |
| 23 |
- |
|
| 24 |
- "github.com/pkg/errors" |
|
| 25 | 23 |
) |
| 26 | 24 |
|
| 27 | 25 |
// SyscallConn provides raw access to the fifo's underlying filedescrptor. |
| ... | ... |
@@ -30,13 +28,13 @@ func (f *fifo) SyscallConn() (syscall.RawConn, error) {
|
| 30 | 30 |
// deterministic check for closed |
| 31 | 31 |
select {
|
| 32 | 32 |
case <-f.closed: |
| 33 |
- return nil, errors.New("fifo closed")
|
|
| 33 |
+ return nil, ErrClosed |
|
| 34 | 34 |
default: |
| 35 | 35 |
} |
| 36 | 36 |
|
| 37 | 37 |
select {
|
| 38 | 38 |
case <-f.closed: |
| 39 |
- return nil, errors.New("fifo closed")
|
|
| 39 |
+ return nil, ErrClosed |
|
| 40 | 40 |
case <-f.opened: |
| 41 | 41 |
return f.file.SyscallConn() |
| 42 | 42 |
default: |
| ... | ... |
@@ -68,7 +66,7 @@ type rawConn struct {
|
| 68 | 68 |
func (r *rawConn) Control(f func(fd uintptr)) error {
|
| 69 | 69 |
select {
|
| 70 | 70 |
case <-r.f.closed: |
| 71 |
- return errors.New("control of closed fifo")
|
|
| 71 |
+ return ErrCtrlClosed |
|
| 72 | 72 |
case <-r.ready: |
| 73 | 73 |
} |
| 74 | 74 |
|
| ... | ... |
@@ -81,12 +79,12 @@ func (r *rawConn) Control(f func(fd uintptr)) error {
|
| 81 | 81 |
|
| 82 | 82 |
func (r *rawConn) Read(f func(fd uintptr) (done bool)) error {
|
| 83 | 83 |
if r.f.flag&syscall.O_WRONLY > 0 {
|
| 84 |
- return errors.New("reading from write-only fifo")
|
|
| 84 |
+ return ErrRdFrmWRONLY |
|
| 85 | 85 |
} |
| 86 | 86 |
|
| 87 | 87 |
select {
|
| 88 | 88 |
case <-r.f.closed: |
| 89 |
- return errors.New("reading of a closed fifo")
|
|
| 89 |
+ return ErrReadClosed |
|
| 90 | 90 |
case <-r.ready: |
| 91 | 91 |
} |
| 92 | 92 |
|
| ... | ... |
@@ -99,12 +97,12 @@ func (r *rawConn) Read(f func(fd uintptr) (done bool)) error {
|
| 99 | 99 |
|
| 100 | 100 |
func (r *rawConn) Write(f func(fd uintptr) (done bool)) error {
|
| 101 | 101 |
if r.f.flag&(syscall.O_WRONLY|syscall.O_RDWR) == 0 {
|
| 102 |
- return errors.New("writing to read-only fifo")
|
|
| 102 |
+ return ErrWrToRDONLY |
|
| 103 | 103 |
} |
| 104 | 104 |
|
| 105 | 105 |
select {
|
| 106 | 106 |
case <-r.f.closed: |
| 107 |
- return errors.New("writing to a closed fifo")
|
|
| 107 |
+ return ErrWriteClosed |
|
| 108 | 108 |
case <-r.ready: |
| 109 | 109 |
} |
| 110 | 110 |
|