forked from keybase/kbfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
79 lines (69 loc) · 2.33 KB
/
errors.go
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
// Copyright 2017 Keybase Inc. All rights reserved.
// Use of this source code is governed by a BSD
// license that can be found in the LICENSE file.
package libfuse
import (
"syscall"
"github.com/pkg/errors"
"bazil.org/fuse"
"github.com/keybase/kbfs/kbfsblock"
"github.com/keybase/kbfs/kbfsmd"
"github.com/keybase/kbfs/libkbfs"
)
type errorWithErrno struct {
error
errno syscall.Errno
}
var _ fuse.ErrorNumber = errorWithErrno{}
func (e errorWithErrno) Errno() fuse.Errno {
return fuse.Errno(e.errno)
}
func filterError(err error) error {
switch errors.Cause(err).(type) {
case kbfsblock.ServerErrorUnauthorized:
return errorWithErrno{err, syscall.EACCES}
case kbfsmd.ServerErrorUnauthorized:
return errorWithErrno{err, syscall.EACCES}
case kbfsmd.ServerErrorWriteAccess:
return errorWithErrno{err, syscall.EACCES}
case kbfsmd.MetadataIsFinalError:
return errorWithErrno{err, syscall.EACCES}
case libkbfs.NoSuchUserError:
return errorWithErrno{err, syscall.ENOENT}
case libkbfs.NoSuchTeamError:
return errorWithErrno{err, syscall.ENOENT}
case libkbfs.DirNotEmptyError:
return errorWithErrno{err, syscall.ENOTEMPTY}
case libkbfs.ReadAccessError:
return errorWithErrno{err, syscall.EACCES}
case libkbfs.WriteAccessError:
return errorWithErrno{err, syscall.EACCES}
case libkbfs.WriteUnsupportedError:
return errorWithErrno{err, syscall.ENOENT}
case libkbfs.WriteToReadonlyNodeError:
return errorWithErrno{err, syscall.EACCES}
case libkbfs.UnsupportedOpInUnlinkedDirError:
return errorWithErrno{err, syscall.ENOENT}
case libkbfs.NeedSelfRekeyError:
return errorWithErrno{err, syscall.EACCES}
case libkbfs.NeedOtherRekeyError:
return errorWithErrno{err, syscall.EACCES}
case libkbfs.DisallowedPrefixError:
return errorWithErrno{err, syscall.EINVAL}
case libkbfs.FileTooBigError:
return errorWithErrno{err, syscall.EFBIG}
case libkbfs.NameTooLongError:
return errorWithErrno{err, syscall.ENAMETOOLONG}
case libkbfs.DirTooBigError:
return errorWithErrno{err, syscall.EFBIG}
case libkbfs.NoCurrentSessionError:
return errorWithErrno{err, syscall.EACCES}
case libkbfs.NoSuchFolderListError:
return errorWithErrno{err, syscall.ENOENT}
case libkbfs.RenameAcrossDirsError:
return errorWithErrno{err, syscall.EXDEV}
case *libkbfs.ErrDiskLimitTimeout:
return errorWithErrno{err, syscall.ENOSPC}
}
return err
}