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
f7de38df
Commit
f7de38df
authored
Aug 18, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a inode => openedFile mapping.
parent
80362c9c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
14 deletions
+25
-14
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+25
-14
No files found.
fuse/pathfilesystem.go
View file @
f7de38df
...
...
@@ -72,16 +72,27 @@ func (me *fileSystemMount) unregisterFileHandle(node *inode, handle uint64) *ope
obj
:=
me
.
openFiles
.
Forget
(
handle
)
opened
:=
(
*
openedFile
)(
unsafe
.
Pointer
(
obj
))
node
.
OpenCountMutex
.
Lock
()
defer
node
.
OpenCountMutex
.
Unlock
()
node
.
OpenCount
--
node
.
OpenFilesMutex
.
Lock
()
defer
node
.
OpenFilesMutex
.
Unlock
()
idx
:=
-
1
for
i
,
v
:=
range
node
.
OpenFiles
{
if
v
==
opened
{
idx
=
i
break
}
}
l
:=
len
(
node
.
OpenFiles
)
node
.
OpenFiles
[
idx
]
=
node
.
OpenFiles
[
l
-
1
]
node
.
OpenFiles
=
node
.
OpenFiles
[
:
l
-
1
]
return
opened
}
func
(
me
*
fileSystemMount
)
registerFileHandle
(
node
*
inode
,
dir
rawDir
,
f
File
,
flags
uint32
)
(
uint64
,
*
openedFile
)
{
node
.
Open
Count
Mutex
.
Lock
()
defer
node
.
Open
Count
Mutex
.
Unlock
()
node
.
Open
Files
Mutex
.
Lock
()
defer
node
.
Open
Files
Mutex
.
Unlock
()
b
:=
&
openedFile
{
dir
:
dir
,
file
:
f
,
...
...
@@ -96,7 +107,7 @@ func (me *fileSystemMount) registerFileHandle(node *inode, dir rawDir, f File, f
f
=
withFlags
.
File
}
node
.
Open
Count
++
node
.
Open
Files
=
append
(
node
.
OpenFiles
,
b
)
handle
:=
me
.
openFiles
.
Register
(
&
b
.
Handled
)
return
handle
,
b
}
...
...
@@ -116,8 +127,8 @@ type inode struct {
NodeId
uint64
// Number of open files and its protection.
Open
Count
Mutex
sync
.
Mutex
Open
Count
int
Open
Files
Mutex
sync
.
Mutex
Open
Files
[]
*
openedFile
// treeLock is a pointer to me.mount.treeLock; we need store
// this mutex separately, since unmount may set me.mount = nil
...
...
@@ -168,9 +179,9 @@ func (me *inode) canUnmount() bool {
}
}
me
.
Open
Count
Mutex
.
Lock
()
defer
me
.
Open
Count
Mutex
.
Unlock
()
return
me
.
OpenCount
==
0
me
.
Open
Files
Mutex
.
Lock
()
defer
me
.
Open
Files
Mutex
.
Unlock
()
return
len
(
me
.
OpenFiles
)
==
0
}
// Must be called with treeLock held
...
...
@@ -411,10 +422,10 @@ func (me *FileSystemConnector) considerDropInode(n *inode) {
defer
n
.
treeLock
.
Unlock
()
}
n
.
Open
Count
Mutex
.
Lock
()
defer
n
.
Open
Count
Mutex
.
Unlock
()
n
.
Open
Files
Mutex
.
Lock
()
defer
n
.
Open
Files
Mutex
.
Unlock
()
dropInode
:=
n
.
LookupCount
<=
0
&&
len
(
n
.
Children
)
==
0
&&
n
.
OpenCount
<=
0
&&
n
!=
me
.
rootNode
&&
n
.
mountPoint
==
nil
len
(
n
.
OpenFiles
)
<=
0
&&
n
!=
me
.
rootNode
&&
n
.
mountPoint
==
nil
if
dropInode
{
n
.
setParent
(
nil
)
if
n
!=
me
.
rootNode
{
...
...
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