@@ -1055,7 +1055,11 @@ VmFileSystemDevice HcsVirtualMachineBackend::CreateFileSystemDevice(const VmFile
10551055 }
10561056
10571057 VmFileSystemDevice device{
1058- {m_configuration.Description .Identity , m_nextDeviceId}, VmFileSystemDeviceState::Prepared, {}, Request.Transport };
1058+ {m_configuration.Description .Identity , m_nextDeviceId},
1059+ VmFileSystemDeviceState::Prepared,
1060+ {},
1061+ Request.Transport ,
1062+ wsl::windows::common::security::IsTokenElevated (userToken.get ())};
10591063 std::wstring mountOptions;
10601064 wil::com_ptr<IPlan9FileSystem> plan9Server;
10611065 std::optional<GUID > guestInstanceId;
@@ -1145,16 +1149,17 @@ VmFileSystemDevice HcsVirtualMachineBackend::CreateFileSystemDevice(const VmFile
11451149 return device;
11461150}
11471151
1148- std::vector <VmFileSystemDevice> HcsVirtualMachineBackend::GetFileSystemDevices ( ) const
1152+ std::optional <VmFileSystemDevice> HcsVirtualMachineBackend::GetFileSystemDevice ( const VmFileSystemDevicePredicate& Predicate ) const
11491153{
11501154 auto lock = m_lock.lock_shared ();
1151- std::vector<VmFileSystemDevice> devices;
1152- devices.reserve (m_fileSystemDevices.size ());
11531155 for (const auto & entry : m_fileSystemDevices)
11541156 {
1155- devices.push_back (entry.second );
1157+ if (Predicate (entry.second ))
1158+ {
1159+ return entry.second ;
1160+ }
11561161 }
1157- return devices ;
1162+ return {} ;
11581163}
11591164
11601165VmFileSystemDevice HcsVirtualMachineBackend::GetFileSystemDeviceStatus (VmDeviceId Device)
@@ -1320,6 +1325,7 @@ VmFileSystemShare HcsVirtualMachineBackend::AddFileSystemShare(VmDeviceId Device
13201325 // prefix such as '\\?' so that the guest can mount arbitrary subpaths below it.
13211326 std::wstring hostPath;
13221327 std::wstring mountOptions;
1328+ std::map<std::wstring, std::wstring> effectiveMountOptions;
13231329 std::optional<VmFileSystemShare> reused;
13241330 VmFileSystemShareAddress guestAddress;
13251331 std::visit (
@@ -1342,6 +1348,7 @@ VmFileSystemShare HcsVirtualMachineBackend::AddFileSystemShare(VmDeviceId Device
13421348 shareOptions[L" ro" ] = {};
13431349 }
13441350
1351+ effectiveMountOptions = shareOptions;
13451352 mountOptions = FormatVirtioFsMountOptions (shareOptions);
13461353
13471354 // Repeating a request for the same path and options reuses the existing share so that
@@ -1427,6 +1434,8 @@ VmFileSystemShare HcsVirtualMachineBackend::AddFileSystemShare(VmDeviceId Device
14271434 share.Device = Device;
14281435 share.GuestAddress = std::move (guestAddress);
14291436 share.EffectiveHostPath = hostPath;
1437+ share.MountOptions = std::move (effectiveMountOptions);
1438+ share.Elevated = device->second .Elevated ;
14301439 share.ReadOnly = Request.ReadOnly ;
14311440
14321441 const auto inserted = m_fileSystemShares.emplace (share.Id .Value , FileSystemShare{share, {std::move (mountOptions), userToken}}).second ;
@@ -1443,6 +1452,19 @@ VmFileSystemShare HcsVirtualMachineBackend::AddFileSystemShare(VmDeviceId Device
14431452 return share;
14441453}
14451454
1455+ std::optional<VmFileSystemShare> HcsVirtualMachineBackend::GetFileSystemShare (const VmFileSystemSharePredicate& Predicate) const
1456+ {
1457+ auto lock = m_lock.lock_shared ();
1458+ for (const auto & entry : m_fileSystemShares)
1459+ {
1460+ if (Predicate (entry.second ))
1461+ {
1462+ return entry.second ;
1463+ }
1464+ }
1465+ return {};
1466+ }
1467+
14461468void HcsVirtualMachineBackend::RemoveFileSystemShare (VmShareId Share)
14471469{
14481470 WSL_LOG (
0 commit comments