Skip to content

Commit

Permalink
Add type definitions for block & single file CIMs
Browse files Browse the repository at this point in the history
CimFS now supports a new format for storing CIMs, named BlockCIM.
A block CIM format can store the entire CIM on a block device (like a VHD) or a file
formatted like a block device.
This commit adds a Go wrapper for the new  CimFS CreateImage2 API that allows creation of
CIMs in these new formats. Some new flags required when creating and mounting these CIMs
are also added.
Lastly, a new type has been introduced to represent these new formats of CIM in our
codebase.

Signed-off-by: Amit Barve <[email protected]>
  • Loading branch information
ambarve committed May 30, 2024
1 parent 8d77be2 commit 582e35c
Show file tree
Hide file tree
Showing 7 changed files with 611 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ const (
CimMountFlagEnableDax uint32 = 0x2
CimMountFlagCacheFiles uint32 = 0x4
CimMountFlagCacheRegions uint32 = 0x8
CimMountBlockDeviceCim uint32 = 0x10
CimMountSingleFileCim uint32 = 0x20

CimCreateFlagNone uint32 = 0x0
CimCreateFlagDoNotExpandPEImages uint32 = 0x1
CimCreateFlagFixedSizeChunks uint32 = 0x2
CimCreateFlagBlockDeviceCim uint32 = 0x4
CimCreateFlagSingleFileCim uint32 = 0x8

CimMergeFlagNone uint32 = 0x0
CimMergeFlagSingleFile uint32 = 0x1
CimMergeFlagBlockDevice uint32 = 0x2
)

type CimMount struct {
Expand Down
11 changes: 10 additions & 1 deletion internal/winapi/cimfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ type CimFsFileMetadata struct {
EACount uint32
}

type CimFsImagePath struct {
ImageDir *uint16
ImageName *uint16
}

//sys CimMountImage(imagePath string, fsName string, flags uint32, volumeID *g) (hr error) = cimfs.CimMountImage?
//sys CimDismountImage(volumeID *g) (hr error) = cimfs.CimDismountImage?

//sys CimCreateImage(imagePath string, oldFSName *uint16, newFSName *uint16, cimFSHandle *FsHandle) (hr error) = cimfs.CimCreateImage?
//sys CimCloseImage(cimFSHandle FsHandle) = cimfs.CimCloseImage?
//sys CimCreateImage2(imagePath string, flags uint32, oldFSName *uint16, newFSName *uint16, cimFSHandle *FsHandle) (hr error) = cimfs.CimCreateImage2?
//sys CimCloseImage(cimFSHandle FsHandle) = cimfs.CimCloseImage
//sys CimCommitImage(cimFSHandle FsHandle) (hr error) = cimfs.CimCommitImage?

//sys CimCreateFile(cimFSHandle FsHandle, path string, file *CimFsFileMetadata, cimStreamHandle *StreamHandle) (hr error) = cimfs.CimCreateFile?
Expand All @@ -45,3 +51,6 @@ type CimFsFileMetadata struct {
//sys CimDeletePath(cimFSHandle FsHandle, path string) (hr error) = cimfs.CimDeletePath?
//sys CimCreateHardLink(cimFSHandle FsHandle, newPath string, oldPath string) (hr error) = cimfs.CimCreateHardLink?
//sys CimCreateAlternateStream(cimFSHandle FsHandle, path string, size uint64, cimStreamHandle *StreamHandle) (hr error) = cimfs.CimCreateAlternateStream?
//sys CimAddFsToMergedImage(cimFSHandle FsHandle, path string) (hr error) = cimfs.CimAddFsToMergedImage?
//sys CimAddFsToMergedImage2(cimFSHandle FsHandle, path string, flags uint32) (hr error) = cimfs.CimAddFsToMergedImage2?
//sys CimMergeMountImage(numCimPaths uint32, backingImagePaths *CimFsImagePath, flags uint32, volumeID *g) (hr error) = cimfs.CimMergeMountImage?
93 changes: 90 additions & 3 deletions internal/winapi/zsyscall_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 582e35c

Please sign in to comment.