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
a1677314
Commit
a1677314
authored
Apr 22, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use pointer based handles for files too.
parent
d415f3e7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
15 deletions
+18
-15
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+18
-15
No files found.
fuse/pathfilesystem.go
View file @
a1677314
...
...
@@ -154,7 +154,7 @@ type FileSystemConnector struct {
////////////////
// Protects the inode
hashmap, its contents and the nextFreeInode counter
.
// Protects the inode
Map and each node's Children map
.
lock
sync
.
RWMutex
// Invariants: see the verify() method.
...
...
@@ -163,8 +163,11 @@ type FileSystemConnector struct {
// Open files/directories.
fileLock
sync
.
RWMutex
openFiles
map
[
uint64
]
interface
{}
nextFreeHandle
uint64
openFiles
map
[
uint64
]
*
interfaceBridge
}
type
interfaceBridge
struct
{
Iface
interface
{}
}
func
(
me
*
FileSystemConnector
)
DebugString
()
string
{
...
...
@@ -183,41 +186,41 @@ func (me *FileSystemConnector) DebugString() string {
func
(
me
*
FileSystemConnector
)
unregisterFile
(
node
*
inode
,
handle
uint64
)
interface
{}
{
me
.
fileLock
.
Lock
()
defer
me
.
fileLock
.
Unlock
()
f
,
ok
:=
me
.
openFiles
[
handle
]
b
,
ok
:=
me
.
openFiles
[
handle
]
if
!
ok
{
panic
(
"invalid handle"
)
}
me
.
openFiles
[
handle
]
=
nil
,
false
node
.
OpenCount
--
return
f
return
b
.
Iface
}
func
(
me
*
FileSystemConnector
)
registerFile
(
node
*
inode
,
f
interface
{})
uint64
{
me
.
fileLock
.
Lock
()
defer
me
.
fileLock
.
Unlock
()
h
:=
me
.
nextFreeHandle
me
.
nextFreeHandle
++
b
:=
&
interfaceBridge
{
Iface
:
f
,
}
h
:=
uint64
(
uintptr
(
unsafe
.
Pointer
(
b
)))
_
,
ok
:=
me
.
openFiles
[
h
]
if
ok
{
panic
(
"handle counter wrapped"
)
}
node
.
OpenCount
++
me
.
openFiles
[
h
]
=
f
me
.
openFiles
[
h
]
=
b
return
h
}
func
(
me
*
FileSystemConnector
)
getDir
(
h
uint64
)
RawDir
{
me
.
fileLock
.
RLock
()
defer
me
.
fileLock
.
RUnlock
()
return
me
.
openFiles
[
h
]
.
(
RawDir
)
b
:=
(
*
interfaceBridge
)(
unsafe
.
Pointer
(
uintptr
(
h
)))
return
b
.
Iface
.
(
RawDir
)
}
func
(
me
*
FileSystemConnector
)
getFile
(
h
uint64
)
File
{
me
.
fileLock
.
RLock
()
defer
me
.
fileLock
.
RUnlock
()
return
me
.
openFiles
[
h
]
.
(
File
)
b
:=
(
*
interfaceBridge
)(
unsafe
.
Pointer
(
uintptr
(
h
)))
return
b
.
Iface
.
(
File
)
}
func
(
me
*
FileSystemConnector
)
verify
()
{
...
...
@@ -373,7 +376,7 @@ func (me *FileSystemConnector) findInode(fullPath string) *inode {
func
EmptyFileSystemConnector
()
(
out
*
FileSystemConnector
)
{
out
=
new
(
FileSystemConnector
)
out
.
inodeMap
=
make
(
map
[
uint64
]
*
inode
)
out
.
openFiles
=
make
(
map
[
uint64
]
interface
{}
)
out
.
openFiles
=
make
(
map
[
uint64
]
*
interfaceBridge
)
rootData
:=
out
.
newInode
(
true
)
rootData
.
Type
=
ModeToType
(
S_IFDIR
)
...
...
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