1
2
3
4
5 package computestorage
6
7 import (
8 "syscall"
9 "unsafe"
10
11 "golang.org/x/sys/windows"
12 )
13
14 var _ unsafe.Pointer
15
16
17
18 const (
19 errnoERROR_IO_PENDING = 997
20 )
21
22 var (
23 errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
24 errERROR_EINVAL error = syscall.EINVAL
25 )
26
27
28
29 func errnoErr(e syscall.Errno) error {
30 switch e {
31 case 0:
32 return errERROR_EINVAL
33 case errnoERROR_IO_PENDING:
34 return errERROR_IO_PENDING
35 }
36
37
38
39 return e
40 }
41
42 var (
43 modcomputestorage = windows.NewLazySystemDLL("computestorage.dll")
44
45 procHcsAttachLayerStorageFilter = modcomputestorage.NewProc("HcsAttachLayerStorageFilter")
46 procHcsDestoryLayer = modcomputestorage.NewProc("HcsDestoryLayer")
47 procHcsDetachLayerStorageFilter = modcomputestorage.NewProc("HcsDetachLayerStorageFilter")
48 procHcsExportLayer = modcomputestorage.NewProc("HcsExportLayer")
49 procHcsFormatWritableLayerVhd = modcomputestorage.NewProc("HcsFormatWritableLayerVhd")
50 procHcsGetLayerVhdMountPath = modcomputestorage.NewProc("HcsGetLayerVhdMountPath")
51 procHcsImportLayer = modcomputestorage.NewProc("HcsImportLayer")
52 procHcsInitializeWritableLayer = modcomputestorage.NewProc("HcsInitializeWritableLayer")
53 procHcsSetupBaseOSLayer = modcomputestorage.NewProc("HcsSetupBaseOSLayer")
54 procHcsSetupBaseOSVolume = modcomputestorage.NewProc("HcsSetupBaseOSVolume")
55 )
56
57 func hcsAttachLayerStorageFilter(layerPath string, layerData string) (hr error) {
58 var _p0 *uint16
59 _p0, hr = syscall.UTF16PtrFromString(layerPath)
60 if hr != nil {
61 return
62 }
63 var _p1 *uint16
64 _p1, hr = syscall.UTF16PtrFromString(layerData)
65 if hr != nil {
66 return
67 }
68 return _hcsAttachLayerStorageFilter(_p0, _p1)
69 }
70
71 func _hcsAttachLayerStorageFilter(layerPath *uint16, layerData *uint16) (hr error) {
72 hr = procHcsAttachLayerStorageFilter.Find()
73 if hr != nil {
74 return
75 }
76 r0, _, _ := syscall.Syscall(procHcsAttachLayerStorageFilter.Addr(), 2, uintptr(unsafe.Pointer(layerPath)), uintptr(unsafe.Pointer(layerData)), 0)
77 if int32(r0) < 0 {
78 if r0&0x1fff0000 == 0x00070000 {
79 r0 &= 0xffff
80 }
81 hr = syscall.Errno(r0)
82 }
83 return
84 }
85
86 func hcsDestroyLayer(layerPath string) (hr error) {
87 var _p0 *uint16
88 _p0, hr = syscall.UTF16PtrFromString(layerPath)
89 if hr != nil {
90 return
91 }
92 return _hcsDestroyLayer(_p0)
93 }
94
95 func _hcsDestroyLayer(layerPath *uint16) (hr error) {
96 hr = procHcsDestoryLayer.Find()
97 if hr != nil {
98 return
99 }
100 r0, _, _ := syscall.Syscall(procHcsDestoryLayer.Addr(), 1, uintptr(unsafe.Pointer(layerPath)), 0, 0)
101 if int32(r0) < 0 {
102 if r0&0x1fff0000 == 0x00070000 {
103 r0 &= 0xffff
104 }
105 hr = syscall.Errno(r0)
106 }
107 return
108 }
109
110 func hcsDetachLayerStorageFilter(layerPath string) (hr error) {
111 var _p0 *uint16
112 _p0, hr = syscall.UTF16PtrFromString(layerPath)
113 if hr != nil {
114 return
115 }
116 return _hcsDetachLayerStorageFilter(_p0)
117 }
118
119 func _hcsDetachLayerStorageFilter(layerPath *uint16) (hr error) {
120 hr = procHcsDetachLayerStorageFilter.Find()
121 if hr != nil {
122 return
123 }
124 r0, _, _ := syscall.Syscall(procHcsDetachLayerStorageFilter.Addr(), 1, uintptr(unsafe.Pointer(layerPath)), 0, 0)
125 if int32(r0) < 0 {
126 if r0&0x1fff0000 == 0x00070000 {
127 r0 &= 0xffff
128 }
129 hr = syscall.Errno(r0)
130 }
131 return
132 }
133
134 func hcsExportLayer(layerPath string, exportFolderPath string, layerData string, options string) (hr error) {
135 var _p0 *uint16
136 _p0, hr = syscall.UTF16PtrFromString(layerPath)
137 if hr != nil {
138 return
139 }
140 var _p1 *uint16
141 _p1, hr = syscall.UTF16PtrFromString(exportFolderPath)
142 if hr != nil {
143 return
144 }
145 var _p2 *uint16
146 _p2, hr = syscall.UTF16PtrFromString(layerData)
147 if hr != nil {
148 return
149 }
150 var _p3 *uint16
151 _p3, hr = syscall.UTF16PtrFromString(options)
152 if hr != nil {
153 return
154 }
155 return _hcsExportLayer(_p0, _p1, _p2, _p3)
156 }
157
158 func _hcsExportLayer(layerPath *uint16, exportFolderPath *uint16, layerData *uint16, options *uint16) (hr error) {
159 hr = procHcsExportLayer.Find()
160 if hr != nil {
161 return
162 }
163 r0, _, _ := syscall.Syscall6(procHcsExportLayer.Addr(), 4, uintptr(unsafe.Pointer(layerPath)), uintptr(unsafe.Pointer(exportFolderPath)), uintptr(unsafe.Pointer(layerData)), uintptr(unsafe.Pointer(options)), 0, 0)
164 if int32(r0) < 0 {
165 if r0&0x1fff0000 == 0x00070000 {
166 r0 &= 0xffff
167 }
168 hr = syscall.Errno(r0)
169 }
170 return
171 }
172
173 func hcsFormatWritableLayerVhd(handle windows.Handle) (hr error) {
174 hr = procHcsFormatWritableLayerVhd.Find()
175 if hr != nil {
176 return
177 }
178 r0, _, _ := syscall.Syscall(procHcsFormatWritableLayerVhd.Addr(), 1, uintptr(handle), 0, 0)
179 if int32(r0) < 0 {
180 if r0&0x1fff0000 == 0x00070000 {
181 r0 &= 0xffff
182 }
183 hr = syscall.Errno(r0)
184 }
185 return
186 }
187
188 func hcsGetLayerVhdMountPath(vhdHandle windows.Handle, mountPath **uint16) (hr error) {
189 hr = procHcsGetLayerVhdMountPath.Find()
190 if hr != nil {
191 return
192 }
193 r0, _, _ := syscall.Syscall(procHcsGetLayerVhdMountPath.Addr(), 2, uintptr(vhdHandle), uintptr(unsafe.Pointer(mountPath)), 0)
194 if int32(r0) < 0 {
195 if r0&0x1fff0000 == 0x00070000 {
196 r0 &= 0xffff
197 }
198 hr = syscall.Errno(r0)
199 }
200 return
201 }
202
203 func hcsImportLayer(layerPath string, sourceFolderPath string, layerData string) (hr error) {
204 var _p0 *uint16
205 _p0, hr = syscall.UTF16PtrFromString(layerPath)
206 if hr != nil {
207 return
208 }
209 var _p1 *uint16
210 _p1, hr = syscall.UTF16PtrFromString(sourceFolderPath)
211 if hr != nil {
212 return
213 }
214 var _p2 *uint16
215 _p2, hr = syscall.UTF16PtrFromString(layerData)
216 if hr != nil {
217 return
218 }
219 return _hcsImportLayer(_p0, _p1, _p2)
220 }
221
222 func _hcsImportLayer(layerPath *uint16, sourceFolderPath *uint16, layerData *uint16) (hr error) {
223 hr = procHcsImportLayer.Find()
224 if hr != nil {
225 return
226 }
227 r0, _, _ := syscall.Syscall(procHcsImportLayer.Addr(), 3, uintptr(unsafe.Pointer(layerPath)), uintptr(unsafe.Pointer(sourceFolderPath)), uintptr(unsafe.Pointer(layerData)))
228 if int32(r0) < 0 {
229 if r0&0x1fff0000 == 0x00070000 {
230 r0 &= 0xffff
231 }
232 hr = syscall.Errno(r0)
233 }
234 return
235 }
236
237 func hcsInitializeWritableLayer(writableLayerPath string, layerData string, options string) (hr error) {
238 var _p0 *uint16
239 _p0, hr = syscall.UTF16PtrFromString(writableLayerPath)
240 if hr != nil {
241 return
242 }
243 var _p1 *uint16
244 _p1, hr = syscall.UTF16PtrFromString(layerData)
245 if hr != nil {
246 return
247 }
248 var _p2 *uint16
249 _p2, hr = syscall.UTF16PtrFromString(options)
250 if hr != nil {
251 return
252 }
253 return _hcsInitializeWritableLayer(_p0, _p1, _p2)
254 }
255
256 func _hcsInitializeWritableLayer(writableLayerPath *uint16, layerData *uint16, options *uint16) (hr error) {
257 hr = procHcsInitializeWritableLayer.Find()
258 if hr != nil {
259 return
260 }
261 r0, _, _ := syscall.Syscall(procHcsInitializeWritableLayer.Addr(), 3, uintptr(unsafe.Pointer(writableLayerPath)), uintptr(unsafe.Pointer(layerData)), uintptr(unsafe.Pointer(options)))
262 if int32(r0) < 0 {
263 if r0&0x1fff0000 == 0x00070000 {
264 r0 &= 0xffff
265 }
266 hr = syscall.Errno(r0)
267 }
268 return
269 }
270
271 func hcsSetupBaseOSLayer(layerPath string, handle windows.Handle, options string) (hr error) {
272 var _p0 *uint16
273 _p0, hr = syscall.UTF16PtrFromString(layerPath)
274 if hr != nil {
275 return
276 }
277 var _p1 *uint16
278 _p1, hr = syscall.UTF16PtrFromString(options)
279 if hr != nil {
280 return
281 }
282 return _hcsSetupBaseOSLayer(_p0, handle, _p1)
283 }
284
285 func _hcsSetupBaseOSLayer(layerPath *uint16, handle windows.Handle, options *uint16) (hr error) {
286 hr = procHcsSetupBaseOSLayer.Find()
287 if hr != nil {
288 return
289 }
290 r0, _, _ := syscall.Syscall(procHcsSetupBaseOSLayer.Addr(), 3, uintptr(unsafe.Pointer(layerPath)), uintptr(handle), uintptr(unsafe.Pointer(options)))
291 if int32(r0) < 0 {
292 if r0&0x1fff0000 == 0x00070000 {
293 r0 &= 0xffff
294 }
295 hr = syscall.Errno(r0)
296 }
297 return
298 }
299
300 func hcsSetupBaseOSVolume(layerPath string, volumePath string, options string) (hr error) {
301 var _p0 *uint16
302 _p0, hr = syscall.UTF16PtrFromString(layerPath)
303 if hr != nil {
304 return
305 }
306 var _p1 *uint16
307 _p1, hr = syscall.UTF16PtrFromString(volumePath)
308 if hr != nil {
309 return
310 }
311 var _p2 *uint16
312 _p2, hr = syscall.UTF16PtrFromString(options)
313 if hr != nil {
314 return
315 }
316 return _hcsSetupBaseOSVolume(_p0, _p1, _p2)
317 }
318
319 func _hcsSetupBaseOSVolume(layerPath *uint16, volumePath *uint16, options *uint16) (hr error) {
320 hr = procHcsSetupBaseOSVolume.Find()
321 if hr != nil {
322 return
323 }
324 r0, _, _ := syscall.Syscall(procHcsSetupBaseOSVolume.Addr(), 3, uintptr(unsafe.Pointer(layerPath)), uintptr(unsafe.Pointer(volumePath)), uintptr(unsafe.Pointer(options)))
325 if int32(r0) < 0 {
326 if r0&0x1fff0000 == 0x00070000 {
327 r0 &= 0xffff
328 }
329 hr = syscall.Errno(r0)
330 }
331 return
332 }
333
View as plain text