Commit 93276d3e authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

AutoUnionFs: allow reads of status/gounionfs_version.

parent fa9a8c95
...@@ -245,6 +245,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*os.FileInfo, fuse.Status) { ...@@ -245,6 +245,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*os.FileInfo, fuse.Status) {
if path == filepath.Join(_STATUS, _VERSION) { if path == filepath.Join(_STATUS, _VERSION) {
a := &os.FileInfo{ a := &os.FileInfo{
Mode: fuse.S_IFREG | 0644, Mode: fuse.S_IFREG | 0644,
Size: int64(len(fuse.Version())),
} }
return a, fuse.OK return a, fuse.OK
} }
...@@ -295,6 +296,16 @@ func (me *AutoUnionFs) StatusDir() (stream chan fuse.DirEntry, status fuse.Statu ...@@ -295,6 +296,16 @@ func (me *AutoUnionFs) StatusDir() (stream chan fuse.DirEntry, status fuse.Statu
return stream, fuse.OK return stream, fuse.OK
} }
func (me *AutoUnionFs) Open(path string, flags uint32) (fuse.File, fuse.Status) {
if path == _STATUS + "/" + _VERSION {
if flags & fuse.O_ANYWRITE != 0 {
return nil, fuse.EPERM
}
return fuse.NewReadOnlyFile([]byte(fuse.Version())), fuse.OK
}
return nil, fuse.ENOENT
}
func (me *AutoUnionFs) OpenDir(name string) (stream chan fuse.DirEntry, status fuse.Status) { func (me *AutoUnionFs) OpenDir(name string) (stream chan fuse.DirEntry, status fuse.Status) {
switch name { switch name {
case _STATUS: case _STATUS:
......
...@@ -55,6 +55,18 @@ func setup(t *testing.T) (workdir string, cleanup func()) { ...@@ -55,6 +55,18 @@ func setup(t *testing.T) (workdir string, cleanup func()) {
} }
} }
func TestVersion(t *testing.T) {
wd, clean := setup(t)
defer clean()
c, err := ioutil.ReadFile(wd+"/mount/status/gounionfs_version")
CheckSuccess(err)
if len(c) == 0 {
t.Fatal("No version found.")
}
log.Println("Found version:", string(c))
}
func TestAutoFsSymlink(t *testing.T) { func TestAutoFsSymlink(t *testing.T) {
wd, clean := setup(t) wd, clean := setup(t)
defer clean() defer clean()
......
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