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
Levin Zimmermann
go-fuse
Commits
0f459cbf
Commit
0f459cbf
authored
Sep 26, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MemUnionFs: wait for closes to reap unionfs.
parent
5b5bf08b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
8 deletions
+28
-8
unionfs/memunionfs.go
unionfs/memunionfs.go
+28
-8
No files found.
unionfs/memunionfs.go
View file @
0f459cbf
...
...
@@ -20,9 +20,12 @@ type MemUnionFs struct {
root
*
memNode
mutex
sync
.
RWMutex
cond
*
sync
.
Cond
nextFree
int
readonly
fuse
.
FileSystem
openWritable
int
}
type
memNode
struct
{
...
...
@@ -46,10 +49,20 @@ type Result struct {
Link
string
}
func
(
me
*
MemUnionFs
)
Reap
()
map
[
string
]
*
Result
{
me
.
mutex
.
RLock
()
defer
me
.
mutex
.
RUnlock
()
func
(
me
*
MemUnionFs
)
release
()
{
me
.
mutex
.
Lock
()
defer
me
.
mutex
.
Unlock
()
me
.
openWritable
--
me
.
cond
.
Broadcast
()
}
func
(
me
*
MemUnionFs
)
Reap
()
map
[
string
]
*
Result
{
me
.
mutex
.
Lock
()
defer
me
.
mutex
.
Unlock
()
for
me
.
openWritable
>
0
{
me
.
cond
.
Wait
()
}
m
:=
map
[
string
]
*
Result
{}
me
.
root
.
Reap
(
""
,
m
)
return
m
...
...
@@ -96,6 +109,7 @@ func NewMemUnionFs(backingStore string, roFs fuse.FileSystem) *MemUnionFs {
me
.
backingStore
=
backingStore
me
.
readonly
=
roFs
me
.
root
=
me
.
newNode
(
true
)
me
.
cond
=
sync
.
NewCond
(
&
me
.
mutex
)
return
me
}
...
...
@@ -236,6 +250,7 @@ func (me *memNode) Create(name string, flags uint32, mode uint32, context *fuse.
me
.
Inode
()
.
AddChild
(
name
,
n
.
Inode
())
me
.
touch
()
me
.
deleted
[
name
]
=
false
,
false
me
.
fs
.
openWritable
++
return
n
.
newFile
(
&
fuse
.
LoopbackFile
{
File
:
f
},
true
),
&
n
.
info
,
n
,
fuse
.
OK
}
...
...
@@ -249,6 +264,11 @@ func (me *memNodeFile) InnerFile() fuse.File {
return
me
.
File
}
func
(
me
*
memNodeFile
)
Release
()
{
me
.
node
.
fs
.
release
()
me
.
File
.
Release
()
}
func
(
me
*
memNodeFile
)
Flush
()
fuse
.
Status
{
code
:=
me
.
File
.
Flush
()
if
me
.
writable
{
...
...
@@ -294,22 +314,22 @@ func (me *memNode) promote() {
}
func
(
me
*
memNode
)
Open
(
flags
uint32
,
context
*
fuse
.
Context
)
(
file
fuse
.
File
,
code
fuse
.
Status
)
{
me
.
mutex
.
Lock
()
defer
me
.
mutex
.
Unlock
()
if
flags
&
fuse
.
O_ANYWRITE
!=
0
{
me
.
mutex
.
Lock
()
me
.
promote
()
me
.
touch
()
me
.
mutex
.
Unlock
()
}
me
.
mutex
.
RLock
()
defer
me
.
mutex
.
RUnlock
()
if
me
.
backing
!=
""
{
f
,
err
:=
os
.
OpenFile
(
me
.
backing
,
int
(
flags
),
0666
)
if
err
!=
nil
{
return
nil
,
fuse
.
OsErrorToErrno
(
err
)
}
wr
:=
flags
&
fuse
.
O_ANYWRITE
!=
0
if
wr
{
me
.
fs
.
openWritable
++
}
return
me
.
newFile
(
&
fuse
.
LoopbackFile
{
File
:
f
},
wr
),
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