Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
jacobsa-fuse
Commits
c71b2cbf
Commit
c71b2cbf
authored
Aug 04, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed two bugs.
parent
c3601bff
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
samples/errorfs/error_fs.go
samples/errorfs/error_fs.go
+10
-8
No files found.
samples/errorfs/error_fs.go
View file @
c71b2cbf
...
@@ -46,7 +46,7 @@ type FS interface {
...
@@ -46,7 +46,7 @@ type FS interface {
func
New
()
(
fs
FS
,
err
error
)
{
func
New
()
(
fs
FS
,
err
error
)
{
fs
=
&
errorFS
{
fs
=
&
errorFS
{
errors
:
make
(
map
[
string
]
syscall
.
Errno
),
errors
:
make
(
map
[
reflect
.
Type
]
syscall
.
Errno
),
}
}
return
return
...
@@ -57,10 +57,8 @@ type errorFS struct {
...
@@ -57,10 +57,8 @@ type errorFS struct {
mu
sync
.
Mutex
mu
sync
.
Mutex
// Keys are reflect.Type.Name strings.
//
// GUARDED_BY(mu)
// GUARDED_BY(mu)
errors
map
[
string
]
syscall
.
Errno
errors
map
[
reflect
.
Type
]
syscall
.
Errno
}
}
// LOCKS_EXCLUDED(fs.mu)
// LOCKS_EXCLUDED(fs.mu)
...
@@ -68,7 +66,7 @@ func (fs *errorFS) SetError(t reflect.Type, err syscall.Errno) {
...
@@ -68,7 +66,7 @@ func (fs *errorFS) SetError(t reflect.Type, err syscall.Errno) {
fs
.
mu
.
Lock
()
fs
.
mu
.
Lock
()
defer
fs
.
mu
.
Unlock
()
defer
fs
.
mu
.
Unlock
()
fs
.
errors
[
t
.
Name
()
]
=
err
fs
.
errors
[
t
]
=
err
}
}
// LOCKS_EXCLUDED(fs.mu)
// LOCKS_EXCLUDED(fs.mu)
...
@@ -76,9 +74,13 @@ func (fs *errorFS) transformError(op interface{}, err *error) bool {
...
@@ -76,9 +74,13 @@ func (fs *errorFS) transformError(op interface{}, err *error) bool {
fs
.
mu
.
Lock
()
fs
.
mu
.
Lock
()
defer
fs
.
mu
.
Unlock
()
defer
fs
.
mu
.
Unlock
()
var
ok
bool
cannedErr
,
ok
:=
fs
.
errors
[
reflect
.
TypeOf
(
op
)]
*
err
,
ok
=
fs
.
errors
[
reflect
.
TypeOf
(
op
)
.
Name
()]
if
ok
{
return
ok
*
err
=
cannedErr
return
true
}
return
false
}
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment