summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDean Deng <deandeng@google.com>2020-06-19 08:44:26 -0700
committergVisor bot <gvisor-bot@google.com>2020-06-19 08:45:40 -0700
commitf40d023ad6f8c19898ca105842a88961b3c2994c (patch)
treeceafd352e40ee4d1933d9a306e8bd12783425c47
parent6b69b955d7613ff391984661a7269eabc86020e3 (diff)
Don't adjust parent link count if we replace a child dir with another.
Updates #2923. PiperOrigin-RevId: 317314460
-rw-r--r--pkg/sentry/fsimpl/gofer/filesystem.go3
-rw-r--r--test/syscalls/BUILD1
2 files changed, 3 insertions, 1 deletions
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()
}
}
diff --git a/test/syscalls/BUILD b/test/syscalls/BUILD
index 7b0248a39..131f09ab4 100644
--- a/test/syscalls/BUILD
+++ b/test/syscalls/BUILD
@@ -572,6 +572,7 @@ syscall_test(
size = "medium",
add_overlay = True,
test = "//test/syscalls/linux:rename_test",
+ vfs2 = "True",
)
syscall_test(