Commit 8278f60e authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Run gofmt.

parent 336fe3bc
......@@ -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,
......
......@@ -59,7 +59,6 @@ func (me *DevNullFile) String() string {
return "DevNullFile"
}
func (me *DevNullFile) Read(input *ReadIn, bp BufferPool) ([]byte, Status) {
return []byte{}, OK
}
......
......@@ -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)
}
}
......@@ -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)
......
......@@ -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
......
......@@ -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)
}
}
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