Commit 4269d7cd authored by Aaron Jacobs's avatar Aaron Jacobs

Check for already existing in memFS.CreateFile.

parent eafe864b
......@@ -341,6 +341,14 @@ 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
// duplicate.
_, exists := parent.LookUpChild(op.Name)
if exists {
err = fmt.Errorf("Name %q already exists in parent", op.Name)
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()
......
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