From 93b37dad70ea37c4b873fffa546de286c459df14 Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Thu, 10 Nov 2022 03:56:38 -0800 Subject: [PATCH] Update gofer mount options to only show version for 9P. PiperOrigin-RevId: 487493605 --- pkg/sentry/fsimpl/gofer/filesystem.go | 5 ++++- pkg/sentry/fsimpl/gofer/gofer.go | 31 ++++++++++++++------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/pkg/sentry/fsimpl/gofer/filesystem.go b/pkg/sentry/fsimpl/gofer/filesystem.go index f2cea329e..0085eed75 100644 --- a/pkg/sentry/fsimpl/gofer/filesystem.go +++ b/pkg/sentry/fsimpl/gofer/filesystem.go @@ -1898,7 +1898,6 @@ func (fs *filesystem) MountOptions() string { {moptDfltUID, fs.opts.dfltuid}, {moptDfltGID, fs.opts.dfltgid}, {moptMsize, fs.opts.msize}, - {moptVersion, fs.opts.version}, } switch fs.opts.interop { @@ -1923,7 +1922,11 @@ func (fs *filesystem) MountOptions() string { optsKV = append(optsKV, mopt{moptOverlayfsStaleRead, nil}) } if fs.opts.lisaEnabled { + // LISAFS does not have a protocol level version number. Simply add + // `lisafs` in the opts to indicate that we are using LISAFS. optsKV = append(optsKV, mopt{moptLisafs, nil}) + } else { + optsKV = append(optsKV, mopt{moptVersion, fs.opts.version9P}) } opts := make([]string, 0, len(optsKV)) diff --git a/pkg/sentry/fsimpl/gofer/gofer.go b/pkg/sentry/fsimpl/gofer/gofer.go index 6f09f31e5..1c3407aea 100644 --- a/pkg/sentry/fsimpl/gofer/gofer.go +++ b/pkg/sentry/fsimpl/gofer/gofer.go @@ -212,13 +212,13 @@ type filesystem struct { // +stateify savable type filesystemOptions struct { // "Standard" 9P options. - fd int - aname string - interop InteropMode // derived from the "cache" mount option - dfltuid auth.KUID - dfltgid auth.KGID - msize uint32 - version string + fd int + aname string + interop InteropMode // derived from the "cache" mount option + dfltuid auth.KUID + dfltgid auth.KGID + msize uint32 + version9P string // If forcePageCache is true, host FDs may not be used for application // memory mappings even if available; instead, the client must perform its @@ -438,13 +438,6 @@ func (fstype FilesystemType) GetFilesystem(ctx context.Context, vfsObj *vfs.Virt fsopts.msize = uint32(msize) } - // Parse the 9P protocol version. - fsopts.version = p9.HighestVersionString() - if version, ok := mopts[moptVersion]; ok { - delete(mopts, moptVersion) - fsopts.version = version - } - // Handle simple flags. if _, ok := mopts[moptForcePageCache]; ok { delete(mopts, moptForcePageCache) @@ -466,6 +459,14 @@ func (fstype FilesystemType) GetFilesystem(ctx context.Context, vfsObj *vfs.Virt return nil, nil, linuxerr.EINVAL } } + if !fsopts.lisaEnabled { + // Parse the 9P protocol version. + fsopts.version9P = p9.HighestVersionString() + if version, ok := mopts[moptVersion]; ok { + delete(mopts, moptVersion) + fsopts.version9P = version + } + } // fsopts.regularFilesUseSpecialFileFD can only be enabled by specifying // "cache=none". @@ -673,7 +674,7 @@ func (fs *filesystem) dial(ctx context.Context) error { // Perform version negotiation with the server. ctx.UninterruptibleSleepStart(false) - client, err := p9.NewClient(conn, fs.opts.msize, fs.opts.version) + client, err := p9.NewClient(conn, fs.opts.msize, fs.opts.version9P) ctx.UninterruptibleSleepFinish(false) if err != nil { conn.Close()