Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-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
go-fuse
Commits
7f7894d2
Commit
7f7894d2
authored
Jan 30, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fuse/nodefs: protect mutable memnode fields with lock
This fixes race conditions found by the race detector.
parent
e6fa1a12
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
fuse/nodefs/memnode.go
fuse/nodefs/memnode.go
+20
-0
No files found.
fuse/nodefs/memnode.go
View file @
7f7894d2
...
@@ -75,6 +75,7 @@ type memNode struct {
...
@@ -75,6 +75,7 @@ type memNode struct {
fs
*
memNodeFs
fs
*
memNodeFs
id
int
id
int
mu
sync
.
Mutex
link
string
link
string
info
fuse
.
Attr
info
fuse
.
Attr
}
}
...
@@ -88,6 +89,8 @@ func (n *memNode) Deletable() bool {
...
@@ -88,6 +89,8 @@ func (n *memNode) Deletable() bool {
}
}
func
(
n
*
memNode
)
Readlink
(
c
*
fuse
.
Context
)
([]
byte
,
fuse
.
Status
)
{
func
(
n
*
memNode
)
Readlink
(
c
*
fuse
.
Context
)
([]
byte
,
fuse
.
Status
)
{
n
.
mu
.
Lock
()
defer
n
.
mu
.
Unlock
()
return
[]
byte
(
n
.
link
),
fuse
.
OK
return
[]
byte
(
n
.
link
),
fuse
.
OK
}
}
...
@@ -168,6 +171,9 @@ func (n *memNodeFile) Flush() fuse.Status {
...
@@ -168,6 +171,9 @@ func (n *memNodeFile) Flush() fuse.Status {
st
:=
syscall
.
Stat_t
{}
st
:=
syscall
.
Stat_t
{}
err
:=
syscall
.
Stat
(
n
.
node
.
filename
(),
&
st
)
err
:=
syscall
.
Stat
(
n
.
node
.
filename
(),
&
st
)
n
.
node
.
mu
.
Lock
()
defer
n
.
node
.
mu
.
Unlock
()
n
.
node
.
info
.
Size
=
uint64
(
st
.
Size
)
n
.
node
.
info
.
Size
=
uint64
(
st
.
Size
)
n
.
node
.
info
.
Blocks
=
uint64
(
st
.
Blocks
)
n
.
node
.
info
.
Blocks
=
uint64
(
st
.
Blocks
)
return
fuse
.
ToStatus
(
err
)
return
fuse
.
ToStatus
(
err
)
...
@@ -190,6 +196,9 @@ func (n *memNode) Open(flags uint32, context *fuse.Context) (file File, code fus
...
@@ -190,6 +196,9 @@ func (n *memNode) Open(flags uint32, context *fuse.Context) (file File, code fus
}
}
func
(
n
*
memNode
)
GetAttr
(
fi
*
fuse
.
Attr
,
file
File
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
func
(
n
*
memNode
)
GetAttr
(
fi
*
fuse
.
Attr
,
file
File
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
n
.
mu
.
Lock
()
defer
n
.
mu
.
Unlock
()
*
fi
=
n
.
info
*
fi
=
n
.
info
return
fuse
.
OK
return
fuse
.
OK
}
}
...
@@ -203,6 +212,10 @@ func (n *memNode) Truncate(file File, size uint64, context *fuse.Context) (code
...
@@ -203,6 +212,10 @@ func (n *memNode) Truncate(file File, size uint64, context *fuse.Context) (code
}
}
if
code
.
Ok
()
{
if
code
.
Ok
()
{
now
:=
time
.
Now
()
now
:=
time
.
Now
()
n
.
mu
.
Lock
()
defer
n
.
mu
.
Unlock
()
n
.
info
.
SetTimes
(
nil
,
nil
,
&
now
)
n
.
info
.
SetTimes
(
nil
,
nil
,
&
now
)
// TODO - should update mtime too?
// TODO - should update mtime too?
n
.
info
.
Size
=
size
n
.
info
.
Size
=
size
...
@@ -212,6 +225,9 @@ func (n *memNode) Truncate(file File, size uint64, context *fuse.Context) (code
...
@@ -212,6 +225,9 @@ func (n *memNode) Truncate(file File, size uint64, context *fuse.Context) (code
func
(
n
*
memNode
)
Utimens
(
file
File
,
atime
*
time
.
Time
,
mtime
*
time
.
Time
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
func
(
n
*
memNode
)
Utimens
(
file
File
,
atime
*
time
.
Time
,
mtime
*
time
.
Time
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
c
:=
time
.
Now
()
c
:=
time
.
Now
()
n
.
mu
.
Lock
()
defer
n
.
mu
.
Unlock
()
n
.
info
.
SetTimes
(
atime
,
mtime
,
&
c
)
n
.
info
.
SetTimes
(
atime
,
mtime
,
&
c
)
return
fuse
.
OK
return
fuse
.
OK
}
}
...
@@ -219,6 +235,8 @@ func (n *memNode) Utimens(file File, atime *time.Time, mtime *time.Time, context
...
@@ -219,6 +235,8 @@ func (n *memNode) Utimens(file File, atime *time.Time, mtime *time.Time, context
func
(
n
*
memNode
)
Chmod
(
file
File
,
perms
uint32
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
func
(
n
*
memNode
)
Chmod
(
file
File
,
perms
uint32
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
n
.
info
.
Mode
=
(
n
.
info
.
Mode
&^
07777
)
|
perms
n
.
info
.
Mode
=
(
n
.
info
.
Mode
&^
07777
)
|
perms
now
:=
time
.
Now
()
now
:=
time
.
Now
()
n
.
mu
.
Lock
()
defer
n
.
mu
.
Unlock
()
n
.
info
.
SetTimes
(
nil
,
nil
,
&
now
)
n
.
info
.
SetTimes
(
nil
,
nil
,
&
now
)
return
fuse
.
OK
return
fuse
.
OK
}
}
...
@@ -227,6 +245,8 @@ func (n *memNode) Chown(file File, uid uint32, gid uint32, context *fuse.Context
...
@@ -227,6 +245,8 @@ func (n *memNode) Chown(file File, uid uint32, gid uint32, context *fuse.Context
n
.
info
.
Uid
=
uid
n
.
info
.
Uid
=
uid
n
.
info
.
Gid
=
gid
n
.
info
.
Gid
=
gid
now
:=
time
.
Now
()
now
:=
time
.
Now
()
n
.
mu
.
Lock
()
defer
n
.
mu
.
Unlock
()
n
.
info
.
SetTimes
(
nil
,
nil
,
&
now
)
n
.
info
.
SetTimes
(
nil
,
nil
,
&
now
)
return
fuse
.
OK
return
fuse
.
OK
}
}
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