From f40d023ad6f8c19898ca105842a88961b3c2994c Mon Sep 17 00:00:00 2001 From: Dean Deng Date: Fri, 19 Jun 2020 08:44:26 -0700 Subject: Don't adjust parent link count if we replace a child dir with another. Updates #2923. PiperOrigin-RevId: 317314460 --- pkg/sentry/fsimpl/gofer/filesystem.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pkg/sentry/fsimpl') diff --git a/pkg/sentry/fsimpl/gofer/filesystem.go b/pkg/sentry/fsimpl/gofer/filesystem.go index 21eb976cb..5501781ac 100644 --- a/pkg/sentry/fsimpl/gofer/filesystem.go +++ b/pkg/sentry/fsimpl/gofer/filesystem.go @@ -1196,7 +1196,8 @@ func (fs *filesystem) RenameAt(ctx context.Context, rp *vfs.ResolvingPath, oldPa if newParent.cachedMetadataAuthoritative() { newParent.dirents = nil newParent.touchCMtime() - if renamed.isDir() { + if renamed.isDir() && (replaced == nil || !replaced.isDir()) { + // Increase the link count if we did not replace another directory. newParent.incLinks() } } -- cgit v1.2.3