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

Run gofmt.

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