Commit 90981c86 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

UnionFs: handle mkdir after rmdir.

parent 24b35705
...@@ -105,6 +105,8 @@ func NewUnionFs(fileSystems []fuse.FileSystem, options UnionFsOptions) *UnionFs ...@@ -105,6 +105,8 @@ func NewUnionFs(fileSystems []fuse.FileSystem, options UnionFsOptions) *UnionFs
//////////////// ////////////////
// Deal with all the caches. // Deal with all the caches.
// The isDeleted() method tells us if a path has a marker in the deletion store.
// It may return an error code if the store could not be accessed.
func (me *UnionFs) isDeleted(name string) (deleted bool, code fuse.Status) { func (me *UnionFs) isDeleted(name string) (deleted bool, code fuse.Status) {
marker := me.deletionPath(name) marker := me.deletionPath(name)
haveCache, found := me.deletionCache.HasEntry(filepath.Base(marker)) haveCache, found := me.deletionCache.HasEntry(filepath.Base(marker))
...@@ -322,9 +324,16 @@ func (me *UnionFs) Rmdir(path string) (code fuse.Status) { ...@@ -322,9 +324,16 @@ func (me *UnionFs) Rmdir(path string) (code fuse.Status) {
} }
func (me *UnionFs) Mkdir(path string, mode uint32) (code fuse.Status) { func (me *UnionFs) Mkdir(path string, mode uint32) (code fuse.Status) {
r := me.getBranch(path) deleted, code := me.isDeleted(path)
if r.code != fuse.ENOENT { if !code.Ok() {
return syscall.EEXIST return code
}
if !deleted {
r := me.getBranch(path)
if r.code != fuse.ENOENT {
return syscall.EEXIST
}
} }
code = me.promoteDirsTo(path) code = me.promoteDirsTo(path)
......
...@@ -351,6 +351,21 @@ func TestMkdirPromote(t *testing.T) { ...@@ -351,6 +351,21 @@ func TestMkdirPromote(t *testing.T) {
} }
} }
func TestRmdirMkdir(t *testing.T) {
wd, clean := setupUfs(t)
defer clean()
err := os.Mkdir(wd + "/ro/subdir", 0755)
CheckSuccess(err)
dirname := wd + "/mount/subdir"
err = os.Remove(dirname)
CheckSuccess(err)
err = os.Mkdir(dirname, 0755)
CheckSuccess(err)
}
func TestRename(t *testing.T) { func TestRename(t *testing.T) {
type Config struct { type Config struct {
f1_ro bool f1_ro bool
...@@ -409,7 +424,7 @@ func TestRename(t *testing.T) { ...@@ -409,7 +424,7 @@ func TestRename(t *testing.T) {
} }
} }
func TestRenameDir(t *testing.T) { func TestRenameDirBasic(t *testing.T) {
wd, clean := setupUfs(t) wd, clean := setupUfs(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