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
2c39d5b4
Commit
2c39d5b4
authored
Jun 24, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run gofmt.
parent
391ae350
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
38 additions
and
38 deletions
+38
-38
fuse/handle.go
fuse/handle.go
+17
-17
fuse/handle_test.go
fuse/handle_test.go
+6
-6
fuse/owner_test.go
fuse/owner_test.go
+2
-2
fuse/pathdebug.go
fuse/pathdebug.go
+2
-2
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+7
-7
unionfs/autounion.go
unionfs/autounion.go
+1
-1
unionfs/cachingfs.go
unionfs/cachingfs.go
+2
-2
unionfs/unionfs.go
unionfs/unionfs.go
+1
-1
No files found.
fuse/handle.go
View file @
2c39d5b4
package
fuse
import
(
"fmt"
"unsafe"
...
...
@@ -17,16 +18,16 @@ import (
//
// This structure is thread-safe.
type
HandleMap
struct
{
mutex
sync
.
Mutex
handles
map
[
uint64
]
*
Handled
nextFree
uint32
mutex
sync
.
Mutex
handles
map
[
uint64
]
*
Handled
nextFree
uint32
}
func
(
me
*
HandleMap
)
verify
()
{
if
!
paranoia
{
return
}
me
.
mutex
.
Lock
()
defer
me
.
mutex
.
Unlock
()
for
k
,
v
:=
range
me
.
handles
{
...
...
@@ -39,7 +40,7 @@ func (me *HandleMap) verify() {
func
NewHandleMap
()
*
HandleMap
{
return
&
HandleMap
{
handles
:
make
(
map
[
uint64
]
*
Handled
),
nextFree
:
1
,
// to make tests easier.
nextFree
:
1
,
// to make tests easier.
}
}
...
...
@@ -59,27 +60,27 @@ func (me *HandleMap) Register(obj *Handled) (handle uint64) {
}
me
.
mutex
.
Lock
()
defer
me
.
mutex
.
Unlock
()
handle
=
uint64
(
uintptr
(
unsafe
.
Pointer
(
obj
)))
check
:=
me
.
nextFree
me
.
nextFree
++
if
unsafe
.
Sizeof
(
obj
)
==
8
{
me
.
nextFree
=
me
.
nextFree
&
(
1
<<
(
64
-
48
+
3
)
-
1
)
rest
:=
(
handle
&^
(
1
<<
48
-
1
))
|
(
handle
&
(
1
<<
3
-
1
))
me
.
nextFree
=
me
.
nextFree
&
(
1
<<
(
64
-
48
+
3
)
-
1
)
rest
:=
(
handle
&^
(
1
<<
48
-
1
))
|
(
handle
&
(
1
<<
3
-
1
))
if
rest
!=
0
{
panic
(
"unaligned ptr or more than 48 bits in address"
)
}
handle
>>=
3
handle
|=
uint64
(
obj
.
check
)
<<
(
64
-
48
+
3
)
handle
|=
uint64
(
obj
.
check
)
<<
(
64
-
48
+
3
)
}
if
unsafe
.
Sizeof
(
obj
)
==
4
{
rest
:=
(
handle
&
0x3
)
if
rest
!=
0
{
panic
(
"unaligned ptr"
)
}
handle
|=
uint64
(
check
)
<<
32
}
obj
.
check
=
check
...
...
@@ -100,19 +101,18 @@ func (me *HandleMap) Forget(handle uint64) (val *Handled) {
func
DecodeHandle
(
handle
uint64
)
(
val
*
Handled
)
{
var
check
uint32
if
unsafe
.
Sizeof
(
val
)
==
8
{
ptrBits
:=
uintptr
(
handle
&
(
1
<<
45
-
1
))
ptrBits
:=
uintptr
(
handle
&
(
1
<<
45
-
1
))
check
=
uint32
(
handle
>>
45
)
val
=
(
*
Handled
)(
unsafe
.
Pointer
(
ptrBits
<<
3
))
val
=
(
*
Handled
)(
unsafe
.
Pointer
(
ptrBits
<<
3
))
}
if
unsafe
.
Sizeof
(
val
)
==
4
{
check
=
uint32
(
handle
>>
32
)
val
=
(
*
Handled
)(
unsafe
.
Pointer
(
uintptr
(
handle
&
((
1
<<
32
)
-
1
))))
val
=
(
*
Handled
)(
unsafe
.
Pointer
(
uintptr
(
handle
&
((
1
<<
32
)
-
1
))))
}
if
val
.
check
!=
check
{
msg
:=
fmt
.
Sprintf
(
"handle check mismatch; handle has 0x%x, object has 0x%x"
,
check
,
val
.
check
)
panic
(
msg
)
panic
(
msg
)
}
return
val
}
fuse/handle_test.go
View file @
2c39d5b4
...
...
@@ -34,7 +34,7 @@ func TestHandleMapUnaligned(t *testing.T) {
b
:=
make
([]
byte
,
100
)
v
:=
(
*
Handled
)(
unsafe
.
Pointer
(
&
b
[
1
]))
defer
markSeen
(
"unaligned"
)
hm
.
Register
(
v
)
t
.
Error
(
"Unaligned register did not panic"
)
...
...
@@ -42,11 +42,11 @@ func TestHandleMapUnaligned(t *testing.T) {
func
TestHandleMapPointerLayout
(
t
*
testing
.
T
)
{
if
unsafe
.
Sizeof
(
t
)
==
4
{
return
return
}
hm
:=
NewHandleMap
()
bogus
:=
uint64
(
1
)
<<
uint32
((
8
*
(
unsafe
.
Sizeof
(
t
)
-
1
)))
bogus
:=
uint64
(
1
)
<<
uint32
((
8
*
(
unsafe
.
Sizeof
(
t
)
-
1
)))
p
:=
uintptr
(
bogus
)
v
:=
(
*
Handled
)(
unsafe
.
Pointer
(
p
))
defer
markSeen
(
"48"
)
...
...
@@ -79,7 +79,7 @@ func TestHandleMapMultiple(t *testing.T) {
if
DecodeHandle
(
h
)
!=
v
{
t
.
Fatal
(
"address mismatch"
)
}
if
hm
.
Count
()
!=
i
+
1
{
if
hm
.
Count
()
!=
i
+
1
{
t
.
Fatal
(
"count error"
)
}
}
...
...
@@ -87,10 +87,10 @@ func TestHandleMapMultiple(t *testing.T) {
func
TestHandleMapCheckFail
(
t
*
testing
.
T
)
{
defer
markSeen
(
"check mismatch"
)
v
:=
new
(
Handled
)
hm
:=
NewHandleMap
()
h
:=
hm
.
Register
(
v
)
DecodeHandle
(
h
|
(
uint64
(
1
)
<<
63
))
DecodeHandle
(
h
|
(
uint64
(
1
)
<<
63
))
t
.
Error
(
"Borked decode did not panic"
)
}
fuse/owner_test.go
View file @
2c39d5b4
...
...
@@ -16,13 +16,13 @@ func (me *ownerFs) GetAttr(name string) (*os.FileInfo, Status) {
if
name
==
""
{
return
&
os
.
FileInfo
{
Mode
:
S_IFDIR
|
0755
,
},
OK
},
OK
}
return
&
os
.
FileInfo
{
Mode
:
S_IFREG
|
0644
,
Uid
:
_RANDOM_OWNER
,
Gid
:
_RANDOM_OWNER
,
},
OK
},
OK
}
func
setupOwnerTest
(
opts
*
FileSystemOptions
)
(
workdir
string
,
cleanup
func
())
{
...
...
fuse/pathdebug.go
View file @
2c39d5b4
...
...
@@ -80,14 +80,14 @@ func (me *FileSystemDebug) GetAttr(path string) (*os.FileInfo, Status) {
if
path
==
DebugDir
{
return
&
os
.
FileInfo
{
Mode
:
S_IFDIR
|
0755
,
},
OK
},
OK
}
c
:=
me
.
getContent
(
path
)
if
c
!=
nil
{
return
&
os
.
FileInfo
{
Mode
:
S_IFREG
|
0644
,
Size
:
int64
(
len
(
c
)),
},
OK
},
OK
}
return
nil
,
ENOENT
}
...
...
fuse/pathfilesystem.go
View file @
2c39d5b4
...
...
@@ -34,8 +34,8 @@ type openedFile struct {
*
inode
Flags
uint32
dir
rawDir
file
File
dir
rawDir
file
File
}
type
mountData
struct
{
...
...
@@ -79,10 +79,10 @@ func (me *mountData) setOwner(attr *Attr) {
}
}
func
(
me
*
mountData
)
unregisterFileHandle
(
node
*
inode
,
handle
uint64
)
(
*
openedFile
)
{
func
(
me
*
mountData
)
unregisterFileHandle
(
node
*
inode
,
handle
uint64
)
*
openedFile
{
obj
:=
me
.
openFiles
.
Forget
(
handle
)
opened
:=
(
*
openedFile
)(
unsafe
.
Pointer
(
obj
))
node
.
OpenCountMutex
.
Lock
()
defer
node
.
OpenCountMutex
.
Unlock
()
node
.
OpenCount
--
...
...
@@ -95,7 +95,7 @@ func (me *mountData) registerFileHandle(node *inode, dir rawDir, f File, flags u
defer
node
.
OpenCountMutex
.
Unlock
()
b
:=
&
openedFile
{
dir
:
dir
,
file
:
f
,
file
:
f
,
inode
:
node
,
mountData
:
me
,
Flags
:
flags
,
...
...
@@ -119,7 +119,7 @@ type inode struct {
LookupCount
int
OpenCountMutex
sync
.
Mutex
OpenCount
int
OpenCount
int
// Non-nil if this is a mountpoint.
mountPoint
*
mountData
...
...
@@ -218,7 +218,7 @@ func (me *inode) GetFullPath() (path string) {
func
(
me
*
inode
)
GetPath
()
(
path
string
,
mount
*
mountData
)
{
me
.
mount
.
treeLock
.
RLock
()
defer
me
.
mount
.
treeLock
.
RUnlock
()
if
me
.
NodeId
!=
FUSE_ROOT_ID
&&
me
.
Parent
==
nil
{
// Deleted node. Treat as if the filesystem was unmounted.
return
".deleted"
,
nil
...
...
unionfs/autounion.go
View file @
2c39d5b4
...
...
@@ -283,7 +283,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*os.FileInfo, fuse.Status) {
if
me
.
getUnionFs
(
path
)
!=
nil
{
return
&
os
.
FileInfo
{
Mode
:
fuse
.
S_IFDIR
|
0755
,
},
fuse
.
OK
},
fuse
.
OK
}
return
nil
,
fuse
.
ENOENT
...
...
unionfs/cachingfs.go
View file @
2c39d5b4
...
...
@@ -136,10 +136,10 @@ func NewCachingFileSystem(fs fuse.FileSystem, ttlNs int64) *CachingFileSystem {
c
.
links
=
NewTimedCache
(
func
(
n
string
)
interface
{}
{
return
readLink
(
fs
,
n
)
},
ttlNs
)
c
.
xattr
=
NewTimedCache
(
func
(
n
string
)
interface
{}
{
return
getXAttr
(
fs
,
n
)
},
ttlNs
)
},
ttlNs
)
c
.
files
=
NewTimedCache
(
func
(
n
string
)
interface
{}
{
return
openFile
(
fs
,
n
)
},
ttlNs
)
},
ttlNs
)
return
c
}
...
...
unionfs/unionfs.go
View file @
2c39d5b4
...
...
@@ -571,7 +571,7 @@ func (me *UnionFs) GetAttr(name string) (a *os.FileInfo, s fuse.Status) {
if
name
==
_DROP_CACHE
{
return
&
os
.
FileInfo
{
Mode
:
fuse
.
S_IFREG
|
0777
,
},
fuse
.
OK
},
fuse
.
OK
}
if
name
==
me
.
options
.
DeletionDirName
{
return
nil
,
fuse
.
ENOENT
...
...
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