Commit 3cd80699 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Only hash directory part of filename.

parent b216a171
...@@ -93,6 +93,10 @@ func (me *AutoUnionFs) updateKnownFses() { ...@@ -93,6 +93,10 @@ func (me *AutoUnionFs) updateKnownFses() {
func (me *AutoUnionFs) Readlink(path string) (out string, code fuse.Status) { func (me *AutoUnionFs) Readlink(path string) (out string, code fuse.Status) {
comps := strings.Split(path, filepath.SeparatorString, -1) comps := strings.Split(path, filepath.SeparatorString, -1)
if comps[0] == "status" && comps[1] == "autobase" {
return me.root, fuse.OK
}
if comps[0] != "config" { if comps[0] != "config" {
return "", fuse.ENOENT return "", fuse.ENOENT
} }
...@@ -121,6 +125,13 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) { ...@@ -121,6 +125,13 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) {
return a, fuse.OK return a, fuse.OK
} }
if path == "status/autobase" {
a := &fuse.Attr{
Mode: syscall.S_IFLNK | 0644,
}
return a, fuse.OK
}
comps := strings.Split(path, filepath.SeparatorString, -1) comps := strings.Split(path, filepath.SeparatorString, -1)
me.lock.RLock() me.lock.RLock()
...@@ -148,11 +159,16 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) { ...@@ -148,11 +159,16 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) {
} }
func (me *AutoUnionFs) StatusDir() (stream chan fuse.DirEntry, status fuse.Status) { func (me *AutoUnionFs) StatusDir() (stream chan fuse.DirEntry, status fuse.Status) {
stream = make(chan fuse.DirEntry, 1) stream = make(chan fuse.DirEntry, 10)
stream <- fuse.DirEntry{ stream <- fuse.DirEntry{
Name: "gounionfs_version", Name: "gounionfs_version",
Mode: fuse.S_IFREG | 0644, Mode: fuse.S_IFREG | 0644,
} }
stream <- fuse.DirEntry{
Name: "autobase",
Mode: syscall.S_IFLNK | 0644,
}
close(stream) close(stream)
return stream, fuse.OK return stream, fuse.OK
} }
......
...@@ -16,12 +16,14 @@ import ( ...@@ -16,12 +16,14 @@ import (
// TODO(hanwen): is md5 sufficiently fast? // TODO(hanwen): is md5 sufficiently fast?
func filePathHash(path string) string { func filePathHash(path string) string {
dir, base := filepath.Split(path)
h := md5.New() h := md5.New()
h.Write([]byte(path)) h.Write([]byte(dir))
// TODO(hanwen): should use a tighter format, so we can pack // TODO(hanwen): should use a tighter format, so we can pack
// more results in a readdir() roundtrip. // more results in a readdir() roundtrip.
return fmt.Sprintf("%x", h.Sum()) return fmt.Sprintf("%x-%s", h.Sum()[:8], base)
} }
/* /*
......
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