Skip to content

Conversation

@anmaxvl
Copy link
Contributor

@anmaxvl anmaxvl commented Jan 13, 2026

The PR introducing cimwriter.dll was a breaking change, which is fixed in this PR.

Add both cimfs.dll and cimwriter.dll syscalls and only use cimwriter.dll when present.

@anmaxvl anmaxvl force-pushed the cimfs-backward-compat branch 3 times, most recently from 2ccfeab to 47570f0 Compare January 13, 2026 16:26
@anmaxvl anmaxvl marked this pull request as ready for review January 13, 2026 18:02
@anmaxvl anmaxvl requested a review from a team as a code owner January 13, 2026 18:02
The PR introducing cimwriter.dll was a breaking change, which
is fixed in this PR.

Add both cimfs.dll and cimwriter.dll syscalls and only
use cimwriter.dll when present.

Signed-off-by: Maksim An <maksiman@microsoft.com>
@anmaxvl anmaxvl force-pushed the cimfs-backward-compat branch from 47570f0 to 36bea94 Compare January 13, 2026 18:04
Copy link
Contributor

@helsaawy helsaawy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits in comments; but LGTM overall

)

// Type aliases
type g = guid.GUID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know its already called g elsewhere, but can we do

Suggested change
type g = guid.GUID
type GUID = guid.GUID

//sys CimMergeMountVerifiedImage(numCimPaths uint32, backingImagePaths *ImagePath, flags uint32, volumeID *g, hashSize uint16, hash *byte) (hr error) = cimfs.CimMergeMountVerifiedImage

// CimFsSupported checks if cimfs.dll is present on the system.
func CimFsSupported() bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: avoid stutter here (cimfs.CimFsSupported()) and with cimwriter (cimwriter.CimWriterSupported())

Suggested change
func CimFsSupported() bool {
func Supported() bool {

//sys CimSealImage(blockCimPath string, hashSize *uint64, fixedHeaderSize *uint64, hash *byte) (hr error) = cimfs.CimSealImage?
//sys CimGetVerificationInformation(blockCimPath string, isSealed *uint32, hashSize *uint64, signatureSize *uint64, fixedHeaderSize *uint64, hash *byte, signature *byte) (hr error) = cimfs.CimGetVerificationInformation?
//sys CimMountVerifiedImage(imagePath string, fsName string, flags uint32, volumeID *g, hashSize uint16, hash *byte) (hr error) = cimfs.CimMountVerifiedImage?
//sys CimMergeMountVerifiedImage(numCimPaths uint32, backingImagePaths *ImagePath, flags uint32, volumeID *g, hashSize uint16, hash *byte) (hr error) = cimfs.CimMergeMountVerifiedImage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

carried over from internal/winapi/cimfs.go, but CimMergeMountVerifiedImage is the declaration without a ?:

Suggested change
//sys CimMergeMountVerifiedImage(numCimPaths uint32, backingImagePaths *ImagePath, flags uint32, volumeID *g, hashSize uint16, hash *byte) (hr error) = cimfs.CimMergeMountVerifiedImage
//sys CimMergeMountVerifiedImage(numCimPaths uint32, backingImagePaths *ImagePath, flags uint32, volumeID *g, hashSize uint16, hash *byte) (hr error) = cimfs.CimMergeMountVerifiedImage?

//sys CimGetVerificationInformation(blockCimPath string, isSealed *uint32, hashSize *uint64, signatureSize *uint64, fixedHeaderSize *uint64, hash *byte, signature *byte) (hr error) = cimfs.CimGetVerificationInformation?
//sys CimMountVerifiedImage(imagePath string, fsName string, flags uint32, volumeID *g, hashSize uint16, hash *byte) (hr error) = cimfs.CimMountVerifiedImage?
//sys CimMergeMountVerifiedImage(numCimPaths uint32, backingImagePaths *CimFsImagePath, flags uint32, volumeID *g, hashSize uint16, hash *byte) (hr error) = cimfs.CimMergeMountVerifiedImage

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could probably do something like the below to simplify a lot the boilerplate for picking between the cimfs and cimwriter (playground):

func pick[F any](cwFn, cFn F) F {
	if cimwriter.CimWriterSupported() {
		return cwFn
	}
	return cFn
}

func CimCreateImage(imagePath string, oldFSName *uint16, newFSName *uint16, cimFSHandle *types.FsHandle) error {
	return pick(
		cimwriter.CimCreateImage,
		cimfs.CimCreateImage,
	)(imagePath, oldFSName, newFSName, cimFSHandle)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants