Fixed memfs bugs.

geesefs-0-30-9
Aaron Jacobs 2015-05-21 15:22:26 +10:00
parent 49a5ff2328
commit bc969387ca
1 changed files with 17 additions and 1 deletions

View File

@ -301,6 +301,14 @@ func (fs *memFS) MkDir(
parent := fs.getInodeForModifyingOrDie(op.Parent)
defer parent.mu.Unlock()
// Ensure that the name doesn't already exist, so we don't wind up with a
// duplicate.
_, exists := parent.LookUpChild(op.Name)
if exists {
err = fuse.EEXIST
return
}
// Set up attributes from the child, using the credentials of the calling
// process as owner (matching inode_init_owner, cf. http://goo.gl/5qavg8).
childAttrs := fuseops.InodeAttributes{
@ -341,7 +349,7 @@ func (fs *memFS) CreateFile(
parent := fs.getInodeForModifyingOrDie(op.Parent)
defer parent.mu.Unlock()
// Ensure that the name doesn't alread exist, so we don't wind up with a
// Ensure that the name doesn't already exist, so we don't wind up with a
// duplicate.
_, exists := parent.LookUpChild(op.Name)
if exists {
@ -396,6 +404,14 @@ func (fs *memFS) CreateSymlink(
parent := fs.getInodeForModifyingOrDie(op.Parent)
defer parent.mu.Unlock()
// Ensure that the name doesn't already exist, so we don't wind up with a
// duplicate.
_, exists := parent.LookUpChild(op.Name)
if exists {
err = fuse.EEXIST
return
}
// Set up attributes from the child, using the credentials of the calling
// process as owner (matching inode_init_owner, cf. http://goo.gl/5qavg8).
now := fs.clock.Now()