-
Notifications
You must be signed in to change notification settings - Fork 275
support both cimfs and cimwriter dlls #2587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
2ccfeab to
47570f0
Compare
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>
47570f0 to
36bea94
Compare
helsaawy
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
| 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 { |
There was a problem hiding this comment.
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())
| 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 |
There was a problem hiding this comment.
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 ?:
| //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 | ||
|
|
There was a problem hiding this comment.
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)
}
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.