diff --git a/src/SharpEmu.Libs/Kernel/KernelFileExtendedExports.cs b/src/SharpEmu.Libs/Kernel/KernelFileExtendedExports.cs index ab487ce..b4887f6 100644 --- a/src/SharpEmu.Libs/Kernel/KernelFileExtendedExports.cs +++ b/src/SharpEmu.Libs/Kernel/KernelFileExtendedExports.cs @@ -274,7 +274,7 @@ public static partial class KernelMemoryCompatExports try { - using var stream = new FileStream(hostPath, FileMode.Open, FileAccess.Write, FileShare.ReadWrite); + using var stream = new FileStream(hostPath, FileMode.Open, FileAccess.Write, GuestFileShare); stream.SetLength(length); } catch (FileNotFoundException) diff --git a/src/SharpEmu.Libs/Kernel/KernelMemoryCompatExports.cs b/src/SharpEmu.Libs/Kernel/KernelMemoryCompatExports.cs index 17e6b20..fa88d6b 100644 --- a/src/SharpEmu.Libs/Kernel/KernelMemoryCompatExports.cs +++ b/src/SharpEmu.Libs/Kernel/KernelMemoryCompatExports.cs @@ -20,6 +20,7 @@ namespace SharpEmu.Libs.Kernel; public static partial class KernelMemoryCompatExports { private const int MaxGuestStringLength = 4096; + internal const FileShare GuestFileShare = FileShare.ReadWrite | FileShare.Delete; private const int WideCharSize = sizeof(ushort); private const int MemsetChunkSize = 16 * 1024; private static readonly byte[] _zeroChunk = new byte[MemsetChunkSize]; @@ -1519,7 +1520,7 @@ public static partial class KernelMemoryCompatExports } EnsureOpenParentDirectoryExists(guestPath, hostPath, flags); - var stream = new FileStream(hostPath, mode, access, FileShare.ReadWrite); + var stream = new FileStream(hostPath, mode, access, GuestFileShare); if ((flags & O_APPEND) != 0) { stream.Seek(0, SeekOrigin.End); diff --git a/src/SharpEmu.Libs/LibcStdioExports.cs b/src/SharpEmu.Libs/LibcStdioExports.cs index 53429f3..31f979c 100644 --- a/src/SharpEmu.Libs/LibcStdioExports.cs +++ b/src/SharpEmu.Libs/LibcStdioExports.cs @@ -147,7 +147,7 @@ public static class LibcStdioExports } } - var stream = new FileStream(hostPath, fileMode, fileAccess, FileShare.ReadWrite); + var stream = new FileStream(hostPath, fileMode, fileAccess, KernelMemoryCompatExports.GuestFileShare); if (mode.StartsWith('a') && fileAccess == FileAccess.ReadWrite) { stream.Seek(0, SeekOrigin.End); @@ -1063,7 +1063,7 @@ public static class LibcStdioExports } } - var replacement = new FileStream(hostPath, fileMode, fileAccess, FileShare.ReadWrite); + var replacement = new FileStream(hostPath, fileMode, fileAccess, KernelMemoryCompatExports.GuestFileShare); lock (file.Gate) { if (file.IsClosed)