Skip to content

Commit

Permalink
Block CIM types and new CimFS API wrappers
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 Go wrappers for the new CimFS APIs that allow creation, merging and
mounting of such Block CIMs. Some new flags required when creating and mounting these CIMs
are added and some deprecated flags have been removed. New type has been introduced to
represent a block CIM. Unit tests have been added to test the newly added CimFS
functionality. Lastly, CimFS flags aren't a part of the hcs schema (only the CimMount
request is), those flags are moved from the hcs/schema2 package to the cimfs package.

Signed-off-by: Amit Barve <[email protected]>
  • Loading branch information
ambarve committed Oct 14, 2024
1 parent b28bdd3 commit e222cc9
Show file tree
Hide file tree
Showing 8 changed files with 997 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@

package hcsschema

const (
CimMountFlagNone uint32 = 0x0
CimMountFlagChildOnly uint32 = 0x1
CimMountFlagEnableDax uint32 = 0x2
CimMountFlagCacheFiles uint32 = 0x4
CimMountFlagCacheRegions uint32 = 0x8
)

type CimMount struct {
ImagePath string `json:"ImagePath,omitempty"`
FileSystemName string `json:"FileSystemName,omitempty"`
Expand Down
13 changes: 12 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,8 @@ 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?
//sys CimTombstoneFile(cimFSHandle FsHandle, path string) (hr error) = cimfs.CimTombstoneFile?
//sys CimCreateMergeLink(cimFSHandle FsHandle, newPath string, oldPath string) (hr error) = cimfs.CimCreateMergeLink?
148 changes: 145 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 e222cc9

Please sign in to comment.