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
8278f60e
Commit
8278f60e
authored
Sep 29, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run gofmt.
parent
336fe3bc
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
60 additions
and
63 deletions
+60
-63
example/unionfs/main.go
example/unionfs/main.go
+1
-1
fuse/files.go
fuse/files.go
+0
-1
fuse/fsconnector.go
fuse/fsconnector.go
+1
-1
fuse/fsops.go
fuse/fsops.go
+1
-1
fuse/loopback_test.go
fuse/loopback_test.go
+3
-3
fuse/memnode.go
fuse/memnode.go
+1
-1
fuse/opcode.go
fuse/opcode.go
+9
-9
fuse/prefixfs.go
fuse/prefixfs.go
+1
-1
unionfs/memunionfs.go
unionfs/memunionfs.go
+8
-9
unionfs/memunionfs_test.go
unionfs/memunionfs_test.go
+15
-15
unionfs/unionfs.go
unionfs/unionfs.go
+3
-4
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+17
-17
No files found.
example/unionfs/main.go
View file @
8278f60e
...
...
@@ -30,7 +30,7 @@ func main() {
var
nodeFs
fuse
.
NodeFileSystem
if
*
mem
{
nodeFs
=
unionfs
.
NewMemUnionFs
(
flag
.
Arg
(
1
)
+
"/"
,
&
fuse
.
LoopbackFileSystem
{
Root
:
flag
.
Arg
(
2
)})
flag
.
Arg
(
1
)
+
"/"
,
&
fuse
.
LoopbackFileSystem
{
Root
:
flag
.
Arg
(
2
)})
}
else
{
ufsOptions
:=
unionfs
.
UnionFsOptions
{
DeletionCacheTTLSecs
:
*
delcache_ttl
,
...
...
fuse/files.go
View file @
8278f60e
...
...
@@ -59,7 +59,6 @@ func (me *DevNullFile) String() string {
return
"DevNullFile"
}
func
(
me
*
DevNullFile
)
Read
(
input
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
return
[]
byte
{},
OK
}
...
...
fuse/fsconnector.go
View file @
8278f60e
fuse/fsops.go
View file @
8278f60e
fuse/loopback_test.go
View file @
8278f60e
fuse/memnode.go
View file @
8278f60e
fuse/opcode.go
View file @
8278f60e
fuse/prefixfs.go
View file @
8278f60e
unionfs/memunionfs.go
View file @
8278f60e
...
...
@@ -87,7 +87,7 @@ func (me *MemUnionFs) Reap() map[string]*Result {
todo
:=
[]
string
{
name
}
for
len
(
todo
)
>
0
{
l
:=
len
(
todo
)
-
1
l
:=
len
(
todo
)
-
1
n
:=
todo
[
l
]
todo
=
todo
[
:
l
]
...
...
@@ -95,7 +95,7 @@ func (me *MemUnionFs) Reap() map[string]*Result {
for
e
:=
range
s
{
full
:=
filepath
.
Join
(
n
,
e
.
Name
)
m
[
full
]
=
&
Result
{}
if
e
.
Mode
&
fuse
.
S_IFDIR
!=
0
{
if
e
.
Mode
&
fuse
.
S_IFDIR
!=
0
{
todo
=
append
(
todo
,
full
)
}
}
...
...
@@ -137,7 +137,7 @@ func (me *MemUnionFs) Update(results map[string]*Result) {
}
sort
.
Strings
(
del
)
for
i
:=
len
(
del
)
-
1
;
i
>=
0
;
i
--
{
for
i
:=
len
(
del
)
-
1
;
i
>=
0
;
i
--
{
n
:=
del
[
i
]
dir
,
base
:=
filepath
.
Split
(
n
)
dir
=
strings
.
TrimRight
(
dir
,
"/"
)
...
...
@@ -633,4 +633,3 @@ func (me *memNode) Clear(path string) {
mn
.
Clear
(
p
)
}
}
unionfs/memunionfs_test.go
View file @
8278f60e
...
...
@@ -32,7 +32,7 @@ func setupMemUfs(t *testing.T) (workdir string, ufs *MemUnionFs, cleanup func())
os
.
Mkdir
(
wd
+
"/ro"
,
0700
)
fuse
.
CheckSuccess
(
err
)
roFs
:=
fuse
.
NewLoopbackFileSystem
(
wd
+
"/ro"
)
roFs
:=
fuse
.
NewLoopbackFileSystem
(
wd
+
"/ro"
)
memFs
:=
NewMemUnionFs
(
wd
+
"/backing"
,
roFs
)
// We configure timeouts are smaller, so we can check for
...
...
@@ -292,7 +292,7 @@ func TestMemUnionFsMkdirPromote(t *testing.T) {
CheckSuccess
(
err
)
r
:=
ufs
.
Reap
()
if
r
[
"subdir/subdir2/dir3"
]
==
nil
||
r
[
"subdir/subdir2/dir3"
]
.
FileInfo
.
Mode
&
fuse
.
S_IFDIR
==
0
{
if
r
[
"subdir/subdir2/dir3"
]
==
nil
||
r
[
"subdir/subdir2/dir3"
]
.
FileInfo
.
Mode
&
fuse
.
S_IFDIR
==
0
{
t
.
Errorf
(
"expect 1 file reap result: %v"
,
r
)
}
}
...
...
@@ -517,11 +517,11 @@ func TestMemUnionFsUpdate(t *testing.T) {
t
.
Fatal
(
"symlink should not exist"
,
fi
)
}
err
=
os
.
Remove
(
wd
+
"/ro/file1"
)
err
=
os
.
Remove
(
wd
+
"/ro/file1"
)
CheckSuccess
(
err
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/file2"
,
[]
byte
(
"foobar"
),
0644
)
CheckSuccess
(
err
)
err
=
os
.
Symlink
(
"target"
,
wd
+
"/ro/symlink"
)
err
=
os
.
Symlink
(
"target"
,
wd
+
"/ro/symlink"
)
CheckSuccess
(
err
)
// Still have cached attributes.
...
...
@@ -782,11 +782,11 @@ func TestMemUnionGc(t *testing.T) {
writeToFile
(
wd
+
"/mount/file1"
,
"other-content"
)
writeToFile
(
wd
+
"/mount/file2"
,
"other-content"
)
err
:=
os
.
Remove
(
wd
+
"/mount/file1"
)
err
:=
os
.
Remove
(
wd
+
"/mount/file1"
)
CheckSuccess
(
err
)
ufs
.
Clear
()
entries
,
err
:=
ioutil
.
ReadDir
(
wd
+
"/backing"
)
entries
,
err
:=
ioutil
.
ReadDir
(
wd
+
"/backing"
)
CheckSuccess
(
err
)
if
len
(
entries
)
!=
0
{
t
.
Fatalf
(
"should have 1 file after backing store gc: %v"
,
entries
)
...
...
unionfs/unionfs.go
View file @
8278f60e
...
...
@@ -280,7 +280,7 @@ func (me *UnionFs) Promote(name string, srcResult branchResult, context *fuse.Co
code
=
fuse
.
CopyFile
(
sourceFs
,
writable
,
name
,
name
,
context
)
if
code
.
Ok
()
{
code
=
writable
.
Chmod
(
name
,
srcResult
.
attr
.
Mode
&
07777
|
0200
,
context
)
code
=
writable
.
Chmod
(
name
,
srcResult
.
attr
.
Mode
&
07777
|
0200
,
context
)
}
if
code
.
Ok
()
{
code
=
writable
.
Utimens
(
name
,
uint64
(
srcResult
.
attr
.
Atime_ns
),
...
...
@@ -321,13 +321,12 @@ func (me *UnionFs) Promote(name string, srcResult branchResult, context *fuse.Co
code
=
writable
.
Symlink
(
link
,
name
,
context
)
}
}
else
if
srcResult
.
attr
.
IsDirectory
()
{
code
=
writable
.
Mkdir
(
name
,
srcResult
.
attr
.
Mode
&
07777
|
0200
,
context
)
code
=
writable
.
Mkdir
(
name
,
srcResult
.
attr
.
Mode
&
07777
|
0200
,
context
)
}
else
{
log
.
Println
(
"Unknown file type:"
,
srcResult
.
attr
)
return
fuse
.
ENOSYS
}
if
!
code
.
Ok
()
{
me
.
branchCache
.
GetFresh
(
name
)
return
code
...
...
@@ -635,7 +634,7 @@ func (me *UnionFs) promoteDirsTo(filename string) fuse.Status {
j
:=
len
(
todo
)
-
i
-
1
d
:=
todo
[
j
]
r
:=
results
[
j
]
code
:=
me
.
fileSystems
[
0
]
.
Mkdir
(
d
,
r
.
attr
.
Mode
&
07777
|
0200
,
nil
)
code
:=
me
.
fileSystems
[
0
]
.
Mkdir
(
d
,
r
.
attr
.
Mode
&
07777
|
0200
,
nil
)
if
code
!=
fuse
.
OK
{
log
.
Println
(
"Error creating dir leading to path"
,
d
,
code
,
me
.
fileSystems
[
0
])
return
fuse
.
EPERM
...
...
unionfs/unionfs_test.go
View file @
8278f60e
...
...
@@ -31,7 +31,7 @@ func freezeRo(dir string) {
err
:=
filepath
.
Walk
(
dir
,
func
(
path
string
,
fi
*
os
.
FileInfo
,
err
os
.
Error
)
os
.
Error
{
return
os
.
Chmod
(
path
,
(
fi
.
Mode
&
0777
)
&^
0222
)
return
os
.
Chmod
(
path
,
(
fi
.
Mode
&
0777
)
&^
0222
)
})
CheckSuccess
(
err
)
}
...
...
@@ -493,7 +493,7 @@ func TestUnionFsRenameDirAllSourcesGone(t *testing.T) {
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/dir/file.txt"
,
[]
byte
{
42
},
0644
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
err
=
os
.
Rename
(
wd
+
"/mount/dir"
,
wd
+
"/mount/renamed"
)
CheckSuccess
(
err
)
...
...
@@ -515,7 +515,7 @@ func TestUnionFsRenameDirWithDeletions(t *testing.T) {
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/dir/subdir/file.txt"
,
[]
byte
{
42
},
0644
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
if
fi
,
_
:=
os
.
Lstat
(
wd
+
"/mount/dir/subdir/file.txt"
);
fi
==
nil
||
!
fi
.
IsRegular
()
{
t
.
Fatalf
(
"%s/mount/dir/subdir/file.txt should be file: %v"
,
wd
,
fi
)
...
...
@@ -582,7 +582,7 @@ func TestUnionFsWritableDir(t *testing.T) {
dirname
:=
wd
+
"/ro/subdir"
err
:=
os
.
Mkdir
(
dirname
,
0555
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
fi
,
err
:=
os
.
Lstat
(
wd
+
"/mount/subdir"
)
CheckSuccess
(
err
)
...
...
@@ -599,7 +599,7 @@ func TestUnionFsWriteAccess(t *testing.T) {
// No write perms.
err
:=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
"foo"
),
0444
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
errno
:=
syscall
.
Access
(
wd
+
"/mount/file"
,
fuse
.
W_OK
)
if
errno
!=
0
{
...
...
@@ -616,7 +616,7 @@ func TestUnionFsLink(t *testing.T) {
fn
:=
wd
+
"/ro/file"
err
:=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
content
),
0666
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
err
=
os
.
Link
(
wd
+
"/mount/file"
,
wd
+
"/mount/linked"
)
CheckSuccess
(
err
)
...
...
@@ -640,7 +640,7 @@ func TestUnionFsTruncate(t *testing.T) {
defer
clean
()
writeToFile
(
wd
+
"/ro/file"
,
"hello"
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
os
.
Truncate
(
wd
+
"/mount/file"
,
2
)
content
:=
readFromFile
(
wd
+
"/mount/file"
)
...
...
@@ -718,7 +718,7 @@ func TestUnionFsRemoveAll(t *testing.T) {
fn
:=
wd
+
"/ro/dir/subdir/y"
err
=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
contents
),
0644
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
err
=
os
.
RemoveAll
(
wd
+
"/mount/dir"
)
if
err
!=
nil
{
...
...
@@ -749,7 +749,7 @@ func TestUnionFsRmRf(t *testing.T) {
fn
:=
wd
+
"/ro/dir/subdir/y"
err
=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
contents
),
0644
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
bin
,
err
:=
exec
.
LookPath
(
"rm"
)
CheckSuccess
(
err
)
...
...
@@ -788,7 +788,7 @@ func TestUnionFsDropDeletionCache(t *testing.T) {
err
:=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"bla"
),
0644
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
_
,
err
=
os
.
Lstat
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
...
...
@@ -887,7 +887,7 @@ func TestUnionFsDisappearing(t *testing.T) {
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"blabla"
),
0644
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
err
=
os
.
Remove
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
...
...
@@ -928,7 +928,7 @@ func TestUnionFsDeletedGetAttr(t *testing.T) {
err
:=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"blabla"
),
0644
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
f
,
err
:=
os
.
Open
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
...
...
@@ -947,7 +947,7 @@ func TestUnionFsDoubleOpen(t *testing.T) {
defer
clean
()
err
:=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"blablabla"
),
0644
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
roFile
,
err
:=
os
.
Open
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
...
...
@@ -985,7 +985,7 @@ func TestUnionFsFdLeak(t *testing.T) {
wd
,
clean
:=
setupUfs
(
t
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"blablabla"
),
0644
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
contents
,
err
:=
ioutil
.
ReadFile
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
...
...
@@ -1091,7 +1091,7 @@ func TestUnionFsPromoteDirTimeStamp(t *testing.T) {
CheckSuccess
(
err
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/subdir/file"
,
[]
byte
(
"hello"
),
0644
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
err
=
os
.
Chmod
(
wd
+
"/mount/subdir/file"
,
0060
)
CheckSuccess
(
err
)
...
...
@@ -1107,7 +1107,7 @@ func TestUnionFsPromoteDirTimeStamp(t *testing.T) {
t
.
Errorf
(
"Changed timestamps on promoted subdir: ro %d rw %d"
,
fRo
.
Mtime_ns
,
fRw
.
Mtime_ns
)
}
if
fRo
.
Mode
|
0200
!=
fRw
.
Mode
{
if
fRo
.
Mode
|
0200
!=
fRw
.
Mode
{
t
.
Errorf
(
"Changed mode ro: %o, rw: %o"
,
fRo
.
Mode
,
fRw
.
Mode
)
}
}
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