Commit bfca2606 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Run gofmt.

parent 94f9b193
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" {
......
......@@ -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
......
......@@ -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 + "\000")
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
}
......@@ -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)
}
......@@ -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
}
......
......@@ -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
......
......@@ -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() {
......
......@@ -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)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment