Skip to content

Commit 9df3a80

Browse files
authored
switch to CimWriter.dll and regenerate syscalls (#2578)
switch to CimWriter.dll and regenerate syscalls Update CIMFS image creation syscalls to use CimWriter.dll. Add `CimFsSupported` utility to check for CIM FS dlls. Update `pkg/cimfs/cimfs.go` to use `CimFsSupported` together with build number check. Signed-off-by: Maksim An <[email protected]>
1 parent e3ffe3d commit 9df3a80

File tree

4 files changed

+164
-157
lines changed

4 files changed

+164
-157
lines changed

internal/winapi/cimfs.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,23 @@ type CimFsImagePath struct {
4040
//sys CimMountImage(imagePath string, fsName string, flags uint32, volumeID *g) (hr error) = cimfs.CimMountImage?
4141
//sys CimDismountImage(volumeID *g) (hr error) = cimfs.CimDismountImage?
4242

43-
//sys CimCreateImage(imagePath string, oldFSName *uint16, newFSName *uint16, cimFSHandle *FsHandle) (hr error) = cimfs.CimCreateImage?
44-
//sys CimCreateImage2(imagePath string, flags uint32, oldFSName *uint16, newFSName *uint16, cimFSHandle *FsHandle) (hr error) = cimfs.CimCreateImage2?
45-
//sys CimCloseImage(cimFSHandle FsHandle) = cimfs.CimCloseImage?
46-
//sys CimCommitImage(cimFSHandle FsHandle) (hr error) = cimfs.CimCommitImage?
47-
48-
//sys CimCreateFile(cimFSHandle FsHandle, path string, file *CimFsFileMetadata, cimStreamHandle *StreamHandle) (hr error) = cimfs.CimCreateFile?
49-
//sys CimCloseStream(cimStreamHandle StreamHandle) (hr error) = cimfs.CimCloseStream?
50-
//sys CimWriteStream(cimStreamHandle StreamHandle, buffer uintptr, bufferSize uint32) (hr error) = cimfs.CimWriteStream?
51-
//sys CimDeletePath(cimFSHandle FsHandle, path string) (hr error) = cimfs.CimDeletePath?
52-
//sys CimCreateHardLink(cimFSHandle FsHandle, newPath string, oldPath string) (hr error) = cimfs.CimCreateHardLink?
53-
//sys CimCreateAlternateStream(cimFSHandle FsHandle, path string, size uint64, cimStreamHandle *StreamHandle) (hr error) = cimfs.CimCreateAlternateStream?
54-
//sys CimAddFsToMergedImage(cimFSHandle FsHandle, path string) (hr error) = cimfs.CimAddFsToMergedImage?
55-
//sys CimAddFsToMergedImage2(cimFSHandle FsHandle, path string, flags uint32) (hr error) = cimfs.CimAddFsToMergedImage2?
43+
//sys CimCreateImage(imagePath string, oldFSName *uint16, newFSName *uint16, cimFSHandle *FsHandle) (hr error) = cimwriter.CimCreateImage?
44+
//sys CimCreateImage2(imagePath string, flags uint32, oldFSName *uint16, newFSName *uint16, cimFSHandle *FsHandle) (hr error) = cimwriter.CimCreateImage2?
45+
//sys CimCloseImage(cimFSHandle FsHandle) = cimwriter.CimCloseImage?
46+
//sys CimCommitImage(cimFSHandle FsHandle) (hr error) = cimwriter.CimCommitImage?
47+
48+
//sys CimCreateFile(cimFSHandle FsHandle, path string, file *CimFsFileMetadata, cimStreamHandle *StreamHandle) (hr error) = cimwriter.CimCreateFile?
49+
//sys CimCloseStream(cimStreamHandle StreamHandle) (hr error) = cimwriter.CimCloseStream?
50+
//sys CimWriteStream(cimStreamHandle StreamHandle, buffer uintptr, bufferSize uint32) (hr error) = cimwriter.CimWriteStream?
51+
//sys CimDeletePath(cimFSHandle FsHandle, path string) (hr error) = cimwriter.CimDeletePath?
52+
//sys CimCreateHardLink(cimFSHandle FsHandle, newPath string, oldPath string) (hr error) = cimwriter.CimCreateHardLink?
53+
//sys CimCreateAlternateStream(cimFSHandle FsHandle, path string, size uint64, cimStreamHandle *StreamHandle) (hr error) = cimwriter.CimCreateAlternateStream?
54+
//sys CimAddFsToMergedImage(cimFSHandle FsHandle, path string) (hr error) = cimwriter.CimAddFsToMergedImage?
55+
//sys CimAddFsToMergedImage2(cimFSHandle FsHandle, path string, flags uint32) (hr error) = cimwriter.CimAddFsToMergedImage2?
5656
//sys CimMergeMountImage(numCimPaths uint32, backingImagePaths *CimFsImagePath, flags uint32, volumeID *g) (hr error) = cimfs.CimMergeMountImage?
57-
//sys CimTombstoneFile(cimFSHandle FsHandle, path string) (hr error) = cimfs.CimTombstoneFile?
58-
//sys CimCreateMergeLink(cimFSHandle FsHandle, newPath string, oldPath string) (hr error) = cimfs.CimCreateMergeLink?
59-
//sys CimSealImage(blockCimPath string, hashSize *uint64, fixedHeaderSize *uint64, hash *byte) (hr error) = cimfs.CimSealImage?
57+
//sys CimTombstoneFile(cimFSHandle FsHandle, path string) (hr error) = cimwriter.CimTombstoneFile?
58+
//sys CimCreateMergeLink(cimFSHandle FsHandle, newPath string, oldPath string) (hr error) = cimwriter.CimCreateMergeLink?
59+
//sys CimSealImage(blockCimPath string, hashSize *uint64, fixedHeaderSize *uint64, hash *byte) (hr error) = cimwriter.CimSealImage?
6060
//sys CimGetVerificationInformation(blockCimPath string, isSealed *uint32, hashSize *uint64, signatureSize *uint64, fixedHeaderSize *uint64, hash *byte, signature *byte) (hr error) = cimfs.CimGetVerificationInformation?
6161
//sys CimMountVerifiedImage(imagePath string, fsName string, flags uint32, volumeID *g, hashSize uint16, hash *byte) (hr error) = cimfs.CimMountVerifiedImage?
6262
//sys CimMergeMountVerifiedImage(numCimPaths uint32, backingImagePaths *CimFsImagePath, flags uint32, volumeID *g, hashSize uint16, hash *byte) (hr error) = cimfs.CimMergeMountVerifiedImage

internal/winapi/utils.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,8 @@ func ConvertStringSetToSlice(buf []byte) ([]string, error) {
8181
func ParseUtf16LE(b []byte) string {
8282
return windows.UTF16PtrToString((*uint16)(unsafe.Pointer(&b[0])))
8383
}
84+
85+
// CimFsSupported checks if CIM FS dlls are present on the system.
86+
func CimFsSupported() bool {
87+
return modcimfs.Load() == nil && modcimwriter.Load() == nil
88+
}

internal/winapi/zsyscall_windows.go

Lines changed: 139 additions & 138 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cimfs/cimfs.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package cimfs
55

66
import (
7+
"github.com/Microsoft/hcsshim/internal/winapi"
78
"path/filepath"
89

910
"github.com/Microsoft/hcsshim/osversion"
@@ -18,7 +19,7 @@ func IsCimFSSupported() bool {
1819
build := osversion.Build()
1920
// CimFS support is backported to LTSC2022 starting with revision 2031 and should
2021
// otherwise be available on all builds >= V25H1Server
21-
return build >= osversion.V25H1Server || (build == osversion.V21H2Server && rv >= 2031)
22+
return (build >= osversion.V25H1Server || (build == osversion.V21H2Server && rv >= 2031)) && winapi.CimFsSupported()
2223
}
2324

2425
// IsBlockCimSupported returns true if block formatted CIMs (i.e block device CIM &
@@ -28,7 +29,7 @@ func IsBlockCimSupported() bool {
2829
// TODO(ambarve): Currently we are checking against a higher build number since there is no
2930
// official build with block CIM support yet. Once we have that build, we should
3031
// update the build number here.
31-
return build >= 27766
32+
return build >= 27766 && winapi.CimFsSupported()
3233
}
3334

3435
// IsVerifiedCimSupported returns true if block CIM format supports also writing verification information in the CIM.
@@ -37,7 +38,7 @@ func IsVerifiedCimSupported() bool {
3738
// TODO(ambarve): Currently we are checking against a higher build number since there is no
3839
// official build with block CIM support yet. Once we have that build, we should
3940
// update the build number here.
40-
return build >= 27800
41+
return build >= 27800 && winapi.CimFsSupported()
4142
}
4243

4344
func IsMergedCimSupported() bool {

0 commit comments

Comments
 (0)