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
bfca2606
Commit
bfca2606
authored
Aug 15, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run gofmt.
parent
94f9b193
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
52 deletions
+42
-52
fuse/cache_test.go
fuse/cache_test.go
+9
-11
fuse/loopback_test.go
fuse/loopback_test.go
+1
-1
fuse/mountstate.go
fuse/mountstate.go
+18
-20
fuse/notify_test.go
fuse/notify_test.go
+1
-3
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+2
-2
fuse/pathops.go
fuse/pathops.go
+0
-1
unionfs/unionfs.go
unionfs/unionfs.go
+0
-2
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+11
-12
No files found.
fuse/cache_test.go
View file @
bfca2606
package
fuse
import
(
"testing"
"os"
...
...
@@ -12,12 +11,12 @@ type cacheFs struct {
}
func
(
me
*
cacheFs
)
Open
(
name
string
,
flags
uint32
)
(
fuseFile
File
,
status
Status
)
{
f
,
c
:=
me
.
LoopbackFileSystem
.
Open
(
name
,
flags
)
f
,
c
:=
me
.
LoopbackFileSystem
.
Open
(
name
,
flags
)
if
!
c
.
Ok
()
{
return
f
,
c
}
return
&
WithFlags
{
File
:
f
,
File
:
f
,
Flags
:
FOPEN_KEEP_CACHE
,
},
c
...
...
@@ -25,13 +24,13 @@ func (me *cacheFs) Open(name string, flags uint32) (fuseFile File, status Status
func
setupCacheTest
()
(
string
,
func
())
{
dir
:=
MakeTempDir
()
os
.
Mkdir
(
dir
+
"/mnt"
,
0755
)
os
.
Mkdir
(
dir
+
"/orig"
,
0755
)
os
.
Mkdir
(
dir
+
"/mnt"
,
0755
)
os
.
Mkdir
(
dir
+
"/orig"
,
0755
)
fs
:=
&
cacheFs
{
LoopbackFileSystem
:
NewLoopbackFileSystem
(
dir
+
"/orig"
),
}
state
,
_
,
err
:=
MountFileSystem
(
dir
+
"/mnt"
,
fs
,
nil
)
state
,
_
,
err
:=
MountFileSystem
(
dir
+
"/mnt"
,
fs
,
nil
)
CheckSuccess
(
err
)
go
state
.
Loop
(
false
)
...
...
@@ -48,21 +47,20 @@ func TestCacheFs(t *testing.T) {
wd
,
clean
:=
setupCacheTest
()
defer
clean
()
err
:=
ioutil
.
WriteFile
(
wd
+
"/orig/file.txt"
,
[]
byte
(
"hello"
),
0644
)
err
:=
ioutil
.
WriteFile
(
wd
+
"/orig/file.txt"
,
[]
byte
(
"hello"
),
0644
)
CheckSuccess
(
err
)
c
,
err
:=
ioutil
.
ReadFile
(
wd
+
"/mnt/file.txt"
)
c
,
err
:=
ioutil
.
ReadFile
(
wd
+
"/mnt/file.txt"
)
CheckSuccess
(
err
)
if
string
(
c
)
!=
"hello"
{
t
.
Fatalf
(
"expect 'hello' %q"
,
string
(
c
))
}
err
=
ioutil
.
WriteFile
(
wd
+
"/orig/file.txt"
,
[]
byte
(
"qqqqq"
),
0644
)
err
=
ioutil
.
WriteFile
(
wd
+
"/orig/file.txt"
,
[]
byte
(
"qqqqq"
),
0644
)
CheckSuccess
(
err
)
c
,
err
=
ioutil
.
ReadFile
(
wd
+
"/mnt/file.txt"
)
c
,
err
=
ioutil
.
ReadFile
(
wd
+
"/mnt/file.txt"
)
CheckSuccess
(
err
)
if
string
(
c
)
!=
"hello"
{
...
...
fuse/loopback_test.go
View file @
bfca2606
...
...
@@ -654,7 +654,7 @@ func TestStatFs(t *testing.T) {
s1
.
Fsid
=
empty
.
Fsid
s2
.
Fsid
=
empty
.
Fsid
s1
.
Spare
=
empty
.
Spare
s2
.
Spare
=
empty
.
Spare
...
...
fuse/mountstate.go
View file @
bfca2606
...
...
@@ -280,31 +280,29 @@ func (me *MountState) writeInodeNotify(entry *NotifyInvalInodeOut) Status {
}
func
(
me
*
MountState
)
writeEntryNotify
(
parent
uint64
,
name
string
)
Status
{
req
:=
request
{
inHeader
:
&
InHeader
{
opcode
:
_OP_NOTIFY_ENTRY
,
},
handler
:
operationHandlers
[
_OP_NOTIFY_ENTRY
],
status
:
NOTIFY_INVAL_ENTRY
,
}
req
:=
request
{
inHeader
:
&
InHeader
{
opcode
:
_OP_NOTIFY_ENTRY
,
},
handler
:
operationHandlers
[
_OP_NOTIFY_ENTRY
],
status
:
NOTIFY_INVAL_ENTRY
,
}
entry
:=
&
NotifyInvalEntryOut
{
Parent
:
parent
,
Parent
:
parent
,
NameLen
:
uint32
(
len
(
name
)),
}
// Many versions of FUSE generate stacktraces if the
// terminating null byte is missing.
nameBytes
:=
[]
byte
(
name
+
"
\0
00"
)
req
.
outData
=
unsafe
.
Pointer
(
entry
)
req
.
flatData
=
nameBytes
req
.
serialize
()
log
.
Println
([][]
byte
{
req
.
outHeaderBytes
,
req
.
flatData
})
result
:=
me
.
write
(
&
req
)
if
me
.
Debug
{
log
.
Printf
(
"ENTRY_NOTIFY: %v"
,
result
)
}
return
result
}
req
.
outData
=
unsafe
.
Pointer
(
entry
)
req
.
flatData
=
nameBytes
req
.
serialize
()
log
.
Println
([][]
byte
{
req
.
outHeaderBytes
,
req
.
flatData
})
result
:=
me
.
write
(
&
req
)
if
me
.
Debug
{
log
.
Printf
(
"ENTRY_NOTIFY: %v"
,
result
)
}
return
result
}
fuse/notify_test.go
View file @
bfca2606
...
...
@@ -146,9 +146,7 @@ func TestEntryNotify(t *testing.T) {
if
!
code
.
Ok
()
{
t
.
Errorf
(
"EntryNotify returns error: %v"
,
code
)
}
fi
,
err
:=
os
.
Lstat
(
fn
)
CheckSuccess
(
err
)
}
fuse/pathfilesystem.go
View file @
bfca2606
...
...
@@ -463,7 +463,7 @@ func (me *FileSystemConnector) findInode(fullPath string) *inode {
if
fullPath
==
""
{
return
me
.
rootNode
}
fullPath
=
strings
.
TrimLeft
(
filepath
.
Clean
(
fullPath
),
"/"
)
comps
:=
strings
.
Split
(
fullPath
,
"/"
)
...
...
@@ -675,7 +675,7 @@ func (me *FileSystemConnector) FileNotify(path string, off int64, length int64)
func
(
me
*
FileSystemConnector
)
EntryNotify
(
dir
string
,
name
string
)
Status
{
node
:=
me
.
findInode
(
dir
)
if
node
==
nil
{
log
.
Printf
(
"dir not found, %q"
,
dir
)
log
.
Printf
(
"dir not found, %q"
,
dir
)
return
ENOENT
}
...
...
fuse/pathops.go
View file @
bfca2606
...
...
@@ -177,7 +177,6 @@ func (me *FileSystemConnector) Open(header *InHeader, input *OpenIn) (flags uint
return
0
,
0
,
err
}
h
,
opened
:=
mount
.
registerFileHandle
(
node
,
nil
,
f
,
input
.
Flags
)
return
opened
.
FuseFlags
,
h
,
OK
...
...
unionfs/unionfs.go
View file @
bfca2606
...
...
@@ -711,7 +711,6 @@ func (me *UnionFs) OpenDir(directory string) (stream chan fuse.DirEntry, status
return
stream
,
fuse
.
OK
}
// recursivePromote promotes path, and if a directory, everything
// below that directory. It returns a list of all promoted paths.
func
(
me
*
UnionFs
)
recursivePromote
(
path
string
,
pathResult
branchResult
)
(
names
[]
string
,
code
fuse
.
Status
)
{
...
...
@@ -745,7 +744,6 @@ func (me *UnionFs) recursivePromote(path string, pathResult branchResult) (names
return
names
,
code
}
func
(
me
*
UnionFs
)
renameDirectory
(
srcResult
branchResult
,
srcDir
string
,
dstDir
string
)
(
code
fuse
.
Status
)
{
names
:=
[]
string
{}
if
code
.
Ok
()
{
...
...
unionfs/unionfs_test.go
View file @
bfca2606
...
...
@@ -355,7 +355,7 @@ func TestRmdirMkdir(t *testing.T) {
wd
,
clean
:=
setupUfs
(
t
)
defer
clean
()
err
:=
os
.
Mkdir
(
wd
+
"/ro/subdir"
,
0755
)
err
:=
os
.
Mkdir
(
wd
+
"/ro/subdir"
,
0755
)
CheckSuccess
(
err
)
dirname
:=
wd
+
"/mount/subdir"
...
...
@@ -428,10 +428,10 @@ func TestRenameDirBasic(t *testing.T) {
wd
,
clean
:=
setupUfs
(
t
)
defer
clean
()
err
:=
os
.
MkdirAll
(
wd
+
"/ro/dir/subdir"
,
0755
)
err
:=
os
.
MkdirAll
(
wd
+
"/ro/dir/subdir"
,
0755
)
CheckSuccess
(
err
)
err
=
os
.
Rename
(
wd
+
"/mount/dir"
,
wd
+
"/mount/renamed"
)
err
=
os
.
Rename
(
wd
+
"/mount/dir"
,
wd
+
"/mount/renamed"
)
CheckSuccess
(
err
)
if
fi
,
_
:=
os
.
Lstat
(
wd
+
"/mount/dir"
);
fi
!=
nil
{
...
...
@@ -447,7 +447,7 @@ func TestRenameDirBasic(t *testing.T) {
t
.
Errorf
(
"readdir(%s/mount/renamed) should have one entry: %v, err %v"
,
wd
,
entries
,
err
)
}
if
err
=
os
.
Mkdir
(
wd
+
"/mount/dir"
,
0755
);
err
!=
nil
{
if
err
=
os
.
Mkdir
(
wd
+
"/mount/dir"
,
0755
);
err
!=
nil
{
t
.
Errorf
(
"mkdir should succeed %v"
,
err
)
}
}
...
...
@@ -456,13 +456,13 @@ func TestRenameDirWithDeletions(t *testing.T) {
wd
,
clean
:=
setupUfs
(
t
)
defer
clean
()
err
:=
os
.
MkdirAll
(
wd
+
"/ro/dir/subdir"
,
0755
)
err
:=
os
.
MkdirAll
(
wd
+
"/ro/dir/subdir"
,
0755
)
CheckSuccess
(
err
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/dir/file.txt"
,
[]
byte
{
42
},
0644
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/dir/file.txt"
,
[]
byte
{
42
},
0644
)
CheckSuccess
(
err
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/dir/subdir/file.txt"
,
[]
byte
{
42
},
0644
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/dir/subdir/file.txt"
,
[]
byte
{
42
},
0644
)
CheckSuccess
(
err
)
if
fi
,
_
:=
os
.
Lstat
(
wd
+
"/mount/dir/subdir/file.txt"
);
fi
==
nil
||
!
fi
.
IsRegular
()
{
...
...
@@ -472,7 +472,7 @@ func TestRenameDirWithDeletions(t *testing.T) {
err
=
os
.
Remove
(
wd
+
"/mount/dir/file.txt"
)
CheckSuccess
(
err
)
err
=
os
.
Rename
(
wd
+
"/mount/dir"
,
wd
+
"/mount/renamed"
)
err
=
os
.
Rename
(
wd
+
"/mount/dir"
,
wd
+
"/mount/renamed"
)
CheckSuccess
(
err
)
if
fi
,
_
:=
os
.
Lstat
(
wd
+
"/mount/dir/subdir/file.txt"
);
fi
!=
nil
{
...
...
@@ -491,7 +491,7 @@ func TestRenameDirWithDeletions(t *testing.T) {
t
.
Fatalf
(
"%s/mount/renamed/file.txt should have disappeared %#v"
,
wd
,
fi
)
}
if
err
=
os
.
Mkdir
(
wd
+
"/mount/dir"
,
0755
);
err
!=
nil
{
if
err
=
os
.
Mkdir
(
wd
+
"/mount/dir"
,
0755
);
err
!=
nil
{
t
.
Errorf
(
"mkdir should succeed %v"
,
err
)
}
...
...
@@ -504,10 +504,10 @@ func TestRenameSymlink(t *testing.T) {
wd
,
clean
:=
setupUfs
(
t
)
defer
clean
()
err
:=
os
.
Symlink
(
"linktarget"
,
wd
+
"/ro/link"
)
err
:=
os
.
Symlink
(
"linktarget"
,
wd
+
"/ro/link"
)
CheckSuccess
(
err
)
err
=
os
.
Rename
(
wd
+
"/mount/link"
,
wd
+
"/mount/renamed"
)
err
=
os
.
Rename
(
wd
+
"/mount/link"
,
wd
+
"/mount/renamed"
)
CheckSuccess
(
err
)
if
fi
,
_
:=
os
.
Lstat
(
wd
+
"/mount/link"
);
fi
!=
nil
{
...
...
@@ -796,4 +796,3 @@ func TestDisappearing(t *testing.T) {
t
.
Fatal
(
"write should succeed"
,
err
)
}
}
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