From c97f0978b7ced0a31891fab639cc6c9a80e7fb37 Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Wed, 9 May 2018 16:57:31 -0700 Subject: [PATCH] Cache symlinks in addition to files and directories. PiperOrigin-RevId: 196051326 Change-Id: I4195b110e9a7d38d1ce1ed9c613971dea1be3bf0 --- pkg/sentry/fs/gofer/session.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/sentry/fs/gofer/session.go b/pkg/sentry/fs/gofer/session.go index ab3b964e0..1076e3e55 100644 --- a/pkg/sentry/fs/gofer/session.go +++ b/pkg/sentry/fs/gofer/session.go @@ -126,9 +126,12 @@ func (s *session) Revalidate(*fs.Dirent) bool { // TakeRefs takes an extra reference on dirent if possible. func (s *session) Keep(dirent *fs.Dirent) bool { - // NOTE: Only cache files and directories. sattr := dirent.Inode.StableAttr - return s.cachePolicy != cacheNone && (fs.IsFile(sattr) || fs.IsDir(sattr)) + if s.cachePolicy == cacheNone { + return false + } + // NOTE: Only cache files, directories, and symlinks. + return fs.IsFile(sattr) || fs.IsDir(sattr) || fs.IsSymlink(sattr) } // ResetInodeMappings implements fs.MountSourceOperations.ResetInodeMappings.