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
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
99 additions
and
100 deletions
+99
-100
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
fuse/fuse.go
fuse/fuse.go
+1
-1
fuse/misc.go
fuse/misc.go
+3
-3
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+3
-3
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."
)
...
...
@@ -31,7 +32,7 @@ func main() {
if
cpus
>
1
{
runtime
.
GOMAXPROCS
(
cpus
)
}
fmt
.
Printf
(
"Mounted %s on %s (threaded=%v, debug=%v, cpus=%v)
\n
"
,
orig
,
mountPoint
,
*
threaded
,
*
debug
,
cpus
)
state
.
Loop
(
*
threaded
)
}
examplelib/stackfs.go
View file @
aed6ef69
This diff is collapsed.
Click to expand it.
examplelib/stackfs_test.go
View file @
aed6ef69
...
...
@@ -34,14 +34,14 @@ func FileExists(name string) bool {
const
magicMode
uint32
=
0753
type
testCase
struct
{
origDir1
string
origDir2
string
mountDir
string
testDir
string
tester
*
testing
.
T
fs
*
SubmountFileSystem
state
*
fuse
.
MountState
origDir1
string
origDir2
string
mountDir
string
testDir
string
tester
*
testing
.
T
fs
*
SubmountFileSystem
state
*
fuse
.
MountState
}
func
(
self
*
testCase
)
Setup
(
t
*
testing
.
T
)
{
...
...
@@ -55,19 +55,19 @@ func (self *testCase) Setup(t *testing.T) {
os
.
Mkdir
(
self
.
origDir1
,
0700
)
os
.
Mkdir
(
self
.
origDir2
,
0700
)
os
.
Mkdir
(
self
.
mountDir
,
0700
)
fs1
:=
fuse
.
NewPathFileSystemConnector
(
NewPassThroughFuse
(
self
.
origDir1
))
fs2
:=
fuse
.
NewPathFileSystemConnector
(
NewPassThroughFuse
(
self
.
origDir2
))
self
.
fs
=
NewSubmountFileSystem
()
attr
:=
fuse
.
Attr
{
Mode
:
uint32
(
magicMode
),
Mode
:
uint32
(
magicMode
),
}
self
.
fs
.
AddFileSystem
(
"sub1"
,
fs1
,
attr
)
self
.
fs
.
AddFileSystem
(
"sub2"
,
fs2
,
attr
)
self
.
state
=
fuse
.
NewMountState
(
self
.
fs
)
self
.
state
.
Mount
(
self
.
mountDir
)
...
...
@@ -102,7 +102,7 @@ func (self *testCase) testReaddir() {
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"readdir err %v"
,
err
)
}
wanted
:=
map
[
string
]
bool
{
"sub1"
:
true
,
"sub2"
:
true
,
...
...
@@ -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
)
}
}
...
...
@@ -133,7 +133,7 @@ func (self *testCase) testSubFs() {
mount
:=
path
.
Join
(
self
.
mountDir
,
fmt
.
Sprintf
(
"sub%d"
,
i
))
name
:=
"testFile"
mountFile
:=
path
.
Join
(
mount
,
name
)
f
,
err
:=
os
.
Open
(
mountFile
,
os
.
O_WRONLY
,
0
)
...
...
@@ -142,9 +142,9 @@ 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
)
self
.
tester
.
Errorf
(
"Create %v"
,
err
)
}
f
.
Write
([]
byte
(
content1
))
...
...
@@ -152,21 +152,21 @@ func (self *testCase) testSubFs() {
err
=
os
.
Chmod
(
mountFile
,
magicMode
)
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"chmod %v"
,
err
)
self
.
tester
.
Errorf
(
"chmod %v"
,
err
)
}
fi
,
err
:=
os
.
Lstat
(
mountFile
)
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"Lstat %v"
,
err
)
self
.
tester
.
Errorf
(
"Lstat %v"
,
err
)
}
else
{
if
fi
.
Mode
&
0777
!=
magicMode
{
self
.
tester
.
Errorf
(
"Mode %o"
,
fi
.
Mode
)
if
fi
.
Mode
&
0777
!=
magicMode
{
self
.
tester
.
Errorf
(
"Mode %o"
,
fi
.
Mode
)
}
}
g
,
err
:=
os
.
Open
(
mountFile
,
os
.
O_RDONLY
,
0
)
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"Open %v"
,
err
)
self
.
tester
.
Errorf
(
"Open %v"
,
err
)
}
else
{
buf
:=
make
([]
byte
,
1024
)
n
,
err
:=
g
.
Read
(
buf
)
...
...
@@ -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
))
...
...
@@ -197,8 +197,8 @@ func (self *testCase) testAddRemove() {
if
!
ok
{
self
.
tester
.
Errorf
(
"AddFileSystem fail"
)
}
conn
.
Init
(
new
(
fuse
.
InHeader
),
new
(
fuse
.
InitIn
))
conn
.
Init
(
new
(
fuse
.
InHeader
),
new
(
fuse
.
InitIn
))
fi
,
err
:=
os
.
Lstat
(
path
.
Join
(
self
.
mountDir
,
"third"
))
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"third lstat err %v"
,
err
)
...
...
fuse/fuse.go
View file @
aed6ef69
...
...
@@ -14,7 +14,7 @@ import (
// TODO make generic option setting.
const
(
maxRead
=
(
1
<<
16
)
maxRead
=
(
1
<<
16
)
bufSize
=
maxRead
+
1024
)
...
...
fuse/misc.go
View file @
aed6ef69
...
...
@@ -272,14 +272,14 @@ func Writev(fd int, packet [][]byte) (n int, err os.Error) {
func
CountCpus
()
int
{
var
contents
[
10240
]
byte
f
,
err
:=
os
.
Open
(
"/proc/stat"
,
os
.
O_RDONLY
,
0
)
defer
f
.
Close
()
if
err
!=
nil
{
return
1
return
1
}
n
,
_
:=
f
.
Read
(
contents
[
:
])
re
,
_
:=
regexp
.
Compile
(
"
\n
cpu[0-9]"
)
return
len
(
re
.
FindAllString
(
string
(
contents
[
:
n
]),
100
))
}
fuse/pathfilesystem.go
View file @
aed6ef69
...
...
@@ -55,9 +55,9 @@ type TimeoutOptions struct {
func
MakeTimeoutOptions
()
TimeoutOptions
{
return
TimeoutOptions
{
NegativeTimeout
:
0.0
,
AttrTimeout
:
1.0
,
EntryTimeout
:
1.0
,
NegativeTimeout
:
0.0
,
AttrTimeout
:
1.0
,
EntryTimeout
:
1.0
,
}
}
...
...
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