Correctly decrement link counts in tmpfs rename operations.

When a directory is replaced by a rename operation, its link count should
reach zero. We were missing the link from `dir/.`

PiperOrigin-RevId: 325141730
This commit is contained in:
Dean Deng
2020-08-05 18:16:57 -07:00
committed by gVisor bot
parent ce463c027b
commit 7ed4b2b5a6
+3 -1
View File
@@ -566,7 +566,9 @@ func (fs *filesystem) RenameAt(ctx context.Context, rp *vfs.ResolvingPath, oldPa
if replaced != nil {
newParentDir.removeChildLocked(replaced)
if replaced.inode.isDir() {
newParentDir.inode.decLinksLocked(ctx) // from replaced's ".."
// Remove links for replaced/. and replaced/..
replaced.inode.decLinksLocked(ctx)
newParentDir.inode.decLinksLocked(ctx)
}
replaced.inode.decLinksLocked(ctx)
}