Commit 1f07b43d authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Use promoteDirsTo() for Rename and Mkdir too.

parent 03c3c9b9
......@@ -310,7 +310,11 @@ func (me *UnionFs) Mkdir(path string, mode uint32) (code fuse.Status) {
if r.code != fuse.ENOENT {
return syscall.EEXIST
}
code = me.fileSystems[0].Mkdir(path, mode)
code = me.promoteDirsTo(path)
if code == fuse.OK {
code = me.fileSystems[0].Mkdir(path, mode)
}
if code == fuse.OK {
me.removeDeletion(path)
attr := &fuse.Attr{
......@@ -619,36 +623,36 @@ func (me *UnionFs) OpenDir(directory string) (stream chan fuse.DirEntry, status
return stream, fuse.OK
}
func (me *UnionFs) Rename(src string, dst string) (status fuse.Status) {
func (me *UnionFs) Rename(src string, dst string) (code fuse.Status) {
srcResult := me.getBranch(src)
if srcResult.code != fuse.OK {
return srcResult.code
code = srcResult.code
if code == fuse.OK {
code = srcResult.code
}
if srcResult.branch > 0 {
code := me.Promote(src, srcResult)
if code != fuse.OK {
return code
}
if code == fuse.OK && srcResult.branch > 0 {
code = me.Promote(src, srcResult)
}
code := me.fileSystems[0].Rename(src, dst)
if code != fuse.OK {
return code
if code == fuse.OK {
code = me.promoteDirsTo(dst)
}
me.removeDeletion(dst)
srcResult.branch = 0
me.branchCache.Set(dst, srcResult)
if srcResult.branch == 0 {
srcResult := me.branchCache.GetFresh(src)
if srcResult.(branchResult).branch > 0 {
if code == fuse.OK {
code = me.fileSystems[0].Rename(src, dst)
}
if code == fuse.OK {
me.removeDeletion(dst)
srcResult.branch = 0
me.branchCache.Set(dst, srcResult)
if srcResult.branch == 0 {
srcResult := me.branchCache.GetFresh(src)
if srcResult.(branchResult).branch > 0 {
code = me.putDeletion(src)
}
} else {
code = me.putDeletion(src)
}
} else {
code = me.putDeletion(src)
}
return code
}
......
......@@ -266,6 +266,7 @@ func TestOpenUndeletes(t *testing.T) {
_, err = os.Lstat(wd + "/mount/file")
CheckSuccess(err)
}
func TestMkdir(t *testing.T) {
wd, state := setup(t)
defer state.Unmount()
......@@ -278,6 +279,22 @@ func TestMkdir(t *testing.T) {
CheckSuccess(err)
}
func TestMkdirPromote(t *testing.T) {
wd, state := setup(t)
defer state.Unmount()
dirname := wd + "/ro/subdir/subdir2"
err := os.MkdirAll(dirname, 0755)
CheckSuccess(err)
err = os.Mkdir(wd+"/mount/subdir/subdir2/dir3", 0755)
CheckSuccess(err)
fi, _ := os.Lstat(wd+"/rw/subdir/subdir2/dir3")
CheckSuccess(err)
if fi == nil || !fi.IsDirectory() {
t.Error("is not a directory: ", fi)
}
}
func TestRename(t *testing.T) {
type Config struct {
f1_ro bool
......
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