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
aed6ef69
Commit
aed6ef69
authored
Jan 03, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run Gofmt.
parent
2445a2e9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
93 deletions
+92
-93
example/main.go
example/main.go
+2
-1
examplelib/stackfs.go
examplelib/stackfs.go
+64
-66
examplelib/stackfs_test.go
examplelib/stackfs_test.go
+26
-26
No files found.
example/main.go
View file @
aed6ef69
...
...
@@ -8,6 +8,7 @@ import (
"flag"
"runtime"
)
func
main
()
{
// Scans the arg list and sets up flags
debug
:=
flag
.
Bool
(
"debug"
,
false
,
"print debugging messages."
)
...
...
examplelib/stackfs.go
View file @
aed6ef69
...
...
@@ -17,7 +17,7 @@ type subFsInfo struct {
GlobalNodeId
uint64
// Maps Fs's Inodes back to the parent inode.
ParentNodeIds
map
[
uint64
]
uint64
ParentNodeIds
map
[
uint64
]
uint64
// This must always be the inner lock in the locking order.
ParentNodeIdsLock
sync
.
RWMutex
...
...
@@ -80,11 +80,11 @@ func (self *subInodeData) Deletable() bool {
// /config directory.
type
SubmountFileSystem
struct
{
toplevelEntriesLock
sync
.
RWMutex
toplevelEntries
map
[
string
]
*
subFsInfo
toplevelEntries
map
[
string
]
*
subFsInfo
// Mutex protects map and nextFreeInode.
nodeMapLock
sync
.
RWMutex
nodeMap
map
[
uint64
]
*
subInodeData
nodeMap
map
[
uint64
]
*
subInodeData
nextFreeInode
uint64
Options
SubmountFileSystemOptions
...
...
@@ -153,7 +153,7 @@ func (self *SubmountFileSystem) addFileSystem(name string, fs fuse.RawFileSystem
NodeId
:
fuse
.
FUSE_ROOT_ID
,
LookupCount
:
0
,
}
subfs
.
ParentNodeIds
=
map
[
uint64
]
uint64
{
fuse
.
FUSE_ROOT_ID
:
self
.
nextFreeInode
}
subfs
.
ParentNodeIds
=
map
[
uint64
]
uint64
{
fuse
.
FUSE_ROOT_ID
:
self
.
nextFreeInode
}
subfs
.
GlobalNodeId
=
self
.
nextFreeInode
subfs
.
Attr
.
Mode
|=
fuse
.
S_IFDIR
...
...
@@ -180,7 +180,7 @@ func (self *SubmountFileSystem) removeFileSystem(name string) *subFsInfo {
self
.
nodeMapLock
.
Lock
()
defer
self
.
nodeMapLock
.
Unlock
()
for
_
,
v
:=
range
(
self
.
nodeMap
)
{
for
_
,
v
:=
range
self
.
nodeMap
{
if
v
.
SubFs
==
subfs
{
v
.
SubFs
=
nil
}
...
...
@@ -197,7 +197,7 @@ func (self *SubmountFileSystem) listFileSystems() ([]string, []uint32) {
modes
:=
make
([]
uint32
,
len
(
self
.
toplevelEntries
))
j
:=
0
for
name
,
entry
:=
range
(
self
.
toplevelEntries
)
{
for
name
,
entry
:=
range
self
.
toplevelEntries
{
names
[
j
]
=
name
modes
[
j
]
=
entry
.
Attr
.
Mode
j
++
...
...
@@ -306,11 +306,11 @@ func (self *SubmountFileSystem) Forget(h *fuse.InHeader, input *fuse.ForgetIn) {
}
}
func
NewSubmountFileSystem
()
(
*
SubmountFileSystem
)
{
func
NewSubmountFileSystem
()
*
SubmountFileSystem
{
out
:=
new
(
SubmountFileSystem
)
out
.
nextFreeInode
=
fuse
.
FUSE_ROOT_ID
+
1
out
.
nodeMap
=
make
(
map
[
uint64
]
*
subInodeData
)
out
.
toplevelEntries
=
make
(
map
[
string
]
*
subFsInfo
)
out
.
nodeMap
=
make
(
map
[
uint64
]
*
subInodeData
)
out
.
toplevelEntries
=
make
(
map
[
string
]
*
subFsInfo
)
out
.
Options
.
TimeoutOptions
=
fuse
.
MakeTimeoutOptions
()
return
out
}
...
...
@@ -321,7 +321,7 @@ func (self *SubmountFileSystem) Init(h *fuse.InHeader, input *fuse.InitIn) (*fus
}
func
(
self
*
SubmountFileSystem
)
Destroy
(
h
*
fuse
.
InHeader
,
input
*
fuse
.
InitIn
)
{
for
_
,
v
:=
range
(
self
.
toplevelEntries
)
{
for
_
,
v
:=
range
self
.
toplevelEntries
{
v
.
Fs
.
Destroy
(
h
,
input
)
}
}
...
...
@@ -579,7 +579,7 @@ func (self *SubmountFileSystem) Poll(header *fuse.InHeader, input *fuse.PollIn)
}
func
(
self
*
SubmountFileSystem
)
OpenDir
(
header
*
fuse
.
InHeader
,
input
*
fuse
.
OpenIn
)
(
flags
uint32
,
fuseFile
fuse
.
RawFuseDir
,
status
fuse
.
Status
)
{
if
(
header
.
NodeId
==
fuse
.
FUSE_ROOT_ID
)
{
if
header
.
NodeId
==
fuse
.
FUSE_ROOT_ID
{
return
0
,
NewSubmountFileSystemTopDir
(
self
),
fuse
.
OK
}
...
...
@@ -613,7 +613,7 @@ func (self *SubmountFileSystemTopDir) ReadDir(input *fuse.ReadIn) (*fuse.DirEntr
for
self
.
nextRead
<
len
(
self
.
names
)
{
i
:=
self
.
nextRead
if
(
de
.
AddString
(
self
.
names
[
i
],
fuse
.
FUSE_UNKNOWN_INO
,
self
.
modes
[
i
])
)
{
if
de
.
AddString
(
self
.
names
[
i
],
fuse
.
FUSE_UNKNOWN_INO
,
self
.
modes
[
i
]
)
{
self
.
nextRead
++
}
else
{
break
...
...
@@ -629,5 +629,3 @@ func (self *SubmountFileSystemTopDir) ReleaseDir() {
func
(
self
*
SubmountFileSystemTopDir
)
FsyncDir
(
input
*
fuse
.
FsyncIn
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOENT
}
examplelib/stackfs_test.go
View file @
aed6ef69
...
...
@@ -116,7 +116,7 @@ func (self *testCase) testReaddir() {
self
.
tester
.
Errorf
(
"Unexpected name %v"
,
v
.
Name
)
}
if
v
.
Mode
&
0777
!=
magicMode
{
if
v
.
Mode
&
0777
!=
magicMode
{
self
.
tester
.
Errorf
(
"Unexpected mode %o, %v"
,
v
.
Mode
,
v
)
}
}
...
...
@@ -142,7 +142,7 @@ func (self *testCase) testSubFs() {
continue
}
content1
:=
"booh!"
f
,
err
=
os
.
Open
(
mountFile
,
os
.
O_WRONLY
|
os
.
O_CREATE
,
magicMode
)
f
,
err
=
os
.
Open
(
mountFile
,
os
.
O_WRONLY
|
os
.
O_CREATE
,
magicMode
)
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"Create %v"
,
err
)
}
...
...
@@ -159,7 +159,7 @@ func (self *testCase) testSubFs() {
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"Lstat %v"
,
err
)
}
else
{
if
fi
.
Mode
&
0777
!=
magicMode
{
if
fi
.
Mode
&
0777
!=
magicMode
{
self
.
tester
.
Errorf
(
"Mode %o"
,
fi
.
Mode
)
}
}
...
...
@@ -184,7 +184,7 @@ func (self *testCase) testSubFs() {
func
(
self
*
testCase
)
testAddRemove
()
{
self
.
tester
.
Log
(
"testAddRemove"
)
attr
:=
fuse
.
Attr
{
Mode
:
0755
,
Mode
:
0755
,
}
conn
:=
fuse
.
NewPathFileSystemConnector
(
NewPassThroughFuse
(
self
.
origDir1
))
...
...
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