Commit 2d65aab9 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Run gofmt.

parent ed34f5da
......@@ -97,7 +97,7 @@ type FileSystemOptions struct {
}
type MountOptions struct {
AllowOther bool
AllowOther bool
}
// DefaultFileSystem implements a FileSystem that returns ENOSYS for every operation.
......
package fuse
import (
"os"
"fmt"
......
......@@ -65,10 +65,10 @@ func (me *testCase) Setup(t *testing.T) {
var rfs RawFileSystem
me.connector = NewFileSystemConnector(pfs,
&FileSystemOptions{
EntryTimeout: testTtl,
AttrTimeout: testTtl,
NegativeTimeout: 0.0,
})
EntryTimeout: testTtl,
AttrTimeout: testTtl,
NegativeTimeout: 0.0,
})
rfs = me.connector
rfs = NewTimingRawFileSystem(rfs)
rfs = NewLockingRawFileSystem(rfs)
......@@ -601,7 +601,7 @@ func TestLargeRead(t *testing.T) {
ts := new(testCase)
ts.Setup(t)
defer ts.Cleanup()
ts.testLargeRead()
}
......@@ -609,7 +609,7 @@ func TestLargeDirRead(t *testing.T) {
ts := new(testCase)
ts.Setup(t)
defer ts.Cleanup()
ts.testLargeDirRead()
}
......@@ -680,9 +680,9 @@ func TestRecursiveMount(t *testing.T) {
t.Error("expect EBUSY")
}
err = os.Rename(ts.mountPoint + "/mnt", ts.mountPoint + "/foobar")
err = os.Rename(ts.mountPoint+"/mnt", ts.mountPoint+"/foobar")
CheckSuccess(err)
f.Close()
log.Println("Waiting for kernel to flush file-close to fuse...")
......@@ -702,11 +702,11 @@ func TestDeletedUnmount(t *testing.T) {
ts := new(testCase)
ts.Setup(t)
defer ts.Cleanup()
submnt := filepath.Join(ts.mountPoint, "mnt")
err := os.Mkdir(submnt, 0777)
CheckSuccess(err)
pfs2 := NewLoopbackFileSystem(ts.origDir)
code := ts.connector.Mount("/mnt", pfs2, nil)
if !code.Ok() {
......
......@@ -185,8 +185,7 @@ func ReverseJoin(rev_components []string, sep string) string {
func CurrentOwner() *Owner {
return &Owner{
Uid: uint32(os.Getuid()),
Gid: uint32(os.Getgid()),
Uid: uint32(os.Getuid()),
Gid: uint32(os.Getgid()),
}
}
......@@ -50,13 +50,13 @@ func mount(mountPoint string, options string) (f *os.File, finalMountPoint strin
}
mountPoint = filepath.Clean(filepath.Join(cwd, mountPoint))
}
cmd := []string{"/bin/fusermount", mountPoint}
if options != "" {
cmd = append(cmd, "-o")
cmd = append(cmd, options)
}
proc, err := os.StartProcess("/bin/fusermount",
cmd,
&os.ProcAttr{
......
......@@ -51,7 +51,7 @@ func (me *MountState) Mount(mountPoint string, opts *MountOptions) os.Error {
if opts != nil && opts.AllowOther {
optStr = "allow_other"
}
file, mp, err := mount(mountPoint, optStr)
if err != nil {
return err
......
......@@ -20,8 +20,8 @@ func (me *ownerFs) GetAttr(name string) (*os.FileInfo, Status) {
}
return &os.FileInfo{
Mode: S_IFREG | 0644,
Uid: _RANDOM_OWNER,
Gid: _RANDOM_OWNER,
Uid: _RANDOM_OWNER,
Gid: _RANDOM_OWNER,
}, OK
}
......@@ -70,4 +70,3 @@ func TestOwnerOverride(t *testing.T) {
t.Fatal("Should use current uid for mount", fi.Uid, fi.Gid)
}
}
......@@ -80,14 +80,14 @@ func (me *FileSystemDebug) GetAttr(path string) (*os.FileInfo, Status) {
if path == DebugDir {
return &os.FileInfo{
Mode: S_IFDIR | 0755,
},OK
}, OK
}
c := me.getContent(path)
if c != nil {
return &os.FileInfo{
Mode: S_IFREG | 0644,
Size: int64(len(c)),
},OK
}, OK
}
return nil, ENOENT
}
......
......@@ -58,9 +58,9 @@ type mountData struct {
// Protects parent/child relations within the mount.
// treeLock should be acquired before openFilesLock
treeLock sync.RWMutex
// Protects openFiles
openFilesLock sync.RWMutex
openFilesLock sync.RWMutex
// Open files/directories.
openFiles map[uint64]*fileBridge
......@@ -68,7 +68,7 @@ type mountData struct {
func newMount(fs FileSystem) *mountData {
return &mountData{
fs: fs,
fs: fs,
openFiles: make(map[uint64]*fileBridge),
}
}
......@@ -126,14 +126,14 @@ type inode struct {
// Protected by openFilesLock.
// TODO - verify() this variable too.
OpenCount int
OpenCount int
// Non-nil if this is a mountpoint.
mountPoint *mountData
mountPoint *mountData
// The point under which this node is. Should be non-nil for
// all nodes.
mount *mountData
mount *mountData
}
// TotalOpenCount counts open files. It should only be entered from
......@@ -143,7 +143,7 @@ func (me *inode) TotalOpenCount() int {
if me.mountPoint != nil {
me.mountPoint.treeLock.RLock()
defer me.mountPoint.treeLock.RUnlock()
me.mountPoint.openFilesLock.RLock()
defer me.mountPoint.openFilesLock.RUnlock()
......@@ -164,12 +164,12 @@ func (me *inode) TotalMountCount() int {
if me.mountPoint.unmountPending {
return 0
}
o++
me.mountPoint.treeLock.RLock()
defer me.mountPoint.treeLock.RUnlock()
}
for _, v := range me.Children {
o += v.TotalMountCount()
}
......@@ -196,7 +196,7 @@ func (me *inode) verify(cur *mountData) {
if me.mount != cur {
panic(fmt.Sprintf("me.mount not set correctly %v %v", me.mount, cur))
}
for n, ch := range me.Children {
if ch == nil {
panic("Found nil child.")
......@@ -230,7 +230,7 @@ func (me *inode) GetPath() (path string, mount *mountData) {
// Deleted node. Treat as if the filesystem was unmounted.
return ".deleted", nil
}
rev_components := make([]string, 0, 10)
inode := me
......@@ -292,7 +292,7 @@ func NewFileSystemOptions() *FileSystemOptions {
NegativeTimeout: 0.0,
AttrTimeout: 1.0,
EntryTimeout: 1.0,
Owner: CurrentOwner(),
Owner: CurrentOwner(),
}
}
......@@ -402,7 +402,7 @@ func (me *FileSystemConnector) forgetUpdate(nodeId uint64, forgetCount int) {
defer me.verify()
node := me.getInodeData(nodeId)
node.LookupCount -= forgetCount
me.considerDropInode(node)
}
......@@ -410,15 +410,15 @@ func (me *FileSystemConnector) forgetUpdate(nodeId uint64, forgetCount int) {
func (me *FileSystemConnector) considerDropInode(n *inode) {
n.mount.treeLock.Lock()
defer n.mount.treeLock.Unlock()
if n.LookupCount <= 0 && len(n.Children) == 0 && (n.mountPoint == nil || n.mountPoint.unmountPending) &&
n.OpenCount <= 0 {
n.setParent(nil)
me.inodeMapMutex.Lock()
defer me.inodeMapMutex.Unlock()
me.inodeMapMutex.Lock()
defer me.inodeMapMutex.Unlock()
me.inodeMap[n.NodeId] = nil, false
}
}
}
func (me *FileSystemConnector) renameUpdate(oldParent *inode, oldName string, newParent *inode, newName string) {
......@@ -470,7 +470,7 @@ func (me *FileSystemConnector) findInode(fullPath string) *inode {
node.mountPoint.treeLock.RLock()
defer node.mountPoint.treeLock.RUnlock()
}
node = node.Children[component]
if node == nil {
return nil
......@@ -525,7 +525,7 @@ func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem, opts *Fil
if node != me.rootNode {
node.mount.treeLock.RUnlock()
}
if hasChildren {
return EBUSY
}
......
......@@ -492,4 +492,3 @@ func (me *FileSystemConnector) Ioctl(header *InHeader, input *IoctlIn) (out *Ioc
}
return f.Ioctl(input)
}
......@@ -39,11 +39,11 @@ type AutoUnionFsOptions struct {
}
const (
_READONLY = "READONLY"
_STATUS = "status"
_CONFIG = "config"
_ROOT = "root"
_VERSION = "gounionfs_version"
_READONLY = "READONLY"
_STATUS = "status"
_CONFIG = "config"
_ROOT = "root"
_VERSION = "gounionfs_version"
_SCAN_CONFIG = ".scan_config"
)
......@@ -258,7 +258,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*os.FileInfo, fuse.Status) {
}
return a, fuse.OK
}
if path == filepath.Join(_CONFIG, _SCAN_CONFIG) {
a := &os.FileInfo{
Mode: fuse.S_IFREG | 0644,
......@@ -283,7 +283,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*os.FileInfo, fuse.Status) {
if me.getUnionFs(path) != nil {
return &os.FileInfo{
Mode: fuse.S_IFDIR | 0755,
},fuse.OK
}, fuse.OK
}
return nil, fuse.ENOENT
......@@ -306,13 +306,13 @@ func (me *AutoUnionFs) StatusDir() (stream chan fuse.DirEntry, status fuse.Statu
func (me *AutoUnionFs) Open(path string, flags uint32) (fuse.File, fuse.Status) {
if path == filepath.Join(_STATUS, _VERSION) {
if flags & fuse.O_ANYWRITE != 0 {
if flags&fuse.O_ANYWRITE != 0 {
return nil, fuse.EPERM
}
return fuse.NewReadOnlyFile([]byte(fuse.Version())), fuse.OK
}
if path == filepath.Join(_CONFIG, _SCAN_CONFIG) {
if flags & fuse.O_ANYWRITE != 0 {
if flags&fuse.O_ANYWRITE != 0 {
me.updateKnownFses()
}
return fuse.NewDevNullFile(), fuse.OK
......
......@@ -44,7 +44,7 @@ func setup(t *testing.T) (workdir string, cleanup func()) {
WriteFile(wd+"/ro/file2", "file2")
fs := NewAutoUnionFs(wd+"/store", testAOpts)
state, conn, err := fuse.MountFileSystem(wd + "/mount", fs, &testAOpts.FileSystemOptions)
state, conn, err := fuse.MountFileSystem(wd+"/mount", fs, &testAOpts.FileSystemOptions)
CheckSuccess(err)
state.Debug = true
conn.Debug = true
......@@ -60,7 +60,7 @@ func TestVersion(t *testing.T) {
wd, clean := setup(t)
defer clean()
c, err := ioutil.ReadFile(wd+"/mount/status/gounionfs_version")
c, err := ioutil.ReadFile(wd + "/mount/status/gounionfs_version")
CheckSuccess(err)
if len(c) == 0 {
t.Fatal("No version found.")
......@@ -91,7 +91,7 @@ func TestAutoFsSymlink(t *testing.T) {
time.Sleep(2 * entryTtl * 1e9)
scan := wd + "/mount/config/" + _SCAN_CONFIG
err = ioutil.WriteFile(scan, []byte("something"), 0644 )
err = ioutil.WriteFile(scan, []byte("something"), 0644)
if err != nil {
t.Error("error writing:", err)
}
......@@ -127,12 +127,12 @@ func TestExplicitScan(t *testing.T) {
if err != nil {
t.Error(".scan_config missing:", err)
}
err = ioutil.WriteFile(scan, []byte("something"), 0644 )
err = ioutil.WriteFile(scan, []byte("something"), 0644)
if err != nil {
t.Error("error writing:", err)
}
_, err = os.Lstat(wd + "/mount/backing1")
if err != nil {
t.Error("Should have workspace backing1:", err)
......
......@@ -136,10 +136,10 @@ func NewCachingFileSystem(fs fuse.FileSystem, ttlNs int64) *CachingFileSystem {
c.links = NewTimedCache(func(n string) interface{} { return readLink(fs, n) }, ttlNs)
c.xattr = NewTimedCache(func(n string) interface{} {
return getXAttr(fs, n)
},ttlNs)
}, ttlNs)
c.files = NewTimedCache(func(n string) interface{} {
return openFile(fs, n)
},ttlNs)
}, ttlNs)
return c
}
......
......@@ -16,7 +16,7 @@ func newDirnameMap(fs fuse.FileSystem, dir string) map[string]bool {
log.Printf("newDirnameMap(): %v %v", dir, code)
return nil
}
result := make(map[string]bool)
for e := range stream {
if e.Mode&fuse.S_IFREG != 0 {
......
......@@ -570,7 +570,7 @@ func (me *UnionFs) GetAttr(name string) (a *os.FileInfo, s fuse.Status) {
if name == _DROP_CACHE {
return &os.FileInfo{
Mode: fuse.S_IFREG | 0777,
},fuse.OK
}, fuse.OK
}
if name == me.options.DeletionDirName {
return nil, fuse.ENOENT
......
......@@ -48,7 +48,7 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
NegativeTimeout: entryTtl,
}
state, _, err := fuse.MountFileSystem(wd + "/mount", ufs, opts)
state, _, err := fuse.MountFileSystem(wd+"/mount", ufs, opts)
CheckSuccess(err)
state.Debug = true
go state.Loop(false)
......@@ -123,13 +123,13 @@ func TestAutocreateDeletionDir(t *testing.T) {
wd, clean := setupUfs(t)
defer clean()
err := os.Remove(wd+"/rw/DELETIONS")
err := os.Remove(wd + "/rw/DELETIONS")
CheckSuccess(err)
err = os.Mkdir(wd+"/mount/dir", 0755)
CheckSuccess(err)
_, err = ioutil.ReadDir(wd+"/mount/dir")
_, err = ioutil.ReadDir(wd + "/mount/dir")
CheckSuccess(err)
}
......@@ -498,7 +498,7 @@ func TestRemoveAll(t *testing.T) {
wd, clean := setupUfs(t)
defer clean()
err := os.Mkdir(wd + "/ro/dir", 0755)
err := os.Mkdir(wd+"/ro/dir", 0755)
CheckSuccess(err)
contents := "hello"
......@@ -506,7 +506,7 @@ func TestRemoveAll(t *testing.T) {
err = ioutil.WriteFile(fn, []byte(contents), 0644)
CheckSuccess(err)
err = os.RemoveAll(wd+"/mount/dir")
err = os.RemoveAll(wd + "/mount/dir")
if err != nil {
t.Error("Should delete all")
}
......@@ -527,7 +527,7 @@ func TestDropCache(t *testing.T) {
wd, clean := setupUfs(t)
defer clean()
err := ioutil.WriteFile(wd + "/ro/file", []byte("bla"), 0644)
err := ioutil.WriteFile(wd+"/ro/file", []byte("bla"), 0644)
CheckSuccess(err)
_, err = os.Lstat(wd + "/mount/.drop_cache")
......@@ -535,18 +535,18 @@ func TestDropCache(t *testing.T) {
names, err := Readdirnames(wd + "/mount")
CheckSuccess(err)
if len(names) != 1 || names[0] != "file" {
if len(names) != 1 || names[0] != "file" {
t.Fatal("unexpected names", names)
}
err = ioutil.WriteFile(wd + "/ro/file2", []byte("blabla"), 0644)
err = ioutil.WriteFile(wd+"/ro/file2", []byte("blabla"), 0644)
names2, err := Readdirnames(wd + "/mount")
CheckSuccess(err)
if len(names2) != len(names) {
t.Fatal("mismatch", names2)
}
err = ioutil.WriteFile(wd + "/mount/.drop_cache", []byte("does not matter"), 0644)
err = ioutil.WriteFile(wd+"/mount/.drop_cache", []byte("does not matter"), 0644)
CheckSuccess(err)
names2, err = Readdirnames(wd + "/mount")
if len(names2) != 2 {
......@@ -568,19 +568,19 @@ func TestDisappearing(t *testing.T) {
os.Mkdir(wd+"/ro", 0700)
fuse.CheckSuccess(err)
wrFs := fuse.NewLoopbackFileSystem(wd+"/rw")
wrFs := fuse.NewLoopbackFileSystem(wd + "/rw")
var fses []fuse.FileSystem
fses = append(fses, wrFs)
fses = append(fses, fuse.NewLoopbackFileSystem(wd+"/ro"))
ufs := NewUnionFs("testFs", fses, testOpts)
opts := &fuse.FileSystemOptions{
EntryTimeout: entryTtl,
AttrTimeout: entryTtl,
NegativeTimeout: entryTtl,
EntryTimeout: entryTtl,
AttrTimeout: entryTtl,
NegativeTimeout: entryTtl,
}
state, _, err := fuse.MountFileSystem(wd + "/mount", ufs, opts)
state, _, err := fuse.MountFileSystem(wd+"/mount", ufs, opts)
CheckSuccess(err)
defer state.Unmount()
state.Debug = true
......@@ -588,23 +588,23 @@ func TestDisappearing(t *testing.T) {
log.Println("TestDisappearing2")
err = ioutil.WriteFile(wd + "/ro/file", []byte("blabla"), 0644)
err = ioutil.WriteFile(wd+"/ro/file", []byte("blabla"), 0644)
CheckSuccess(err)
err = os.Remove(wd+"/mount/file")
err = os.Remove(wd + "/mount/file")
CheckSuccess(err)
oldRoot := wrFs.Root
wrFs.Root = "/dev/null"
time.Sleep(1.5*entryTtl*1e9)
time.Sleep(1.5 * entryTtl * 1e9)
_, err = ioutil.ReadDir(wd+"/mount")
_, err = ioutil.ReadDir(wd + "/mount")
if err == nil {
t.Fatal("Readdir should have failed")
t.Fatal("Readdir should have failed")
}
log.Println("expected readdir failure:", err)
err = ioutil.WriteFile(wd + "/mount/file2", []byte("blabla"), 0644)
err = ioutil.WriteFile(wd+"/mount/file2", []byte("blabla"), 0644)
if err == nil {
t.Fatal("write should have failed")
}
......@@ -612,15 +612,14 @@ func TestDisappearing(t *testing.T) {
// Restore, and wait for caches to catch up.
wrFs.Root = oldRoot
time.Sleep(1.5*entryTtl*1e9)
time.Sleep(1.5 * entryTtl * 1e9)
_, err = ioutil.ReadDir(wd+"/mount")
_, err = ioutil.ReadDir(wd + "/mount")
if err != nil {
t.Fatal("Readdir should succeed", err)
t.Fatal("Readdir should succeed", err)
}
err = ioutil.WriteFile(wd + "/mount/file2", []byte("blabla"), 0644)
err = ioutil.WriteFile(wd+"/mount/file2", []byte("blabla"), 0644)
if err != nil {
t.Fatal("write should succeed", err)
}
}
......@@ -21,15 +21,15 @@ func TestMultiZipFs(t *testing.T) {
fs := NewMultiZipFs()
mountPoint := fuse.MakeTempDir()
state, _, err := fuse.MountFileSystem(mountPoint, fs, &fuse.FileSystemOptions{
EntryTimeout: testTtl,
AttrTimeout: testTtl,
state, _, err := fuse.MountFileSystem(mountPoint, fs, &fuse.FileSystemOptions{
EntryTimeout: testTtl,
AttrTimeout: testTtl,
NegativeTimeout: 0.0,
})
defer os.RemoveAll(mountPoint)
CheckSuccess(err)
defer state.Unmount()
state.Debug = true
go state.Loop(true)
......
......@@ -73,7 +73,7 @@ func NewTarTree(r io.Reader) *MemTree {
hdr.Name = *longName
longName = nil
}
comps := strings.Split(filepath.Clean(hdr.Name), "/", -1)
base := ""
if !strings.HasSuffix(hdr.Name, "/") {
......
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