Commit 2d9827cf authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Graceful exit if GetAttr after mkdir/mknod/etc. fails.

parent 0776cb0f
...@@ -157,12 +157,17 @@ type pathInode struct { ...@@ -157,12 +157,17 @@ type pathInode struct {
DefaultFsNode DefaultFsNode
} }
func (me *pathInode) fillNewChildAttr(path string, child *pathInode, c *Context) (fi *os.FileInfo) { func (me *pathInode) fillNewChildAttr(path string, child *pathInode, c *Context) (fi *os.FileInfo, code Status) {
fi, _ = me.fs.GetAttr(path, c) fi, _ = me.fs.GetAttr(path, c)
if fi != nil && fi.Ino > 0 { if fi != nil && fi.Ino > 0 {
child.clientInode = fi.Ino child.clientInode = fi.Ino
} }
return fi
if fi == nil {
log.Println("fillNewChildAttr found nil FileInfo", path)
return nil, ENOENT
}
return fi, OK
} }
// GetPath returns the path relative to the mount governing this // GetPath returns the path relative to the mount governing this
...@@ -320,7 +325,7 @@ func (me *pathInode) Mknod(name string, mode uint32, dev uint32, context *Contex ...@@ -320,7 +325,7 @@ func (me *pathInode) Mknod(name string, mode uint32, dev uint32, context *Contex
if code.Ok() { if code.Ok() {
pNode := me.createChild(name) pNode := me.createChild(name)
newNode = pNode newNode = pNode
fi = me.fillNewChildAttr(fullPath, pNode, context) fi, code = me.fillNewChildAttr(fullPath, pNode, context)
} }
return return
} }
...@@ -331,7 +336,7 @@ func (me *pathInode) Mkdir(name string, mode uint32, context *Context) (fi *os.F ...@@ -331,7 +336,7 @@ func (me *pathInode) Mkdir(name string, mode uint32, context *Context) (fi *os.F
if code.Ok() { if code.Ok() {
pNode := me.createChild(name) pNode := me.createChild(name)
newNode = pNode newNode = pNode
fi = me.fillNewChildAttr(fullPath, pNode, context) fi, code = me.fillNewChildAttr(fullPath, pNode, context)
} }
return return
} }
...@@ -350,7 +355,7 @@ func (me *pathInode) Symlink(name string, content string, context *Context) (fi ...@@ -350,7 +355,7 @@ func (me *pathInode) Symlink(name string, content string, context *Context) (fi
if code.Ok() { if code.Ok() {
pNode := me.createChild(name) pNode := me.createChild(name)
newNode = pNode newNode = pNode
fi = me.fillNewChildAttr(fullPath, pNode, context) fi, code = me.fillNewChildAttr(fullPath, pNode, context)
} }
return return
} }
...@@ -385,7 +390,7 @@ func (me *pathInode) Create(name string, flags uint32, mode uint32, context *Con ...@@ -385,7 +390,7 @@ func (me *pathInode) Create(name string, flags uint32, mode uint32, context *Con
if code.Ok() { if code.Ok() {
pNode := me.createChild(name) pNode := me.createChild(name)
newNode = pNode newNode = pNode
fi = me.fillNewChildAttr(fullPath, pNode, context) fi, code = me.fillNewChildAttr(fullPath, pNode, context)
} }
return return
} }
......
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