|
3 | 3 | package winapi |
4 | 4 |
|
5 | 5 | import ( |
6 | | - "unsafe" |
7 | | - |
8 | 6 | "github.com/Microsoft/go-winio/pkg/guid" |
9 | | - "golang.org/x/sys/windows" |
| 7 | + |
| 8 | + "github.com/Microsoft/hcsshim/internal/winapi/cimfs" |
| 9 | + "github.com/Microsoft/hcsshim/internal/winapi/cimwriter" |
| 10 | + "github.com/Microsoft/hcsshim/internal/winapi/types" |
10 | 11 | ) |
11 | 12 |
|
12 | 13 | type g = guid.GUID |
13 | | -type FsHandle uintptr |
14 | | -type StreamHandle uintptr |
15 | | - |
16 | | -type CimFsFileMetadata struct { |
17 | | - Attributes uint32 |
18 | | - FileSize int64 |
19 | | - |
20 | | - CreationTime windows.Filetime |
21 | | - LastWriteTime windows.Filetime |
22 | | - ChangeTime windows.Filetime |
23 | | - LastAccessTime windows.Filetime |
24 | | - |
25 | | - SecurityDescriptorBuffer unsafe.Pointer |
26 | | - SecurityDescriptorSize uint32 |
27 | | - |
28 | | - ReparseDataBuffer unsafe.Pointer |
29 | | - ReparseDataSize uint32 |
30 | | - |
31 | | - ExtendedAttributes unsafe.Pointer |
32 | | - EACount uint32 |
33 | | -} |
34 | | - |
35 | | -type CimFsImagePath struct { |
36 | | - ImageDir *uint16 |
37 | | - ImageName *uint16 |
38 | | -} |
39 | | - |
40 | | -//sys CimMountImage(imagePath string, fsName string, flags uint32, volumeID *g) (hr error) = cimfs.CimMountImage? |
41 | | -//sys CimDismountImage(volumeID *g) (hr error) = cimfs.CimDismountImage? |
42 | | - |
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? |
56 | | -//sys CimMergeMountImage(numCimPaths uint32, backingImagePaths *CimFsImagePath, flags uint32, volumeID *g) (hr error) = cimfs.CimMergeMountImage? |
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? |
60 | | -//sys CimGetVerificationInformation(blockCimPath string, isSealed *uint32, hashSize *uint64, signatureSize *uint64, fixedHeaderSize *uint64, hash *byte, signature *byte) (hr error) = cimfs.CimGetVerificationInformation? |
61 | | -//sys CimMountVerifiedImage(imagePath string, fsName string, flags uint32, volumeID *g, hashSize uint16, hash *byte) (hr error) = cimfs.CimMountVerifiedImage? |
62 | | -//sys CimMergeMountVerifiedImage(numCimPaths uint32, backingImagePaths *CimFsImagePath, flags uint32, volumeID *g, hashSize uint16, hash *byte) (hr error) = cimfs.CimMergeMountVerifiedImage |
| 14 | + |
| 15 | +func CimMountImage(imagePath string, fsName string, flags uint32, volumeID *guid.GUID) error { |
| 16 | + return cimfs.CimMountImage(imagePath, fsName, flags, volumeID) |
| 17 | +} |
| 18 | + |
| 19 | +func CimDismountImage(volumeID *guid.GUID) error { |
| 20 | + return cimfs.CimDismountImage(volumeID) |
| 21 | +} |
| 22 | + |
| 23 | +func CimCreateImage(imagePath string, oldFSName *uint16, newFSName *uint16, cimFSHandle *types.FsHandle) error { |
| 24 | + if cimwriter.CimWriterSupported() { |
| 25 | + return cimwriter.CimCreateImage(imagePath, oldFSName, newFSName, cimFSHandle) |
| 26 | + } |
| 27 | + return cimfs.CimCreateImage(imagePath, oldFSName, newFSName, cimFSHandle) |
| 28 | +} |
| 29 | + |
| 30 | +func CimCreateImage2(imagePath string, flags uint32, oldFSName *uint16, newFSName *uint16, cimFSHandle *types.FsHandle) error { |
| 31 | + if cimwriter.CimWriterSupported() { |
| 32 | + return cimwriter.CimCreateImage2(imagePath, flags, oldFSName, newFSName, cimFSHandle) |
| 33 | + } |
| 34 | + return cimfs.CimCreateImage2(imagePath, flags, oldFSName, newFSName, cimFSHandle) |
| 35 | +} |
| 36 | + |
| 37 | +func CimCloseImage(cimFSHandle types.FsHandle) error { |
| 38 | + if cimwriter.CimWriterSupported() { |
| 39 | + return cimwriter.CimCloseImage(cimFSHandle) |
| 40 | + } |
| 41 | + return cimfs.CimCloseImage(cimFSHandle) |
| 42 | +} |
| 43 | + |
| 44 | +func CimCommitImage(cimFSHandle types.FsHandle) error { |
| 45 | + if cimwriter.CimWriterSupported() { |
| 46 | + return cimwriter.CimCommitImage(cimFSHandle) |
| 47 | + } |
| 48 | + return cimfs.CimCommitImage(cimFSHandle) |
| 49 | +} |
| 50 | + |
| 51 | +func CimCreateFile(cimFSHandle types.FsHandle, path string, file *types.CimFsFileMetadata, cimStreamHandle *types.StreamHandle) error { |
| 52 | + if cimwriter.CimWriterSupported() { |
| 53 | + return cimwriter.CimCreateFile(cimFSHandle, path, file, cimStreamHandle) |
| 54 | + } |
| 55 | + return cimfs.CimCreateFile(cimFSHandle, path, file, cimStreamHandle) |
| 56 | +} |
| 57 | + |
| 58 | +func CimCloseStream(cimStreamHandle types.StreamHandle) error { |
| 59 | + if cimwriter.CimWriterSupported() { |
| 60 | + return cimwriter.CimCloseStream(cimStreamHandle) |
| 61 | + } |
| 62 | + return cimfs.CimCloseStream(cimStreamHandle) |
| 63 | +} |
| 64 | + |
| 65 | +func CimWriteStream(cimStreamHandle types.StreamHandle, buffer uintptr, bufferSize uint32) error { |
| 66 | + if cimwriter.CimWriterSupported() { |
| 67 | + return cimwriter.CimWriteStream(cimStreamHandle, buffer, bufferSize) |
| 68 | + } |
| 69 | + return cimfs.CimWriteStream(cimStreamHandle, buffer, bufferSize) |
| 70 | +} |
| 71 | + |
| 72 | +func CimDeletePath(cimFSHandle types.FsHandle, path string) error { |
| 73 | + if cimwriter.CimWriterSupported() { |
| 74 | + return cimwriter.CimDeletePath(cimFSHandle, path) |
| 75 | + } |
| 76 | + return cimfs.CimDeletePath(cimFSHandle, path) |
| 77 | +} |
| 78 | + |
| 79 | +func CimCreateHardLink(cimFSHandle types.FsHandle, newPath string, oldPath string) error { |
| 80 | + if cimwriter.CimWriterSupported() { |
| 81 | + return cimwriter.CimCreateHardLink(cimFSHandle, newPath, oldPath) |
| 82 | + } |
| 83 | + return cimfs.CimCreateHardLink(cimFSHandle, newPath, oldPath) |
| 84 | +} |
| 85 | + |
| 86 | +func CimCreateAlternateStream(cimFSHandle types.FsHandle, path string, size uint64, cimStreamHandle *types.StreamHandle) error { |
| 87 | + if cimwriter.CimWriterSupported() { |
| 88 | + return cimwriter.CimCreateAlternateStream(cimFSHandle, path, size, cimStreamHandle) |
| 89 | + } |
| 90 | + return cimfs.CimCreateAlternateStream(cimFSHandle, path, size, cimStreamHandle) |
| 91 | +} |
| 92 | + |
| 93 | +func CimAddFsToMergedImage(cimFSHandle types.FsHandle, path string) error { |
| 94 | + if cimwriter.CimWriterSupported() { |
| 95 | + return cimwriter.CimAddFsToMergedImage(cimFSHandle, path) |
| 96 | + } |
| 97 | + return cimfs.CimAddFsToMergedImage(cimFSHandle, path) |
| 98 | +} |
| 99 | + |
| 100 | +func CimAddFsToMergedImage2(cimFSHandle types.FsHandle, path string, flags uint32) error { |
| 101 | + if cimwriter.CimWriterSupported() { |
| 102 | + return cimwriter.CimAddFsToMergedImage2(cimFSHandle, path, flags) |
| 103 | + } |
| 104 | + return cimfs.CimAddFsToMergedImage2(cimFSHandle, path, flags) |
| 105 | +} |
| 106 | + |
| 107 | +func CimMergeMountImage(numCimPaths uint32, backingImagePaths *types.CimFsImagePath, flags uint32, volumeID *guid.GUID) error { |
| 108 | + return cimfs.CimMergeMountImage(numCimPaths, backingImagePaths, flags, volumeID) |
| 109 | +} |
| 110 | + |
| 111 | +func CimTombstoneFile(cimFSHandle types.FsHandle, path string) error { |
| 112 | + if cimwriter.CimWriterSupported() { |
| 113 | + return cimwriter.CimTombstoneFile(cimFSHandle, path) |
| 114 | + } |
| 115 | + return cimfs.CimTombstoneFile(cimFSHandle, path) |
| 116 | +} |
| 117 | + |
| 118 | +func CimCreateMergeLink(cimFSHandle types.FsHandle, newPath string, oldPath string) (hr error) { |
| 119 | + if cimwriter.CimWriterSupported() { |
| 120 | + return cimwriter.CimCreateMergeLink(cimFSHandle, newPath, oldPath) |
| 121 | + } |
| 122 | + return cimfs.CimCreateMergeLink(cimFSHandle, newPath, oldPath) |
| 123 | +} |
| 124 | + |
| 125 | +func CimSealImage(blockCimPath string, hashSize *uint64, fixedHeaderSize *uint64, hash *byte) (hr error) { |
| 126 | + if cimwriter.CimWriterSupported() { |
| 127 | + return cimwriter.CimSealImage(blockCimPath, hashSize, fixedHeaderSize, hash) |
| 128 | + } |
| 129 | + return cimfs.CimSealImage(blockCimPath, hashSize, fixedHeaderSize, hash) |
| 130 | +} |
| 131 | + |
| 132 | +func CimGetVerificationInformation(blockCimPath string, isSealed *uint32, hashSize *uint64, signatureSize *uint64, fixedHeaderSize *uint64, hash *byte, signature *byte) (hr error) { |
| 133 | + return cimfs.CimGetVerificationInformation(blockCimPath, isSealed, hashSize, signatureSize, fixedHeaderSize, hash, signature) |
| 134 | +} |
| 135 | + |
| 136 | +func CimMountVerifiedImage(imagePath string, fsName string, flags uint32, volumeID *guid.GUID, hashSize uint16, hash *byte) error { |
| 137 | + return cimfs.CimMountVerifiedImage(imagePath, fsName, flags, volumeID, hashSize, hash) |
| 138 | +} |
| 139 | + |
| 140 | +func CimMergeMountVerifiedImage(numCimPaths uint32, backingImagePaths *types.CimFsImagePath, flags uint32, volumeID *guid.GUID, hashSize uint16, hash *byte) error { |
| 141 | + return cimfs.CimMergeMountVerifiedImage(numCimPaths, backingImagePaths, flags, volumeID, hashSize, hash) |
| 142 | +} |
0 commit comments