Commit 7a0e5b38 authored by Manuel Klimek's avatar Manuel Klimek

Allows autoconfiguration of directories that were symlinked into

the root path.
parent 4c2b5911
......@@ -10,6 +10,7 @@ import (
"syscall"
"sync"
"time"
"io/ioutil"
)
// Creates unions for all files under a given directory,
......@@ -168,7 +169,18 @@ func (me *AutoUnionFs) VisitFile(path string, f *os.FileInfo) {
func (me *AutoUnionFs) updateKnownFses() {
log.Println("Looking for new filesystems")
filepath.Walk(me.root, me, nil)
// We unroll the first level of entries in the root manually in order
// to allow symbolic links on that level.
directoryEntries, err := ioutil.ReadDir(me.root)
if err == nil {
for _, dir := range directoryEntries {
if dir.IsDirectory() || dir.IsSymlink() {
path := filepath.Join(me.root, dir.Name)
me.VisitDir(path, nil)
filepath.Walk(path, me, nil)
}
}
}
log.Println("Done looking")
}
......
......@@ -73,7 +73,7 @@ func TestAutoFsSymlink(t *testing.T) {
err := os.Mkdir(wd+"/store/backing1", 0755)
CheckSuccess(err)
os.Symlink(wd+"/ro", wd+"/store/backing1/READONLY")
err = os.Symlink(wd+"/ro", wd+"/store/backing1/READONLY")
CheckSuccess(err)
err = os.Symlink(wd+"/store/backing1", wd+"/mount/config/manual1")
......@@ -109,6 +109,29 @@ func TestAutoFsSymlink(t *testing.T) {
CheckSuccess(err)
}
func TestDetectSymlinkedDirectories(t *testing.T) {
wd, clean := setup(t)
defer clean()
err := os.Mkdir(wd+"/backing1", 0755)
CheckSuccess(err)
err = os.Symlink(wd+"/ro", wd+"/backing1/READONLY")
CheckSuccess(err)
err = os.Symlink(wd+"/backing1", wd+"/store/backing1")
CheckSuccess(err)
scan := wd + "/mount/config/" + _SCAN_CONFIG
err = ioutil.WriteFile(scan, []byte("something"), 0644)
if err != nil {
t.Error("error writing:", err)
}
_, err = os.Lstat(wd + "/mount/backing1")
CheckSuccess(err)
}
func TestExplicitScan(t *testing.T) {
wd, clean := setup(t)
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