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

Signal end-of-directory using channel close. Change callers.

parent b68c22d2
...@@ -124,7 +124,7 @@ func (me *MultiZipFs) OpenDir(name string) (stream chan fuse.DirEntry, code fuse ...@@ -124,7 +124,7 @@ func (me *MultiZipFs) OpenDir(name string) (stream chan fuse.DirEntry, code fuse
stream <- fuse.DirEntry(d) stream <- fuse.DirEntry(d)
} }
stream <- fuse.DirEntry{Name: ""} close(stream)
return stream, fuse.OK return stream, fuse.OK
} }
......
...@@ -167,7 +167,7 @@ func (me *ZipFileFuse) OpenDir(name string) (stream chan fuse.DirEntry, code fus ...@@ -167,7 +167,7 @@ func (me *ZipFileFuse) OpenDir(name string) (stream chan fuse.DirEntry, code fus
Mode: zip_DIRMODE, Mode: zip_DIRMODE,
} }
} }
stream <- fuse.DirEntry{} close(stream)
}() }()
return stream, fuse.OK return stream, fuse.OK
} }
......
...@@ -9,11 +9,11 @@ import ( ...@@ -9,11 +9,11 @@ import (
func TestZipFs(t *testing.T) { func TestZipFs(t *testing.T) {
wd, err := os.Getwd() wd, err := os.Getwd()
CheckSuccess(err) CheckSuccess(err)
zfs := NewZipFileFuse(wd + "/test.zip") zfs := NewZipArchiveFileSystem(wd + "/test.zip")
connector := fuse.NewPathFileSystemConnector(zfs) connector := fuse.NewPathFileSystemConnector(zfs)
mountPoint := fuse.MakeTempDir() mountPoint := fuse.MakeTempDir()
state := fuse.NewMountState(connector) state := fuse.NewMountState(connector)
state.Mount(mountPoint) state.Mount(mountPoint)
...@@ -21,12 +21,12 @@ func TestZipFs(t *testing.T) { ...@@ -21,12 +21,12 @@ func TestZipFs(t *testing.T) {
d, err := os.Open(mountPoint, os.O_RDONLY, 0) d, err := os.Open(mountPoint, os.O_RDONLY, 0)
CheckSuccess(err) CheckSuccess(err)
names, err := d.Readdirnames(-1) names, err := d.Readdirnames(-1)
CheckSuccess(err) CheckSuccess(err)
err = d.Close() err = d.Close()
CheckSuccess(err) CheckSuccess(err)
if len(names) != 2 { if len(names) != 2 {
t.Error("wrong length", names) t.Error("wrong length", names)
} }
...@@ -38,7 +38,7 @@ func TestZipFs(t *testing.T) { ...@@ -38,7 +38,7 @@ func TestZipFs(t *testing.T) {
fi, err = os.Stat(mountPoint + "/file.txt") fi, err = os.Stat(mountPoint + "/file.txt")
CheckSuccess(err) CheckSuccess(err)
if !fi.IsRegular() { if !fi.IsRegular() {
t.Error("file type", fi) t.Error("file type", fi)
} }
...@@ -54,6 +54,6 @@ func TestZipFs(t *testing.T) { ...@@ -54,6 +54,6 @@ func TestZipFs(t *testing.T) {
t.Error("content fail", b[:n]) t.Error("content fail", b[:n])
} }
f.Close() f.Close()
state.Unmount() state.Unmount()
} }
...@@ -99,9 +99,8 @@ func (me *FuseDir) ReadDir(input *ReadIn) (*DirEntryList, Status) { ...@@ -99,9 +99,8 @@ func (me *FuseDir) ReadDir(input *ReadIn) (*DirEntryList, Status) {
} }
for { for {
d := <-me.stream d, isOpen := <-me.stream
if d.Name == "" { if !isOpen {
close(me.stream)
me.stream = nil me.stream = nil
break break
} }
......
...@@ -70,7 +70,7 @@ func (me *LoopbackFileSystem) OpenDir(name string) (stream chan DirEntry, status ...@@ -70,7 +70,7 @@ func (me *LoopbackFileSystem) OpenDir(name string) (stream chan DirEntry, status
break break
} }
} }
output <- DirEntry{} close(output)
f.Close() f.Close()
}() }()
......
...@@ -52,9 +52,10 @@ func mount(mountPoint string) (f *os.File, finalMountPoint string, err os.Error) ...@@ -52,9 +52,10 @@ func mount(mountPoint string) (f *os.File, finalMountPoint string, err os.Error)
} }
proc, err := os.StartProcess("/bin/fusermount", proc, err := os.StartProcess("/bin/fusermount",
[]string{"/bin/fusermount", mountPoint}, []string{"/bin/fusermount", mountPoint},
[]string{"_FUSE_COMMFD=3"}, &os.ProcAttr{
"", Env:[]string{"_FUSE_COMMFD=3"},
[]*os.File{os.Stdin, os.Stdout, os.Stderr, remote}) Files: []*os.File{os.Stdin, os.Stdout, os.Stderr, remote}})
if err != nil { if err != nil {
return return
} }
...@@ -76,9 +77,7 @@ func unmount(mountPoint string) (err os.Error) { ...@@ -76,9 +77,7 @@ func unmount(mountPoint string) (err os.Error) {
dir, _ := filepath.Split(mountPoint) dir, _ := filepath.Split(mountPoint)
proc, err := os.StartProcess("/bin/fusermount", proc, err := os.StartProcess("/bin/fusermount",
[]string{"/bin/fusermount", "-u", mountPoint}, []string{"/bin/fusermount", "-u", mountPoint},
nil, &os.ProcAttr{Dir: dir, Files: []*os.File{nil, nil, os.Stderr}})
dir,
[]*os.File{nil, nil, os.Stderr})
if err != nil { if err != nil {
return return
} }
......
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