Make unlink tests pass with goferfs

Required directory checks were being skipped when there was
no child cached. Now the code always loads the child file
before unlinking it.

Updates #1198

PiperOrigin-RevId: 305382323
This commit is contained in:
Fabricio Voznika
2020-04-07 18:27:55 -07:00
committed by gVisor bot
parent dbcc59af0b
commit 5a1324625f
+5
View File
@@ -437,14 +437,19 @@ func (fs *filesystem) unlinkAt(ctx context.Context, rp *vfs.ResolvingPath, dir b
flags := uint32(0)
if dir {
if child != nil && !child.isDir() {
vfsObj.AbortDeleteDentry(childVFSD)
return syserror.ENOTDIR
}
flags = linux.AT_REMOVEDIR
} else {
if child != nil && child.isDir() {
vfsObj.AbortDeleteDentry(childVFSD)
return syserror.EISDIR
}
if rp.MustBeDir() {
if childVFSD != nil {
vfsObj.AbortDeleteDentry(childVFSD)
}
return syserror.ENOTDIR
}
}