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
92ccb1ff
Commit
92ccb1ff
authored
Nov 25, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add creation functions for different HandleMaps.
parent
fe8805f9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
12 deletions
+23
-12
fuse/handle.go
fuse/handle.go
+23
-12
No files found.
fuse/handle.go
View file @
92ccb1ff
...
...
@@ -55,6 +55,13 @@ type portableHandleMap struct {
freeIds
[]
uint64
}
func
newPortableHandleMap
()
*
portableHandleMap
{
return
&
portableHandleMap
{
// Avoid handing out ID 0 and 1.
handles
:
[]
*
Handled
{
nil
,
nil
},
}
}
func
(
m
*
portableHandleMap
)
Register
(
obj
*
Handled
)
(
handle
uint64
)
{
m
.
Lock
()
if
obj
.
count
==
0
{
...
...
@@ -192,6 +199,11 @@ func (m *int32HandleMap) Decode(handle uint64) *Handled {
val
:=
(
*
Handled
)(
unsafe
.
Pointer
(
uintptr
(
handle
&
((
1
<<
32
)
-
1
))))
return
val
}
func
newInt32HandleMap
()
*
int32HandleMap
{
return
&
int32HandleMap
{
handles
:
make
(
map
[
uint32
]
*
Handled
),
}
}
// 64 bits version of HandleMap
type
int64HandleMap
struct
{
...
...
@@ -214,29 +226,28 @@ func (m *int64HandleMap) verify() {
}
}
func
newInt64HandleMap
()
*
int64HandleMap
{
return
&
int64HandleMap
{
handles
:
make
(
map
[
uint64
]
*
Handled
),
nextFree
:
1
,
// to make tests easier.
}
}
// NewHandleMap creates a new HandleMap. If verify is given, we
// use remaining bits in the handle to store sanity check bits.
func
NewHandleMap
(
portable
bool
)
(
hm
HandleMap
)
{
if
portable
{
return
&
portableHandleMap
{
// Avoid handing out ID 0 and 1.
handles
:
[]
*
Handled
{
nil
,
nil
},
}
return
newPortableHandleMap
()
}
var
obj
*
Handled
switch
unsafe
.
Sizeof
(
obj
)
{
case
8
:
return
&
int64HandleMap
{
handles
:
make
(
map
[
uint64
]
*
Handled
),
nextFree
:
1
,
// to make tests easier.
}
return
newInt64HandleMap
()
case
4
:
return
&
int32HandleMap
{
handles
:
make
(
map
[
uint32
]
*
Handled
),
}
return
newInt32HandleMap
()
default
:
log
.
Println
(
"Unknown size."
)
log
.
Fatalf
(
"Unknown size."
)
}
return
nil
...
...
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