diff --git a/computestorage/storage.go b/computestorage/storage.go index d8b3d6a319..f2c391c483 100644 --- a/computestorage/storage.go +++ b/computestorage/storage.go @@ -7,7 +7,7 @@ import ( hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" ) -//go:generate go run ../mksyscall_windows.go -output zsyscall_windows.go storage.go +//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -sort=false -output zsyscall_windows.go storage.go //sys hcsImportLayer(layerPath string, sourceFolderPath string, layerData string) (hr error) = computestorage.HcsImportLayer? //sys hcsExportLayer(layerPath string, exportFolderPath string, layerData string, options string) (hr error) = computestorage.HcsExportLayer? diff --git a/computestorage/zsyscall_windows.go b/computestorage/zsyscall_windows.go index 4f95180674..39fec99ca6 100644 --- a/computestorage/zsyscall_windows.go +++ b/computestorage/zsyscall_windows.go @@ -1,4 +1,6 @@ -// Code generated mksyscall_windows.exe DO NOT EDIT +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package computestorage @@ -19,6 +21,7 @@ const ( var ( errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) + errERROR_EINVAL error = syscall.EINVAL ) // errnoErr returns common boxed Errno values, to prevent @@ -26,7 +29,7 @@ var ( func errnoErr(e syscall.Errno) error { switch e { case 0: - return nil + return errERROR_EINVAL case errnoERROR_IO_PENDING: return errERROR_IO_PENDING } @@ -71,7 +74,8 @@ func hcsImportLayer(layerPath string, sourceFolderPath string, layerData string) } func _hcsImportLayer(layerPath *uint16, sourceFolderPath *uint16, layerData *uint16) (hr error) { - if hr = procHcsImportLayer.Find(); hr != nil { + hr = procHcsImportLayer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsImportLayer.Addr(), 3, uintptr(unsafe.Pointer(layerPath)), uintptr(unsafe.Pointer(sourceFolderPath)), uintptr(unsafe.Pointer(layerData))) @@ -109,7 +113,8 @@ func hcsExportLayer(layerPath string, exportFolderPath string, layerData string, } func _hcsExportLayer(layerPath *uint16, exportFolderPath *uint16, layerData *uint16, options *uint16) (hr error) { - if hr = procHcsExportLayer.Find(); hr != nil { + hr = procHcsExportLayer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcsExportLayer.Addr(), 4, uintptr(unsafe.Pointer(layerPath)), uintptr(unsafe.Pointer(exportFolderPath)), uintptr(unsafe.Pointer(layerData)), uintptr(unsafe.Pointer(options)), 0, 0) @@ -132,7 +137,8 @@ func hcsDestroyLayer(layerPath string) (hr error) { } func _hcsDestroyLayer(layerPath *uint16) (hr error) { - if hr = procHcsDestoryLayer.Find(); hr != nil { + hr = procHcsDestoryLayer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsDestoryLayer.Addr(), 1, uintptr(unsafe.Pointer(layerPath)), 0, 0) @@ -160,7 +166,8 @@ func hcsSetupBaseOSLayer(layerPath string, handle windows.Handle, options string } func _hcsSetupBaseOSLayer(layerPath *uint16, handle windows.Handle, options *uint16) (hr error) { - if hr = procHcsSetupBaseOSLayer.Find(); hr != nil { + hr = procHcsSetupBaseOSLayer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsSetupBaseOSLayer.Addr(), 3, uintptr(unsafe.Pointer(layerPath)), uintptr(handle), uintptr(unsafe.Pointer(options))) @@ -193,7 +200,8 @@ func hcsInitializeWritableLayer(writableLayerPath string, layerData string, opti } func _hcsInitializeWritableLayer(writableLayerPath *uint16, layerData *uint16, options *uint16) (hr error) { - if hr = procHcsInitializeWritableLayer.Find(); hr != nil { + hr = procHcsInitializeWritableLayer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsInitializeWritableLayer.Addr(), 3, uintptr(unsafe.Pointer(writableLayerPath)), uintptr(unsafe.Pointer(layerData)), uintptr(unsafe.Pointer(options))) @@ -221,7 +229,8 @@ func hcsAttachLayerStorageFilter(layerPath string, layerData string) (hr error) } func _hcsAttachLayerStorageFilter(layerPath *uint16, layerData *uint16) (hr error) { - if hr = procHcsAttachLayerStorageFilter.Find(); hr != nil { + hr = procHcsAttachLayerStorageFilter.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsAttachLayerStorageFilter.Addr(), 2, uintptr(unsafe.Pointer(layerPath)), uintptr(unsafe.Pointer(layerData)), 0) @@ -244,7 +253,8 @@ func hcsDetachLayerStorageFilter(layerPath string) (hr error) { } func _hcsDetachLayerStorageFilter(layerPath *uint16) (hr error) { - if hr = procHcsDetachLayerStorageFilter.Find(); hr != nil { + hr = procHcsDetachLayerStorageFilter.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsDetachLayerStorageFilter.Addr(), 1, uintptr(unsafe.Pointer(layerPath)), 0, 0) @@ -258,7 +268,8 @@ func _hcsDetachLayerStorageFilter(layerPath *uint16) (hr error) { } func hcsFormatWritableLayerVhd(handle windows.Handle) (hr error) { - if hr = procHcsFormatWritableLayerVhd.Find(); hr != nil { + hr = procHcsFormatWritableLayerVhd.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsFormatWritableLayerVhd.Addr(), 1, uintptr(handle), 0, 0) @@ -272,7 +283,8 @@ func hcsFormatWritableLayerVhd(handle windows.Handle) (hr error) { } func hcsGetLayerVhdMountPath(vhdHandle windows.Handle, mountPath **uint16) (hr error) { - if hr = procHcsGetLayerVhdMountPath.Find(); hr != nil { + hr = procHcsGetLayerVhdMountPath.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsGetLayerVhdMountPath.Addr(), 2, uintptr(vhdHandle), uintptr(unsafe.Pointer(mountPath)), 0) @@ -305,7 +317,8 @@ func hcsSetupBaseOSVolume(layerPath string, volumePath string, options string) ( } func _hcsSetupBaseOSVolume(layerPath *uint16, volumePath *uint16, options *uint16) (hr error) { - if hr = procHcsSetupBaseOSVolume.Find(); hr != nil { + hr = procHcsSetupBaseOSVolume.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsSetupBaseOSVolume.Addr(), 3, uintptr(unsafe.Pointer(layerPath)), uintptr(unsafe.Pointer(volumePath)), uintptr(unsafe.Pointer(options))) diff --git a/go.mod b/go.mod index 34986a7e0c..71586c5760 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,8 @@ go 1.17 require ( github.com/BurntSushi/toml v0.3.1 - github.com/Microsoft/go-winio v0.5.2 + // temporary untill mkwinsyscall is part of a new go-winio release + github.com/Microsoft/go-winio v0.5.3-0.20220616180519-35837cff61c7 github.com/cenkalti/backoff/v4 v4.1.1 github.com/containerd/cgroups v1.0.3 github.com/containerd/console v1.0.2 @@ -17,6 +18,7 @@ require ( github.com/google/go-cmp v0.5.6 github.com/google/go-containerregistry v0.5.1 github.com/google/uuid v1.3.0 + github.com/josephspurrier/goversioninfo v1.4.0 github.com/linuxkit/virtsock v0.0.0-20201010232012-f8cee7dfc7a3 github.com/mattn/go-shellwords v1.0.6 github.com/opencontainers/runc v1.0.3 @@ -29,11 +31,12 @@ require ( go.etcd.io/bbolt v1.3.6 go.opencensus.io v0.22.3 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c - golang.org/x/sys v0.0.0-20220412211240-33da011f77ad + golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 google.golang.org/grpc v1.40.0 ) require ( + github.com/akavel/rsrc v0.10.2 // indirect github.com/containerd/fifo v1.0.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect diff --git a/go.sum b/go.sum index e8491dc2c6..d4f3e03d42 100644 --- a/go.sum +++ b/go.sum @@ -45,8 +45,8 @@ github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugX github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.4.17-0.20210324224401-5516f17a5958/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.4.17/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= -github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= +github.com/Microsoft/go-winio v0.5.3-0.20220616180519-35837cff61c7 h1:x5GlFkNiN34KDVE01MvMSzfXjtbBYXRNpqbI7usLtgo= +github.com/Microsoft/go-winio v0.5.3-0.20220616180519-35837cff61c7/go.mod h1:9ZRWkpdsaDaHBql4MK5YereVcy6vkcO0xVhq5B1THlk= github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= github.com/Microsoft/hcsshim v0.8.7-0.20190325164909-8abdbb8205e4/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= github.com/Microsoft/hcsshim v0.8.7/go.mod h1:OHd7sQqRFrYd3RmSgbgji+ctCwkbq2wbEYNSzOYtcBQ= @@ -64,6 +64,8 @@ github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbt github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= +github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw= +github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -406,6 +408,8 @@ github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/josephspurrier/goversioninfo v1.4.0 h1:Puhl12NSHUSALHSuzYwPYQkqa2E1+7SrtAPJorKK0C8= +github.com/josephspurrier/goversioninfo v1.4.0/go.mod h1:JWzv5rKQr+MmW+LvM412ToT/IkYDZjaclF2pKDss8IY= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -819,8 +823,9 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc= +golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/hcn/hcn.go b/hcn/hcn.go index 17539b8694..e180920c48 100644 --- a/hcn/hcn.go +++ b/hcn/hcn.go @@ -10,7 +10,7 @@ import ( "github.com/Microsoft/go-winio/pkg/guid" ) -//go:generate go run ../mksyscall_windows.go -output zsyscall_windows.go hcn.go +//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -sort=false -output zsyscall_windows.go hcn.go /// HNS V1 API diff --git a/hcn/zsyscall_windows.go b/hcn/zsyscall_windows.go index 7ec5b58b66..b44b3099e5 100644 --- a/hcn/zsyscall_windows.go +++ b/hcn/zsyscall_windows.go @@ -1,4 +1,6 @@ -// Code generated mksyscall_windows.exe DO NOT EDIT +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package hcn @@ -19,6 +21,7 @@ const ( var ( errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) + errERROR_EINVAL error = syscall.EINVAL ) // errnoErr returns common boxed Errno values, to prevent @@ -26,7 +29,7 @@ var ( func errnoErr(e syscall.Errno) error { switch e { case 0: - return nil + return errERROR_EINVAL case errnoERROR_IO_PENDING: return errERROR_IO_PENDING } @@ -111,7 +114,8 @@ func _hnsCall(method string, path string, object string, response **uint16) (hr } func __hnsCall(method *uint16, path *uint16, object *uint16, response **uint16) (hr error) { - if hr = procHNSCall.Find(); hr != nil { + hr = procHNSCall.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHNSCall.Addr(), 4, uintptr(unsafe.Pointer(method)), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(object)), uintptr(unsafe.Pointer(response)), 0, 0) @@ -134,7 +138,8 @@ func hcnEnumerateNetworks(query string, networks **uint16, result **uint16) (hr } func _hcnEnumerateNetworks(query *uint16, networks **uint16, result **uint16) (hr error) { - if hr = procHcnEnumerateNetworks.Find(); hr != nil { + hr = procHcnEnumerateNetworks.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnEnumerateNetworks.Addr(), 3, uintptr(unsafe.Pointer(query)), uintptr(unsafe.Pointer(networks)), uintptr(unsafe.Pointer(result))) @@ -157,7 +162,8 @@ func hcnCreateNetwork(id *_guid, settings string, network *hcnNetwork, result ** } func _hcnCreateNetwork(id *_guid, settings *uint16, network *hcnNetwork, result **uint16) (hr error) { - if hr = procHcnCreateNetwork.Find(); hr != nil { + hr = procHcnCreateNetwork.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcnCreateNetwork.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(network)), uintptr(unsafe.Pointer(result)), 0, 0) @@ -171,7 +177,8 @@ func _hcnCreateNetwork(id *_guid, settings *uint16, network *hcnNetwork, result } func hcnOpenNetwork(id *_guid, network *hcnNetwork, result **uint16) (hr error) { - if hr = procHcnOpenNetwork.Find(); hr != nil { + hr = procHcnOpenNetwork.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnOpenNetwork.Addr(), 3, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(network)), uintptr(unsafe.Pointer(result))) @@ -194,7 +201,8 @@ func hcnModifyNetwork(network hcnNetwork, settings string, result **uint16) (hr } func _hcnModifyNetwork(network hcnNetwork, settings *uint16, result **uint16) (hr error) { - if hr = procHcnModifyNetwork.Find(); hr != nil { + hr = procHcnModifyNetwork.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnModifyNetwork.Addr(), 3, uintptr(network), uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(result))) @@ -217,7 +225,8 @@ func hcnQueryNetworkProperties(network hcnNetwork, query string, properties **ui } func _hcnQueryNetworkProperties(network hcnNetwork, query *uint16, properties **uint16, result **uint16) (hr error) { - if hr = procHcnQueryNetworkProperties.Find(); hr != nil { + hr = procHcnQueryNetworkProperties.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcnQueryNetworkProperties.Addr(), 4, uintptr(network), uintptr(unsafe.Pointer(query)), uintptr(unsafe.Pointer(properties)), uintptr(unsafe.Pointer(result)), 0, 0) @@ -231,7 +240,8 @@ func _hcnQueryNetworkProperties(network hcnNetwork, query *uint16, properties ** } func hcnDeleteNetwork(id *_guid, result **uint16) (hr error) { - if hr = procHcnDeleteNetwork.Find(); hr != nil { + hr = procHcnDeleteNetwork.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnDeleteNetwork.Addr(), 2, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(result)), 0) @@ -245,7 +255,8 @@ func hcnDeleteNetwork(id *_guid, result **uint16) (hr error) { } func hcnCloseNetwork(network hcnNetwork) (hr error) { - if hr = procHcnCloseNetwork.Find(); hr != nil { + hr = procHcnCloseNetwork.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnCloseNetwork.Addr(), 1, uintptr(network), 0, 0) @@ -268,7 +279,8 @@ func hcnEnumerateEndpoints(query string, endpoints **uint16, result **uint16) (h } func _hcnEnumerateEndpoints(query *uint16, endpoints **uint16, result **uint16) (hr error) { - if hr = procHcnEnumerateEndpoints.Find(); hr != nil { + hr = procHcnEnumerateEndpoints.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnEnumerateEndpoints.Addr(), 3, uintptr(unsafe.Pointer(query)), uintptr(unsafe.Pointer(endpoints)), uintptr(unsafe.Pointer(result))) @@ -291,7 +303,8 @@ func hcnCreateEndpoint(network hcnNetwork, id *_guid, settings string, endpoint } func _hcnCreateEndpoint(network hcnNetwork, id *_guid, settings *uint16, endpoint *hcnEndpoint, result **uint16) (hr error) { - if hr = procHcnCreateEndpoint.Find(); hr != nil { + hr = procHcnCreateEndpoint.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcnCreateEndpoint.Addr(), 5, uintptr(network), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(endpoint)), uintptr(unsafe.Pointer(result)), 0) @@ -305,7 +318,8 @@ func _hcnCreateEndpoint(network hcnNetwork, id *_guid, settings *uint16, endpoin } func hcnOpenEndpoint(id *_guid, endpoint *hcnEndpoint, result **uint16) (hr error) { - if hr = procHcnOpenEndpoint.Find(); hr != nil { + hr = procHcnOpenEndpoint.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnOpenEndpoint.Addr(), 3, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(endpoint)), uintptr(unsafe.Pointer(result))) @@ -328,7 +342,8 @@ func hcnModifyEndpoint(endpoint hcnEndpoint, settings string, result **uint16) ( } func _hcnModifyEndpoint(endpoint hcnEndpoint, settings *uint16, result **uint16) (hr error) { - if hr = procHcnModifyEndpoint.Find(); hr != nil { + hr = procHcnModifyEndpoint.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnModifyEndpoint.Addr(), 3, uintptr(endpoint), uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(result))) @@ -351,7 +366,8 @@ func hcnQueryEndpointProperties(endpoint hcnEndpoint, query string, properties * } func _hcnQueryEndpointProperties(endpoint hcnEndpoint, query *uint16, properties **uint16, result **uint16) (hr error) { - if hr = procHcnQueryEndpointProperties.Find(); hr != nil { + hr = procHcnQueryEndpointProperties.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcnQueryEndpointProperties.Addr(), 4, uintptr(endpoint), uintptr(unsafe.Pointer(query)), uintptr(unsafe.Pointer(properties)), uintptr(unsafe.Pointer(result)), 0, 0) @@ -365,7 +381,8 @@ func _hcnQueryEndpointProperties(endpoint hcnEndpoint, query *uint16, properties } func hcnDeleteEndpoint(id *_guid, result **uint16) (hr error) { - if hr = procHcnDeleteEndpoint.Find(); hr != nil { + hr = procHcnDeleteEndpoint.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnDeleteEndpoint.Addr(), 2, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(result)), 0) @@ -379,7 +396,8 @@ func hcnDeleteEndpoint(id *_guid, result **uint16) (hr error) { } func hcnCloseEndpoint(endpoint hcnEndpoint) (hr error) { - if hr = procHcnCloseEndpoint.Find(); hr != nil { + hr = procHcnCloseEndpoint.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnCloseEndpoint.Addr(), 1, uintptr(endpoint), 0, 0) @@ -402,7 +420,8 @@ func hcnEnumerateNamespaces(query string, namespaces **uint16, result **uint16) } func _hcnEnumerateNamespaces(query *uint16, namespaces **uint16, result **uint16) (hr error) { - if hr = procHcnEnumerateNamespaces.Find(); hr != nil { + hr = procHcnEnumerateNamespaces.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnEnumerateNamespaces.Addr(), 3, uintptr(unsafe.Pointer(query)), uintptr(unsafe.Pointer(namespaces)), uintptr(unsafe.Pointer(result))) @@ -425,7 +444,8 @@ func hcnCreateNamespace(id *_guid, settings string, namespace *hcnNamespace, res } func _hcnCreateNamespace(id *_guid, settings *uint16, namespace *hcnNamespace, result **uint16) (hr error) { - if hr = procHcnCreateNamespace.Find(); hr != nil { + hr = procHcnCreateNamespace.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcnCreateNamespace.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(namespace)), uintptr(unsafe.Pointer(result)), 0, 0) @@ -439,7 +459,8 @@ func _hcnCreateNamespace(id *_guid, settings *uint16, namespace *hcnNamespace, r } func hcnOpenNamespace(id *_guid, namespace *hcnNamespace, result **uint16) (hr error) { - if hr = procHcnOpenNamespace.Find(); hr != nil { + hr = procHcnOpenNamespace.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnOpenNamespace.Addr(), 3, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(namespace)), uintptr(unsafe.Pointer(result))) @@ -462,7 +483,8 @@ func hcnModifyNamespace(namespace hcnNamespace, settings string, result **uint16 } func _hcnModifyNamespace(namespace hcnNamespace, settings *uint16, result **uint16) (hr error) { - if hr = procHcnModifyNamespace.Find(); hr != nil { + hr = procHcnModifyNamespace.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnModifyNamespace.Addr(), 3, uintptr(namespace), uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(result))) @@ -485,7 +507,8 @@ func hcnQueryNamespaceProperties(namespace hcnNamespace, query string, propertie } func _hcnQueryNamespaceProperties(namespace hcnNamespace, query *uint16, properties **uint16, result **uint16) (hr error) { - if hr = procHcnQueryNamespaceProperties.Find(); hr != nil { + hr = procHcnQueryNamespaceProperties.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcnQueryNamespaceProperties.Addr(), 4, uintptr(namespace), uintptr(unsafe.Pointer(query)), uintptr(unsafe.Pointer(properties)), uintptr(unsafe.Pointer(result)), 0, 0) @@ -499,7 +522,8 @@ func _hcnQueryNamespaceProperties(namespace hcnNamespace, query *uint16, propert } func hcnDeleteNamespace(id *_guid, result **uint16) (hr error) { - if hr = procHcnDeleteNamespace.Find(); hr != nil { + hr = procHcnDeleteNamespace.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnDeleteNamespace.Addr(), 2, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(result)), 0) @@ -513,7 +537,8 @@ func hcnDeleteNamespace(id *_guid, result **uint16) (hr error) { } func hcnCloseNamespace(namespace hcnNamespace) (hr error) { - if hr = procHcnCloseNamespace.Find(); hr != nil { + hr = procHcnCloseNamespace.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnCloseNamespace.Addr(), 1, uintptr(namespace), 0, 0) @@ -536,7 +561,8 @@ func hcnEnumerateLoadBalancers(query string, loadBalancers **uint16, result **ui } func _hcnEnumerateLoadBalancers(query *uint16, loadBalancers **uint16, result **uint16) (hr error) { - if hr = procHcnEnumerateLoadBalancers.Find(); hr != nil { + hr = procHcnEnumerateLoadBalancers.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnEnumerateLoadBalancers.Addr(), 3, uintptr(unsafe.Pointer(query)), uintptr(unsafe.Pointer(loadBalancers)), uintptr(unsafe.Pointer(result))) @@ -559,7 +585,8 @@ func hcnCreateLoadBalancer(id *_guid, settings string, loadBalancer *hcnLoadBala } func _hcnCreateLoadBalancer(id *_guid, settings *uint16, loadBalancer *hcnLoadBalancer, result **uint16) (hr error) { - if hr = procHcnCreateLoadBalancer.Find(); hr != nil { + hr = procHcnCreateLoadBalancer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcnCreateLoadBalancer.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(loadBalancer)), uintptr(unsafe.Pointer(result)), 0, 0) @@ -573,7 +600,8 @@ func _hcnCreateLoadBalancer(id *_guid, settings *uint16, loadBalancer *hcnLoadBa } func hcnOpenLoadBalancer(id *_guid, loadBalancer *hcnLoadBalancer, result **uint16) (hr error) { - if hr = procHcnOpenLoadBalancer.Find(); hr != nil { + hr = procHcnOpenLoadBalancer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnOpenLoadBalancer.Addr(), 3, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(loadBalancer)), uintptr(unsafe.Pointer(result))) @@ -596,7 +624,8 @@ func hcnModifyLoadBalancer(loadBalancer hcnLoadBalancer, settings string, result } func _hcnModifyLoadBalancer(loadBalancer hcnLoadBalancer, settings *uint16, result **uint16) (hr error) { - if hr = procHcnModifyLoadBalancer.Find(); hr != nil { + hr = procHcnModifyLoadBalancer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnModifyLoadBalancer.Addr(), 3, uintptr(loadBalancer), uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(result))) @@ -619,7 +648,8 @@ func hcnQueryLoadBalancerProperties(loadBalancer hcnLoadBalancer, query string, } func _hcnQueryLoadBalancerProperties(loadBalancer hcnLoadBalancer, query *uint16, properties **uint16, result **uint16) (hr error) { - if hr = procHcnQueryLoadBalancerProperties.Find(); hr != nil { + hr = procHcnQueryLoadBalancerProperties.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcnQueryLoadBalancerProperties.Addr(), 4, uintptr(loadBalancer), uintptr(unsafe.Pointer(query)), uintptr(unsafe.Pointer(properties)), uintptr(unsafe.Pointer(result)), 0, 0) @@ -633,7 +663,8 @@ func _hcnQueryLoadBalancerProperties(loadBalancer hcnLoadBalancer, query *uint16 } func hcnDeleteLoadBalancer(id *_guid, result **uint16) (hr error) { - if hr = procHcnDeleteLoadBalancer.Find(); hr != nil { + hr = procHcnDeleteLoadBalancer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnDeleteLoadBalancer.Addr(), 2, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(result)), 0) @@ -647,7 +678,8 @@ func hcnDeleteLoadBalancer(id *_guid, result **uint16) (hr error) { } func hcnCloseLoadBalancer(loadBalancer hcnLoadBalancer) (hr error) { - if hr = procHcnCloseLoadBalancer.Find(); hr != nil { + hr = procHcnCloseLoadBalancer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnCloseLoadBalancer.Addr(), 1, uintptr(loadBalancer), 0, 0) @@ -670,7 +702,8 @@ func hcnEnumerateRoutes(query string, routes **uint16, result **uint16) (hr erro } func _hcnEnumerateRoutes(query *uint16, routes **uint16, result **uint16) (hr error) { - if hr = procHcnEnumerateSdnRoutes.Find(); hr != nil { + hr = procHcnEnumerateSdnRoutes.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnEnumerateSdnRoutes.Addr(), 3, uintptr(unsafe.Pointer(query)), uintptr(unsafe.Pointer(routes)), uintptr(unsafe.Pointer(result))) @@ -693,7 +726,8 @@ func hcnCreateRoute(id *_guid, settings string, route *hcnRoute, result **uint16 } func _hcnCreateRoute(id *_guid, settings *uint16, route *hcnRoute, result **uint16) (hr error) { - if hr = procHcnCreateSdnRoute.Find(); hr != nil { + hr = procHcnCreateSdnRoute.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcnCreateSdnRoute.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(route)), uintptr(unsafe.Pointer(result)), 0, 0) @@ -707,7 +741,8 @@ func _hcnCreateRoute(id *_guid, settings *uint16, route *hcnRoute, result **uint } func hcnOpenRoute(id *_guid, route *hcnRoute, result **uint16) (hr error) { - if hr = procHcnOpenSdnRoute.Find(); hr != nil { + hr = procHcnOpenSdnRoute.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnOpenSdnRoute.Addr(), 3, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(route)), uintptr(unsafe.Pointer(result))) @@ -730,7 +765,8 @@ func hcnModifyRoute(route hcnRoute, settings string, result **uint16) (hr error) } func _hcnModifyRoute(route hcnRoute, settings *uint16, result **uint16) (hr error) { - if hr = procHcnModifySdnRoute.Find(); hr != nil { + hr = procHcnModifySdnRoute.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnModifySdnRoute.Addr(), 3, uintptr(route), uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(result))) @@ -753,7 +789,8 @@ func hcnQueryRouteProperties(route hcnRoute, query string, properties **uint16, } func _hcnQueryRouteProperties(route hcnRoute, query *uint16, properties **uint16, result **uint16) (hr error) { - if hr = procHcnQuerySdnRouteProperties.Find(); hr != nil { + hr = procHcnQuerySdnRouteProperties.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcnQuerySdnRouteProperties.Addr(), 4, uintptr(route), uintptr(unsafe.Pointer(query)), uintptr(unsafe.Pointer(properties)), uintptr(unsafe.Pointer(result)), 0, 0) @@ -767,7 +804,8 @@ func _hcnQueryRouteProperties(route hcnRoute, query *uint16, properties **uint16 } func hcnDeleteRoute(id *_guid, result **uint16) (hr error) { - if hr = procHcnDeleteSdnRoute.Find(); hr != nil { + hr = procHcnDeleteSdnRoute.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnDeleteSdnRoute.Addr(), 2, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(result)), 0) @@ -781,7 +819,8 @@ func hcnDeleteRoute(id *_guid, result **uint16) (hr error) { } func hcnCloseRoute(route hcnRoute) (hr error) { - if hr = procHcnCloseSdnRoute.Find(); hr != nil { + hr = procHcnCloseSdnRoute.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcnCloseSdnRoute.Addr(), 1, uintptr(route), 0, 0) diff --git a/hcsshim.go b/hcsshim.go index 95dc2a0255..46a66cd2ec 100644 --- a/hcsshim.go +++ b/hcsshim.go @@ -11,7 +11,7 @@ import ( "github.com/Microsoft/hcsshim/internal/hcserror" ) -//go:generate go run mksyscall_windows.go -output zsyscall_windows.go hcsshim.go +//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -sort=false -output zsyscall_windows.go hcsshim.go //sys SetCurrentThreadCompartmentId(compartmentId uint32) (hr error) = iphlpapi.SetCurrentThreadCompartmentId diff --git a/internal/hns/hns.go b/internal/hns/hns.go index b2e475f53c..fe557e3b97 100644 --- a/internal/hns/hns.go +++ b/internal/hns/hns.go @@ -2,7 +2,7 @@ package hns import "fmt" -//go:generate go run ../../mksyscall_windows.go -output zsyscall_windows.go hns.go +//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -sort=false -output zsyscall_windows.go hns.go //sys _hnsCall(method string, path string, object string, response **uint16) (hr error) = vmcompute.HNSCall? diff --git a/internal/hns/zsyscall_windows.go b/internal/hns/zsyscall_windows.go index 204633a488..a35ee945db 100644 --- a/internal/hns/zsyscall_windows.go +++ b/internal/hns/zsyscall_windows.go @@ -1,4 +1,6 @@ -// Code generated mksyscall_windows.exe DO NOT EDIT +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package hns @@ -19,6 +21,7 @@ const ( var ( errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) + errERROR_EINVAL error = syscall.EINVAL ) // errnoErr returns common boxed Errno values, to prevent @@ -26,7 +29,7 @@ var ( func errnoErr(e syscall.Errno) error { switch e { case 0: - return nil + return errERROR_EINVAL case errnoERROR_IO_PENDING: return errERROR_IO_PENDING } @@ -62,7 +65,8 @@ func _hnsCall(method string, path string, object string, response **uint16) (hr } func __hnsCall(method *uint16, path *uint16, object *uint16, response **uint16) (hr error) { - if hr = procHNSCall.Find(); hr != nil { + hr = procHNSCall.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHNSCall.Addr(), 4, uintptr(unsafe.Pointer(method)), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(object)), uintptr(unsafe.Pointer(response)), 0, 0) diff --git a/internal/interop/interop.go b/internal/interop/interop.go index 137dc3990a..fda8b01d4b 100644 --- a/internal/interop/interop.go +++ b/internal/interop/interop.go @@ -7,7 +7,7 @@ import ( "unsafe" ) -//go:generate go run ../../mksyscall_windows.go -output zsyscall_windows.go interop.go +//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -sort=false -output zsyscall_windows.go interop.go //sys coTaskMemFree(buffer unsafe.Pointer) = api_ms_win_core_com_l1_1_0.CoTaskMemFree diff --git a/internal/interop/zsyscall_windows.go b/internal/interop/zsyscall_windows.go index 12b0c71c5a..a17a112508 100644 --- a/internal/interop/zsyscall_windows.go +++ b/internal/interop/zsyscall_windows.go @@ -1,4 +1,6 @@ -// Code generated mksyscall_windows.exe DO NOT EDIT +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package interop @@ -19,6 +21,7 @@ const ( var ( errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) + errERROR_EINVAL error = syscall.EINVAL ) // errnoErr returns common boxed Errno values, to prevent @@ -26,7 +29,7 @@ var ( func errnoErr(e syscall.Errno) error { switch e { case 0: - return nil + return errERROR_EINVAL case errnoERROR_IO_PENDING: return errERROR_IO_PENDING } diff --git a/internal/regstate/regstate.go b/internal/regstate/regstate.go index 184975add8..a56be7b265 100644 --- a/internal/regstate/regstate.go +++ b/internal/regstate/regstate.go @@ -15,7 +15,7 @@ import ( "golang.org/x/sys/windows/registry" ) -//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go regstate.go +//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -output zsyscall_windows.go regstate.go //sys regCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *uint16, options uint32, desired uint32, sa *syscall.SecurityAttributes, result *syscall.Handle, disposition *uint32) (regerrno error) = advapi32.RegCreateKeyExW diff --git a/internal/regstate/zsyscall_windows.go b/internal/regstate/zsyscall_windows.go index 4e349ad498..4ff1b333a5 100644 --- a/internal/regstate/zsyscall_windows.go +++ b/internal/regstate/zsyscall_windows.go @@ -1,4 +1,6 @@ -// Code generated by 'go generate'; DO NOT EDIT. +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package regstate @@ -19,6 +21,7 @@ const ( var ( errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) + errERROR_EINVAL error = syscall.EINVAL ) // errnoErr returns common boxed Errno values, to prevent @@ -26,7 +29,7 @@ var ( func errnoErr(e syscall.Errno) error { switch e { case 0: - return nil + return errERROR_EINVAL case errnoERROR_IO_PENDING: return errERROR_IO_PENDING } diff --git a/internal/security/syscall_windows.go b/internal/security/syscall_windows.go index f0cdd7d20c..71326e4e46 100644 --- a/internal/security/syscall_windows.go +++ b/internal/security/syscall_windows.go @@ -1,6 +1,6 @@ package security -//go:generate go run $GOPATH/src/golang.org/x/sys/windows/mkwinsyscall/mkwinsyscall.go -output zsyscall_windows.go syscall_windows.go +//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -output zsyscall_windows.go syscall_windows.go //sys getSecurityInfo(handle syscall.Handle, objectType uint32, si uint32, ppsidOwner **uintptr, ppsidGroup **uintptr, ppDacl *uintptr, ppSacl *uintptr, ppSecurityDescriptor *uintptr) (win32err error) = advapi32.GetSecurityInfo //sys setSecurityInfo(handle syscall.Handle, objectType uint32, si uint32, psidOwner uintptr, psidGroup uintptr, pDacl uintptr, pSacl uintptr) (win32err error) = advapi32.SetSecurityInfo diff --git a/internal/security/zsyscall_windows.go b/internal/security/zsyscall_windows.go index 4084680e0f..26c986b88f 100644 --- a/internal/security/zsyscall_windows.go +++ b/internal/security/zsyscall_windows.go @@ -1,4 +1,6 @@ -// Code generated by 'go generate'; DO NOT EDIT. +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package security diff --git a/internal/vmcompute/vmcompute.go b/internal/vmcompute/vmcompute.go index 3622f3bbee..08e6ec227a 100644 --- a/internal/vmcompute/vmcompute.go +++ b/internal/vmcompute/vmcompute.go @@ -16,7 +16,7 @@ import ( "github.com/Microsoft/hcsshim/internal/timeout" ) -//go:generate go run ../../mksyscall_windows.go -output zsyscall_windows.go vmcompute.go +//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -sort=false -output zsyscall_windows.go vmcompute.go //sys hcsEnumerateComputeSystems(query string, computeSystems **uint16, result **uint16) (hr error) = vmcompute.HcsEnumerateComputeSystems? //sys hcsCreateComputeSystem(id string, configuration string, identity syscall.Handle, computeSystem *HcsSystem, result **uint16) (hr error) = vmcompute.HcsCreateComputeSystem? diff --git a/internal/vmcompute/zsyscall_windows.go b/internal/vmcompute/zsyscall_windows.go index cae55058de..ecd47f2e49 100644 --- a/internal/vmcompute/zsyscall_windows.go +++ b/internal/vmcompute/zsyscall_windows.go @@ -1,4 +1,6 @@ -// Code generated mksyscall_windows.exe DO NOT EDIT +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package vmcompute @@ -19,6 +21,7 @@ const ( var ( errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) + errERROR_EINVAL error = syscall.EINVAL ) // errnoErr returns common boxed Errno values, to prevent @@ -26,7 +29,7 @@ var ( func errnoErr(e syscall.Errno) error { switch e { case 0: - return nil + return errERROR_EINVAL case errnoERROR_IO_PENDING: return errERROR_IO_PENDING } @@ -77,7 +80,8 @@ func hcsEnumerateComputeSystems(query string, computeSystems **uint16, result ** } func _hcsEnumerateComputeSystems(query *uint16, computeSystems **uint16, result **uint16) (hr error) { - if hr = procHcsEnumerateComputeSystems.Find(); hr != nil { + hr = procHcsEnumerateComputeSystems.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsEnumerateComputeSystems.Addr(), 3, uintptr(unsafe.Pointer(query)), uintptr(unsafe.Pointer(computeSystems)), uintptr(unsafe.Pointer(result))) @@ -105,7 +109,8 @@ func hcsCreateComputeSystem(id string, configuration string, identity syscall.Ha } func _hcsCreateComputeSystem(id *uint16, configuration *uint16, identity syscall.Handle, computeSystem *HcsSystem, result **uint16) (hr error) { - if hr = procHcsCreateComputeSystem.Find(); hr != nil { + hr = procHcsCreateComputeSystem.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcsCreateComputeSystem.Addr(), 5, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(configuration)), uintptr(identity), uintptr(unsafe.Pointer(computeSystem)), uintptr(unsafe.Pointer(result)), 0) @@ -128,7 +133,8 @@ func hcsOpenComputeSystem(id string, computeSystem *HcsSystem, result **uint16) } func _hcsOpenComputeSystem(id *uint16, computeSystem *HcsSystem, result **uint16) (hr error) { - if hr = procHcsOpenComputeSystem.Find(); hr != nil { + hr = procHcsOpenComputeSystem.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsOpenComputeSystem.Addr(), 3, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(computeSystem)), uintptr(unsafe.Pointer(result))) @@ -142,7 +148,8 @@ func _hcsOpenComputeSystem(id *uint16, computeSystem *HcsSystem, result **uint16 } func hcsCloseComputeSystem(computeSystem HcsSystem) (hr error) { - if hr = procHcsCloseComputeSystem.Find(); hr != nil { + hr = procHcsCloseComputeSystem.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsCloseComputeSystem.Addr(), 1, uintptr(computeSystem), 0, 0) @@ -165,7 +172,8 @@ func hcsStartComputeSystem(computeSystem HcsSystem, options string, result **uin } func _hcsStartComputeSystem(computeSystem HcsSystem, options *uint16, result **uint16) (hr error) { - if hr = procHcsStartComputeSystem.Find(); hr != nil { + hr = procHcsStartComputeSystem.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsStartComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result))) @@ -188,7 +196,8 @@ func hcsShutdownComputeSystem(computeSystem HcsSystem, options string, result ** } func _hcsShutdownComputeSystem(computeSystem HcsSystem, options *uint16, result **uint16) (hr error) { - if hr = procHcsShutdownComputeSystem.Find(); hr != nil { + hr = procHcsShutdownComputeSystem.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsShutdownComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result))) @@ -211,7 +220,8 @@ func hcsTerminateComputeSystem(computeSystem HcsSystem, options string, result * } func _hcsTerminateComputeSystem(computeSystem HcsSystem, options *uint16, result **uint16) (hr error) { - if hr = procHcsTerminateComputeSystem.Find(); hr != nil { + hr = procHcsTerminateComputeSystem.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsTerminateComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result))) @@ -234,7 +244,8 @@ func hcsPauseComputeSystem(computeSystem HcsSystem, options string, result **uin } func _hcsPauseComputeSystem(computeSystem HcsSystem, options *uint16, result **uint16) (hr error) { - if hr = procHcsPauseComputeSystem.Find(); hr != nil { + hr = procHcsPauseComputeSystem.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsPauseComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result))) @@ -257,7 +268,8 @@ func hcsResumeComputeSystem(computeSystem HcsSystem, options string, result **ui } func _hcsResumeComputeSystem(computeSystem HcsSystem, options *uint16, result **uint16) (hr error) { - if hr = procHcsResumeComputeSystem.Find(); hr != nil { + hr = procHcsResumeComputeSystem.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsResumeComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result))) @@ -280,7 +292,8 @@ func hcsGetComputeSystemProperties(computeSystem HcsSystem, propertyQuery string } func _hcsGetComputeSystemProperties(computeSystem HcsSystem, propertyQuery *uint16, properties **uint16, result **uint16) (hr error) { - if hr = procHcsGetComputeSystemProperties.Find(); hr != nil { + hr = procHcsGetComputeSystemProperties.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcsGetComputeSystemProperties.Addr(), 4, uintptr(computeSystem), uintptr(unsafe.Pointer(propertyQuery)), uintptr(unsafe.Pointer(properties)), uintptr(unsafe.Pointer(result)), 0, 0) @@ -303,7 +316,8 @@ func hcsModifyComputeSystem(computeSystem HcsSystem, configuration string, resul } func _hcsModifyComputeSystem(computeSystem HcsSystem, configuration *uint16, result **uint16) (hr error) { - if hr = procHcsModifyComputeSystem.Find(); hr != nil { + hr = procHcsModifyComputeSystem.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsModifyComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(configuration)), uintptr(unsafe.Pointer(result))) @@ -326,7 +340,8 @@ func hcsModifyServiceSettings(settings string, result **uint16) (hr error) { } func _hcsModifyServiceSettings(settings *uint16, result **uint16) (hr error) { - if hr = procHcsModifyServiceSettings.Find(); hr != nil { + hr = procHcsModifyServiceSettings.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsModifyServiceSettings.Addr(), 2, uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(result)), 0) @@ -340,7 +355,8 @@ func _hcsModifyServiceSettings(settings *uint16, result **uint16) (hr error) { } func hcsRegisterComputeSystemCallback(computeSystem HcsSystem, callback uintptr, context uintptr, callbackHandle *HcsCallback) (hr error) { - if hr = procHcsRegisterComputeSystemCallback.Find(); hr != nil { + hr = procHcsRegisterComputeSystemCallback.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcsRegisterComputeSystemCallback.Addr(), 4, uintptr(computeSystem), uintptr(callback), uintptr(context), uintptr(unsafe.Pointer(callbackHandle)), 0, 0) @@ -354,7 +370,8 @@ func hcsRegisterComputeSystemCallback(computeSystem HcsSystem, callback uintptr, } func hcsUnregisterComputeSystemCallback(callbackHandle HcsCallback) (hr error) { - if hr = procHcsUnregisterComputeSystemCallback.Find(); hr != nil { + hr = procHcsUnregisterComputeSystemCallback.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsUnregisterComputeSystemCallback.Addr(), 1, uintptr(callbackHandle), 0, 0) @@ -377,7 +394,8 @@ func hcsSaveComputeSystem(computeSystem HcsSystem, options string, result **uint } func _hcsSaveComputeSystem(computeSystem HcsSystem, options *uint16, result **uint16) (hr error) { - if hr = procHcsSaveComputeSystem.Find(); hr != nil { + hr = procHcsSaveComputeSystem.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsSaveComputeSystem.Addr(), 3, uintptr(computeSystem), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result))) @@ -400,7 +418,8 @@ func hcsCreateProcess(computeSystem HcsSystem, processParameters string, process } func _hcsCreateProcess(computeSystem HcsSystem, processParameters *uint16, processInformation *HcsProcessInformation, process *HcsProcess, result **uint16) (hr error) { - if hr = procHcsCreateProcess.Find(); hr != nil { + hr = procHcsCreateProcess.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcsCreateProcess.Addr(), 5, uintptr(computeSystem), uintptr(unsafe.Pointer(processParameters)), uintptr(unsafe.Pointer(processInformation)), uintptr(unsafe.Pointer(process)), uintptr(unsafe.Pointer(result)), 0) @@ -414,7 +433,8 @@ func _hcsCreateProcess(computeSystem HcsSystem, processParameters *uint16, proce } func hcsOpenProcess(computeSystem HcsSystem, pid uint32, process *HcsProcess, result **uint16) (hr error) { - if hr = procHcsOpenProcess.Find(); hr != nil { + hr = procHcsOpenProcess.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcsOpenProcess.Addr(), 4, uintptr(computeSystem), uintptr(pid), uintptr(unsafe.Pointer(process)), uintptr(unsafe.Pointer(result)), 0, 0) @@ -428,7 +448,8 @@ func hcsOpenProcess(computeSystem HcsSystem, pid uint32, process *HcsProcess, re } func hcsCloseProcess(process HcsProcess) (hr error) { - if hr = procHcsCloseProcess.Find(); hr != nil { + hr = procHcsCloseProcess.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsCloseProcess.Addr(), 1, uintptr(process), 0, 0) @@ -442,7 +463,8 @@ func hcsCloseProcess(process HcsProcess) (hr error) { } func hcsTerminateProcess(process HcsProcess, result **uint16) (hr error) { - if hr = procHcsTerminateProcess.Find(); hr != nil { + hr = procHcsTerminateProcess.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsTerminateProcess.Addr(), 2, uintptr(process), uintptr(unsafe.Pointer(result)), 0) @@ -465,7 +487,8 @@ func hcsSignalProcess(process HcsProcess, options string, result **uint16) (hr e } func _hcsSignalProcess(process HcsProcess, options *uint16, result **uint16) (hr error) { - if hr = procHcsSignalProcess.Find(); hr != nil { + hr = procHcsSignalProcess.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsSignalProcess.Addr(), 3, uintptr(process), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(result))) @@ -479,7 +502,8 @@ func _hcsSignalProcess(process HcsProcess, options *uint16, result **uint16) (hr } func hcsGetProcessInfo(process HcsProcess, processInformation *HcsProcessInformation, result **uint16) (hr error) { - if hr = procHcsGetProcessInfo.Find(); hr != nil { + hr = procHcsGetProcessInfo.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsGetProcessInfo.Addr(), 3, uintptr(process), uintptr(unsafe.Pointer(processInformation)), uintptr(unsafe.Pointer(result))) @@ -493,7 +517,8 @@ func hcsGetProcessInfo(process HcsProcess, processInformation *HcsProcessInforma } func hcsGetProcessProperties(process HcsProcess, processProperties **uint16, result **uint16) (hr error) { - if hr = procHcsGetProcessProperties.Find(); hr != nil { + hr = procHcsGetProcessProperties.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsGetProcessProperties.Addr(), 3, uintptr(process), uintptr(unsafe.Pointer(processProperties)), uintptr(unsafe.Pointer(result))) @@ -516,7 +541,8 @@ func hcsModifyProcess(process HcsProcess, settings string, result **uint16) (hr } func _hcsModifyProcess(process HcsProcess, settings *uint16, result **uint16) (hr error) { - if hr = procHcsModifyProcess.Find(); hr != nil { + hr = procHcsModifyProcess.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsModifyProcess.Addr(), 3, uintptr(process), uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(result))) @@ -539,7 +565,8 @@ func hcsGetServiceProperties(propertyQuery string, properties **uint16, result * } func _hcsGetServiceProperties(propertyQuery *uint16, properties **uint16, result **uint16) (hr error) { - if hr = procHcsGetServiceProperties.Find(); hr != nil { + hr = procHcsGetServiceProperties.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsGetServiceProperties.Addr(), 3, uintptr(unsafe.Pointer(propertyQuery)), uintptr(unsafe.Pointer(properties)), uintptr(unsafe.Pointer(result))) @@ -553,7 +580,8 @@ func _hcsGetServiceProperties(propertyQuery *uint16, properties **uint16, result } func hcsRegisterProcessCallback(process HcsProcess, callback uintptr, context uintptr, callbackHandle *HcsCallback) (hr error) { - if hr = procHcsRegisterProcessCallback.Find(); hr != nil { + hr = procHcsRegisterProcessCallback.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procHcsRegisterProcessCallback.Addr(), 4, uintptr(process), uintptr(callback), uintptr(context), uintptr(unsafe.Pointer(callbackHandle)), 0, 0) @@ -567,7 +595,8 @@ func hcsRegisterProcessCallback(process HcsProcess, callback uintptr, context ui } func hcsUnregisterProcessCallback(callbackHandle HcsCallback) (hr error) { - if hr = procHcsUnregisterProcessCallback.Find(); hr != nil { + hr = procHcsUnregisterProcessCallback.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procHcsUnregisterProcessCallback.Addr(), 1, uintptr(callbackHandle), 0, 0) diff --git a/internal/wclayer/wclayer.go b/internal/wclayer/wclayer.go index 8aeab8d24e..f7f7b89e44 100644 --- a/internal/wclayer/wclayer.go +++ b/internal/wclayer/wclayer.go @@ -4,7 +4,7 @@ package wclayer import "github.com/Microsoft/go-winio/pkg/guid" -//go:generate go run ../../mksyscall_windows.go -output zsyscall_windows.go wclayer.go +//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -sort=false -output zsyscall_windows.go wclayer.go //sys activateLayer(info *driverInfo, id string) (hr error) = vmcompute.ActivateLayer? //sys copyLayer(info *driverInfo, srcId string, dstId string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.CopyLayer? diff --git a/internal/wclayer/zsyscall_windows.go b/internal/wclayer/zsyscall_windows.go index 67f917f07e..9acbffecfa 100644 --- a/internal/wclayer/zsyscall_windows.go +++ b/internal/wclayer/zsyscall_windows.go @@ -1,4 +1,6 @@ -// Code generated mksyscall_windows.exe DO NOT EDIT +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package wclayer @@ -19,6 +21,7 @@ const ( var ( errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) + errERROR_EINVAL error = syscall.EINVAL ) // errnoErr returns common boxed Errno values, to prevent @@ -26,7 +29,7 @@ var ( func errnoErr(e syscall.Errno) error { switch e { case 0: - return nil + return errERROR_EINVAL case errnoERROR_IO_PENDING: return errERROR_IO_PENDING } @@ -74,7 +77,8 @@ func activateLayer(info *driverInfo, id string) (hr error) { } func _activateLayer(info *driverInfo, id *uint16) (hr error) { - if hr = procActivateLayer.Find(); hr != nil { + hr = procActivateLayer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procActivateLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0) @@ -102,13 +106,14 @@ func copyLayer(info *driverInfo, srcId string, dstId string, descriptors []WC_LA } func _copyLayer(info *driverInfo, srcId *uint16, dstId *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) { + hr = procCopyLayer.Find() + if hr != nil { + return + } var _p2 *WC_LAYER_DESCRIPTOR if len(descriptors) > 0 { _p2 = &descriptors[0] } - if hr = procCopyLayer.Find(); hr != nil { - return - } r0, _, _ := syscall.Syscall6(procCopyLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(srcId)), uintptr(unsafe.Pointer(dstId)), uintptr(unsafe.Pointer(_p2)), uintptr(len(descriptors)), 0) if int32(r0) < 0 { if r0&0x1fff0000 == 0x00070000 { @@ -134,7 +139,8 @@ func createLayer(info *driverInfo, id string, parent string) (hr error) { } func _createLayer(info *driverInfo, id *uint16, parent *uint16) (hr error) { - if hr = procCreateLayer.Find(); hr != nil { + hr = procCreateLayer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procCreateLayer.Addr(), 3, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(parent))) @@ -157,13 +163,14 @@ func createSandboxLayer(info *driverInfo, id string, parent uintptr, descriptors } func _createSandboxLayer(info *driverInfo, id *uint16, parent uintptr, descriptors []WC_LAYER_DESCRIPTOR) (hr error) { + hr = procCreateSandboxLayer.Find() + if hr != nil { + return + } var _p1 *WC_LAYER_DESCRIPTOR if len(descriptors) > 0 { _p1 = &descriptors[0] } - if hr = procCreateSandboxLayer.Find(); hr != nil { - return - } r0, _, _ := syscall.Syscall6(procCreateSandboxLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(parent), uintptr(unsafe.Pointer(_p1)), uintptr(len(descriptors)), 0) if int32(r0) < 0 { if r0&0x1fff0000 == 0x00070000 { @@ -184,7 +191,8 @@ func expandSandboxSize(info *driverInfo, id string, size uint64) (hr error) { } func _expandSandboxSize(info *driverInfo, id *uint16, size uint64) (hr error) { - if hr = procExpandSandboxSize.Find(); hr != nil { + hr = procExpandSandboxSize.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procExpandSandboxSize.Addr(), 3, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(size)) @@ -207,7 +215,8 @@ func deactivateLayer(info *driverInfo, id string) (hr error) { } func _deactivateLayer(info *driverInfo, id *uint16) (hr error) { - if hr = procDeactivateLayer.Find(); hr != nil { + hr = procDeactivateLayer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procDeactivateLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0) @@ -230,7 +239,8 @@ func destroyLayer(info *driverInfo, id string) (hr error) { } func _destroyLayer(info *driverInfo, id *uint16) (hr error) { - if hr = procDestroyLayer.Find(); hr != nil { + hr = procDestroyLayer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procDestroyLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0) @@ -258,13 +268,14 @@ func exportLayer(info *driverInfo, id string, path string, descriptors []WC_LAYE } func _exportLayer(info *driverInfo, id *uint16, path *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) { + hr = procExportLayer.Find() + if hr != nil { + return + } var _p2 *WC_LAYER_DESCRIPTOR if len(descriptors) > 0 { _p2 = &descriptors[0] } - if hr = procExportLayer.Find(); hr != nil { - return - } r0, _, _ := syscall.Syscall6(procExportLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(_p2)), uintptr(len(descriptors)), 0) if int32(r0) < 0 { if r0&0x1fff0000 == 0x00070000 { @@ -285,7 +296,8 @@ func getLayerMountPath(info *driverInfo, id string, length *uintptr, buffer *uin } func _getLayerMountPath(info *driverInfo, id *uint16, length *uintptr, buffer *uint16) (hr error) { - if hr = procGetLayerMountPath.Find(); hr != nil { + hr = procGetLayerMountPath.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procGetLayerMountPath.Addr(), 4, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(length)), uintptr(unsafe.Pointer(buffer)), 0, 0) @@ -299,7 +311,8 @@ func _getLayerMountPath(info *driverInfo, id *uint16, length *uintptr, buffer *u } func getBaseImages(buffer **uint16) (hr error) { - if hr = procGetBaseImages.Find(); hr != nil { + hr = procGetBaseImages.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procGetBaseImages.Addr(), 1, uintptr(unsafe.Pointer(buffer)), 0, 0) @@ -327,13 +340,14 @@ func importLayer(info *driverInfo, id string, path string, descriptors []WC_LAYE } func _importLayer(info *driverInfo, id *uint16, path *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) { + hr = procImportLayer.Find() + if hr != nil { + return + } var _p2 *WC_LAYER_DESCRIPTOR if len(descriptors) > 0 { _p2 = &descriptors[0] } - if hr = procImportLayer.Find(); hr != nil { - return - } r0, _, _ := syscall.Syscall6(procImportLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(_p2)), uintptr(len(descriptors)), 0) if int32(r0) < 0 { if r0&0x1fff0000 == 0x00070000 { @@ -354,7 +368,8 @@ func layerExists(info *driverInfo, id string, exists *uint32) (hr error) { } func _layerExists(info *driverInfo, id *uint16, exists *uint32) (hr error) { - if hr = procLayerExists.Find(); hr != nil { + hr = procLayerExists.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procLayerExists.Addr(), 3, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(exists))) @@ -377,7 +392,8 @@ func nameToGuid(name string, guid *_guid) (hr error) { } func _nameToGuid(name *uint16, guid *_guid) (hr error) { - if hr = procNameToGuid.Find(); hr != nil { + hr = procNameToGuid.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procNameToGuid.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(guid)), 0) @@ -400,13 +416,14 @@ func prepareLayer(info *driverInfo, id string, descriptors []WC_LAYER_DESCRIPTOR } func _prepareLayer(info *driverInfo, id *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) { + hr = procPrepareLayer.Find() + if hr != nil { + return + } var _p1 *WC_LAYER_DESCRIPTOR if len(descriptors) > 0 { _p1 = &descriptors[0] } - if hr = procPrepareLayer.Find(); hr != nil { - return - } r0, _, _ := syscall.Syscall6(procPrepareLayer.Addr(), 4, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(_p1)), uintptr(len(descriptors)), 0, 0) if int32(r0) < 0 { if r0&0x1fff0000 == 0x00070000 { @@ -427,7 +444,8 @@ func unprepareLayer(info *driverInfo, id string) (hr error) { } func _unprepareLayer(info *driverInfo, id *uint16) (hr error) { - if hr = procUnprepareLayer.Find(); hr != nil { + hr = procUnprepareLayer.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procUnprepareLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0) @@ -450,7 +468,8 @@ func processBaseImage(path string) (hr error) { } func _processBaseImage(path *uint16) (hr error) { - if hr = procProcessBaseImage.Find(); hr != nil { + hr = procProcessBaseImage.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procProcessBaseImage.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) @@ -473,7 +492,8 @@ func processUtilityImage(path string) (hr error) { } func _processUtilityImage(path *uint16) (hr error) { - if hr = procProcessUtilityImage.Find(); hr != nil { + hr = procProcessUtilityImage.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procProcessUtilityImage.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) @@ -501,7 +521,8 @@ func grantVmAccess(vmid string, filepath string) (hr error) { } func _grantVmAccess(vmid *uint16, filepath *uint16) (hr error) { - if hr = procGrantVmAccess.Find(); hr != nil { + hr = procGrantVmAccess.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall(procGrantVmAccess.Addr(), 2, uintptr(unsafe.Pointer(vmid)), uintptr(unsafe.Pointer(filepath)), 0) @@ -526,11 +547,7 @@ func openVirtualDisk(virtualStorageType *virtualStorageType, path string, virtua func _openVirtualDisk(virtualStorageType *virtualStorageType, path *uint16, virtualDiskAccessMask uint32, flags uint32, parameters *openVirtualDiskParameters, handle *syscall.Handle) (err error) { r1, _, e1 := syscall.Syscall6(procOpenVirtualDisk.Addr(), 6, uintptr(unsafe.Pointer(virtualStorageType)), uintptr(unsafe.Pointer(path)), uintptr(virtualDiskAccessMask), uintptr(flags), uintptr(unsafe.Pointer(parameters)), uintptr(unsafe.Pointer(handle))) if r1 != 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } + err = errnoErr(e1) } return } @@ -538,11 +555,7 @@ func _openVirtualDisk(virtualStorageType *virtualStorageType, path *uint16, virt func attachVirtualDisk(handle syscall.Handle, sd uintptr, flags uint32, providerFlags uint32, params uintptr, overlapped uintptr) (err error) { r1, _, e1 := syscall.Syscall6(procAttachVirtualDisk.Addr(), 6, uintptr(handle), uintptr(sd), uintptr(flags), uintptr(providerFlags), uintptr(params), uintptr(overlapped)) if r1 != 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } + err = errnoErr(e1) } return } @@ -559,11 +572,7 @@ func getDiskFreeSpaceEx(directoryName string, freeBytesAvailableToCaller *int64, func _getDiskFreeSpaceEx(directoryName *uint16, freeBytesAvailableToCaller *int64, totalNumberOfBytes *int64, totalNumberOfFreeBytes *int64) (err error) { r1, _, e1 := syscall.Syscall6(procGetDiskFreeSpaceExW.Addr(), 4, uintptr(unsafe.Pointer(directoryName)), uintptr(unsafe.Pointer(freeBytesAvailableToCaller)), uintptr(unsafe.Pointer(totalNumberOfBytes)), uintptr(unsafe.Pointer(totalNumberOfFreeBytes)), 0, 0) if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } + err = errnoErr(e1) } return } diff --git a/internal/winapi/winapi.go b/internal/winapi/winapi.go index b45fc7de43..d36a5a6ac6 100644 --- a/internal/winapi/winapi.go +++ b/internal/winapi/winapi.go @@ -1,3 +1,3 @@ package winapi -//go:generate go run ..\..\mksyscall_windows.go -output zsyscall_windows.go bindflt.go user.go console.go system.go net.go path.go thread.go jobobject.go logon.go memory.go process.go processor.go devices.go filesystem.go errors.go +//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -sort=false -output zsyscall_windows.go bindflt.go user.go console.go system.go net.go path.go thread.go jobobject.go logon.go memory.go process.go processor.go devices.go filesystem.go errors.go diff --git a/internal/winapi/zsyscall_windows.go b/internal/winapi/zsyscall_windows.go index 025d447451..9469eac093 100644 --- a/internal/winapi/zsyscall_windows.go +++ b/internal/winapi/zsyscall_windows.go @@ -1,4 +1,6 @@ -// Code generated mksyscall_windows.exe DO NOT EDIT +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package winapi @@ -19,6 +21,7 @@ const ( var ( errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) + errERROR_EINVAL error = syscall.EINVAL ) // errnoErr returns common boxed Errno values, to prevent @@ -26,7 +29,7 @@ var ( func errnoErr(e syscall.Errno) error { switch e { case 0: - return nil + return errERROR_EINVAL case errnoERROR_IO_PENDING: return errERROR_IO_PENDING } @@ -81,7 +84,8 @@ var ( ) func BfSetupFilter(jobHandle windows.Handle, flags uint32, virtRootPath *uint16, virtTargetPath *uint16, virtExceptions **uint16, virtExceptionPathCount uint32) (hr error) { - if hr = procBfSetupFilter.Find(); hr != nil { + hr = procBfSetupFilter.Find() + if hr != nil { return } r0, _, _ := syscall.Syscall6(procBfSetupFilter.Addr(), 6, uintptr(jobHandle), uintptr(flags), uintptr(unsafe.Pointer(virtRootPath)), uintptr(unsafe.Pointer(virtTargetPath)), uintptr(unsafe.Pointer(virtExceptions)), uintptr(virtExceptionPathCount)) @@ -171,11 +175,7 @@ func SearchPath(lpPath *uint16, lpFileName *uint16, lpExtension *uint16, nBuffer r0, _, e1 := syscall.Syscall6(procSearchPathW.Addr(), 6, uintptr(unsafe.Pointer(lpPath)), uintptr(unsafe.Pointer(lpFileName)), uintptr(unsafe.Pointer(lpExtension)), uintptr(nBufferLength), uintptr(unsafe.Pointer(lpBuffer)), uintptr(unsafe.Pointer(lpFilePath))) size = uint32(r0) if size == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } + err = errnoErr(e1) } return } @@ -184,11 +184,7 @@ func CreateRemoteThread(process windows.Handle, sa *windows.SecurityAttributes, r0, _, e1 := syscall.Syscall9(procCreateRemoteThread.Addr(), 7, uintptr(process), uintptr(unsafe.Pointer(sa)), uintptr(stackSize), uintptr(startAddr), uintptr(parameter), uintptr(creationFlags), uintptr(unsafe.Pointer(threadID)), 0, 0) handle = windows.Handle(r0) if handle == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } + err = errnoErr(e1) } return } @@ -196,11 +192,7 @@ func CreateRemoteThread(process windows.Handle, sa *windows.SecurityAttributes, func IsProcessInJob(procHandle windows.Handle, jobHandle windows.Handle, result *int32) (err error) { r1, _, e1 := syscall.Syscall(procIsProcessInJob.Addr(), 3, uintptr(procHandle), uintptr(jobHandle), uintptr(unsafe.Pointer(result))) if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } + err = errnoErr(e1) } return } @@ -208,11 +200,7 @@ func IsProcessInJob(procHandle windows.Handle, jobHandle windows.Handle, result func QueryInformationJobObject(jobHandle windows.Handle, infoClass uint32, jobObjectInfo uintptr, jobObjectInformationLength uint32, lpReturnLength *uint32) (err error) { r1, _, e1 := syscall.Syscall6(procQueryInformationJobObject.Addr(), 5, uintptr(jobHandle), uintptr(infoClass), uintptr(jobObjectInfo), uintptr(jobObjectInformationLength), uintptr(unsafe.Pointer(lpReturnLength)), 0) if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } + err = errnoErr(e1) } return } @@ -221,17 +209,11 @@ func OpenJobObject(desiredAccess uint32, inheritHandle bool, lpName *uint16) (ha var _p0 uint32 if inheritHandle { _p0 = 1 - } else { - _p0 = 0 } r0, _, e1 := syscall.Syscall(procOpenJobObjectW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(lpName))) handle = windows.Handle(r0) if handle == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } + err = errnoErr(e1) } return } @@ -240,11 +222,7 @@ func SetIoRateControlInformationJobObject(jobHandle windows.Handle, ioRateContro r0, _, e1 := syscall.Syscall(procSetIoRateControlInformationJobObject.Addr(), 2, uintptr(jobHandle), uintptr(unsafe.Pointer(ioRateControlInfo)), 0) ret = uint32(r0) if ret == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } + err = errnoErr(e1) } return } @@ -253,11 +231,7 @@ func QueryIoRateControlInformationJobObject(jobHandle windows.Handle, volumeName r0, _, e1 := syscall.Syscall6(procQueryIoRateControlInformationJobObject.Addr(), 4, uintptr(jobHandle), uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(ioRateControlInfo)), uintptr(unsafe.Pointer(infoBlockCount)), 0, 0) ret = uint32(r0) if ret == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } + err = errnoErr(e1) } return } @@ -277,11 +251,7 @@ func NtCreateJobObject(jobHandle *windows.Handle, desiredAccess uint32, objAttri func LogonUser(username *uint16, domain *uint16, password *uint16, logonType uint32, logonProvider uint32, token *windows.Token) (err error) { r1, _, e1 := syscall.Syscall6(procLogonUserW.Addr(), 6, uintptr(unsafe.Pointer(username)), uintptr(unsafe.Pointer(domain)), uintptr(unsafe.Pointer(password)), uintptr(logonType), uintptr(logonProvider), uintptr(unsafe.Pointer(token))) if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } + err = errnoErr(e1) } return } @@ -384,14 +354,10 @@ func NtQueryDirectoryObject(handle uintptr, buffer *byte, length uint32, singleE var _p0 uint32 if singleEntry { _p0 = 1 - } else { - _p0 = 0 } var _p1 uint32 if restartScan { _p1 = 1 - } else { - _p1 = 0 } r0, _, _ := syscall.Syscall9(procNtQueryDirectoryObject.Addr(), 7, uintptr(handle), uintptr(unsafe.Pointer(buffer)), uintptr(length), uintptr(_p0), uintptr(_p1), uintptr(unsafe.Pointer(context)), uintptr(unsafe.Pointer(returnLength)), 0, 0) status = uint32(r0) diff --git a/test/go.mod b/test/go.mod index 37e15abd5a..1c7c1d3742 100644 --- a/test/go.mod +++ b/test/go.mod @@ -3,7 +3,7 @@ module github.com/Microsoft/hcsshim/test go 1.17 require ( - github.com/Microsoft/go-winio v0.5.2 + github.com/Microsoft/go-winio v0.5.3-0.20220616180519-35837cff61c7 github.com/Microsoft/hcsshim v0.8.24 github.com/containerd/containerd v1.5.13 github.com/containerd/go-runc v1.0.0 @@ -18,12 +18,13 @@ require ( github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.8.1 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c - golang.org/x/sys v0.0.0-20220412211240-33da011f77ad + golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 google.golang.org/grpc v1.40.0 k8s.io/cri-api v0.20.6 ) require ( + github.com/akavel/rsrc v0.10.2 // indirect github.com/bits-and-blooms/bitset v1.2.0 // indirect github.com/blang/semver v3.5.1+incompatible // indirect github.com/cenkalti/backoff/v4 v4.1.1 // indirect @@ -43,6 +44,7 @@ require ( github.com/google/uuid v1.3.0 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-multierror v1.0.0 // indirect + github.com/josephspurrier/goversioninfo v1.4.0 // indirect github.com/klauspost/compress v1.11.13 // indirect github.com/moby/locker v1.0.1 // indirect github.com/moby/sys/mountinfo v0.4.1 // indirect diff --git a/test/go.sum b/test/go.sum index a83acfd1bd..ba0f481c33 100644 --- a/test/go.sum +++ b/test/go.sum @@ -43,8 +43,8 @@ github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugX github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.4.17-0.20210324224401-5516f17a5958/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.4.17/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= -github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= +github.com/Microsoft/go-winio v0.5.3-0.20220616180519-35837cff61c7 h1:x5GlFkNiN34KDVE01MvMSzfXjtbBYXRNpqbI7usLtgo= +github.com/Microsoft/go-winio v0.5.3-0.20220616180519-35837cff61c7/go.mod h1:9ZRWkpdsaDaHBql4MK5YereVcy6vkcO0xVhq5B1THlk= github.com/Microsoft/hcsshim/test v0.0.0-20201218223536-d3e5debf77da/go.mod h1:5hlzMzRKMLyo42nCZ9oml8AdTlq/0cvIaBv6tK1RehU= github.com/Microsoft/hcsshim/test v0.0.0-20210227013316-43a75bb4edd3/go.mod h1:mw7qgWloBUl75W/gVH3cQszUg1+gUITj7D6NY7ywVnY= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= @@ -54,6 +54,8 @@ github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbt github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= +github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw= +github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -383,6 +385,8 @@ github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/josephspurrier/goversioninfo v1.4.0 h1:Puhl12NSHUSALHSuzYwPYQkqa2E1+7SrtAPJorKK0C8= +github.com/josephspurrier/goversioninfo v1.4.0/go.mod h1:JWzv5rKQr+MmW+LvM412ToT/IkYDZjaclF2pKDss8IY= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -790,8 +794,9 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc= +golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/tools.go b/tools.go new file mode 100644 index 0000000000..3964e2f023 --- /dev/null +++ b/tools.go @@ -0,0 +1,5 @@ +//go:build tools + +package hcsshim + +import _ "github.com/Microsoft/go-winio/tools/mkwinsyscall" diff --git a/vendor/github.com/Microsoft/go-winio/.gitignore b/vendor/github.com/Microsoft/go-winio/.gitignore index b883f1fdc6..9d4287724e 100644 --- a/vendor/github.com/Microsoft/go-winio/.gitignore +++ b/vendor/github.com/Microsoft/go-winio/.gitignore @@ -1 +1,7 @@ +.vscode/ + *.exe + +# go workspaces +go.work +go.work.sum diff --git a/vendor/github.com/Microsoft/go-winio/backup.go b/vendor/github.com/Microsoft/go-winio/backup.go index 2be34af431..6b3f121f9f 100644 --- a/vendor/github.com/Microsoft/go-winio/backup.go +++ b/vendor/github.com/Microsoft/go-winio/backup.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package winio diff --git a/vendor/github.com/Microsoft/go-winio/backuptar/tar.go b/vendor/github.com/Microsoft/go-winio/backuptar/tar.go index 2342a7fcd6..038caff3d5 100644 --- a/vendor/github.com/Microsoft/go-winio/backuptar/tar.go +++ b/vendor/github.com/Microsoft/go-winio/backuptar/tar.go @@ -116,24 +116,23 @@ func BasicInfoHeader(name string, size int64, fileInfo *winio.FileBasicInfo) *ta // SecurityDescriptorFromTarHeader reads the SDDL associated with the header of the current file // from the tar header and returns the security descriptor into a byte slice. func SecurityDescriptorFromTarHeader(hdr *tar.Header) ([]byte, error) { - // Maintaining old SDDL-based behavior for backward - // compatibility. All new tar headers written by this library - // will have raw binary for the security descriptor. - var sd []byte - var err error - if sddl, ok := hdr.PAXRecords[hdrSecurityDescriptor]; ok { - sd, err = winio.SddlToSecurityDescriptor(sddl) - if err != nil { - return nil, err - } - } if sdraw, ok := hdr.PAXRecords[hdrRawSecurityDescriptor]; ok { - sd, err = base64.StdEncoding.DecodeString(sdraw) + sd, err := base64.StdEncoding.DecodeString(sdraw) if err != nil { + // Not returning sd as-is in the error-case, as base64.DecodeString + // may return partially decoded data (not nil or empty slice) in case + // of a failure: https://github.com/golang/go/blob/go1.17.7/src/encoding/base64/base64.go#L382-L387 return nil, err } + return sd, nil + } + // Maintaining old SDDL-based behavior for backward compatibility. All new + // tar headers written by this library will have raw binary for the security + // descriptor. + if sddl, ok := hdr.PAXRecords[hdrSecurityDescriptor]; ok { + return winio.SddlToSecurityDescriptor(sddl) } - return sd, nil + return nil, nil } // ExtendedAttributesFromTarHeader reads the EAs associated with the header of the diff --git a/vendor/github.com/Microsoft/go-winio/fileinfo.go b/vendor/github.com/Microsoft/go-winio/fileinfo.go index 3ab6bff69c..350c109670 100644 --- a/vendor/github.com/Microsoft/go-winio/fileinfo.go +++ b/vendor/github.com/Microsoft/go-winio/fileinfo.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package winio diff --git a/vendor/github.com/Microsoft/go-winio/pipe.go b/vendor/github.com/Microsoft/go-winio/pipe.go index 96700a73de..1acb20148f 100644 --- a/vendor/github.com/Microsoft/go-winio/pipe.go +++ b/vendor/github.com/Microsoft/go-winio/pipe.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package winio @@ -88,8 +89,7 @@ const ( var ( // ErrPipeListenerClosed is returned for pipe operations on listeners that have been closed. - // This error should match net.errClosing since docker takes a dependency on its text. - ErrPipeListenerClosed = errors.New("use of closed network connection") + ErrPipeListenerClosed = net.ErrClosed errPipeWriteClosed = errors.New("pipe has been closed for write") ) diff --git a/vendor/github.com/Microsoft/go-winio/pkg/etw/etw.go b/vendor/github.com/Microsoft/go-winio/pkg/etw/etw.go index 10cd08d84c..0bf6e1aa0e 100644 --- a/vendor/github.com/Microsoft/go-winio/pkg/etw/etw.go +++ b/vendor/github.com/Microsoft/go-winio/pkg/etw/etw.go @@ -7,7 +7,7 @@ // set of C macros. package etw -//go:generate go run mksyscall_windows.go -output zsyscall_windows.go etw.go +//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -output zsyscall_windows.go etw.go //sys eventRegister(providerId *windows.GUID, callback uintptr, callbackContext uintptr, providerHandle *providerHandle) (win32err error) = advapi32.EventRegister diff --git a/vendor/github.com/Microsoft/go-winio/pkg/etw/zsyscall_windows.go b/vendor/github.com/Microsoft/go-winio/pkg/etw/zsyscall_windows.go index 719b13d284..c78a6ed543 100644 --- a/vendor/github.com/Microsoft/go-winio/pkg/etw/zsyscall_windows.go +++ b/vendor/github.com/Microsoft/go-winio/pkg/etw/zsyscall_windows.go @@ -1,4 +1,6 @@ -// Code generated by 'go generate'; DO NOT EDIT. +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package etw diff --git a/vendor/github.com/Microsoft/go-winio/pkg/etwlogrus/hook.go b/vendor/github.com/Microsoft/go-winio/pkg/etwlogrus/hook.go index 4332af5649..8cf7baa186 100644 --- a/vendor/github.com/Microsoft/go-winio/pkg/etwlogrus/hook.go +++ b/vendor/github.com/Microsoft/go-winio/pkg/etwlogrus/hook.go @@ -1,35 +1,74 @@ +//go:build windows // +build windows package etwlogrus import ( + "errors" "sort" - "github.com/Microsoft/go-winio/pkg/etw" "github.com/sirupsen/logrus" + + "github.com/Microsoft/go-winio/pkg/etw" ) +const defaultEventName = "LogrusEntry" + +// ErrNoProvider is returned when a hook is created without a provider being configured. +var ErrNoProvider = errors.New("no ETW registered provider") + +// HookOpt is an option to change the behavior of the Logrus ETW hook +type HookOpt func(*Hook) error + // Hook is a Logrus hook which logs received events to ETW. type Hook struct { provider *etw.Provider closeProvider bool + // allows setting the entry name + getName func(*logrus.Entry) string + // returns additional options to add to the event + getEventsOpts func(*logrus.Entry) []etw.EventOpt } // NewHook registers a new ETW provider and returns a hook to log from it. The // provider will be closed when the hook is closed. -func NewHook(providerName string) (*Hook, error) { - provider, err := etw.NewProvider(providerName, nil) - if err != nil { - return nil, err - } +func NewHook(providerName string, opts ...HookOpt) (*Hook, error) { + opts = append(opts, WithNewETWProvider(providerName)) - return &Hook{provider, true}, nil + return NewHookFromOpts(opts...) } // NewHookFromProvider creates a new hook based on an existing ETW provider. The // provider will not be closed when the hook is closed. -func NewHookFromProvider(provider *etw.Provider) (*Hook, error) { - return &Hook{provider, false}, nil +func NewHookFromProvider(provider *etw.Provider, opts ...HookOpt) (*Hook, error) { + opts = append(opts, WithExistingETWProvider(provider)) + + return NewHookFromOpts(opts...) +} + +// NewHookFromOpts creates a new hook with the provided options. +// An error is returned if the hook does not have a valid provider. +func NewHookFromOpts(opts ...HookOpt) (*Hook, error) { + h := defaultHook() + + for _, o := range opts { + if err := o(h); err != nil { + return nil, err + } + } + return h, h.validate() +} + +func defaultHook() *Hook { + h := &Hook{} + return h +} + +func (h *Hook) validate() error { + if h.provider == nil { + return ErrNoProvider + } + return nil } // Levels returns the set of levels that this hook wants to receive log entries @@ -58,6 +97,21 @@ func (h *Hook) Fire(e *logrus.Entry) error { return nil } + name := defaultEventName + if h.getName != nil { + if n := h.getName(e); n != "" { + name = n + } + } + + // extra room for two more options in addition to log level to avoid repeated reallocations + // if the user also provides options + opts := make([]etw.EventOpt, 0, 3) + opts = append(opts, etw.WithLevel(level)) + if h.getEventsOpts != nil { + opts = append(opts, h.getEventsOpts(e)...) + } + // Sort the fields by name so they are consistent in each instance // of an event. Otherwise, the fields don't line up in WPA. names := make([]string, 0, len(e.Data)) @@ -88,10 +142,7 @@ func (h *Hook) Fire(e *logrus.Entry) error { // as a session listening for the event having no available space in its // buffers). Therefore, we don't return the error from WriteEvent, as it is // just noise in many cases. - h.provider.WriteEvent( - "LogrusEntry", - etw.WithEventOpts(etw.WithLevel(level)), - fields) + h.provider.WriteEvent(name, opts, fields) return nil } diff --git a/vendor/github.com/Microsoft/go-winio/pkg/etwlogrus/opts.go b/vendor/github.com/Microsoft/go-winio/pkg/etwlogrus/opts.go new file mode 100644 index 0000000000..ea3f2e4fd6 --- /dev/null +++ b/vendor/github.com/Microsoft/go-winio/pkg/etwlogrus/opts.go @@ -0,0 +1,53 @@ +//go:build windows + +package etwlogrus + +import ( + "github.com/sirupsen/logrus" + + "github.com/Microsoft/go-winio/pkg/etw" +) + +// etw provider + +// WithNewETWProvider registers a new ETW provider and sets the hook to log using it. +// The provider will be closed when the hook is closed. +func WithNewETWProvider(n string) HookOpt { + return func(h *Hook) error { + provider, err := etw.NewProvider(n, nil) + if err != nil { + return err + } + + h.provider = provider + h.closeProvider = true + return nil + } +} + +// WithExistingETWProvider configures the hook to use an existing ETW provider. +// The provider will not be closed when the hook is closed. +func WithExistingETWProvider(p *etw.Provider) HookOpt { + return func(h *Hook) error { + h.provider = p + h.closeProvider = false + return nil + } +} + +// WithGetName sets the ETW EventName of an event to the value returned by f +// If the name is empty, the default event name will be used. +func WithGetName(f func(*logrus.Entry) string) HookOpt { + return func(h *Hook) error { + h.getName = f + return nil + } +} + +// WithAdditionalEventOpts allows additional ETW event properties (keywords, tags, etc.) to be specified +func WithEventOpts(f func(*logrus.Entry) []etw.EventOpt) HookOpt { + return func(h *Hook) error { + h.getEventsOpts = f + return nil + } +} diff --git a/vendor/github.com/Microsoft/go-winio/pkg/guid/guid.go b/vendor/github.com/Microsoft/go-winio/pkg/guid/guid.go index 2d9161e2de..6e5526bd96 100644 --- a/vendor/github.com/Microsoft/go-winio/pkg/guid/guid.go +++ b/vendor/github.com/Microsoft/go-winio/pkg/guid/guid.go @@ -1,5 +1,3 @@ -// +build windows - // Package guid provides a GUID type. The backing structure for a GUID is // identical to that used by the golang.org/x/sys/windows GUID type. // There are two main binary encodings used for a GUID, the big-endian encoding, diff --git a/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_nonwindows.go b/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_nonwindows.go index f64d828c0b..805bd35484 100644 --- a/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_nonwindows.go +++ b/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_nonwindows.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package guid diff --git a/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_windows.go b/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_windows.go index 83617f4eee..27e45ee5cc 100644 --- a/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_windows.go +++ b/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_windows.go @@ -1,3 +1,6 @@ +//go:build windows +// +build windows + package guid import "golang.org/x/sys/windows" diff --git a/vendor/github.com/Microsoft/go-winio/pkg/process/syscall.go b/vendor/github.com/Microsoft/go-winio/pkg/process/syscall.go index 980105fd46..3d47dd7a1e 100644 --- a/vendor/github.com/Microsoft/go-winio/pkg/process/syscall.go +++ b/vendor/github.com/Microsoft/go-winio/pkg/process/syscall.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package process @@ -6,7 +7,7 @@ import ( "golang.org/x/sys/windows" ) -//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go syscall.go +//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -output zsyscall_windows.go syscall.go //sys enumProcesses(pids *uint32, bufferSize uint32, retBufferSize *uint32) (err error) = kernel32.K32EnumProcesses //sys getProcessMemoryInfo(process handle, memCounters *ProcessMemoryCountersEx, size uint32) (err error) = kernel32.K32GetProcessMemoryInfo diff --git a/vendor/github.com/Microsoft/go-winio/pkg/process/zsyscall_windows.go b/vendor/github.com/Microsoft/go-winio/pkg/process/zsyscall_windows.go index 405206b65e..aa39e76080 100644 --- a/vendor/github.com/Microsoft/go-winio/pkg/process/zsyscall_windows.go +++ b/vendor/github.com/Microsoft/go-winio/pkg/process/zsyscall_windows.go @@ -1,4 +1,6 @@ -// Code generated by 'go generate'; DO NOT EDIT. +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package process diff --git a/vendor/github.com/Microsoft/go-winio/privilege.go b/vendor/github.com/Microsoft/go-winio/privilege.go index c3dd7c2176..120b605540 100644 --- a/vendor/github.com/Microsoft/go-winio/privilege.go +++ b/vendor/github.com/Microsoft/go-winio/privilege.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package winio diff --git a/vendor/github.com/Microsoft/go-winio/reparse.go b/vendor/github.com/Microsoft/go-winio/reparse.go index fc1ee4d3a3..5f2f3a475e 100644 --- a/vendor/github.com/Microsoft/go-winio/reparse.go +++ b/vendor/github.com/Microsoft/go-winio/reparse.go @@ -1,3 +1,6 @@ +//go:build windows +// +build windows + package winio import ( diff --git a/vendor/github.com/Microsoft/go-winio/sd.go b/vendor/github.com/Microsoft/go-winio/sd.go index db1b370a1b..8edbc8435f 100644 --- a/vendor/github.com/Microsoft/go-winio/sd.go +++ b/vendor/github.com/Microsoft/go-winio/sd.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package winio @@ -87,7 +88,7 @@ func SddlToSecurityDescriptor(sddl string) ([]byte, error) { func SecurityDescriptorToSddl(sd []byte) (string, error) { var sddl *uint16 - // The returned string length seems to including an aribtrary number of terminating NULs. + // The returned string length seems to include an arbitrary number of terminating NULs. // Don't use it. err := convertSecurityDescriptorToStringSecurityDescriptor(&sd[0], 1, 0xff, &sddl, nil) if err != nil { diff --git a/vendor/github.com/Microsoft/go-winio/syscall.go b/vendor/github.com/Microsoft/go-winio/syscall.go index 5955c99fde..ca0de23491 100644 --- a/vendor/github.com/Microsoft/go-winio/syscall.go +++ b/vendor/github.com/Microsoft/go-winio/syscall.go @@ -1,3 +1,3 @@ package winio -//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go file.go pipe.go sd.go fileinfo.go privilege.go backup.go hvsock.go +//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -output zsyscall_windows.go ./*.go diff --git a/vendor/github.com/Microsoft/go-winio/tools/mkwinsyscall/doc.go b/vendor/github.com/Microsoft/go-winio/tools/mkwinsyscall/doc.go new file mode 100644 index 0000000000..3d638e417b --- /dev/null +++ b/vendor/github.com/Microsoft/go-winio/tools/mkwinsyscall/doc.go @@ -0,0 +1,52 @@ +/* +mkwinsyscall generates windows system call bodies + +It parses all files specified on command line containing function +prototypes (like syscall_windows.go) and prints system call bodies +to standard output. + +The prototypes are marked by lines beginning with "//sys" and read +like func declarations if //sys is replaced by func, but: + + - The parameter lists must give a name for each argument. This + includes return parameters. + + - The parameter lists must give a type for each argument: + the (x, y, z int) shorthand is not allowed. + + - If the return parameter is an error number, it must be named err. + + - If go func name needs to be different from its winapi dll name, + the winapi name could be specified at the end, after "=" sign, like + //sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA + + - Each function that returns err needs to supply a condition, that + return value of winapi will be tested against to detect failure. + This would set err to windows "last-error", otherwise it will be nil. + The value can be provided at end of //sys declaration, like + //sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA + and is [failretval==0] by default. + + - If the function name ends in a "?", then the function not existing is non- + fatal, and an error will be returned instead of panicking. + +Usage: + + mkwinsyscall [flags] [path ...] + +The flags are: + + -output string + Specify output file name (standard output if omitted). + -sort + Sort DLL and Function declarations (default true). Setting to false is intended to maintain + compatibility with older versions of mkwinsyscall so that diffs are easier to read and understand. + -systemdll + Specify that all DLLs should be loaded from the Windows system directory (default true). + -trace + Generate print statement after every syscall. + winio + Import this package ("github.com/Microsoft/go-winio"). + +*/ +package main diff --git a/mksyscall_windows.go b/vendor/github.com/Microsoft/go-winio/tools/mkwinsyscall/mkwinsyscall.go similarity index 81% rename from mksyscall_windows.go rename to vendor/github.com/Microsoft/go-winio/tools/mkwinsyscall/mkwinsyscall.go index 7647734de9..de362c6a29 100644 --- a/mksyscall_windows.go +++ b/vendor/github.com/Microsoft/go-winio/tools/mkwinsyscall/mkwinsyscall.go @@ -1,47 +1,9 @@ +//go:build windows + // Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build ignore - -/* -mksyscall_windows generates windows system call bodies - -It parses all files specified on command line containing function -prototypes (like syscall_windows.go) and prints system call bodies -to standard output. - -The prototypes are marked by lines beginning with "//sys" and read -like func declarations if //sys is replaced by func, but: - -* The parameter lists must give a name for each argument. This - includes return parameters. - -* The parameter lists must give a type for each argument: - the (x, y, z int) shorthand is not allowed. - -* If the return parameter is an error number, it must be named err. - -* If go func name needs to be different from it's winapi dll name, - the winapi name could be specified at the end, after "=" sign, like - //sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA - -* Each function that returns err needs to supply a condition, that - return value of winapi will be tested against to detect failure. - This would set err to windows "last-error", otherwise it will be nil. - The value can be provided at end of //sys declaration, like - //sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA - and is [failretval==0] by default. - -Usage: - mksyscall_windows [flags] [path ...] - -The flags are: - -output - Specify output file name (outputs to console if blank). - -trace - Generate print statement after every syscall. -*/ package main import ( @@ -63,25 +25,40 @@ import ( "strconv" "strings" "text/template" + + "golang.org/x/sys/windows" ) var ( filename = flag.String("output", "", "output file name (standard output if omitted)") printTraceFlag = flag.Bool("trace", false, "generate print statement after every syscall") systemDLL = flag.Bool("systemdll", true, "whether all DLLs should be loaded from the Windows system directory") - winio = flag.Bool("winio", false, "import go-winio") + winio = flag.Bool("winio", false, `import this package ("github.com/Microsoft/go-winio")`) + utf16 = flag.Bool("utf16", true, "encode string arguments as UTF-16 for syscalls not ending in 'A' or 'W'") + sortdecls = flag.Bool("sort", true, "sort DLL and function declarations") ) func trim(s string) string { return strings.Trim(s, " \t") } +func endsIn(s string, c byte) bool { + return len(s) >= 1 && s[len(s)-1] == c +} + var packageName string func packagename() string { return packageName } +func windowsdot() string { + if packageName == "windows" { + return "" + } + return "windows." +} + func syscalldot() string { if packageName == "syscall" { return "" @@ -108,14 +85,20 @@ func (p *Param) tmpVar() string { // BoolTmpVarCode returns source code for bool temp variable. func (p *Param) BoolTmpVarCode() string { - const code = `var %s uint32 - if %s { - %s = 1 - } else { - %s = 0 + const code = `var %[1]s uint32 + if %[2]s { + %[1]s = 1 }` - tmp := p.tmpVar() - return fmt.Sprintf(code, tmp, p.Name, tmp, tmp) + return fmt.Sprintf(code, p.tmpVar(), p.Name) +} + +// BoolPointerTmpVarCode returns source code for bool temp variable. +func (p *Param) BoolPointerTmpVarCode() string { + const code = `var %[1]s uint32 + if *%[2]s { + %[1]s = 1 + }` + return fmt.Sprintf(code, p.tmpVar(), p.Name) } // SliceTmpVarCode returns source code for slice temp variable. @@ -153,6 +136,8 @@ func (p *Param) TmpVarCode() string { switch { case p.Type == "bool": return p.BoolTmpVarCode() + case p.Type == "*bool": + return p.BoolPointerTmpVarCode() case strings.HasPrefix(p.Type, "[]"): return p.SliceTmpVarCode() default: @@ -160,6 +145,16 @@ func (p *Param) TmpVarCode() string { } } +// TmpVarReadbackCode returns source code for reading back the temp variable into the original variable. +func (p *Param) TmpVarReadbackCode() string { + switch { + case p.Type == "*bool": + return fmt.Sprintf("*%s = %s != 0", p.Name, p.tmpVar()) + default: + return "" + } +} + // TmpVarHelperCode returns source code for helper's temp variable. func (p *Param) TmpVarHelperCode() string { if p.Type != "string" { @@ -175,6 +170,8 @@ func (p *Param) SyscallArgList() []string { t := p.HelperType() var s string switch { + case t == "*bool": + s = fmt.Sprintf("unsafe.Pointer(&%s)", p.tmpVar()) case t[0] == '*': s = fmt.Sprintf("unsafe.Pointer(%s)", p.Name) case t == "bool": @@ -219,10 +216,11 @@ func join(ps []*Param, fn func(*Param) string, sep string) string { // Rets describes function return parameters. type Rets struct { - Name string - Type string - ReturnsError bool - FailCond string + Name string + Type string + ReturnsError bool + FailCond string + fnMaybeAbsent bool } // ErrorVarName returns error variable name for r. @@ -253,6 +251,8 @@ func (r *Rets) List() string { s := join(r.ToParams(), func(p *Param) string { return p.Name + " " + p.Type }, ", ") if len(s) > 0 { s = "(" + s + ")" + } else if r.fnMaybeAbsent { + s = "(err error)" } return s } @@ -281,17 +281,13 @@ func (r *Rets) SetReturnValuesCode() string { func (r *Rets) useLongHandleErrorCode(retvar string) string { const code = `if %s { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = %sEINVAL - } + err = errnoErr(e1) }` cond := retvar + " == 0" if r.FailCond != "" { cond = strings.Replace(r.FailCond, "failretval", retvar, 1) } - return fmt.Sprintf(code, cond, syscalldot()) + return fmt.Sprintf(code, cond) } // SetErrorCode returns source code that sets return parameters. @@ -299,12 +295,16 @@ func (r *Rets) SetErrorCode() string { const code = `if r0 != 0 { %s = %sErrno(r0) }` + const ntstatus = `if r0 != 0 { + ntstatus = %sNTStatus(r0) + }` const hrCode = `if int32(r0) < 0 { if r0&0x1fff0000 == 0x00070000 { r0 &= 0xffff } %s = %sErrno(r0) }` + if r.Name == "" && !r.ReturnsError { return "" } @@ -312,12 +312,16 @@ func (r *Rets) SetErrorCode() string { return r.useLongHandleErrorCode("r1") } if r.Type == "error" { - if r.Name == "hr" { + switch r.Name { + case "ntstatus": + return fmt.Sprintf(ntstatus, windowsdot()) + case "hr": return fmt.Sprintf(hrCode, r.Name, syscalldot()) - } else { + default: return fmt.Sprintf(code, r.Name, syscalldot()) } } + s := "" switch { case r.Type[0] == '*': @@ -339,7 +343,6 @@ type Fn struct { Params []*Param Rets *Rets PrintTrace bool - confirmproc bool dllname string dllfuncname string src string @@ -467,9 +470,9 @@ func newFn(s string) (*Fn, error) { default: return nil, errors.New("Could not extract dll name from \"" + f.src + "\"") } - if f.dllfuncname[len(f.dllfuncname)-1] == '?' { - f.confirmproc = true - f.dllfuncname = f.dllfuncname[0 : len(f.dllfuncname)-1] + if n := f.dllfuncname; endsIn(n, '?') { + f.dllfuncname = n[:len(n)-1] + f.Rets.fnMaybeAbsent = true } return f, nil } @@ -490,10 +493,6 @@ func (f *Fn) DLLFuncName() string { return f.dllfuncname } -func (f *Fn) ConfirmProc() bool { - return f.confirmproc -} - // ParamList returns source code for function f parameters. func (f *Fn) ParamList() string { return join(f.Params, func(p *Param) string { return p.Name + " " + p.Type }, ", ") @@ -573,10 +572,28 @@ func (f *Fn) HelperCallParamList() string { return strings.Join(a, ", ") } -// IsUTF16 is true, if f is W (utf16) function. It is false -// for all A (ascii) functions. -func (_ *Fn) IsUTF16() bool { - return true +// MaybeAbsent returns source code for handling functions that are possibly unavailable. +func (f *Fn) MaybeAbsent() string { + if !f.Rets.fnMaybeAbsent { + return "" + } + const code = `%[1]s = proc%[2]s.Find() + if %[1]s != nil { + return + }` + errorVar := f.Rets.ErrorVarName() + if errorVar == "" { + errorVar = "err" + } + return fmt.Sprintf(code, errorVar, f.DLLFuncName()) +} + +// IsUTF16 is true, if f is W (UTF-16) function and false for all A (ASCII) functions. +// Functions ending in neither will default to UTF-16, unless the `-utf16` flag is set +// to `false`. +func (f *Fn) IsUTF16() bool { + s := f.DLLFuncName() + return endsIn(s, 'W') || (*utf16 && !endsIn(s, 'A')) } // StrconvFunc returns name of Go string to OS string function for f. @@ -606,18 +623,6 @@ func (f *Fn) HasStringParam() bool { return false } -var uniqDllFuncName = make(map[string]bool) - -// IsNotDuplicate is true if f is not a duplicated function -func (f *Fn) IsNotDuplicate() bool { - funcName := f.DLLFuncName() - if uniqDllFuncName[funcName] == false { - uniqDllFuncName[funcName] = true - return true - } - return false -} - // HelperName returns name of function f helper. func (f *Fn) HelperName() string { if !f.HasStringParam() { @@ -629,6 +634,7 @@ func (f *Fn) HelperName() string { // Source files and functions. type Source struct { Funcs []*Fn + DLLFuncNames []*Fn Files []string StdLibImports []string ExternalImports []string @@ -645,7 +651,7 @@ func (src *Source) ExternalImport(pkg string) { } // ParseFiles parses files listed in fs and extracts all syscall -// functions listed in sys comments. It returns source files +// functions listed in sys comments. It returns source files // and functions collection *Source if successful. func ParseFiles(fs []string) (*Source, error) { src := &Source{ @@ -661,6 +667,15 @@ func ParseFiles(fs []string) (*Source, error) { return nil, err } } + src.DLLFuncNames = make([]*Fn, 0, len(src.Funcs)) + uniq := make(map[string]bool, len(src.Funcs)) + for _, fn := range src.Funcs { + name := fn.DLLFuncName() + if !uniq[name] { + src.DLLFuncNames = append(src.DLLFuncNames, fn) + uniq[name] = true + } + } return src, nil } @@ -675,17 +690,43 @@ func (src *Source) DLLs() []string { r = append(r, name) } } + if *sortdecls { + sort.Strings(r) + } return r } -// ParseFile adds additional file path to a source set src. +// ParseFile adds additional file (or files, if path is a glob pattern) path to a source set src. func (src *Source) ParseFile(path string) error { file, err := os.Open(path) + if err == nil { + defer file.Close() + return src.parseFile(file) + } else if !(errors.Is(err, os.ErrNotExist) || errors.Is(err, windows.ERROR_INVALID_NAME)) { + return err + } + + paths, err := filepath.Glob(path) if err != nil { return err } - defer file.Close() + for _, path := range paths { + file, err := os.Open(path) + if err != nil { + return err + } + err = src.parseFile(file) + file.Close() + if err != nil { + return err + } + } + + return nil +} + +func (src *Source) parseFile(file *os.File) error { s := bufio.NewScanner(file) for s.Scan() { t := trim(s.Text()) @@ -708,11 +749,20 @@ func (src *Source) ParseFile(path string) error { if err := s.Err(); err != nil { return err } - src.Files = append(src.Files, path) + src.Files = append(src.Files, file.Name()) + if *sortdecls { + sort.Slice(src.Funcs, func(i, j int) bool { + fi, fj := src.Funcs[i], src.Funcs[j] + if fi.DLLName() == fj.DLLName() { + return fi.DLLFuncName() < fj.DLLFuncName() + } + return fi.DLLName() < fj.DLLName() + }) + } // get package name fset := token.NewFileSet() - _, err = file.Seek(0, 0) + _, err := file.Seek(0, 0) if err != nil { return err } @@ -725,7 +775,7 @@ func (src *Source) ParseFile(path string) error { return nil } -// IsStdRepo returns true if src is part of standard library. +// IsStdRepo reports whether src is part of standard library. func (src *Source) IsStdRepo() (bool, error) { if len(src.Files) == 0 { return false, errors.New("no input files provided") @@ -812,7 +862,7 @@ func (src *Source) Generate(w io.Writer) error { } func usage() { - fmt.Fprintf(os.Stderr, "usage: mksyscall_windows [flags] [path ...]\n") + fmt.Fprintf(os.Stderr, "usage: mkwinsyscall [flags] [path ...]\n") flag.PrintDefaults() os.Exit(1) } @@ -851,8 +901,9 @@ func main() { // TODO: use println instead to print in the following template const srcTemplate = ` +{{define "main"}} //go:build windows -{{define "main"}}// Code generated mksyscall_windows.exe DO NOT EDIT +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package {{packagename}} @@ -874,6 +925,7 @@ const ( var ( errERROR_IO_PENDING error = {{syscalldot}}Errno(errnoERROR_IO_PENDING) + errERROR_EINVAL error = {{syscalldot}}EINVAL ) // errnoErr returns common boxed Errno values, to prevent @@ -881,7 +933,7 @@ var ( func errnoErr(e {{syscalldot}}Errno) error { switch e { case 0: - return nil + return errERROR_EINVAL case errnoERROR_IO_PENDING: return errERROR_IO_PENDING } @@ -902,7 +954,7 @@ var ( {{define "dlls"}}{{range .DLLs}} mod{{.}} = {{newlazydll .}} {{end}}{{end}} -{{define "funcnames"}}{{range .Funcs}}{{if .IsNotDuplicate}} proc{{.DLLFuncName}} = mod{{.DLLName}}.NewProc("{{.DLLFuncName}}"){{end}} +{{define "funcnames"}}{{range .DLLFuncNames}} proc{{.DLLFuncName}} = mod{{.DLLName}}.NewProc("{{.DLLFuncName}}") {{end}}{{end}} {{define "helperbody"}} @@ -913,7 +965,7 @@ func {{.Name}}({{.ParamList}}) {{template "results" .}}{ {{define "funcbody"}} func {{.HelperName}}({{.HelperParamList}}) {{template "results" .}}{ -{{template "tmpvars" .}} {{template "syscallcheck" .}}{{template "syscall" .}} +{{template "maybeabsent" .}} {{template "tmpvars" .}} {{template "syscall" .}} {{template "tmpvarsreadback" .}} {{template "seterror" .}}{{template "printtrace" .}} return } {{end}} @@ -921,6 +973,9 @@ func {{.HelperName}}({{.HelperParamList}}) {{template "results" .}}{ {{define "helpertmpvars"}}{{range .Params}}{{if .TmpVarHelperCode}} {{.TmpVarHelperCode}} {{end}}{{end}}{{end}} +{{define "maybeabsent"}}{{if .MaybeAbsent}}{{.MaybeAbsent}} +{{end}}{{end}} + {{define "tmpvars"}}{{range .Params}}{{if .TmpVarCode}} {{.TmpVarCode}} {{end}}{{end}}{{end}} @@ -928,11 +983,8 @@ func {{.HelperName}}({{.HelperParamList}}) {{template "results" .}}{ {{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(), {{.ParamCount}}, {{.SyscallParamList}}){{end}} -{{define "syscallcheck"}}{{if .ConfirmProc}}if {{.Rets.ErrorVarName}} = proc{{.DLLFuncName}}.Find(); {{.Rets.ErrorVarName}} != nil { - return -} -{{end}}{{end}} - +{{define "tmpvarsreadback"}}{{range .Params}}{{if .TmpVarReadbackCode}} +{{.TmpVarReadbackCode}}{{end}}{{end}}{{end}} {{define "seterror"}}{{if .Rets.SetErrorCode}} {{.Rets.SetErrorCode}} {{end}}{{end}} diff --git a/vendor/github.com/Microsoft/go-winio/vhd/vhd.go b/vendor/github.com/Microsoft/go-winio/vhd/vhd.go index f7f78fc230..46f6998443 100644 --- a/vendor/github.com/Microsoft/go-winio/vhd/vhd.go +++ b/vendor/github.com/Microsoft/go-winio/vhd/vhd.go @@ -11,7 +11,7 @@ import ( "golang.org/x/sys/windows" ) -//go:generate go run mksyscall_windows.go -output zvhd_windows.go vhd.go +//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -output zvhd_windows.go vhd.go //sys createVirtualDisk(virtualStorageType *VirtualStorageType, path string, virtualDiskAccessMask uint32, securityDescriptor *uintptr, createVirtualDiskFlags uint32, providerSpecificFlags uint32, parameters *CreateVirtualDiskParameters, overlapped *syscall.Overlapped, handle *syscall.Handle) (win32err error) = virtdisk.CreateVirtualDisk //sys openVirtualDisk(virtualStorageType *VirtualStorageType, path string, virtualDiskAccessMask uint32, openVirtualDiskFlags uint32, parameters *openVirtualDiskParameters, handle *syscall.Handle) (win32err error) = virtdisk.OpenVirtualDisk diff --git a/vendor/github.com/Microsoft/go-winio/vhd/zvhd_windows.go b/vendor/github.com/Microsoft/go-winio/vhd/zvhd_windows.go index 1d7498db3b..d0e917d2be 100644 --- a/vendor/github.com/Microsoft/go-winio/vhd/zvhd_windows.go +++ b/vendor/github.com/Microsoft/go-winio/vhd/zvhd_windows.go @@ -1,4 +1,6 @@ -// Code generated by 'go generate'; DO NOT EDIT. +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package vhd diff --git a/vendor/github.com/Microsoft/go-winio/zsyscall_windows.go b/vendor/github.com/Microsoft/go-winio/zsyscall_windows.go index 176ff75e32..8be405cfd9 100644 --- a/vendor/github.com/Microsoft/go-winio/zsyscall_windows.go +++ b/vendor/github.com/Microsoft/go-winio/zsyscall_windows.go @@ -1,4 +1,6 @@ -// Code generated by 'go generate'; DO NOT EDIT. +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package winio diff --git a/vendor/github.com/akavel/rsrc/AUTHORS b/vendor/github.com/akavel/rsrc/AUTHORS new file mode 100644 index 0000000000..06fb069913 --- /dev/null +++ b/vendor/github.com/akavel/rsrc/AUTHORS @@ -0,0 +1,5 @@ +Force Charlie +Mateusz Czapliński +Quentin Renard +shnmng +Thomas Combeléran diff --git a/vendor/github.com/akavel/rsrc/LICENSE.txt b/vendor/github.com/akavel/rsrc/LICENSE.txt new file mode 100644 index 0000000000..5c1511ec15 --- /dev/null +++ b/vendor/github.com/akavel/rsrc/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013-2017 The rsrc Authors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/github.com/akavel/rsrc/binutil/plain.go b/vendor/github.com/akavel/rsrc/binutil/plain.go new file mode 100644 index 0000000000..ddf5238b94 --- /dev/null +++ b/vendor/github.com/akavel/rsrc/binutil/plain.go @@ -0,0 +1,13 @@ +package binutil + +import ( + "reflect" +) + +func Plain(kind reflect.Kind) bool { + switch kind { + case reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128: + return true + } + return false +} diff --git a/vendor/github.com/akavel/rsrc/binutil/sizedfile.go b/vendor/github.com/akavel/rsrc/binutil/sizedfile.go new file mode 100644 index 0000000000..3a6606fd85 --- /dev/null +++ b/vendor/github.com/akavel/rsrc/binutil/sizedfile.go @@ -0,0 +1,35 @@ +package binutil + +import ( + "io" + "os" +) + +type SizedReader interface { + io.Reader + Size() int64 +} + +type SizedFile struct { + f *os.File + s *io.SectionReader // helper, for Size() +} + +func (r *SizedFile) Read(p []byte) (n int, err error) { return r.s.Read(p) } +func (r *SizedFile) Size() int64 { return r.s.Size() } +func (r *SizedFile) Close() error { return r.f.Close() } + +func SizedOpen(filename string) (*SizedFile, error) { + f, err := os.Open(filename) + if err != nil { + return nil, err + } + info, err := f.Stat() + if err != nil { + return nil, err + } + return &SizedFile{ + f: f, + s: io.NewSectionReader(f, 0, info.Size()), + }, nil +} diff --git a/vendor/github.com/akavel/rsrc/binutil/walk.go b/vendor/github.com/akavel/rsrc/binutil/walk.go new file mode 100644 index 0000000000..4aa4ad30e8 --- /dev/null +++ b/vendor/github.com/akavel/rsrc/binutil/walk.go @@ -0,0 +1,63 @@ +package binutil + +import ( + "errors" + "fmt" + "path" + "reflect" +) + +var ( + WALK_SKIP = errors.New("") +) + +type Walker func(v reflect.Value, path string) error + +func Walk(value interface{}, walker Walker) error { + err := walk(reflect.ValueOf(value), "/", walker) + if err == WALK_SKIP { + err = nil + } + return err +} + +func stopping(err error) bool { + return err != nil && err != WALK_SKIP +} + +func walk(v reflect.Value, spath string, walker Walker) error { + err := walker(v, spath) + if err != nil { + return err + } + v = reflect.Indirect(v) + switch v.Kind() { + case reflect.Slice, reflect.Array: + for i := 0; i < v.Len(); i++ { + err = walk(v.Index(i), spath+fmt.Sprintf("[%d]", i), walker) + if stopping(err) { + return err + } + } + case reflect.Interface: + err = walk(v.Elem(), spath, walker) + if stopping(err) { + return err + } + case reflect.Struct: + //t := v.Type() + for i := 0; i < v.NumField(); i++ { + //f := t.Field(i) //TODO: handle unexported fields + vv := v.Field(i) + err = walk(vv, path.Join(spath, v.Type().Field(i).Name), walker) + if stopping(err) { + return err + } + } + default: + // FIXME: handle other special cases too + // String + return nil + } + return nil +} diff --git a/vendor/github.com/akavel/rsrc/binutil/writer.go b/vendor/github.com/akavel/rsrc/binutil/writer.go new file mode 100644 index 0000000000..cd2ef97818 --- /dev/null +++ b/vendor/github.com/akavel/rsrc/binutil/writer.go @@ -0,0 +1,33 @@ +package binutil + +import ( + "encoding/binary" + "io" + "reflect" +) + +type Writer struct { + W io.Writer + Offset uint32 //FIXME: int64? + Err error +} + +func (w *Writer) WriteLE(v interface{}) { + if w.Err != nil { + return + } + w.Err = binary.Write(w.W, binary.LittleEndian, v) + if w.Err != nil { + return + } + w.Offset += uint32(reflect.TypeOf(v).Size()) +} + +func (w *Writer) WriteFromSized(r SizedReader) { + if w.Err != nil { + return + } + var n int64 + n, w.Err = io.CopyN(w.W, r, r.Size()) + w.Offset += uint32(n) +} diff --git a/vendor/github.com/akavel/rsrc/coff/coff.go b/vendor/github.com/akavel/rsrc/coff/coff.go new file mode 100644 index 0000000000..3c6d5f4b93 --- /dev/null +++ b/vendor/github.com/akavel/rsrc/coff/coff.go @@ -0,0 +1,363 @@ +package coff + +import ( + "debug/pe" + "encoding/binary" + "errors" + "io" + "reflect" + "regexp" + "sort" + "strconv" + "strings" + + "github.com/akavel/rsrc/binutil" +) + +type Dir struct { // struct IMAGE_RESOURCE_DIRECTORY + Characteristics uint32 + TimeDateStamp uint32 + MajorVersion uint16 + MinorVersion uint16 + NumberOfNamedEntries uint16 + NumberOfIdEntries uint16 + DirEntries + Dirs +} + +type DirEntries []DirEntry +type Dirs []Dir + +type DirEntry struct { // struct IMAGE_RESOURCE_DIRECTORY_ENTRY + NameOrId uint32 + OffsetToData uint32 +} + +type DataEntry struct { // struct IMAGE_RESOURCE_DATA_ENTRY + OffsetToData uint32 + Size1 uint32 + CodePage uint32 //FIXME: what value here? for now just using 0 + Reserved uint32 +} + +type RelocationEntry struct { + RVA uint32 // "offset within the Section's raw data where the address starts." + SymbolIndex uint32 // "(zero based) index in the Symbol table to which the reference refers." + Type uint16 +} + +// Values reverse-engineered from windres output; names from teh Internets. +// Teh googlies Internets don't seem to have much to say about the AMD64 one, +// unfortunately :/ but it works... +const ( + _IMAGE_REL_AMD64_ADDR32NB = 0x03 + _IMAGE_REL_I386_DIR32NB = 0x07 + _IMAGE_REL_ARM64_ADDR32NB = 0x02 + _IMAGE_REL_ARM_ADDR32NB = 0x02 +) + +type Auxiliary [18]byte + +type Symbol struct { + Name [8]byte + Value uint32 + SectionNumber uint16 + Type uint16 + StorageClass uint8 + AuxiliaryCount uint8 + Auxiliaries []Auxiliary +} + +type StringsHeader struct { + Length uint32 +} + +const ( + MASK_SUBDIRECTORY = 1 << 31 + + RT_ICON = 3 + RT_GROUP_ICON = 3 + 11 + RT_MANIFEST = 24 +) + +// http://www.delorie.com/djgpp/doc/coff/symtab.html +const ( + DT_PTR = 1 + T_UCHAR = 12 +) + +var ( + STRING_RSRC = [8]byte{'.', 'r', 's', 'r', 'c', 0, 0, 0} + + LANG_ENTRY = DirEntry{NameOrId: 0x0409} //FIXME: language; what value should be here? +) + +type PaddedData struct { + Data Sizer + Padding []byte +} + +type Sizer interface { + Size() int64 //NOTE: must not exceed limits of uint32, or behavior is undefined +} + +type Coff struct { + pe.FileHeader + pe.SectionHeader32 + + *Dir + DataEntries []DataEntry + Data []PaddedData + + Relocations []RelocationEntry + Symbols []Symbol + StringsHeader + Strings []Sizer +} + +// NOTE: must be called immediately after NewRSRC, before any other +// functions. +func (coff *Coff) Arch(arch string) error { + switch arch { + case "386": + coff.Machine = pe.IMAGE_FILE_MACHINE_I386 + case "amd64": + // Sources: + // https://github.com/golang/go/blob/0e23ca41d99c82d301badf1b762888e2c69e6c57/src/debug/pe/pe.go#L116 + // https://github.com/yasm/yasm/blob/7160679eee91323db98b0974596c7221eeff772c/modules/objfmts/coff/coff-objfmt.c#L38 + // FIXME: currently experimental -- not sure if something more doesn't need to be changed + coff.Machine = pe.IMAGE_FILE_MACHINE_AMD64 + case "arm": + // see + // https://github.com/golang/go/blob/f3424ceff2fa48615ed98580f337ab044925c940/src/cmd/link/internal/ld/pe.go#L736 + coff.Machine = pe.IMAGE_FILE_MACHINE_ARMNT + case "arm64": + // Waiting https://github.com/golang/go/issues/36439 + coff.Machine = pe.IMAGE_FILE_MACHINE_ARM64 + default: + return errors.New("coff: unknown architecture: " + arch) + } + return nil +} + +// addSymbol appends a symbol to Coff.Symbols and to Coff.Strings. +//NOTE: symbol s must be probably >8 characters long +//NOTE: symbol s should not contain embedded zeroes +func (coff *Coff) addSymbol(s string) { + coff.FileHeader.NumberOfSymbols++ + + buf := strings.NewReader(s + "\000") // ASCIIZ + r := io.NewSectionReader(buf, 0, int64(len(s)+1)) + coff.Strings = append(coff.Strings, r) + + coff.StringsHeader.Length += uint32(r.Size()) + + coff.Symbols = append(coff.Symbols, Symbol{ + //Name: // will be filled in Freeze + //Value: // as above + SectionNumber: 1, + Type: 0, // why 0??? // DT_PTR<<4 | T_UCHAR, // unsigned char* // (?) or use void* ? T_VOID=1 + StorageClass: 2, // 2=C_EXT, or 5=C_EXTDEF ? + AuxiliaryCount: 0, + }) +} + +func NewRSRC() *Coff { + return &Coff{ + pe.FileHeader{ + Machine: pe.IMAGE_FILE_MACHINE_I386, + NumberOfSections: 1, // .rsrc + TimeDateStamp: 0, // was also 0 in sample data from MinGW's windres.exe + NumberOfSymbols: 1, + SizeOfOptionalHeader: 0, + Characteristics: 0x0104, //FIXME: copied from windres.exe output, find out what should be here and why + }, + pe.SectionHeader32{ + Name: STRING_RSRC, + Characteristics: 0x40000040, // "INITIALIZED_DATA MEM_READ" ? + }, + + // "directory hierarchy" of .rsrc section: top level goes resource type, then id/name, then language + &Dir{}, + + []DataEntry{}, + []PaddedData{}, + + []RelocationEntry{}, + + []Symbol{Symbol{ + Name: STRING_RSRC, + Value: 0, + SectionNumber: 1, + Type: 0, // FIXME: wtf? + StorageClass: 3, // FIXME: is it ok? and uint8? and what does the value mean? + AuxiliaryCount: 0, // FIXME: wtf? + }}, + + StringsHeader{ + Length: uint32(binary.Size(StringsHeader{})), // empty strings table -- but we must still show size of the table's header... + }, + []Sizer{}, + } +} + +//NOTE: function assumes that 'id' is increasing on each entry +//NOTE: only usable for Coff created using NewRSRC +func (coff *Coff) AddResource(kind uint32, id uint16, data Sizer) { + re := RelocationEntry{ + // "(zero based) index in the Symbol table to which the + // reference refers. Once you have loaded the COFF file into + // memory and know where each symbol is, you find the new + // updated address for the given symbol and update the + // reference accordingly." + SymbolIndex: 0, + } + switch coff.Machine { + case pe.IMAGE_FILE_MACHINE_I386: + re.Type = _IMAGE_REL_I386_DIR32NB + case pe.IMAGE_FILE_MACHINE_AMD64: + re.Type = _IMAGE_REL_AMD64_ADDR32NB + case pe.IMAGE_FILE_MACHINE_ARMNT: + re.Type = _IMAGE_REL_ARM_ADDR32NB + case pe.IMAGE_FILE_MACHINE_ARM64: + re.Type = _IMAGE_REL_ARM64_ADDR32NB + } + coff.Relocations = append(coff.Relocations, re) + coff.SectionHeader32.NumberOfRelocations++ + + // find top level entry, inserting new if necessary at correct sorted position + entries0 := coff.Dir.DirEntries + dirs0 := coff.Dir.Dirs + i0 := sort.Search(len(entries0), func(i int) bool { + return entries0[i].NameOrId >= kind + }) + if i0 >= len(entries0) || entries0[i0].NameOrId != kind { + // inserting new entry & dir + entries0 = append(entries0[:i0], append([]DirEntry{{NameOrId: kind}}, entries0[i0:]...)...) + dirs0 = append(dirs0[:i0], append([]Dir{{}}, dirs0[i0:]...)...) + coff.Dir.NumberOfIdEntries++ + } + coff.Dir.DirEntries = entries0 + coff.Dir.Dirs = dirs0 + + // for second level, assume ID is always increasing, so we don't have to sort + dirs0[i0].DirEntries = append(dirs0[i0].DirEntries, DirEntry{NameOrId: uint32(id)}) + dirs0[i0].Dirs = append(dirs0[i0].Dirs, Dir{ + NumberOfIdEntries: 1, + DirEntries: DirEntries{LANG_ENTRY}, + }) + dirs0[i0].NumberOfIdEntries++ + + // calculate preceding DirEntry leaves, to find new index in Data & DataEntries + n := 0 + for _, dir0 := range dirs0[:i0+1] { + n += len(dir0.DirEntries) //NOTE: assuming 1 language here; TODO: dwell deeper if more langs added + } + n-- + + // insert new data in correct place + coff.DataEntries = append(coff.DataEntries[:n], append([]DataEntry{{Size1: uint32(data.Size())}}, coff.DataEntries[n:]...)...) + coff.Data = append(coff.Data[:n], append([]PaddedData{pad(data)}, coff.Data[n:]...)...) +} + +func pad(data Sizer) PaddedData { + return PaddedData{ + Data: data, + Padding: make([]byte, -data.Size()&7), + } +} + +// Freeze fills in some important offsets in resulting file. +func (coff *Coff) Freeze() { + switch coff.SectionHeader32.Name { + case STRING_RSRC: + coff.freezeRSRC() + } +} + +func (coff *Coff) freezeCommon1(path string, offset, diroff uint32) (newdiroff uint32) { + switch path { + case "/Dir": + coff.SectionHeader32.PointerToRawData = offset + diroff = offset + case "/Relocations": + coff.SectionHeader32.PointerToRelocations = offset + coff.SectionHeader32.SizeOfRawData = offset - diroff + case "/Symbols": + coff.FileHeader.PointerToSymbolTable = offset + } + return diroff +} + +func freezeCommon2(v reflect.Value, offset *uint32) error { + if binutil.Plain(v.Kind()) { + *offset += uint32(binary.Size(v.Interface())) // TODO: change to v.Type().Size() ? + return nil + } + vv, ok := v.Interface().(Sizer) + if ok { + *offset += uint32(vv.Size()) + return binutil.WALK_SKIP + } + return nil +} + +func (coff *Coff) freezeRSRC() { + leafwalker := make(chan *DirEntry) + go func() { + for _, dir1 := range coff.Dir.Dirs { // resource type + for _, dir2 := range dir1.Dirs { // resource ID + for i := range dir2.DirEntries { // resource lang + leafwalker <- &dir2.DirEntries[i] + } + } + } + }() + + var offset, diroff uint32 + binutil.Walk(coff, func(v reflect.Value, path string) error { + diroff = coff.freezeCommon1(path, offset, diroff) + + RE := regexp.MustCompile + const N = `\[(\d+)\]` + m := matcher{} + switch { + case m.Find(path, RE("^/Dir/Dirs"+N+"$")): + coff.Dir.DirEntries[m[0]].OffsetToData = MASK_SUBDIRECTORY | (offset - diroff) + case m.Find(path, RE("^/Dir/Dirs"+N+"/Dirs"+N+"$")): + coff.Dir.Dirs[m[0]].DirEntries[m[1]].OffsetToData = MASK_SUBDIRECTORY | (offset - diroff) + case m.Find(path, RE("^/DataEntries"+N+"$")): + direntry := <-leafwalker + direntry.OffsetToData = offset - diroff + case m.Find(path, RE("^/DataEntries"+N+"/OffsetToData$")): + coff.Relocations[m[0]].RVA = offset - diroff + case m.Find(path, RE("^/Data"+N+"$")): + coff.DataEntries[m[0]].OffsetToData = offset - diroff + } + + return freezeCommon2(v, &offset) + }) +} + +func mustAtoi(s string) int { + i, err := strconv.Atoi(s) + if err != nil { + panic(err) + } + return i +} + +type matcher []int + +func (m *matcher) Find(s string, re *regexp.Regexp) bool { + subs := re.FindStringSubmatch(s) + if subs == nil { + return false + } + + *m = (*m)[:0] + for i := 1; i < len(subs); i++ { + *m = append(*m, mustAtoi(subs[i])) + } + return true +} diff --git a/vendor/github.com/akavel/rsrc/ico/ico.go b/vendor/github.com/akavel/rsrc/ico/ico.go new file mode 100644 index 0000000000..0d419b1272 --- /dev/null +++ b/vendor/github.com/akavel/rsrc/ico/ico.go @@ -0,0 +1,214 @@ +// Package ico describes Windows ICO file format. +package ico + +// ICO: http://msdn.microsoft.com/en-us/library/ms997538.aspx +// BMP/DIB: http://msdn.microsoft.com/en-us/library/windows/desktop/dd183562%28v=vs.85%29.aspx + +import ( + "bytes" + "encoding/binary" + "fmt" + "image" + "image/color" + "io" + "io/ioutil" + "sort" +) + +const ( + BI_RGB = 0 +) + +type ICONDIR struct { + Reserved uint16 // must be 0 + Type uint16 // Resource Type (1 for icons) + Count uint16 // How many images? +} + +type IconDirEntryCommon struct { + Width byte // Width, in pixels, of the image + Height byte // Height, in pixels, of the image + ColorCount byte // Number of colors in image (0 if >=8bpp) + Reserved byte // Reserved (must be 0) + Planes uint16 // Color Planes + BitCount uint16 // Bits per pixel + BytesInRes uint32 // How many bytes in this resource? +} + +type ICONDIRENTRY struct { + IconDirEntryCommon + ImageOffset uint32 // Where in the file is this image? [from beginning of file] +} + +type BITMAPINFOHEADER struct { + Size uint32 + Width int32 + Height int32 // NOTE: "represents the combined height of the XOR and AND masks. Remember to divide this number by two before using it to perform calculations for either of the XOR or AND masks." + Planes uint16 // [BMP/DIB]: "is always 1" + BitCount uint16 + Compression uint32 // for ico = 0 + SizeImage uint32 + XPelsPerMeter int32 // for ico = 0 + YPelsPerMeter int32 // for ico = 0 + ClrUsed uint32 // for ico = 0 + ClrImportant uint32 // for ico = 0 +} + +type RGBQUAD struct { + Blue byte + Green byte + Red byte + Reserved byte // must be 0 +} + +func skip(r io.Reader, n int64) error { + _, err := io.CopyN(ioutil.Discard, r, n) + return err +} + +type icoOffset struct { + n int + offset uint32 +} + +type rawico struct { + icoinfo ICONDIRENTRY + bmpinfo *BITMAPINFOHEADER + idx int + data []byte +} + +type byOffsets []rawico + +func (o byOffsets) Len() int { return len(o) } +func (o byOffsets) Less(i, j int) bool { return o[i].icoinfo.ImageOffset < o[j].icoinfo.ImageOffset } +func (o byOffsets) Swap(i, j int) { + tmp := o[i] + o[i] = o[j] + o[j] = tmp +} + +type ICO struct { + image.Image +} + +func DecodeHeaders(r io.Reader) ([]ICONDIRENTRY, error) { + var hdr ICONDIR + err := binary.Read(r, binary.LittleEndian, &hdr) + if err != nil { + return nil, err + } + if hdr.Reserved != 0 || hdr.Type != 1 { + return nil, fmt.Errorf("bad magic number") + } + + entries := make([]ICONDIRENTRY, hdr.Count) + for i := 0; i < len(entries); i++ { + err = binary.Read(r, binary.LittleEndian, &entries[i]) + if err != nil { + return nil, err + } + } + return entries, nil +} + +// NOTE: won't succeed on files with overlapping offsets +func unused_decodeAll(r io.Reader) ([]*ICO, error) { + var hdr ICONDIR + err := binary.Read(r, binary.LittleEndian, &hdr) + if err != nil { + return nil, err + } + if hdr.Reserved != 0 || hdr.Type != 1 { + return nil, fmt.Errorf("bad magic number") + } + + raws := make([]rawico, hdr.Count) + for i := 0; i < len(raws); i++ { + err = binary.Read(r, binary.LittleEndian, &raws[i].icoinfo) + if err != nil { + return nil, err + } + raws[i].idx = i + } + + sort.Sort(byOffsets(raws)) + + offset := uint32(binary.Size(&hdr) + len(raws)*binary.Size(ICONDIRENTRY{})) + for i := 0; i < len(raws); i++ { + err = skip(r, int64(raws[i].icoinfo.ImageOffset-offset)) + if err != nil { + return nil, err + } + offset = raws[i].icoinfo.ImageOffset + + raws[i].bmpinfo = &BITMAPINFOHEADER{} + err = binary.Read(r, binary.LittleEndian, raws[i].bmpinfo) + if err != nil { + return nil, err + } + + err = skip(r, int64(raws[i].bmpinfo.Size-uint32(binary.Size(BITMAPINFOHEADER{})))) + if err != nil { + return nil, err + } + raws[i].data = make([]byte, raws[i].icoinfo.BytesInRes-raws[i].bmpinfo.Size) + _, err = io.ReadFull(r, raws[i].data) + if err != nil { + return nil, err + } + } + + icos := make([]*ICO, len(raws)) + for i := 0; i < len(raws); i++ { + fmt.Println(i) + icos[raws[i].idx], err = decode(raws[i].bmpinfo, &raws[i].icoinfo, raws[i].data) + if err != nil { + return nil, err + } + } + return icos, nil +} + +func decode(info *BITMAPINFOHEADER, icoinfo *ICONDIRENTRY, data []byte) (*ICO, error) { + if info.Compression != BI_RGB { + return nil, fmt.Errorf("ICO compression not supported (got %d)", info.Compression) + } + + //if info.ClrUsed!=0 { + // panic(info.ClrUsed) + //} + + r := bytes.NewBuffer(data) + + bottomup := info.Height > 0 + if !bottomup { + info.Height = -info.Height + } + + switch info.BitCount { + case 8: + ncol := int(icoinfo.ColorCount) + if ncol == 0 { + ncol = 256 + } + + pal := make(color.Palette, ncol) + for i := 0; i < ncol; i++ { + var rgb RGBQUAD + err := binary.Read(r, binary.LittleEndian, &rgb) + if err != nil { + return nil, err + } + pal[i] = color.NRGBA{R: rgb.Red, G: rgb.Green, B: rgb.Blue, A: 0xff} //FIXME: is Alpha ok 0xff? + } + fmt.Println(pal) + + fmt.Println(info.SizeImage, len(data)-binary.Size(RGBQUAD{})*len(pal), info.Width, info.Height) + + default: + return nil, fmt.Errorf("unsupported ICO bit depth (BitCount) %d", info.BitCount) + } + + return nil, nil +} diff --git a/vendor/github.com/josephspurrier/goversioninfo/.gitattributes b/vendor/github.com/josephspurrier/goversioninfo/.gitattributes new file mode 100644 index 0000000000..9f224172fc --- /dev/null +++ b/vendor/github.com/josephspurrier/goversioninfo/.gitattributes @@ -0,0 +1,8 @@ +*.sh text eol=lf +*.hex binary +*.rc text eol=crlf +*.manifest text eol=crlf +*.ico binary +testdata/go/*.go text eol=lf +go.mod text eol=lf +go.sum text eol=lf diff --git a/vendor/github.com/josephspurrier/goversioninfo/.gitignore b/vendor/github.com/josephspurrier/goversioninfo/.gitignore new file mode 100644 index 0000000000..b83ed98b82 --- /dev/null +++ b/vendor/github.com/josephspurrier/goversioninfo/.gitignore @@ -0,0 +1,19 @@ +# IDE Settings +.vscode/ + +# Folders +vendor/ + +# Files +cmd/goversioninfo/goversioninfo +*.exe +*.syso +versioninfo.go +/bin + +# OS Files +.DS_Store +thumbs.db + +# Environment Files +.envrc \ No newline at end of file diff --git a/vendor/github.com/josephspurrier/goversioninfo/.travis.yml b/vendor/github.com/josephspurrier/goversioninfo/.travis.yml new file mode 100644 index 0000000000..d4173b8923 --- /dev/null +++ b/vendor/github.com/josephspurrier/goversioninfo/.travis.yml @@ -0,0 +1,23 @@ +os: windows +sudo: false +language: go +go: + - "1.12" + - "1.13" + - "1.14" +env: + - GO111MODULE=on +before_install: + - go get github.com/axw/gocov/gocov + - go get github.com/mattn/goveralls + - go get golang.org/x/tools/cmd/cover +script: + # Output directory. + - pwd + # Install binary. + - go install github.com/$TRAVIS_REPO_SLUG/cmd/goversioninfo + # Test building 32 and 64 on Windows. + - bash $TRAVIS_BUILD_DIR/testdata/bash/build.sh + # Run tests and send coverage info. + - cd $TRAVIS_BUILD_DIR + - $GOPATH/bin/goveralls -service=travis-ci diff --git a/vendor/github.com/josephspurrier/goversioninfo/LICENSE b/vendor/github.com/josephspurrier/goversioninfo/LICENSE new file mode 100644 index 0000000000..85f6e7e913 --- /dev/null +++ b/vendor/github.com/josephspurrier/goversioninfo/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Joseph Spurrier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/josephspurrier/goversioninfo/Makefile b/vendor/github.com/josephspurrier/goversioninfo/Makefile new file mode 100644 index 0000000000..bbaa6729e2 --- /dev/null +++ b/vendor/github.com/josephspurrier/goversioninfo/Makefile @@ -0,0 +1,26 @@ +# This Makefile is an easy way to run common operations. +# Execute commands this: +# * make test-go +# * make test-integration +# +# Tip: Each command is run on its own line so you can't CD unless you +# connect commands together using operators. See examples: +# A; B # Run A and then B, regardless of success of A +# A && B # Run B if and only if A succeeded +# A || B # Run B if and only if A failed +# A & # Run A in background. +# Source: https://askubuntu.com/a/539293 +# +# Tip: Use $(shell app param) syntax when expanding a shell return value. + +.PHONY: test-go +test-go: + # Run the Go tests. + go test ./... + +.PHONY: test-integration +test-integration: + # Build the application. + mkdir -p bin && go build -o bin/goversioninfo cmd/goversioninfo/main.go + # Test the application. + PATH="${PATH}:$(shell pwd)/bin" ./testdata/bash/build.sh \ No newline at end of file diff --git a/vendor/github.com/josephspurrier/goversioninfo/README.md b/vendor/github.com/josephspurrier/goversioninfo/README.md new file mode 100644 index 0000000000..b70c1e6396 --- /dev/null +++ b/vendor/github.com/josephspurrier/goversioninfo/README.md @@ -0,0 +1,127 @@ +GoVersionInfo +========== + +[![Go Report Card](https://goreportcard.com/badge/github.com/josephspurrier/goversioninfo)](https://goreportcard.com/report/github.com/josephspurrier/goversioninfo) [![Build Status](https://travis-ci.org/josephspurrier/goversioninfo.svg)](https://travis-ci.org/josephspurrier/goversioninfo) [![Coverage Status](https://coveralls.io/repos/josephspurrier/goversioninfo/badge.svg)](https://coveralls.io/r/josephspurrier/goversioninfo) [![GoDoc](https://godoc.org/github.com/josephspurrier/goversioninfo?status.svg)](https://godoc.org/github.com/josephspurrier/goversioninfo) + +Microsoft Windows File Properties/Version Info and Icon Resource Generator for the Go Language + +Package creates a syso file which contains Microsoft Windows Version Information and an optional icon. When you run "go build", Go will embed the version information and an optional icon and an optional manifest in the executable. Go will automatically use the syso file if it's in the same directory as the main() function. + +Example of the file properties you can set using this package: + +![Image of File Properties](https://cloud.githubusercontent.com/assets/2394539/12073634/0b32cb04-b0f6-11e5-9d8e-f9923ca554cf.jpg) + +## Usage + +To install, run the following command: +~~~ +go get github.com/josephspurrier/goversioninfo/cmd/goversioninfo +~~~ + +Copy testdata/resource/versioninfo.json into your working directory and then modify the file with your own settings. + +Add a similar text to the top of your Go source code (-icon and -manifest are optional, but can also be specified in the versioninfo.json file): +~~~ go +//go:generate goversioninfo -icon=testdata/resource/icon.ico -manifest=testdata/resource/goversioninfo.exe.manifest +~~~ + +Run the Go commands in this order so goversioninfo will create a file called resource.syso in the same directory as the Go source code. +~~~ +go generate +go build +~~~ + +## Command-Line Flags + +Complete list of the flags for goversioninfo: + +~~~ + -charset=0: charset ID + -comment="": StringFileInfo.Comments + -company="": StringFileInfo.CompanyName + -copyright="": StringFileInfo.LegalCopyright + -description="": StringFileInfo.FileDescription + -example=false: dump out an example versioninfo.json to stdout + -file-version="": StringFileInfo.FileVersion + -icon="": icon file name + -internal-name="": StringFileInfo.InternalName + -manifest="": manifest file name + -skip-versioninfo=false: skip version info reading on true, allows setting just icon + -o="resource.syso": output file name + -gofile="": Go output file name (optional) - generates a Go file to access version information internally + -gofilepackage="main": Go output package name (optional, requires parameter: 'gofile') + -platform-specific=false: output i386 and amd64 named resource.syso, ignores -o + -original-name="": StringFileInfo.OriginalFilename + -private-build="": StringFileInfo.PrivateBuild + -product-name="": StringFileInfo.ProductName + -product-version="": StringFileInfo.ProductVersion + -special-build="": StringFileInfo.SpecialBuild + -trademark="": StringFileInfo.LegalTrademarks + -translation=0: translation ID + -64:false: generate 64-bit binaries on true + -arm:false: generate ARM binaries on true + -ver-major=-1: FileVersion.Major + -ver-minor=-1: FileVersion.Minor + -ver-patch=-1: FileVersion.Patch + -ver-build=-1: FileVersion.Build + -product-ver-major=-1: ProductVersion.Major + -product-ver-minor=-1: ProductVersion.Minor + -product-ver-patch=-1: ProductVersion.Patch + -product-ver-build=-1: ProductVersion.Build +~~~ + +You can look over the Microsoft Resource Information: [VERSIONINFO resource](https://msdn.microsoft.com/en-us/library/windows/desktop/aa381058(v=vs.85).aspx) + +You can look through the Microsoft Version Information structures: [Version Information Structures](https://msdn.microsoft.com/en-us/library/windows/desktop/ff468916(v=vs.85).aspx) + +## PowerShell Differences + +In PowerShell, the version components are named differently than the fields in +the versioninfo.json file: + +``` +PowerShell: versioninfo.json: +----------- ----------------- +FileMajorPart = FileVersion.Major +FileMinorPart = FileVersion.Minor +FileBuildPart = FileVersion.Patch +FilePrivatePart = FileVersion.Build +ProductMajorPart = ProductVersion.Major +ProductMinorPart = ProductVersion.Minor +ProductBuildPart = ProductVersion.Patch +ProductPrivatePart = ProductVersion.Build + +``` + +If you find any other differences, let me know. + +## Alternatives to this Tool + +You can also use [windres](https://sourceware.org/binutils/docs/binutils/windres.html) to create the syso file. The windres executable is available in either [MinGW](http://www.mingw.org/) or [tdm-gcc](http://tdm-gcc.tdragon.net/). + +Below is a sample batch file you can use to create a .syso file from a .rc file. There are sample .rc files in the testdata/rc folder. + +~~~ +@ECHO OFF + +SET PATH=C:\TDM-GCC-64\bin;%PATH% +REM SET PATH=C:\mingw64\bin;%PATH% + +windres -i testdata/rc/versioninfo.rc -O coff -o versioninfo.syso + +PAUSE +~~~ + +The information on how to create a .rc file is available [here](https://msdn.microsoft.com/en-us/library/windows/desktop/aa381043(v=vs.85).aspx). You can use the testdata/rc/versioninfo.rc file to create a .syso file that contains version info, icon, and manifest. + +## Issues + +The majority of the code for the creation of the syso file is from this package: [https://github.com/akavel/rsrc](https://github.com/akavel/rsrc) + +There is an [issue](https://github.com/akavel/rsrc/issues/12) with adding the icon resource that prevents your application from being compressed or modified with a resource editor. Please use with caution. + +## Major Contributions + +Thanks to [Tamás Gulácsi](https://github.com/tgulacsi) for his superb code additions, refactoring, and optimization to make this a solid package. + +Thanks to [Mateusz Czaplinski](https://github.com/akavel/rsrc) for his embedded binary resource package with icon and manifest functionality. diff --git a/vendor/github.com/josephspurrier/goversioninfo/cmd/goversioninfo/main.go b/vendor/github.com/josephspurrier/goversioninfo/cmd/goversioninfo/main.go new file mode 100644 index 0000000000..74e30dfe67 --- /dev/null +++ b/vendor/github.com/josephspurrier/goversioninfo/cmd/goversioninfo/main.go @@ -0,0 +1,271 @@ +// Contribution by Tamás Gulácsi + +package main + +import ( + "flag" + "fmt" + "io" + "io/ioutil" + "log" + "os" + + "github.com/josephspurrier/goversioninfo" +) + +func main() { + flagExample := flag.Bool("example", false, "dump out an example versioninfo.json to stdout") + flagOut := flag.String("o", "resource.syso", "output file name") + flagGo := flag.String("gofile", "", "Go output file name (optional)") + flagPackage := flag.String("gofilepackage", "main", "Go output package name (optional, requires parameter: 'gofile')") + flagPlatformSpecific := flag.Bool("platform-specific", false, "output i386, amd64, arm and arm64 named resource.syso, ignores -o") + flagIcon := flag.String("icon", "", "icon file name") + flagManifest := flag.String("manifest", "", "manifest file name") + flagSkipVersion := flag.Bool("skip-versioninfo", false, "skip version info") + + flagComment := flag.String("comment", "", "StringFileInfo.Comments") + flagCompany := flag.String("company", "", "StringFileInfo.CompanyName") + flagDescription := flag.String("description", "", "StringFileInfo.FileDescription") + flagFileVersion := flag.String("file-version", "", "StringFileInfo.FileVersion") + flagInternalName := flag.String("internal-name", "", "StringFileInfo.InternalName") + flagCopyright := flag.String("copyright", "", "StringFileInfo.LegalCopyright") + flagTrademark := flag.String("trademark", "", "StringFileInfo.LegalTrademarks") + flagOriginalName := flag.String("original-name", "", "StringFileInfo.OriginalFilename") + flagPrivateBuild := flag.String("private-build", "", "StringFileInfo.PrivateBuild") + flagProductName := flag.String("product-name", "", "StringFileInfo.ProductName") + flagProductVersion := flag.String("product-version", "", "StringFileInfo.ProductVersion") + flagSpecialBuild := flag.String("special-build", "", "StringFileInfo.SpecialBuild") + + flagTranslation := flag.Int("translation", 0, "translation ID") + flagCharset := flag.Int("charset", 0, "charset ID") + + flag64 := flag.Bool("64", false, "generate 64-bit binaries") + flagarm := flag.Bool("arm", false, "generate arm binaries") + + flagVerMajor := flag.Int("ver-major", -1, "FileVersion.Major") + flagVerMinor := flag.Int("ver-minor", -1, "FileVersion.Minor") + flagVerPatch := flag.Int("ver-patch", -1, "FileVersion.Patch") + flagVerBuild := flag.Int("ver-build", -1, "FileVersion.Build") + + flagProductVerMajor := flag.Int("product-ver-major", -1, "ProductVersion.Major") + flagProductVerMinor := flag.Int("product-ver-minor", -1, "ProductVersion.Minor") + flagProductVerPatch := flag.Int("product-ver-patch", -1, "ProductVersion.Patch") + flagProductVerBuild := flag.Int("product-ver-build", -1, "ProductVersion.Build") + + flag.Usage = func() { + fmt.Fprintf(os.Stderr, "Usage: %s [flags] \n\nPossible flags:\n", os.Args[0]) + flag.PrintDefaults() + } + flag.Parse() + if *flagExample { + io.WriteString(os.Stdout, example) + return + } + + configFile := flag.Arg(0) + if configFile == "" { + configFile = "versioninfo.json" + } + + // Create a new container. + vi := &goversioninfo.VersionInfo{} + + if !*flagSkipVersion { + var err error + var input = io.ReadCloser(os.Stdin) + if configFile != "-" { + if input, err = os.Open(configFile); err != nil { + log.Printf("Cannot open %q: %v", configFile, err) + os.Exit(1) + } + } + + // Read the config file. + jsonBytes, err := ioutil.ReadAll(input) + input.Close() + if err != nil { + log.Printf("Error reading %q: %v", configFile, err) + os.Exit(1) + } + + // Parse the config. + if err := vi.ParseJSON(jsonBytes); err != nil { + log.Printf("Could not parse the .json file: %v", err) + os.Exit(2) + } + + } + + // Override from flags. + if *flagIcon != "" { + vi.IconPath = *flagIcon + } + if *flagManifest != "" { + vi.ManifestPath = *flagManifest + } + if *flagComment != "" { + vi.StringFileInfo.Comments = *flagComment + } + if *flagCompany != "" { + vi.StringFileInfo.CompanyName = *flagCompany + } + if *flagDescription != "" { + vi.StringFileInfo.FileDescription = *flagDescription + } + if *flagFileVersion != "" { + vi.StringFileInfo.FileVersion = *flagFileVersion + } + if *flagInternalName != "" { + vi.StringFileInfo.InternalName = *flagInternalName + } + if *flagCopyright != "" { + vi.StringFileInfo.LegalCopyright = *flagCopyright + } + if *flagTrademark != "" { + vi.StringFileInfo.LegalTrademarks = *flagTrademark + } + if *flagOriginalName != "" { + vi.StringFileInfo.OriginalFilename = *flagOriginalName + } + if *flagPrivateBuild != "" { + vi.StringFileInfo.PrivateBuild = *flagPrivateBuild + } + if *flagProductName != "" { + vi.StringFileInfo.ProductName = *flagProductName + } + if *flagProductVersion != "" { + vi.StringFileInfo.ProductVersion = *flagProductVersion + } + if *flagSpecialBuild != "" { + vi.StringFileInfo.SpecialBuild = *flagSpecialBuild + } + + if *flagTranslation > 0 { + vi.VarFileInfo.Translation.LangID = goversioninfo.LangID(*flagTranslation) + } + if *flagCharset > 0 { + vi.VarFileInfo.Translation.CharsetID = goversioninfo.CharsetID(*flagCharset) + } + + // File Version flags. + if *flagVerMajor >= 0 { + vi.FixedFileInfo.FileVersion.Major = *flagVerMajor + } + if *flagVerMinor >= 0 { + vi.FixedFileInfo.FileVersion.Minor = *flagVerMinor + } + if *flagVerPatch >= 0 { + vi.FixedFileInfo.FileVersion.Patch = *flagVerPatch + } + if *flagVerBuild >= 0 { + vi.FixedFileInfo.FileVersion.Build = *flagVerBuild + } + + // Product Version flags. + if *flagProductVerMajor >= 0 { + vi.FixedFileInfo.ProductVersion.Major = *flagProductVerMajor + } + if *flagProductVerMinor >= 0 { + vi.FixedFileInfo.ProductVersion.Minor = *flagProductVerMinor + } + if *flagProductVerPatch >= 0 { + vi.FixedFileInfo.ProductVersion.Patch = *flagProductVerPatch + } + if *flagProductVerBuild >= 0 { + vi.FixedFileInfo.ProductVersion.Build = *flagProductVerBuild + } + + // Fill the structures with config data. + vi.Build() + + // Write the data to a buffer. + vi.Walk() + + // If the flag is set, then generate the optional Go file. + if *flagGo != "" { + vi.WriteGo(*flagGo, *flagPackage) + } + + // List of the architectures to output. + var archs []string + + // If platform specific, then output all the architectures for Windows. + if flagPlatformSpecific != nil && *flagPlatformSpecific { + archs = []string{"386", "amd64", "arm", "arm64"} + } else { + // Set the architecture, defaulted to 386(32-bit x86). + archs = []string{"386"} // 386(32-bit x86) + if flagarm != nil && *flagarm { + if flag64 != nil && *flag64 { + archs = []string{"arm64"} // arm64(64-bit arm64) + } else { + archs = []string{"arm"} // arm(32-bit arm) + } + } else { + if flag64 != nil && *flag64 { + archs = []string{"amd64"} // amd64(64-bit x86_64) + } + } + + } + + // Loop through each artchitecture. + for _, item := range archs { + // Create the file using the -o argument. + fileout := *flagOut + + // If the number of architectures is greater than one, then don't use + // the -o argument. + if len(archs) > 1 { + fileout = fmt.Sprintf("resource_windows_%v.syso", item) + } + + // Create the file for the specified architecture. + if err := vi.WriteSyso(fileout, item); err != nil { + log.Printf("Error writing syso: %v", err) + os.Exit(3) + } + } +} + +const example = `{ + "FixedFileInfo": { + "FileVersion": { + "Major": 6, + "Minor": 3, + "Patch": 9600, + "Build": 17284 + }, + "ProductVersion": { + "Major": 6, + "Minor": 3, + "Patch": 9600, + "Build": 17284 + }, + "FileFlagsMask": "3f", + "FileFlags ": "00", + "FileOS": "040004", + "FileType": "01", + "FileSubType": "00" + }, + "StringFileInfo": { + "Comments": "", + "CompanyName": "Company, Inc.", + "FileDescription": "", + "FileVersion": "6.3.9600.17284 (aaa.140822-1915)", + "InternalName": "goversioninfo", + "LegalCopyright": "© Author. Licensed under MIT.", + "LegalTrademarks": "", + "OriginalFilename": "goversioninfo", + "PrivateBuild": "", + "ProductName": "Go Version Info", + "ProductVersion": "6.3.9600.17284", + "SpecialBuild": "" + }, + "VarFileInfo": { + "Translation": { + "LangID": "0409", + "CharsetID": "04B0" + } + } +}` diff --git a/vendor/github.com/josephspurrier/goversioninfo/goversioninfo.go b/vendor/github.com/josephspurrier/goversioninfo/goversioninfo.go new file mode 100644 index 0000000000..42701c0180 --- /dev/null +++ b/vendor/github.com/josephspurrier/goversioninfo/goversioninfo.go @@ -0,0 +1,329 @@ +// Package goversioninfo creates a syso file which contains Microsoft Version Information and an optional icon. +package goversioninfo + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "log" + "os" + "reflect" + "strconv" + "strings" + + "github.com/akavel/rsrc/binutil" + "github.com/akavel/rsrc/coff" +) + +// ***************************************************************************** +// JSON and Config +// ***************************************************************************** + +// ParseJSON parses the given bytes as a VersionInfo JSON. +func (vi *VersionInfo) ParseJSON(jsonBytes []byte) error { + return json.Unmarshal([]byte(jsonBytes), &vi) +} + +// VersionInfo data container +type VersionInfo struct { + FixedFileInfo `json:"FixedFileInfo"` + StringFileInfo `json:"StringFileInfo"` + VarFileInfo `json:"VarFileInfo"` + Timestamp bool + Buffer bytes.Buffer + Structure VSVersionInfo + IconPath string `json:"IconPath"` + ManifestPath string `json:"ManifestPath"` +} + +// Translation with langid and charsetid. +type Translation struct { + LangID `json:"LangID"` + CharsetID `json:"CharsetID"` +} + +// FileVersion with 3 parts. +type FileVersion struct { + Major int + Minor int + Patch int + Build int +} + +// FixedFileInfo contains file characteristics - leave most of them at the defaults. +type FixedFileInfo struct { + FileVersion `json:"FileVersion"` + ProductVersion FileVersion + FileFlagsMask string + FileFlags string + FileOS string + FileType string + FileSubType string +} + +// VarFileInfo is the translation container. +type VarFileInfo struct { + Translation `json:"Translation"` +} + +// StringFileInfo is what you want to change. +type StringFileInfo struct { + Comments string + CompanyName string + FileDescription string + FileVersion string + InternalName string + LegalCopyright string + LegalTrademarks string + OriginalFilename string + PrivateBuild string + ProductName string + ProductVersion string + SpecialBuild string +} + +// ***************************************************************************** +// Helpers +// ***************************************************************************** + +// SizedReader is a *bytes.Buffer. +type SizedReader struct { + *bytes.Buffer +} + +// Size returns the length of the buffer. +func (s SizedReader) Size() int64 { + return int64(s.Buffer.Len()) +} + +func str2Uint32(s string) uint32 { + if s == "" { + return 0 + } + u, err := strconv.ParseUint(s, 16, 32) + if err != nil { + log.Printf("Error parsing %q as uint32: %v", s, err) + return 0 + } + + return uint32(u) +} + +func padString(s string, zeros int) []byte { + b := make([]byte, 0, len([]rune(s))*2) + for _, x := range s { + tt := int32(x) + + b = append(b, byte(tt)) + if tt > 255 { + tt = tt >> 8 + b = append(b, byte(tt)) + } else { + b = append(b, byte(0)) + } + } + + for i := 0; i < zeros; i++ { + b = append(b, 0x00) + } + + return b +} + +func padBytes(i int) []byte { + return make([]byte, i) +} + +func (f FileVersion) getVersionHighString() string { + return fmt.Sprintf("%04x%04x", f.Major, f.Minor) +} + +func (f FileVersion) getVersionLowString() string { + return fmt.Sprintf("%04x%04x", f.Patch, f.Build) +} + +// GetVersionString returns a string representation of the version +func (f FileVersion) GetVersionString() string { + return fmt.Sprintf("%d.%d.%d.%d", f.Major, f.Minor, f.Patch, f.Build) +} + +func (t Translation) getTranslationString() string { + return fmt.Sprintf("%04X%04X", t.LangID, t.CharsetID) +} + +func (t Translation) getTranslation() string { + return fmt.Sprintf("%04x%04x", t.CharsetID, t.LangID) +} + +// ***************************************************************************** +// IO Methods +// ***************************************************************************** + +// Walk writes the data buffer with hexadecimal data from the structs +func (vi *VersionInfo) Walk() { + // Create a buffer + var b bytes.Buffer + w := binutil.Writer{W: &b} + + // Write to the buffer + binutil.Walk(vi.Structure, func(v reflect.Value, path string) error { + if binutil.Plain(v.Kind()) { + w.WriteLE(v.Interface()) + } + return nil + }) + + vi.Buffer = b +} + +// WriteSyso creates a resource file from the version info and optionally an icon. +// arch must be an architecture string accepted by coff.Arch, like "386" or "amd64" +func (vi *VersionInfo) WriteSyso(filename string, arch string) error { + + // Channel for generating IDs + newID := make(chan uint16) + go func() { + for i := uint16(1); ; i++ { + newID <- i + } + }() + + // Create a new RSRC section + rsrc := coff.NewRSRC() + + // Set the architecture + err := rsrc.Arch(arch) + if err != nil { + return err + } + + // ID 16 is for Version Information + rsrc.AddResource(16, 1, SizedReader{bytes.NewBuffer(vi.Buffer.Bytes())}) + + // If manifest is enabled + if vi.ManifestPath != "" { + + manifest, err := binutil.SizedOpen(vi.ManifestPath) + if err != nil { + return err + } + defer manifest.Close() + + id := <-newID + rsrc.AddResource(rtManifest, id, manifest) + } + + // If icon is enabled + if vi.IconPath != "" { + if err := addIcon(rsrc, vi.IconPath, newID); err != nil { + return err + } + } + + rsrc.Freeze() + + // Write to file + return writeCoff(rsrc, filename) +} + +// WriteHex creates a hex file for debugging version info +func (vi *VersionInfo) WriteHex(filename string) error { + return ioutil.WriteFile(filename, vi.Buffer.Bytes(), 0655) +} + +// WriteGo creates a Go file that contains the version info so you can access +// it in the application +func (vi *VersionInfo) WriteGo(filename, packageName string) error { + if len(packageName) == 0 { + packageName = "main" + } + + out, err := os.Create(filename) + if err != nil { + return err + } + + ffib, err := json.MarshalIndent(vi.FixedFileInfo, "\t", "\t") + if err != nil { + return err + } + + sfib, err := json.MarshalIndent(vi.StringFileInfo, "\t", "\t") + if err != nil { + return err + } + + vfib, err := json.MarshalIndent(vi.VarFileInfo, "\t", "\t") + if err != nil { + return err + } + + replace := "`\" + \"`\" + \"`" + str := "`{\n\t" + str += `"FixedFileInfo":` + str += strings.Replace(string(ffib), "`", replace, -1) + str += ",\n\t" + str += `"StringFileInfo":` + str += strings.Replace(string(sfib), "`", replace, -1) + str += ",\n\t" + str += `"VarFileInfo":` + str += strings.Replace(string(vfib), "`", replace, -1) + str += "\n" + str += "}`" + fmt.Fprintf(out, `// Auto-generated file by goversioninfo. Do not edit. +package %v + +import ( + "encoding/json" + + "github.com/josephspurrier/goversioninfo" +) + +func unmarshalGoVersionInfo(b []byte) goversioninfo.VersionInfo { + vi := goversioninfo.VersionInfo{} + json.Unmarshal(b, &vi) + return vi +} + +var versionInfo = unmarshalGoVersionInfo([]byte(%v)) +`, packageName, string(str)) + + return nil +} + +func writeCoff(coff *coff.Coff, fnameout string) error { + out, err := os.Create(fnameout) + if err != nil { + return err + } + if err = writeCoffTo(out, coff); err != nil { + return fmt.Errorf("error writing %q: %v", fnameout, err) + } + return nil +} + +func writeCoffTo(w io.WriteCloser, coff *coff.Coff) error { + bw := binutil.Writer{W: w} + + // write the resulting file to disk + binutil.Walk(coff, func(v reflect.Value, path string) error { + if binutil.Plain(v.Kind()) { + bw.WriteLE(v.Interface()) + return nil + } + vv, ok := v.Interface().(binutil.SizedReader) + if ok { + bw.WriteFromSized(vv) + return binutil.WALK_SKIP + } + return nil + }) + + err := bw.Err + if closeErr := w.Close(); closeErr != nil && err == nil { + err = closeErr + } + return err +} diff --git a/vendor/github.com/josephspurrier/goversioninfo/icon.go b/vendor/github.com/josephspurrier/goversioninfo/icon.go new file mode 100644 index 0000000000..87e27b71ba --- /dev/null +++ b/vendor/github.com/josephspurrier/goversioninfo/icon.go @@ -0,0 +1,103 @@ +package goversioninfo + +import ( + "bytes" + "encoding/binary" + "os" + + "github.com/akavel/rsrc/coff" + "github.com/akavel/rsrc/ico" +) + +// ***************************************************************************** +/* +Code from https://github.com/akavel/rsrc + +The MIT License (MIT) + +Copyright (c) 2013-2014 The rsrc Authors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +// ***************************************************************************** + +const ( + rtIcon = coff.RT_ICON + rtGroupIcon = coff.RT_GROUP_ICON + rtManifest = coff.RT_MANIFEST +) + +// on storing icons, see: http://blogs.msdn.com/b/oldnewthing/archive/2012/07/20/10331787.aspx +type gRPICONDIR struct { + ico.ICONDIR + Entries []gRPICONDIRENTRY +} + +func (group gRPICONDIR) Size() int64 { + return int64(binary.Size(group.ICONDIR) + len(group.Entries)*binary.Size(group.Entries[0])) +} + +type gRPICONDIRENTRY struct { + ico.IconDirEntryCommon + ID uint16 +} + +func addIcon(coff *coff.Coff, fname string, newID <-chan uint16) error { + f, err := os.Open(fname) + if err != nil { + return err + } + defer f.Close() + + icons, err := ico.DecodeHeaders(f) + if err != nil { + return err + } + + if len(icons) > 0 { + // RT_ICONs + group := gRPICONDIR{ICONDIR: ico.ICONDIR{ + Reserved: 0, // magic num. + Type: 1, // magic num. + Count: uint16(len(icons)), + }} + gid := <-newID + for _, icon := range icons { + id := <-newID + buff, err := bufferIcon(f, int64(icon.ImageOffset), int(icon.BytesInRes)) + if err != nil { + return err + } + coff.AddResource(rtIcon, id, buff) + group.Entries = append(group.Entries, gRPICONDIRENTRY{IconDirEntryCommon: icon.IconDirEntryCommon, ID: id}) + } + coff.AddResource(rtGroupIcon, gid, group) + } + + return nil +} + +func bufferIcon(f *os.File, offset int64, size int) (*bytes.Reader, error) { + data := make([]byte, size) + _, err := f.ReadAt(data, offset) + if err != nil { + return nil, err + } + return bytes.NewReader(data), nil +} diff --git a/vendor/github.com/josephspurrier/goversioninfo/lang_cs.go b/vendor/github.com/josephspurrier/goversioninfo/lang_cs.go new file mode 100644 index 0000000000..554c9fbf50 --- /dev/null +++ b/vendor/github.com/josephspurrier/goversioninfo/lang_cs.go @@ -0,0 +1,131 @@ +// Contribution by Tamás Gulácsi + +package goversioninfo + +import ( + "encoding/json" + "strconv" +) + +// CharsetID must use be a character-set identifier from: +// https://msdn.microsoft.com/en-us/library/windows/desktop/aa381058(v=vs.85).aspx#charsetID +type CharsetID uint16 + +// CharsetID constants +const ( + Cs7ASCII = CharsetID(0) // Cs7ASCII: 0 0000 7-bit ASCII + CsJIS = CharsetID(932) // CsJIS: 932 03A4 Japan (Shift ? JIS X-0208) + CsKSC = CharsetID(949) // CsKSC: 949 03B5 Korea (Shift ? KSC 5601) + CsBig5 = CharsetID(950) // CsBig5: 950 03B6 Taiwan (Big5) + CsUnicode = CharsetID(1200) // CsUnicode: 1200 04B0 Unicode + CsLatin2 = CharsetID(1250) // CsLatin2: 1250 04E2 Latin-2 (Eastern European) + CsCyrillic = CharsetID(1251) // CsCyrillic: 1251 04E3 Cyrillic + CsMultilingual = CharsetID(1252) // CsMultilingual: 1252 04E4 Multilingual + CsGreek = CharsetID(1253) // CsGreek: 1253 04E5 Greek + CsTurkish = CharsetID(1254) // CsTurkish: 1254 04E6 Turkish + CsHebrew = CharsetID(1255) // CsHebrew: 1255 04E7 Hebrew + CsArabic = CharsetID(1256) // CsArabic: 1256 04E8 Arabic +) + +// UnmarshalJSON converts the string to a CharsetID +func (cs *CharsetID) UnmarshalJSON(p []byte) error { + if len(p) == 0 { + return nil + } + if p[0] != '"' { + var u uint16 + if err := json.Unmarshal(p, &u); err != nil { + return err + } + *cs = CharsetID(u) + return nil + } + var s string + if err := json.Unmarshal(p, &s); err != nil { + return err + } + u, err := strconv.ParseUint(s, 16, 16) + if err != nil { + return err + } + *cs = CharsetID(u) + return nil +} + +// LangID must use be a character-set identifier from: +// https://msdn.microsoft.com/en-us/library/windows/desktop/aa381058(v=vs.85).aspx#langID +type LangID uint16 + +// UnmarshalJSON converts the string to a LangID +func (lng *LangID) UnmarshalJSON(p []byte) error { + if len(p) == 0 { + return nil + } + if p[0] != '"' { + var u uint16 + if err := json.Unmarshal(p, &u); err != nil { + return err + } + *lng = LangID(u) + return nil + } + var s string + if err := json.Unmarshal(p, &s); err != nil { + return err + } + u, err := strconv.ParseUint(s, 16, 16) + if err != nil { + return err + } + *lng = LangID(u) + return nil +} + +// LangID constants +const ( + LngArabic = LangID(0x0401) // LngArabic: 0x0401 Arabic + LngBulgarian = LangID(0x0402) // LngBulgarian: 0x0402 Bulgarian + LngCatalan = LangID(0x0403) // LngCatalan: 0x0403 Catalan + LngTraditionalChinese = LangID(0x0404) // LngTraditionalChinese: 0x0404 Traditional Chinese + LngCzech = LangID(0x0405) // LngCzech: 0x0405 Czech + LngDanish = LangID(0x0406) // LngDanish: 0x0406 Danish + LngGerman = LangID(0x0407) // LngGerman: 0x0407 German + LngGreek = LangID(0x0408) // LngGreek: 0x0408 Greek + LngUSEnglish = LangID(0x0409) // LngUSEnglish: 0x0409 U.S. English + LngCastilianSpanish = LangID(0x040A) // LngCastilianSpanish: 0x040A Castilian Spanish + LngFinnish = LangID(0x040B) // LngFinnish: 0x040B Finnish + LngFrench = LangID(0x040C) // LngFrench: 0x040C French + LngHebrew = LangID(0x040D) // LngHebrew: 0x040D Hebrew + LngHungarian = LangID(0x040E) // LngHungarian: 0x040E Hungarian + LngIcelandic = LangID(0x040F) // LngIcelandic: 0x040F Icelandic + LngItalian = LangID(0x0410) // LngItalian: 0x0410 Italian + LngJapanese = LangID(0x0411) // LngJapanese: 0x0411 Japanese + LngKorean = LangID(0x0412) // LngKorean: 0x0412 Korean + LngDutch = LangID(0x0413) // LngDutch: 0x0413 Dutch + LngNorwegianBokmal = LangID(0x0414) // LngNorwegianBokmal: 0x0414 Norwegian ? Bokmal + LngPolish = LangID(0x0415) // LngPolish: 0x0415 Polish + LngPortugueseBrazil = LangID(0x0416) // LngPortugueseBrazil: 0x0416 Portuguese (Brazil) + LngRhaetoRomanic = LangID(0x0417) // LngRhaetoRomanic: 0x0417 Rhaeto-Romanic + LngRomanian = LangID(0x0418) // LngRomanian: 0x0418 Romanian + LngRussian = LangID(0x0419) // LngRussian: 0x0419 Russian + LngCroatoSerbianLatin = LangID(0x041A) // LngCroatoSerbianLatin: 0x041A Croato-Serbian (Latin) + LngSlovak = LangID(0x041B) // LngSlovak: 0x041B Slovak + LngAlbanian = LangID(0x041C) // LngAlbanian: 0x041C Albanian + LngSwedish = LangID(0x041D) // LngSwedish: 0x041D Swedish + LngThai = LangID(0x041E) // LngThai: 0x041E Thai + LngTurkish = LangID(0x041F) // LngTurkish: 0x041F Turkish + LngUrdu = LangID(0x0420) // LngUrdu: 0x0420 Urdu + LngBahasa = LangID(0x0421) // LngBahasa: 0x0421 Bahasa + LngSimplifiedChinese = LangID(0x0804) // LngSimplifiedChinese: 0x0804 Simplified Chinese + LngSwissGerman = LangID(0x0807) // LngSwiss German: 0x0807 Swiss German + LngUKEnglish = LangID(0x0809) // LngUKEnglish: 0x0809 U.K. English + LngSpanishMexico = LangID(0x080A) // LngSpanishMexico: 0x080A Spanish (Mexico) + LngBelgianFrench = LangID(0x080C) // LngBelgian French: 0x080C Belgian French + LngSwissItalian = LangID(0x0810) // LngSwiss Italian: 0x0810 Swiss Italian + LngBelgianDutch = LangID(0x0813) // LngBelgian Dutch: 0x0813 Belgian Dutch + LngNorwegianNynorsk = LangID(0x0814) // LngNorwegianNynorsk: 0x0814 Norwegian ? Nynorsk + LngPortuguesePortugal = LangID(0x0816) // LngPortuguese (Portugal): 0x0816 Portuguese (Portugal) + LngSerboCroatianCyrillic = LangID(0x081A) // LngSerboCroatianCyrillic: 0x081A Serbo-Croatian (Cyrillic) + LngCanadianFrench = LangID(0x0C0C) // LngCanadian French: 0x0C0C Canadian French + LngSwissFrench = LangID(0x100C) // LngSwiss French: 0x100C Swiss French +) diff --git a/vendor/github.com/josephspurrier/goversioninfo/structbuild.go b/vendor/github.com/josephspurrier/goversioninfo/structbuild.go new file mode 100644 index 0000000000..e5f9d8033a --- /dev/null +++ b/vendor/github.com/josephspurrier/goversioninfo/structbuild.go @@ -0,0 +1,330 @@ +package goversioninfo + +import ( + "reflect" +) + +// ***************************************************************************** +// Structure Building +// ***************************************************************************** + +/* +Version Information Structures +http://msdn.microsoft.com/en-us/library/windows/desktop/ff468916.aspx + +VersionInfo Names +http://msdn.microsoft.com/en-us/library/windows/desktop/aa381058.aspx#string-name + +Translation: LangID +http://msdn.microsoft.com/en-us/library/windows/desktop/aa381058.aspx#langid + +Translation: CharsetID +http://msdn.microsoft.com/en-us/library/windows/desktop/aa381058.aspx#charsetid + +*/ + +// VSVersionInfo is the top level version container. +type VSVersionInfo struct { + WLength uint16 + WValueLength uint16 + WType uint16 + SzKey []byte + Padding1 []byte + Value VSFixedFileInfo + Padding2 []byte + Children VSStringFileInfo + Children2 VSVarFileInfo +} + +// VSFixedFileInfo - most of these should be left at the defaults. +type VSFixedFileInfo struct { + DwSignature uint32 + DwStrucVersion uint32 + DwFileVersionMS uint32 + DwFileVersionLS uint32 + DwProductVersionMS uint32 + DwProductVersionLS uint32 + DwFileFlagsMask uint32 + DwFileFlags uint32 + DwFileOS uint32 + DwFileType uint32 + DwFileSubtype uint32 + DwFileDateMS uint32 + DwFileDateLS uint32 +} + +// VSStringFileInfo holds multiple collections of keys and values, +// only allows for 1 collection in this package. +type VSStringFileInfo struct { + WLength uint16 + WValueLength uint16 + WType uint16 + SzKey []byte + Padding []byte + Children VSStringTable +} + +// VSStringTable holds a collection of string keys and values. +type VSStringTable struct { + WLength uint16 + WValueLength uint16 + WType uint16 + SzKey []byte + Padding []byte + Children []VSString +} + +// VSString holds the keys and values. +type VSString struct { + WLength uint16 + WValueLength uint16 + WType uint16 + SzKey []byte + Padding []byte + Value []byte +} + +// VSVarFileInfo holds the translation collection of 1. +type VSVarFileInfo struct { + WLength uint16 + WValueLength uint16 + WType uint16 + SzKey []byte + Padding []byte + Value VSVar +} + +// VSVar holds the translation key. +type VSVar struct { + WLength uint16 + WValueLength uint16 + WType uint16 + SzKey []byte + Padding []byte + Value uint32 +} + +func buildString(i int, v reflect.Value) (VSString, bool) { + sValue := string(v.Field(i).Interface().(string)) + sName := v.Type().Field(i).Name + + ss := VSString{} + + // If the value is set + if sValue != "" { + // 0 for binary, 1 for text + ss.WType = 0x01 + + // Create key + ss.SzKey = padString(sName, 0) + + // Align to 32-bit boundary + soFar := 2 + for (len(ss.SzKey)+6+soFar)%4 != 0 { + soFar += 2 + } + ss.Padding = padBytes(soFar) + soFar += len(ss.SzKey) + + // Align zeros to 32-bit boundary + zeros := 2 + for (6+soFar+(len(padString(sValue, 0)))+zeros)%4 != 0 { + zeros += 2 + } + + // Create value + ss.Value = padString(sValue, zeros) + + // Length of text in words (2 bytes) plus zero terminate word + ss.WValueLength = uint16(len(padString(sValue, 0))/2) + 1 + + // Length of structure + //ss.WLength = 6 + uint16(soFar) + (ss.WValueLength * 2) + ss.WLength = uint16(6 + soFar + len(ss.Value)) + + return ss, true + } + + return ss, false +} + +func buildStringTable(vi *VersionInfo) VSStringTable { + st := VSStringTable{} + + // Always set to 0 + st.WValueLength = 0x00 + + // 0 for binary, 1 for text + st.WType = 0x01 + + // Language identifier and Code page + st.SzKey = padString(vi.VarFileInfo.Translation.getTranslationString(), 0) + + // Align to 32-bit boundary + soFar := 2 + for (len(st.SzKey)+6+soFar)%4 != 0 { + soFar += 2 + } + st.Padding = padBytes(soFar) + soFar += len(st.SzKey) + + // Loop through the struct fields + v := reflect.ValueOf(vi.StringFileInfo) + for i := 0; i < v.NumField(); i++ { + // If the struct is valid + if r, ok := buildString(i, v); ok { + st.Children = append(st.Children, r) + st.WLength += r.WLength + } + } + + st.WLength += 6 + uint16(soFar) + + return st +} + +func buildStringFileInfo(vi *VersionInfo) VSStringFileInfo { + sf := VSStringFileInfo{} + + // Always set to 0 + sf.WValueLength = 0x00 + + // 0 for binary, 1 for text + sf.WType = 0x01 + + sf.SzKey = padString("StringFileInfo", 0) + + // Align to 32-bit boundary + soFar := 2 + for (len(sf.SzKey)+6+soFar)%4 != 0 { + soFar += 2 + } + sf.Padding = padBytes(soFar) + soFar += len(sf.SzKey) + + // Allows for more than one string table + st := buildStringTable(vi) + sf.Children = st + + sf.WLength = 6 + uint16(soFar) + st.WLength + + return sf +} + +func buildVar(vfi VarFileInfo) VSVar { + vs := VSVar{} + + // 0 for binary, 1 for text + vs.WType = 0x00 + + // Create key + vs.SzKey = padString("Translation", 0) + + // Align to 32-bit boundary + soFar := 2 + for (len(vs.SzKey)+6+soFar)%4 != 0 { + soFar += 2 + } + vs.Padding = padBytes(soFar) + soFar += len(vs.SzKey) + + // Create value + vs.Value = str2Uint32(vfi.Translation.getTranslation()) + + // Length of text in bytes + vs.WValueLength = 4 + + // Length of structure + vs.WLength = 6 + vs.WValueLength + uint16(soFar) + + return vs +} + +func buildVarFileInfo(vfi VarFileInfo) VSVarFileInfo { + vf := VSVarFileInfo{} + + // Always set to 0 + vf.WValueLength = 0x00 + + // 0 for binary, 1 for text + vf.WType = 0x01 + + vf.SzKey = padString("VarFileInfo", 0) + + // Align to 32-bit boundary + soFar := 2 + for (len(vf.SzKey)+6+soFar)%4 != 0 { + soFar += 2 + } + vf.Padding = padBytes(soFar) + soFar += len(vf.SzKey) + + // TODO Allow for more than one var table + st := buildVar(vfi) + vf.Value = st + vf.WLength = 6 + st.WLength + uint16(soFar) + + return vf +} + +func buildFixedFileInfo(vi *VersionInfo) VSFixedFileInfo { + ff := VSFixedFileInfo{} + ff.DwSignature = 0xFEEF04BD + ff.DwStrucVersion = 0x00010000 + ff.DwFileVersionMS = str2Uint32(vi.FixedFileInfo.FileVersion.getVersionHighString()) + ff.DwFileVersionLS = str2Uint32(vi.FixedFileInfo.FileVersion.getVersionLowString()) + ff.DwProductVersionMS = str2Uint32(vi.FixedFileInfo.ProductVersion.getVersionHighString()) + ff.DwProductVersionLS = str2Uint32(vi.FixedFileInfo.ProductVersion.getVersionLowString()) + ff.DwFileFlagsMask = str2Uint32(vi.FixedFileInfo.FileFlagsMask) + ff.DwFileFlags = str2Uint32(vi.FixedFileInfo.FileFlags) + ff.DwFileOS = str2Uint32(vi.FixedFileInfo.FileOS) + ff.DwFileType = str2Uint32(vi.FixedFileInfo.FileType) + ff.DwFileSubtype = str2Uint32(vi.FixedFileInfo.FileSubType) + + // According to the spec, these should be zero...ugh + /*if vi.Timestamp { + now := syscall.NsecToFiletime(time.Now().UnixNano()) + ff.DwFileDateMS = now.HighDateTime + ff.DwFileDateLS = now.LowDateTime + }*/ + + return ff +} + +// Build fills the structs with data from the config file +func (v *VersionInfo) Build() { + vi := VSVersionInfo{} + + // 0 for binary, 1 for text + vi.WType = 0x00 + + vi.SzKey = padString("VS_VERSION_INFO", 0) + + // Align to 32-bit boundary + // 6 is for the size of WLength, WValueLength, and WType (each is 1 word or 2 bytes: FF FF) + soFar := 2 + for (len(vi.SzKey)+6+soFar)%4 != 0 { + soFar += 2 + } + vi.Padding1 = padBytes(soFar) + soFar += len(vi.SzKey) + + vi.Value = buildFixedFileInfo(v) + + // Length of VSFixedFileInfo (always the same) + vi.WValueLength = 0x34 + + // Never needs padding, not included in WLength + vi.Padding2 = []byte{} + + // Build strings + vi.Children = buildStringFileInfo(v) + + // Build translation + vi.Children2 = buildVarFileInfo(v.VarFileInfo) + + // Calculate the total size + vi.WLength += 6 + uint16(soFar) + vi.WValueLength + vi.Children.WLength + vi.Children2.WLength + + v.Structure = vi +} diff --git a/vendor/golang.org/x/sys/unix/endian_little.go b/vendor/golang.org/x/sys/unix/endian_little.go index 4362f47e2c..b0f2bc4ae3 100644 --- a/vendor/golang.org/x/sys/unix/endian_little.go +++ b/vendor/golang.org/x/sys/unix/endian_little.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // -//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh -// +build 386 amd64 amd64p32 alpha arm arm64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh +//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh +// +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go b/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go new file mode 100644 index 0000000000..28ba7b8cb7 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go @@ -0,0 +1,191 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build loong64 && linux +// +build loong64,linux + +package unix + +import "unsafe" + +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT +//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Fstat(fd int, stat *Stat_t) (err error) +//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) +//sys Fstatfs(fd int, buf *Statfs_t) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (euid int) +//sysnb Getgid() (gid int) +//sysnb Getuid() (uid int) +//sys Listen(s int, n int) (err error) +//sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + var ts *Timespec + if timeout != nil { + ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000} + } + return Pselect(nfd, r, w, e, ts, nil) +} + +//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) +//sys setfsgid(gid int) (prev int, err error) +//sys setfsuid(uid int) (prev int, err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) +//sysnb Setresuid(ruid int, euid int, suid int) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sys Shutdown(fd int, how int) (err error) +//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) + +func Stat(path string, stat *Stat_t) (err error) { + return Fstatat(AT_FDCWD, path, stat, 0) +} + +func Lchown(path string, uid int, gid int) (err error) { + return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW) +} + +func Lstat(path string, stat *Stat_t) (err error) { + return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW) +} + +//sys Statfs(path string, buf *Statfs_t) (err error) +//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) +//sys Truncate(path string, length int64) (err error) + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + return ENOSYS +} + +//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) +//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) +//sysnb setgroups(n int, list *_Gid_t) (err error) +//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) +//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) +//sysnb socket(domain int, typ int, proto int) (fd int, err error) +//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) +//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) + +//sysnb Gettimeofday(tv *Timeval) (err error) + +func setTimespec(sec, nsec int64) Timespec { + return Timespec{Sec: sec, Nsec: nsec} +} + +func setTimeval(sec, usec int64) Timeval { + return Timeval{Sec: sec, Usec: usec} +} + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + err = Prlimit(0, resource, nil, rlim) + return +} + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + err = Prlimit(0, resource, rlim, nil) + return +} + +func futimesat(dirfd int, path string, tv *[2]Timeval) (err error) { + if tv == nil { + return utimensat(dirfd, path, nil, 0) + } + + ts := []Timespec{ + NsecToTimespec(TimevalToNsec(tv[0])), + NsecToTimespec(TimevalToNsec(tv[1])), + } + return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) +} + +func Time(t *Time_t) (Time_t, error) { + var tv Timeval + err := Gettimeofday(&tv) + if err != nil { + return 0, err + } + if t != nil { + *t = Time_t(tv.Sec) + } + return Time_t(tv.Sec), nil +} + +func Utime(path string, buf *Utimbuf) error { + tv := []Timeval{ + {Sec: buf.Actime}, + {Sec: buf.Modtime}, + } + return Utimes(path, tv) +} + +func utimes(path string, tv *[2]Timeval) (err error) { + if tv == nil { + return utimensat(AT_FDCWD, path, nil, 0) + } + + ts := []Timespec{ + NsecToTimespec(TimevalToNsec(tv[0])), + NsecToTimespec(TimevalToNsec(tv[1])), + } + return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) +} + +func (r *PtraceRegs) PC() uint64 { return r.Era } + +func (r *PtraceRegs) SetPC(era uint64) { r.Era = era } + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint64(length) +} + +func (msghdr *Msghdr) SetIovlen(length int) { + msghdr.Iovlen = uint64(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint64(length) +} + +func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { + rsa.Service_name_len = uint64(length) +} + +func Pause() error { + _, err := ppoll(nil, 0, nil, nil) + return err +} + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + return Renameat2(olddirfd, oldpath, newdirfd, newpath, 0) +} + +//sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) + +func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { + cmdlineLen := len(cmdline) + if cmdlineLen > 0 { + // Account for the additional NULL byte added by + // BytePtrFromString in kexecFileLoad. The kexec_file_load + // syscall expects a NULL-terminated string. + cmdlineLen++ + } + return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index 3de79fa257..c0a43f8ba6 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -1310,6 +1310,7 @@ const ( KEXEC_ARCH_ARM = 0x280000 KEXEC_ARCH_DEFAULT = 0x0 KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_LOONGARCH = 0x1020000 KEXEC_ARCH_MASK = 0xffff0000 KEXEC_ARCH_MIPS = 0x80000 KEXEC_ARCH_MIPS_LE = 0xa0000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go new file mode 100644 index 0000000000..ebc5f3218e --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -0,0 +1,818 @@ +// mkerrors.sh -Wall -Werror -static -I/tmp/include +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build loong64 && linux +// +build loong64,linux + +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go + +package unix + +import "syscall" + +const ( + B1000000 = 0x1008 + B115200 = 0x1002 + B1152000 = 0x1009 + B1500000 = 0x100a + B2000000 = 0x100b + B230400 = 0x1003 + B2500000 = 0x100c + B3000000 = 0x100d + B3500000 = 0x100e + B4000000 = 0x100f + B460800 = 0x1004 + B500000 = 0x1005 + B57600 = 0x1001 + B576000 = 0x1006 + B921600 = 0x1007 + BLKBSZGET = 0x80081270 + BLKBSZSET = 0x40081271 + BLKFLSBUF = 0x1261 + BLKFRAGET = 0x1265 + BLKFRASET = 0x1264 + BLKGETSIZE = 0x1260 + BLKGETSIZE64 = 0x80081272 + BLKPBSZGET = 0x127b + BLKRAGET = 0x1263 + BLKRASET = 0x1262 + BLKROGET = 0x125e + BLKROSET = 0x125d + BLKRRPART = 0x125f + BLKSECTGET = 0x1267 + BLKSECTSET = 0x1266 + BLKSSZGET = 0x1268 + BOTHER = 0x1000 + BS1 = 0x2000 + BSDLY = 0x2000 + CBAUD = 0x100f + CBAUDEX = 0x1000 + CIBAUD = 0x100f0000 + CLOCAL = 0x800 + CR1 = 0x200 + CR2 = 0x400 + CR3 = 0x600 + CRDLY = 0x600 + CREAD = 0x80 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIZE = 0x30 + CSTOPB = 0x40 + ECCGETLAYOUT = 0x81484d11 + ECCGETSTATS = 0x80104d12 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 + EFD_CLOEXEC = 0x80000 + EFD_NONBLOCK = 0x800 + EPOLL_CLOEXEC = 0x80000 + EXTPROC = 0x10000 + FF1 = 0x8000 + FFDLY = 0x8000 + FICLONE = 0x40049409 + FICLONERANGE = 0x4020940d + FLUSHO = 0x1000 + FPU_CTX_MAGIC = 0x46505501 + FS_IOC_ENABLE_VERITY = 0x40806685 + FS_IOC_GETFLAGS = 0x80086601 + FS_IOC_GET_ENCRYPTION_NONCE = 0x8010661b + FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615 + FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614 + FS_IOC_SETFLAGS = 0x40086602 + FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613 + F_GETLK = 0x5 + F_GETLK64 = 0x5 + F_GETOWN = 0x9 + F_RDLCK = 0x0 + F_SETLK = 0x6 + F_SETLK64 = 0x6 + F_SETLKW = 0x7 + F_SETLKW64 = 0x7 + F_SETOWN = 0x8 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HIDIOCGRAWINFO = 0x80084803 + HIDIOCGRDESC = 0x90044802 + HIDIOCGRDESCSIZE = 0x80044801 + HUPCL = 0x400 + ICANON = 0x2 + IEXTEN = 0x8000 + IN_CLOEXEC = 0x80000 + IN_NONBLOCK = 0x800 + IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 + ISIG = 0x1 + IUCLC = 0x200 + IXOFF = 0x1000 + IXON = 0x400 + LASX_CTX_MAGIC = 0x41535801 + LSX_CTX_MAGIC = 0x53580001 + MAP_ANON = 0x20 + MAP_ANONYMOUS = 0x20 + MAP_DENYWRITE = 0x800 + MAP_EXECUTABLE = 0x1000 + MAP_GROWSDOWN = 0x100 + MAP_HUGETLB = 0x40000 + MAP_LOCKED = 0x2000 + MAP_NONBLOCK = 0x10000 + MAP_NORESERVE = 0x4000 + MAP_POPULATE = 0x8000 + MAP_STACK = 0x20000 + MAP_SYNC = 0x80000 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MCL_ONFAULT = 0x4 + MEMERASE = 0x40084d02 + MEMERASE64 = 0x40104d14 + MEMGETBADBLOCK = 0x40084d0b + MEMGETINFO = 0x80204d01 + MEMGETOOBSEL = 0x80c84d0a + MEMGETREGIONCOUNT = 0x80044d07 + MEMISLOCKED = 0x80084d17 + MEMLOCK = 0x40084d05 + MEMREADOOB = 0xc0104d04 + MEMSETBADBLOCK = 0x40084d0c + MEMUNLOCK = 0x40084d06 + MEMWRITEOOB = 0xc0104d03 + MTDFILEMODE = 0x4d13 + NFDBITS = 0x40 + NLDLY = 0x100 + NOFLSH = 0x80 + NS_GET_NSTYPE = 0xb703 + NS_GET_OWNER_UID = 0xb704 + NS_GET_PARENT = 0xb702 + NS_GET_USERNS = 0xb701 + OLCUC = 0x2 + ONLCR = 0x4 + OTPERASE = 0x400c4d19 + OTPGETREGIONCOUNT = 0x40044d0e + OTPGETREGIONINFO = 0x400c4d0f + OTPLOCK = 0x800c4d10 + OTPSELECT = 0x80044d0d + O_APPEND = 0x400 + O_ASYNC = 0x2000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x40 + O_DIRECT = 0x4000 + O_DIRECTORY = 0x10000 + O_DSYNC = 0x1000 + O_EXCL = 0x80 + O_FSYNC = 0x101000 + O_LARGEFILE = 0x0 + O_NDELAY = 0x800 + O_NOATIME = 0x40000 + O_NOCTTY = 0x100 + O_NOFOLLOW = 0x20000 + O_NONBLOCK = 0x800 + O_PATH = 0x200000 + O_RSYNC = 0x101000 + O_SYNC = 0x101000 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + PARENB = 0x100 + PARODD = 0x200 + PENDIN = 0x4000 + PERF_EVENT_IOC_DISABLE = 0x2401 + PERF_EVENT_IOC_ENABLE = 0x2400 + PERF_EVENT_IOC_ID = 0x80082407 + PERF_EVENT_IOC_MODIFY_ATTRIBUTES = 0x4008240b + PERF_EVENT_IOC_PAUSE_OUTPUT = 0x40042409 + PERF_EVENT_IOC_PERIOD = 0x40082404 + PERF_EVENT_IOC_QUERY_BPF = 0xc008240a + PERF_EVENT_IOC_REFRESH = 0x2402 + PERF_EVENT_IOC_RESET = 0x2403 + PERF_EVENT_IOC_SET_BPF = 0x40042408 + PERF_EVENT_IOC_SET_FILTER = 0x40082406 + PERF_EVENT_IOC_SET_OUTPUT = 0x2405 + PPPIOCATTACH = 0x4004743d + PPPIOCATTCHAN = 0x40047438 + PPPIOCBRIDGECHAN = 0x40047435 + PPPIOCCONNECT = 0x4004743a + PPPIOCDETACH = 0x4004743c + PPPIOCDISCONN = 0x7439 + PPPIOCGASYNCMAP = 0x80047458 + PPPIOCGCHAN = 0x80047437 + PPPIOCGDEBUG = 0x80047441 + PPPIOCGFLAGS = 0x8004745a + PPPIOCGIDLE = 0x8010743f + PPPIOCGIDLE32 = 0x8008743f + PPPIOCGIDLE64 = 0x8010743f + PPPIOCGL2TPSTATS = 0x80487436 + PPPIOCGMRU = 0x80047453 + PPPIOCGRASYNCMAP = 0x80047455 + PPPIOCGUNIT = 0x80047456 + PPPIOCGXASYNCMAP = 0x80207450 + PPPIOCSACTIVE = 0x40107446 + PPPIOCSASYNCMAP = 0x40047457 + PPPIOCSCOMPRESS = 0x4010744d + PPPIOCSDEBUG = 0x40047440 + PPPIOCSFLAGS = 0x40047459 + PPPIOCSMAXCID = 0x40047451 + PPPIOCSMRRU = 0x4004743b + PPPIOCSMRU = 0x40047452 + PPPIOCSNPMODE = 0x4008744b + PPPIOCSPASS = 0x40107447 + PPPIOCSRASYNCMAP = 0x40047454 + PPPIOCSXASYNCMAP = 0x4020744f + PPPIOCUNBRIDGECHAN = 0x7434 + PPPIOCXFERUNIT = 0x744e + PR_SET_PTRACER_ANY = 0xffffffffffffffff + PTRACE_SYSEMU = 0x1f + PTRACE_SYSEMU_SINGLESTEP = 0x20 + RLIMIT_AS = 0x9 + RLIMIT_MEMLOCK = 0x8 + RLIMIT_NOFILE = 0x7 + RLIMIT_NPROC = 0x6 + RLIMIT_RSS = 0x5 + RNDADDENTROPY = 0x40085203 + RNDADDTOENTCNT = 0x40045201 + RNDCLEARPOOL = 0x5206 + RNDGETENTCNT = 0x80045200 + RNDGETPOOL = 0x80085202 + RNDRESEEDCRNG = 0x5207 + RNDZAPENTCNT = 0x5204 + RTC_AIE_OFF = 0x7002 + RTC_AIE_ON = 0x7001 + RTC_ALM_READ = 0x80247008 + RTC_ALM_SET = 0x40247007 + RTC_EPOCH_READ = 0x8008700d + RTC_EPOCH_SET = 0x4008700e + RTC_IRQP_READ = 0x8008700b + RTC_IRQP_SET = 0x4008700c + RTC_PARAM_GET = 0x40187013 + RTC_PARAM_SET = 0x40187014 + RTC_PIE_OFF = 0x7006 + RTC_PIE_ON = 0x7005 + RTC_PLL_GET = 0x80207011 + RTC_PLL_SET = 0x40207012 + RTC_RD_TIME = 0x80247009 + RTC_SET_TIME = 0x4024700a + RTC_UIE_OFF = 0x7004 + RTC_UIE_ON = 0x7003 + RTC_VL_CLR = 0x7014 + RTC_VL_READ = 0x80047013 + RTC_WIE_OFF = 0x7010 + RTC_WIE_ON = 0x700f + RTC_WKALM_RD = 0x80287010 + RTC_WKALM_SET = 0x4028700f + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPING_OPT_STATS = 0x36 + SCM_TIMESTAMPING_PKTINFO = 0x3a + SCM_TIMESTAMPNS = 0x23 + SCM_TXTIME = 0x3d + SCM_WIFI_STATUS = 0x29 + SFD_CLOEXEC = 0x80000 + SFD_NONBLOCK = 0x800 + SIOCATMARK = 0x8905 + SIOCGPGRP = 0x8904 + SIOCGSTAMPNS_NEW = 0x80108907 + SIOCGSTAMP_NEW = 0x80108906 + SIOCINQ = 0x541b + SIOCOUTQ = 0x5411 + SIOCSPGRP = 0x8902 + SOCK_CLOEXEC = 0x80000 + SOCK_DGRAM = 0x2 + SOCK_NONBLOCK = 0x800 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0x1 + SO_ACCEPTCONN = 0x1e + SO_ATTACH_BPF = 0x32 + SO_ATTACH_REUSEPORT_CBPF = 0x33 + SO_ATTACH_REUSEPORT_EBPF = 0x34 + SO_BINDTODEVICE = 0x19 + SO_BINDTOIFINDEX = 0x3e + SO_BPF_EXTENSIONS = 0x30 + SO_BROADCAST = 0x6 + SO_BSDCOMPAT = 0xe + SO_BUF_LOCK = 0x48 + SO_BUSY_POLL = 0x2e + SO_BUSY_POLL_BUDGET = 0x46 + SO_CNX_ADVICE = 0x35 + SO_COOKIE = 0x39 + SO_DETACH_REUSEPORT_BPF = 0x44 + SO_DOMAIN = 0x27 + SO_DONTROUTE = 0x5 + SO_ERROR = 0x4 + SO_INCOMING_CPU = 0x31 + SO_INCOMING_NAPI_ID = 0x38 + SO_KEEPALIVE = 0x9 + SO_LINGER = 0xd + SO_LOCK_FILTER = 0x2c + SO_MARK = 0x24 + SO_MAX_PACING_RATE = 0x2f + SO_MEMINFO = 0x37 + SO_NETNS_COOKIE = 0x47 + SO_NOFCS = 0x2b + SO_OOBINLINE = 0xa + SO_PASSCRED = 0x10 + SO_PASSSEC = 0x22 + SO_PEEK_OFF = 0x2a + SO_PEERCRED = 0x11 + SO_PEERGROUPS = 0x3b + SO_PEERSEC = 0x1f + SO_PREFER_BUSY_POLL = 0x45 + SO_PROTOCOL = 0x26 + SO_RCVBUF = 0x8 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x12 + SO_RCVTIMEO = 0x14 + SO_RCVTIMEO_NEW = 0x42 + SO_RCVTIMEO_OLD = 0x14 + SO_RESERVE_MEM = 0x49 + SO_REUSEADDR = 0x2 + SO_REUSEPORT = 0xf + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SELECT_ERR_QUEUE = 0x2d + SO_SNDBUF = 0x7 + SO_SNDBUFFORCE = 0x20 + SO_SNDLOWAT = 0x13 + SO_SNDTIMEO = 0x15 + SO_SNDTIMEO_NEW = 0x43 + SO_SNDTIMEO_OLD = 0x15 + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPING_NEW = 0x41 + SO_TIMESTAMPING_OLD = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TIMESTAMPNS_NEW = 0x40 + SO_TIMESTAMPNS_OLD = 0x23 + SO_TIMESTAMP_NEW = 0x3f + SO_TXTIME = 0x3d + SO_TYPE = 0x3 + SO_WIFI_STATUS = 0x29 + SO_ZEROCOPY = 0x3c + TAB1 = 0x800 + TAB2 = 0x1000 + TAB3 = 0x1800 + TABDLY = 0x1800 + TCFLSH = 0x540b + TCGETA = 0x5405 + TCGETS = 0x5401 + TCGETS2 = 0x802c542a + TCGETX = 0x5432 + TCSAFLUSH = 0x2 + TCSBRK = 0x5409 + TCSBRKP = 0x5425 + TCSETA = 0x5406 + TCSETAF = 0x5408 + TCSETAW = 0x5407 + TCSETS = 0x5402 + TCSETS2 = 0x402c542b + TCSETSF = 0x5404 + TCSETSF2 = 0x402c542d + TCSETSW = 0x5403 + TCSETSW2 = 0x402c542c + TCSETX = 0x5433 + TCSETXF = 0x5434 + TCSETXW = 0x5435 + TCXONC = 0x540a + TFD_CLOEXEC = 0x80000 + TFD_NONBLOCK = 0x800 + TIOCCBRK = 0x5428 + TIOCCONS = 0x541d + TIOCEXCL = 0x540c + TIOCGDEV = 0x80045432 + TIOCGETD = 0x5424 + TIOCGEXCL = 0x80045440 + TIOCGICOUNT = 0x545d + TIOCGISO7816 = 0x80285442 + TIOCGLCKTRMIOS = 0x5456 + TIOCGPGRP = 0x540f + TIOCGPKT = 0x80045438 + TIOCGPTLCK = 0x80045439 + TIOCGPTN = 0x80045430 + TIOCGPTPEER = 0x5441 + TIOCGRS485 = 0x542e + TIOCGSERIAL = 0x541e + TIOCGSID = 0x5429 + TIOCGSOFTCAR = 0x5419 + TIOCGWINSZ = 0x5413 + TIOCINQ = 0x541b + TIOCLINUX = 0x541c + TIOCMBIC = 0x5417 + TIOCMBIS = 0x5416 + TIOCMGET = 0x5415 + TIOCMIWAIT = 0x545c + TIOCMSET = 0x5418 + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x5422 + TIOCNXCL = 0x540d + TIOCOUTQ = 0x5411 + TIOCPKT = 0x5420 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x540e + TIOCSERCONFIG = 0x5453 + TIOCSERGETLSR = 0x5459 + TIOCSERGETMULTI = 0x545a + TIOCSERGSTRUCT = 0x5458 + TIOCSERGWILD = 0x5454 + TIOCSERSETMULTI = 0x545b + TIOCSERSWILD = 0x5455 + TIOCSER_TEMT = 0x1 + TIOCSETD = 0x5423 + TIOCSIG = 0x40045436 + TIOCSISO7816 = 0xc0285443 + TIOCSLCKTRMIOS = 0x5457 + TIOCSPGRP = 0x5410 + TIOCSPTLCK = 0x40045431 + TIOCSRS485 = 0x542f + TIOCSSERIAL = 0x541f + TIOCSSOFTCAR = 0x541a + TIOCSTI = 0x5412 + TIOCSWINSZ = 0x5414 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x100 + TUNATTACHFILTER = 0x401054d5 + TUNDETACHFILTER = 0x401054d6 + TUNGETDEVNETNS = 0x54e3 + TUNGETFEATURES = 0x800454cf + TUNGETFILTER = 0x801054db + TUNGETIFF = 0x800454d2 + TUNGETSNDBUF = 0x800454d3 + TUNGETVNETBE = 0x800454df + TUNGETVNETHDRSZ = 0x800454d7 + TUNGETVNETLE = 0x800454dd + TUNSETCARRIER = 0x400454e2 + TUNSETDEBUG = 0x400454c9 + TUNSETFILTEREBPF = 0x800454e1 + TUNSETGROUP = 0x400454ce + TUNSETIFF = 0x400454ca + TUNSETIFINDEX = 0x400454da + TUNSETLINK = 0x400454cd + TUNSETNOCSUM = 0x400454c8 + TUNSETOFFLOAD = 0x400454d0 + TUNSETOWNER = 0x400454cc + TUNSETPERSIST = 0x400454cb + TUNSETQUEUE = 0x400454d9 + TUNSETSNDBUF = 0x400454d4 + TUNSETSTEERINGEBPF = 0x800454e0 + TUNSETTXFILTER = 0x400454d1 + TUNSETVNETBE = 0x400454de + TUNSETVNETHDRSZ = 0x400454d8 + TUNSETVNETLE = 0x400454dc + UBI_IOCATT = 0x40186f40 + UBI_IOCDET = 0x40046f41 + UBI_IOCEBCH = 0x40044f02 + UBI_IOCEBER = 0x40044f01 + UBI_IOCEBISMAP = 0x80044f05 + UBI_IOCEBMAP = 0x40084f03 + UBI_IOCEBUNMAP = 0x40044f04 + UBI_IOCMKVOL = 0x40986f00 + UBI_IOCRMVOL = 0x40046f01 + UBI_IOCRNVOL = 0x51106f03 + UBI_IOCRPEB = 0x40046f04 + UBI_IOCRSVOL = 0x400c6f02 + UBI_IOCSETVOLPROP = 0x40104f06 + UBI_IOCSPEB = 0x40046f05 + UBI_IOCVOLCRBLK = 0x40804f07 + UBI_IOCVOLRMBLK = 0x4f08 + UBI_IOCVOLUP = 0x40084f00 + VDISCARD = 0xd + VEOF = 0x4 + VEOL = 0xb + VEOL2 = 0x10 + VMIN = 0x6 + VREPRINT = 0xc + VSTART = 0x8 + VSTOP = 0x9 + VSUSP = 0xa + VSWTC = 0x7 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe + WDIOC_GETBOOTSTATUS = 0x80045702 + WDIOC_GETPRETIMEOUT = 0x80045709 + WDIOC_GETSTATUS = 0x80045701 + WDIOC_GETSUPPORT = 0x80285700 + WDIOC_GETTEMP = 0x80045703 + WDIOC_GETTIMELEFT = 0x8004570a + WDIOC_GETTIMEOUT = 0x80045707 + WDIOC_KEEPALIVE = 0x80045705 + WDIOC_SETOPTIONS = 0x80045704 + WORDSIZE = 0x40 + XCASE = 0x4 + XTABS = 0x1800 + _HIDIOCGRAWNAME = 0x80804804 + _HIDIOCGRAWPHYS = 0x80404805 + _HIDIOCGRAWUNIQ = 0x80404808 +) + +// Errors +const ( + EADDRINUSE = syscall.Errno(0x62) + EADDRNOTAVAIL = syscall.Errno(0x63) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x61) + EALREADY = syscall.Errno(0x72) + EBADE = syscall.Errno(0x34) + EBADFD = syscall.Errno(0x4d) + EBADMSG = syscall.Errno(0x4a) + EBADR = syscall.Errno(0x35) + EBADRQC = syscall.Errno(0x38) + EBADSLT = syscall.Errno(0x39) + EBFONT = syscall.Errno(0x3b) + ECANCELED = syscall.Errno(0x7d) + ECHRNG = syscall.Errno(0x2c) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x67) + ECONNREFUSED = syscall.Errno(0x6f) + ECONNRESET = syscall.Errno(0x68) + EDEADLK = syscall.Errno(0x23) + EDEADLOCK = syscall.Errno(0x23) + EDESTADDRREQ = syscall.Errno(0x59) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x7a) + EHOSTDOWN = syscall.Errno(0x70) + EHOSTUNREACH = syscall.Errno(0x71) + EHWPOISON = syscall.Errno(0x85) + EIDRM = syscall.Errno(0x2b) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x73) + EISCONN = syscall.Errno(0x6a) + EISNAM = syscall.Errno(0x78) + EKEYEXPIRED = syscall.Errno(0x7f) + EKEYREJECTED = syscall.Errno(0x81) + EKEYREVOKED = syscall.Errno(0x80) + EL2HLT = syscall.Errno(0x33) + EL2NSYNC = syscall.Errno(0x2d) + EL3HLT = syscall.Errno(0x2e) + EL3RST = syscall.Errno(0x2f) + ELIBACC = syscall.Errno(0x4f) + ELIBBAD = syscall.Errno(0x50) + ELIBEXEC = syscall.Errno(0x53) + ELIBMAX = syscall.Errno(0x52) + ELIBSCN = syscall.Errno(0x51) + ELNRNG = syscall.Errno(0x30) + ELOOP = syscall.Errno(0x28) + EMEDIUMTYPE = syscall.Errno(0x7c) + EMSGSIZE = syscall.Errno(0x5a) + EMULTIHOP = syscall.Errno(0x48) + ENAMETOOLONG = syscall.Errno(0x24) + ENAVAIL = syscall.Errno(0x77) + ENETDOWN = syscall.Errno(0x64) + ENETRESET = syscall.Errno(0x66) + ENETUNREACH = syscall.Errno(0x65) + ENOANO = syscall.Errno(0x37) + ENOBUFS = syscall.Errno(0x69) + ENOCSI = syscall.Errno(0x32) + ENODATA = syscall.Errno(0x3d) + ENOKEY = syscall.Errno(0x7e) + ENOLCK = syscall.Errno(0x25) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x7b) + ENOMSG = syscall.Errno(0x2a) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x5c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x26) + ENOTCONN = syscall.Errno(0x6b) + ENOTEMPTY = syscall.Errno(0x27) + ENOTNAM = syscall.Errno(0x76) + ENOTRECOVERABLE = syscall.Errno(0x83) + ENOTSOCK = syscall.Errno(0x58) + ENOTSUP = syscall.Errno(0x5f) + ENOTUNIQ = syscall.Errno(0x4c) + EOPNOTSUPP = syscall.Errno(0x5f) + EOVERFLOW = syscall.Errno(0x4b) + EOWNERDEAD = syscall.Errno(0x82) + EPFNOSUPPORT = syscall.Errno(0x60) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x5d) + EPROTOTYPE = syscall.Errno(0x5b) + EREMCHG = syscall.Errno(0x4e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x79) + ERESTART = syscall.Errno(0x55) + ERFKILL = syscall.Errno(0x84) + ESHUTDOWN = syscall.Errno(0x6c) + ESOCKTNOSUPPORT = syscall.Errno(0x5e) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x74) + ESTRPIPE = syscall.Errno(0x56) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x6e) + ETOOMANYREFS = syscall.Errno(0x6d) + EUCLEAN = syscall.Errno(0x75) + EUNATCH = syscall.Errno(0x31) + EUSERS = syscall.Errno(0x57) + EXFULL = syscall.Errno(0x36) +) + +// Signals +const ( + SIGBUS = syscall.Signal(0x7) + SIGCHLD = syscall.Signal(0x11) + SIGCLD = syscall.Signal(0x11) + SIGCONT = syscall.Signal(0x12) + SIGIO = syscall.Signal(0x1d) + SIGPOLL = syscall.Signal(0x1d) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x1e) + SIGSTKFLT = syscall.Signal(0x10) + SIGSTOP = syscall.Signal(0x13) + SIGSYS = syscall.Signal(0x1f) + SIGTSTP = syscall.Signal(0x14) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x17) + SIGUSR1 = syscall.Signal(0xa) + SIGUSR2 = syscall.Signal(0xc) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errorList = [...]struct { + num syscall.Errno + name string + desc string +}{ + {1, "EPERM", "operation not permitted"}, + {2, "ENOENT", "no such file or directory"}, + {3, "ESRCH", "no such process"}, + {4, "EINTR", "interrupted system call"}, + {5, "EIO", "input/output error"}, + {6, "ENXIO", "no such device or address"}, + {7, "E2BIG", "argument list too long"}, + {8, "ENOEXEC", "exec format error"}, + {9, "EBADF", "bad file descriptor"}, + {10, "ECHILD", "no child processes"}, + {11, "EAGAIN", "resource temporarily unavailable"}, + {12, "ENOMEM", "cannot allocate memory"}, + {13, "EACCES", "permission denied"}, + {14, "EFAULT", "bad address"}, + {15, "ENOTBLK", "block device required"}, + {16, "EBUSY", "device or resource busy"}, + {17, "EEXIST", "file exists"}, + {18, "EXDEV", "invalid cross-device link"}, + {19, "ENODEV", "no such device"}, + {20, "ENOTDIR", "not a directory"}, + {21, "EISDIR", "is a directory"}, + {22, "EINVAL", "invalid argument"}, + {23, "ENFILE", "too many open files in system"}, + {24, "EMFILE", "too many open files"}, + {25, "ENOTTY", "inappropriate ioctl for device"}, + {26, "ETXTBSY", "text file busy"}, + {27, "EFBIG", "file too large"}, + {28, "ENOSPC", "no space left on device"}, + {29, "ESPIPE", "illegal seek"}, + {30, "EROFS", "read-only file system"}, + {31, "EMLINK", "too many links"}, + {32, "EPIPE", "broken pipe"}, + {33, "EDOM", "numerical argument out of domain"}, + {34, "ERANGE", "numerical result out of range"}, + {35, "EDEADLK", "resource deadlock avoided"}, + {36, "ENAMETOOLONG", "file name too long"}, + {37, "ENOLCK", "no locks available"}, + {38, "ENOSYS", "function not implemented"}, + {39, "ENOTEMPTY", "directory not empty"}, + {40, "ELOOP", "too many levels of symbolic links"}, + {42, "ENOMSG", "no message of desired type"}, + {43, "EIDRM", "identifier removed"}, + {44, "ECHRNG", "channel number out of range"}, + {45, "EL2NSYNC", "level 2 not synchronized"}, + {46, "EL3HLT", "level 3 halted"}, + {47, "EL3RST", "level 3 reset"}, + {48, "ELNRNG", "link number out of range"}, + {49, "EUNATCH", "protocol driver not attached"}, + {50, "ENOCSI", "no CSI structure available"}, + {51, "EL2HLT", "level 2 halted"}, + {52, "EBADE", "invalid exchange"}, + {53, "EBADR", "invalid request descriptor"}, + {54, "EXFULL", "exchange full"}, + {55, "ENOANO", "no anode"}, + {56, "EBADRQC", "invalid request code"}, + {57, "EBADSLT", "invalid slot"}, + {59, "EBFONT", "bad font file format"}, + {60, "ENOSTR", "device not a stream"}, + {61, "ENODATA", "no data available"}, + {62, "ETIME", "timer expired"}, + {63, "ENOSR", "out of streams resources"}, + {64, "ENONET", "machine is not on the network"}, + {65, "ENOPKG", "package not installed"}, + {66, "EREMOTE", "object is remote"}, + {67, "ENOLINK", "link has been severed"}, + {68, "EADV", "advertise error"}, + {69, "ESRMNT", "srmount error"}, + {70, "ECOMM", "communication error on send"}, + {71, "EPROTO", "protocol error"}, + {72, "EMULTIHOP", "multihop attempted"}, + {73, "EDOTDOT", "RFS specific error"}, + {74, "EBADMSG", "bad message"}, + {75, "EOVERFLOW", "value too large for defined data type"}, + {76, "ENOTUNIQ", "name not unique on network"}, + {77, "EBADFD", "file descriptor in bad state"}, + {78, "EREMCHG", "remote address changed"}, + {79, "ELIBACC", "can not access a needed shared library"}, + {80, "ELIBBAD", "accessing a corrupted shared library"}, + {81, "ELIBSCN", ".lib section in a.out corrupted"}, + {82, "ELIBMAX", "attempting to link in too many shared libraries"}, + {83, "ELIBEXEC", "cannot exec a shared library directly"}, + {84, "EILSEQ", "invalid or incomplete multibyte or wide character"}, + {85, "ERESTART", "interrupted system call should be restarted"}, + {86, "ESTRPIPE", "streams pipe error"}, + {87, "EUSERS", "too many users"}, + {88, "ENOTSOCK", "socket operation on non-socket"}, + {89, "EDESTADDRREQ", "destination address required"}, + {90, "EMSGSIZE", "message too long"}, + {91, "EPROTOTYPE", "protocol wrong type for socket"}, + {92, "ENOPROTOOPT", "protocol not available"}, + {93, "EPROTONOSUPPORT", "protocol not supported"}, + {94, "ESOCKTNOSUPPORT", "socket type not supported"}, + {95, "ENOTSUP", "operation not supported"}, + {96, "EPFNOSUPPORT", "protocol family not supported"}, + {97, "EAFNOSUPPORT", "address family not supported by protocol"}, + {98, "EADDRINUSE", "address already in use"}, + {99, "EADDRNOTAVAIL", "cannot assign requested address"}, + {100, "ENETDOWN", "network is down"}, + {101, "ENETUNREACH", "network is unreachable"}, + {102, "ENETRESET", "network dropped connection on reset"}, + {103, "ECONNABORTED", "software caused connection abort"}, + {104, "ECONNRESET", "connection reset by peer"}, + {105, "ENOBUFS", "no buffer space available"}, + {106, "EISCONN", "transport endpoint is already connected"}, + {107, "ENOTCONN", "transport endpoint is not connected"}, + {108, "ESHUTDOWN", "cannot send after transport endpoint shutdown"}, + {109, "ETOOMANYREFS", "too many references: cannot splice"}, + {110, "ETIMEDOUT", "connection timed out"}, + {111, "ECONNREFUSED", "connection refused"}, + {112, "EHOSTDOWN", "host is down"}, + {113, "EHOSTUNREACH", "no route to host"}, + {114, "EALREADY", "operation already in progress"}, + {115, "EINPROGRESS", "operation now in progress"}, + {116, "ESTALE", "stale file handle"}, + {117, "EUCLEAN", "structure needs cleaning"}, + {118, "ENOTNAM", "not a XENIX named type file"}, + {119, "ENAVAIL", "no XENIX semaphores available"}, + {120, "EISNAM", "is a named type file"}, + {121, "EREMOTEIO", "remote I/O error"}, + {122, "EDQUOT", "disk quota exceeded"}, + {123, "ENOMEDIUM", "no medium found"}, + {124, "EMEDIUMTYPE", "wrong medium type"}, + {125, "ECANCELED", "operation canceled"}, + {126, "ENOKEY", "required key not available"}, + {127, "EKEYEXPIRED", "key has expired"}, + {128, "EKEYREVOKED", "key has been revoked"}, + {129, "EKEYREJECTED", "key was rejected by service"}, + {130, "EOWNERDEAD", "owner died"}, + {131, "ENOTRECOVERABLE", "state not recoverable"}, + {132, "ERFKILL", "operation not possible due to RF-kill"}, + {133, "EHWPOISON", "memory page has hardware error"}, +} + +// Signal table +var signalList = [...]struct { + num syscall.Signal + name string + desc string +}{ + {1, "SIGHUP", "hangup"}, + {2, "SIGINT", "interrupt"}, + {3, "SIGQUIT", "quit"}, + {4, "SIGILL", "illegal instruction"}, + {5, "SIGTRAP", "trace/breakpoint trap"}, + {6, "SIGABRT", "aborted"}, + {7, "SIGBUS", "bus error"}, + {8, "SIGFPE", "floating point exception"}, + {9, "SIGKILL", "killed"}, + {10, "SIGUSR1", "user defined signal 1"}, + {11, "SIGSEGV", "segmentation fault"}, + {12, "SIGUSR2", "user defined signal 2"}, + {13, "SIGPIPE", "broken pipe"}, + {14, "SIGALRM", "alarm clock"}, + {15, "SIGTERM", "terminated"}, + {16, "SIGSTKFLT", "stack fault"}, + {17, "SIGCHLD", "child exited"}, + {18, "SIGCONT", "continued"}, + {19, "SIGSTOP", "stopped (signal)"}, + {20, "SIGTSTP", "stopped"}, + {21, "SIGTTIN", "stopped (tty input)"}, + {22, "SIGTTOU", "stopped (tty output)"}, + {23, "SIGURG", "urgent I/O condition"}, + {24, "SIGXCPU", "CPU time limit exceeded"}, + {25, "SIGXFSZ", "file size limit exceeded"}, + {26, "SIGVTALRM", "virtual timer expired"}, + {27, "SIGPROF", "profiling timer expired"}, + {28, "SIGWINCH", "window changed"}, + {29, "SIGIO", "I/O possible"}, + {30, "SIGPWR", "power failure"}, + {31, "SIGSYS", "bad system call"}, +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go new file mode 100644 index 0000000000..8cdfbe71e6 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go @@ -0,0 +1,552 @@ +// go run mksyscall.go -tags linux,loong64 syscall_linux.go syscall_linux_loong64.go +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build linux && loong64 +// +build linux,loong64 + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) { + _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_PWAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fadvise(fd int, offset int64, length int64, advice int) (err error) { + _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FSTATAT, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _ := RawSyscallNoError(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _ := RawSyscallNoError(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _ := RawSyscallNoError(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _ := RawSyscallNoError(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setfsgid(gid int) (prev int, err error) { + r0, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + prev = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setfsuid(uid int) (prev int, err error) { + r0, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + prev = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(cmdline) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go new file mode 100644 index 0000000000..e443f9a322 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go @@ -0,0 +1,313 @@ +// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build loong64 && linux +// +build loong64,linux + +package unix + +const ( + SYS_IO_SETUP = 0 + SYS_IO_DESTROY = 1 + SYS_IO_SUBMIT = 2 + SYS_IO_CANCEL = 3 + SYS_IO_GETEVENTS = 4 + SYS_SETXATTR = 5 + SYS_LSETXATTR = 6 + SYS_FSETXATTR = 7 + SYS_GETXATTR = 8 + SYS_LGETXATTR = 9 + SYS_FGETXATTR = 10 + SYS_LISTXATTR = 11 + SYS_LLISTXATTR = 12 + SYS_FLISTXATTR = 13 + SYS_REMOVEXATTR = 14 + SYS_LREMOVEXATTR = 15 + SYS_FREMOVEXATTR = 16 + SYS_GETCWD = 17 + SYS_LOOKUP_DCOOKIE = 18 + SYS_EVENTFD2 = 19 + SYS_EPOLL_CREATE1 = 20 + SYS_EPOLL_CTL = 21 + SYS_EPOLL_PWAIT = 22 + SYS_DUP = 23 + SYS_DUP3 = 24 + SYS_FCNTL = 25 + SYS_INOTIFY_INIT1 = 26 + SYS_INOTIFY_ADD_WATCH = 27 + SYS_INOTIFY_RM_WATCH = 28 + SYS_IOCTL = 29 + SYS_IOPRIO_SET = 30 + SYS_IOPRIO_GET = 31 + SYS_FLOCK = 32 + SYS_MKNODAT = 33 + SYS_MKDIRAT = 34 + SYS_UNLINKAT = 35 + SYS_SYMLINKAT = 36 + SYS_LINKAT = 37 + SYS_UMOUNT2 = 39 + SYS_MOUNT = 40 + SYS_PIVOT_ROOT = 41 + SYS_NFSSERVCTL = 42 + SYS_STATFS = 43 + SYS_FSTATFS = 44 + SYS_TRUNCATE = 45 + SYS_FTRUNCATE = 46 + SYS_FALLOCATE = 47 + SYS_FACCESSAT = 48 + SYS_CHDIR = 49 + SYS_FCHDIR = 50 + SYS_CHROOT = 51 + SYS_FCHMOD = 52 + SYS_FCHMODAT = 53 + SYS_FCHOWNAT = 54 + SYS_FCHOWN = 55 + SYS_OPENAT = 56 + SYS_CLOSE = 57 + SYS_VHANGUP = 58 + SYS_PIPE2 = 59 + SYS_QUOTACTL = 60 + SYS_GETDENTS64 = 61 + SYS_LSEEK = 62 + SYS_READ = 63 + SYS_WRITE = 64 + SYS_READV = 65 + SYS_WRITEV = 66 + SYS_PREAD64 = 67 + SYS_PWRITE64 = 68 + SYS_PREADV = 69 + SYS_PWRITEV = 70 + SYS_SENDFILE = 71 + SYS_PSELECT6 = 72 + SYS_PPOLL = 73 + SYS_SIGNALFD4 = 74 + SYS_VMSPLICE = 75 + SYS_SPLICE = 76 + SYS_TEE = 77 + SYS_READLINKAT = 78 + SYS_FSTATAT = 79 + SYS_FSTAT = 80 + SYS_SYNC = 81 + SYS_FSYNC = 82 + SYS_FDATASYNC = 83 + SYS_SYNC_FILE_RANGE = 84 + SYS_TIMERFD_CREATE = 85 + SYS_TIMERFD_SETTIME = 86 + SYS_TIMERFD_GETTIME = 87 + SYS_UTIMENSAT = 88 + SYS_ACCT = 89 + SYS_CAPGET = 90 + SYS_CAPSET = 91 + SYS_PERSONALITY = 92 + SYS_EXIT = 93 + SYS_EXIT_GROUP = 94 + SYS_WAITID = 95 + SYS_SET_TID_ADDRESS = 96 + SYS_UNSHARE = 97 + SYS_FUTEX = 98 + SYS_SET_ROBUST_LIST = 99 + SYS_GET_ROBUST_LIST = 100 + SYS_NANOSLEEP = 101 + SYS_GETITIMER = 102 + SYS_SETITIMER = 103 + SYS_KEXEC_LOAD = 104 + SYS_INIT_MODULE = 105 + SYS_DELETE_MODULE = 106 + SYS_TIMER_CREATE = 107 + SYS_TIMER_GETTIME = 108 + SYS_TIMER_GETOVERRUN = 109 + SYS_TIMER_SETTIME = 110 + SYS_TIMER_DELETE = 111 + SYS_CLOCK_SETTIME = 112 + SYS_CLOCK_GETTIME = 113 + SYS_CLOCK_GETRES = 114 + SYS_CLOCK_NANOSLEEP = 115 + SYS_SYSLOG = 116 + SYS_PTRACE = 117 + SYS_SCHED_SETPARAM = 118 + SYS_SCHED_SETSCHEDULER = 119 + SYS_SCHED_GETSCHEDULER = 120 + SYS_SCHED_GETPARAM = 121 + SYS_SCHED_SETAFFINITY = 122 + SYS_SCHED_GETAFFINITY = 123 + SYS_SCHED_YIELD = 124 + SYS_SCHED_GET_PRIORITY_MAX = 125 + SYS_SCHED_GET_PRIORITY_MIN = 126 + SYS_SCHED_RR_GET_INTERVAL = 127 + SYS_RESTART_SYSCALL = 128 + SYS_KILL = 129 + SYS_TKILL = 130 + SYS_TGKILL = 131 + SYS_SIGALTSTACK = 132 + SYS_RT_SIGSUSPEND = 133 + SYS_RT_SIGACTION = 134 + SYS_RT_SIGPROCMASK = 135 + SYS_RT_SIGPENDING = 136 + SYS_RT_SIGTIMEDWAIT = 137 + SYS_RT_SIGQUEUEINFO = 138 + SYS_RT_SIGRETURN = 139 + SYS_SETPRIORITY = 140 + SYS_GETPRIORITY = 141 + SYS_REBOOT = 142 + SYS_SETREGID = 143 + SYS_SETGID = 144 + SYS_SETREUID = 145 + SYS_SETUID = 146 + SYS_SETRESUID = 147 + SYS_GETRESUID = 148 + SYS_SETRESGID = 149 + SYS_GETRESGID = 150 + SYS_SETFSUID = 151 + SYS_SETFSGID = 152 + SYS_TIMES = 153 + SYS_SETPGID = 154 + SYS_GETPGID = 155 + SYS_GETSID = 156 + SYS_SETSID = 157 + SYS_GETGROUPS = 158 + SYS_SETGROUPS = 159 + SYS_UNAME = 160 + SYS_SETHOSTNAME = 161 + SYS_SETDOMAINNAME = 162 + SYS_GETRUSAGE = 165 + SYS_UMASK = 166 + SYS_PRCTL = 167 + SYS_GETCPU = 168 + SYS_GETTIMEOFDAY = 169 + SYS_SETTIMEOFDAY = 170 + SYS_ADJTIMEX = 171 + SYS_GETPID = 172 + SYS_GETPPID = 173 + SYS_GETUID = 174 + SYS_GETEUID = 175 + SYS_GETGID = 176 + SYS_GETEGID = 177 + SYS_GETTID = 178 + SYS_SYSINFO = 179 + SYS_MQ_OPEN = 180 + SYS_MQ_UNLINK = 181 + SYS_MQ_TIMEDSEND = 182 + SYS_MQ_TIMEDRECEIVE = 183 + SYS_MQ_NOTIFY = 184 + SYS_MQ_GETSETATTR = 185 + SYS_MSGGET = 186 + SYS_MSGCTL = 187 + SYS_MSGRCV = 188 + SYS_MSGSND = 189 + SYS_SEMGET = 190 + SYS_SEMCTL = 191 + SYS_SEMTIMEDOP = 192 + SYS_SEMOP = 193 + SYS_SHMGET = 194 + SYS_SHMCTL = 195 + SYS_SHMAT = 196 + SYS_SHMDT = 197 + SYS_SOCKET = 198 + SYS_SOCKETPAIR = 199 + SYS_BIND = 200 + SYS_LISTEN = 201 + SYS_ACCEPT = 202 + SYS_CONNECT = 203 + SYS_GETSOCKNAME = 204 + SYS_GETPEERNAME = 205 + SYS_SENDTO = 206 + SYS_RECVFROM = 207 + SYS_SETSOCKOPT = 208 + SYS_GETSOCKOPT = 209 + SYS_SHUTDOWN = 210 + SYS_SENDMSG = 211 + SYS_RECVMSG = 212 + SYS_READAHEAD = 213 + SYS_BRK = 214 + SYS_MUNMAP = 215 + SYS_MREMAP = 216 + SYS_ADD_KEY = 217 + SYS_REQUEST_KEY = 218 + SYS_KEYCTL = 219 + SYS_CLONE = 220 + SYS_EXECVE = 221 + SYS_MMAP = 222 + SYS_FADVISE64 = 223 + SYS_SWAPON = 224 + SYS_SWAPOFF = 225 + SYS_MPROTECT = 226 + SYS_MSYNC = 227 + SYS_MLOCK = 228 + SYS_MUNLOCK = 229 + SYS_MLOCKALL = 230 + SYS_MUNLOCKALL = 231 + SYS_MINCORE = 232 + SYS_MADVISE = 233 + SYS_REMAP_FILE_PAGES = 234 + SYS_MBIND = 235 + SYS_GET_MEMPOLICY = 236 + SYS_SET_MEMPOLICY = 237 + SYS_MIGRATE_PAGES = 238 + SYS_MOVE_PAGES = 239 + SYS_RT_TGSIGQUEUEINFO = 240 + SYS_PERF_EVENT_OPEN = 241 + SYS_ACCEPT4 = 242 + SYS_RECVMMSG = 243 + SYS_ARCH_SPECIFIC_SYSCALL = 244 + SYS_WAIT4 = 260 + SYS_PRLIMIT64 = 261 + SYS_FANOTIFY_INIT = 262 + SYS_FANOTIFY_MARK = 263 + SYS_NAME_TO_HANDLE_AT = 264 + SYS_OPEN_BY_HANDLE_AT = 265 + SYS_CLOCK_ADJTIME = 266 + SYS_SYNCFS = 267 + SYS_SETNS = 268 + SYS_SENDMMSG = 269 + SYS_PROCESS_VM_READV = 270 + SYS_PROCESS_VM_WRITEV = 271 + SYS_KCMP = 272 + SYS_FINIT_MODULE = 273 + SYS_SCHED_SETATTR = 274 + SYS_SCHED_GETATTR = 275 + SYS_RENAMEAT2 = 276 + SYS_SECCOMP = 277 + SYS_GETRANDOM = 278 + SYS_MEMFD_CREATE = 279 + SYS_BPF = 280 + SYS_EXECVEAT = 281 + SYS_USERFAULTFD = 282 + SYS_MEMBARRIER = 283 + SYS_MLOCK2 = 284 + SYS_COPY_FILE_RANGE = 285 + SYS_PREADV2 = 286 + SYS_PWRITEV2 = 287 + SYS_PKEY_MPROTECT = 288 + SYS_PKEY_ALLOC = 289 + SYS_PKEY_FREE = 290 + SYS_STATX = 291 + SYS_IO_PGETEVENTS = 292 + SYS_RSEQ = 293 + SYS_KEXEC_FILE_LOAD = 294 + SYS_PIDFD_SEND_SIGNAL = 424 + SYS_IO_URING_SETUP = 425 + SYS_IO_URING_ENTER = 426 + SYS_IO_URING_REGISTER = 427 + SYS_OPEN_TREE = 428 + SYS_MOVE_MOUNT = 429 + SYS_FSOPEN = 430 + SYS_FSCONFIG = 431 + SYS_FSMOUNT = 432 + SYS_FSPICK = 433 + SYS_PIDFD_OPEN = 434 + SYS_CLONE3 = 435 + SYS_CLOSE_RANGE = 436 + SYS_OPENAT2 = 437 + SYS_PIDFD_GETFD = 438 + SYS_FACCESSAT2 = 439 + SYS_PROCESS_MADVISE = 440 + SYS_EPOLL_PWAIT2 = 441 + SYS_MOUNT_SETATTR = 442 + SYS_QUOTACTL_FD = 443 + SYS_LANDLOCK_CREATE_RULESET = 444 + SYS_LANDLOCK_ADD_RULE = 445 + SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_PROCESS_MRELEASE = 448 + SYS_FUTEX_WAITV = 449 + SYS_SET_MEMPOLICY_HOME_NODE = 450 +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go new file mode 100644 index 0000000000..61fbb24f8d --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go @@ -0,0 +1,679 @@ +// cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build loong64 && linux +// +build loong64,linux + +package unix + +const ( + SizeofPtr = 0x8 + SizeofLong = 0x8 +) + +type ( + _C_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + _ [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Stat_t struct { + Dev uint64 + Ino uint64 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint64 + _ uint64 + Size int64 + Blksize int32 + _ int32 + Blocks int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + _ [2]int32 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]int8 + _ [5]byte +} + +type Flock_t struct { + Type int16 + Whence int16 + Start int64 + Len int64 + Pid int32 + _ [4]byte +} + +type DmNameList struct { + Dev uint64 + Next uint32 + Name [0]byte + _ [4]byte +} + +const ( + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrNFCLLCP struct { + Sa_family uint16 + Dev_idx uint32 + Target_idx uint32 + Nfc_protocol uint32 + Dsap uint8 + Ssap uint8 + Service_name [63]uint8 + Service_name_len uint64 +} + +type RawSockaddr struct { + Family uint16 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]int8 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + _ [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 +} + +type ifreq struct { + Ifrn [16]byte + Ifru [24]byte +} + +const ( + SizeofSockaddrNFCLLCP = 0x60 + SizeofIovec = 0x10 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 +) + +const ( + SizeofSockFprog = 0x10 +) + +type PtraceRegs struct { + Regs [32]uint64 + Orig_a0 uint64 + Era uint64 + Badv uint64 + Reserved [10]uint64 +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + _ [0]int8 + _ [4]byte +} + +type Ustat_t struct { + Tfree int32 + Tinode uint64 + Fname [6]int8 + Fpack [6]int8 + _ [4]byte +} + +type EpollEvent struct { + Events uint32 + _ int32 + Fd int32 + Pad int32 +} + +const ( + OPEN_TREE_CLOEXEC = 0x80000 +) + +const ( + POLLRDHUP = 0x2000 +) + +type Sigset_t struct { + Val [16]uint64 +} + +const _C__NSIG = 0x41 + +type Siginfo struct { + Signo int32 + Errno int32 + Code int32 + _ int32 + _ [112]byte +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [19]uint8 + Ispeed uint32 + Ospeed uint32 +} + +type Taskstats struct { + Version uint16 + Ac_exitcode uint32 + Ac_flag uint8 + Ac_nice uint8 + Cpu_count uint64 + Cpu_delay_total uint64 + Blkio_count uint64 + Blkio_delay_total uint64 + Swapin_count uint64 + Swapin_delay_total uint64 + Cpu_run_real_total uint64 + Cpu_run_virtual_total uint64 + Ac_comm [32]int8 + Ac_sched uint8 + Ac_pad [3]uint8 + _ [4]byte + Ac_uid uint32 + Ac_gid uint32 + Ac_pid uint32 + Ac_ppid uint32 + Ac_btime uint32 + Ac_etime uint64 + Ac_utime uint64 + Ac_stime uint64 + Ac_minflt uint64 + Ac_majflt uint64 + Coremem uint64 + Virtmem uint64 + Hiwater_rss uint64 + Hiwater_vm uint64 + Read_char uint64 + Write_char uint64 + Read_syscalls uint64 + Write_syscalls uint64 + Read_bytes uint64 + Write_bytes uint64 + Cancelled_write_bytes uint64 + Nvcsw uint64 + Nivcsw uint64 + Ac_utimescaled uint64 + Ac_stimescaled uint64 + Cpu_scaled_run_real_total uint64 + Freepages_count uint64 + Freepages_delay_total uint64 + Thrashing_count uint64 + Thrashing_delay_total uint64 + Ac_btime64 uint64 + Compact_count uint64 + Compact_delay_total uint64 +} + +type cpuMask uint64 + +const ( + _NCPUBITS = 0x40 +) + +const ( + CBitFieldMaskBit0 = 0x1 + CBitFieldMaskBit1 = 0x2 + CBitFieldMaskBit2 = 0x4 + CBitFieldMaskBit3 = 0x8 + CBitFieldMaskBit4 = 0x10 + CBitFieldMaskBit5 = 0x20 + CBitFieldMaskBit6 = 0x40 + CBitFieldMaskBit7 = 0x80 + CBitFieldMaskBit8 = 0x100 + CBitFieldMaskBit9 = 0x200 + CBitFieldMaskBit10 = 0x400 + CBitFieldMaskBit11 = 0x800 + CBitFieldMaskBit12 = 0x1000 + CBitFieldMaskBit13 = 0x2000 + CBitFieldMaskBit14 = 0x4000 + CBitFieldMaskBit15 = 0x8000 + CBitFieldMaskBit16 = 0x10000 + CBitFieldMaskBit17 = 0x20000 + CBitFieldMaskBit18 = 0x40000 + CBitFieldMaskBit19 = 0x80000 + CBitFieldMaskBit20 = 0x100000 + CBitFieldMaskBit21 = 0x200000 + CBitFieldMaskBit22 = 0x400000 + CBitFieldMaskBit23 = 0x800000 + CBitFieldMaskBit24 = 0x1000000 + CBitFieldMaskBit25 = 0x2000000 + CBitFieldMaskBit26 = 0x4000000 + CBitFieldMaskBit27 = 0x8000000 + CBitFieldMaskBit28 = 0x10000000 + CBitFieldMaskBit29 = 0x20000000 + CBitFieldMaskBit30 = 0x40000000 + CBitFieldMaskBit31 = 0x80000000 + CBitFieldMaskBit32 = 0x100000000 + CBitFieldMaskBit33 = 0x200000000 + CBitFieldMaskBit34 = 0x400000000 + CBitFieldMaskBit35 = 0x800000000 + CBitFieldMaskBit36 = 0x1000000000 + CBitFieldMaskBit37 = 0x2000000000 + CBitFieldMaskBit38 = 0x4000000000 + CBitFieldMaskBit39 = 0x8000000000 + CBitFieldMaskBit40 = 0x10000000000 + CBitFieldMaskBit41 = 0x20000000000 + CBitFieldMaskBit42 = 0x40000000000 + CBitFieldMaskBit43 = 0x80000000000 + CBitFieldMaskBit44 = 0x100000000000 + CBitFieldMaskBit45 = 0x200000000000 + CBitFieldMaskBit46 = 0x400000000000 + CBitFieldMaskBit47 = 0x800000000000 + CBitFieldMaskBit48 = 0x1000000000000 + CBitFieldMaskBit49 = 0x2000000000000 + CBitFieldMaskBit50 = 0x4000000000000 + CBitFieldMaskBit51 = 0x8000000000000 + CBitFieldMaskBit52 = 0x10000000000000 + CBitFieldMaskBit53 = 0x20000000000000 + CBitFieldMaskBit54 = 0x40000000000000 + CBitFieldMaskBit55 = 0x80000000000000 + CBitFieldMaskBit56 = 0x100000000000000 + CBitFieldMaskBit57 = 0x200000000000000 + CBitFieldMaskBit58 = 0x400000000000000 + CBitFieldMaskBit59 = 0x800000000000000 + CBitFieldMaskBit60 = 0x1000000000000000 + CBitFieldMaskBit61 = 0x2000000000000000 + CBitFieldMaskBit62 = 0x4000000000000000 + CBitFieldMaskBit63 = 0x8000000000000000 +) + +type SockaddrStorage struct { + Family uint16 + _ [118]int8 + _ uint64 +} + +type HDGeometry struct { + Heads uint8 + Sectors uint8 + Cylinders uint16 + Start uint64 +} + +type Statfs_t struct { + Type int64 + Bsize int64 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Namelen int64 + Frsize int64 + Flags int64 + Spare [4]int64 +} + +type TpacketHdr struct { + Status uint64 + Len uint32 + Snaplen uint32 + Mac uint16 + Net uint16 + Sec uint32 + Usec uint32 + _ [4]byte +} + +const ( + SizeofTpacketHdr = 0x20 +) + +type RTCPLLInfo struct { + Ctrl int32 + Value int32 + Max int32 + Min int32 + Posmult int32 + Negmult int32 + Clock int64 +} + +type BlkpgPartition struct { + Start int64 + Length int64 + Pno int32 + Devname [64]uint8 + Volname [64]uint8 + _ [4]byte +} + +const ( + BLKPG = 0x1269 +) + +type XDPUmemReg struct { + Addr uint64 + Len uint64 + Size uint32 + Headroom uint32 + Flags uint32 + _ [4]byte +} + +type CryptoUserAlg struct { + Name [64]int8 + Driver_name [64]int8 + Module_name [64]int8 + Type uint32 + Mask uint32 + Refcnt uint32 + Flags uint32 +} + +type CryptoStatAEAD struct { + Type [64]int8 + Encrypt_cnt uint64 + Encrypt_tlen uint64 + Decrypt_cnt uint64 + Decrypt_tlen uint64 + Err_cnt uint64 +} + +type CryptoStatAKCipher struct { + Type [64]int8 + Encrypt_cnt uint64 + Encrypt_tlen uint64 + Decrypt_cnt uint64 + Decrypt_tlen uint64 + Verify_cnt uint64 + Sign_cnt uint64 + Err_cnt uint64 +} + +type CryptoStatCipher struct { + Type [64]int8 + Encrypt_cnt uint64 + Encrypt_tlen uint64 + Decrypt_cnt uint64 + Decrypt_tlen uint64 + Err_cnt uint64 +} + +type CryptoStatCompress struct { + Type [64]int8 + Compress_cnt uint64 + Compress_tlen uint64 + Decompress_cnt uint64 + Decompress_tlen uint64 + Err_cnt uint64 +} + +type CryptoStatHash struct { + Type [64]int8 + Hash_cnt uint64 + Hash_tlen uint64 + Err_cnt uint64 +} + +type CryptoStatKPP struct { + Type [64]int8 + Setsecret_cnt uint64 + Generate_public_key_cnt uint64 + Compute_shared_secret_cnt uint64 + Err_cnt uint64 +} + +type CryptoStatRNG struct { + Type [64]int8 + Generate_cnt uint64 + Generate_tlen uint64 + Seed_cnt uint64 + Err_cnt uint64 +} + +type CryptoStatLarval struct { + Type [64]int8 +} + +type CryptoReportLarval struct { + Type [64]int8 +} + +type CryptoReportHash struct { + Type [64]int8 + Blocksize uint32 + Digestsize uint32 +} + +type CryptoReportCipher struct { + Type [64]int8 + Blocksize uint32 + Min_keysize uint32 + Max_keysize uint32 +} + +type CryptoReportBlkCipher struct { + Type [64]int8 + Geniv [64]int8 + Blocksize uint32 + Min_keysize uint32 + Max_keysize uint32 + Ivsize uint32 +} + +type CryptoReportAEAD struct { + Type [64]int8 + Geniv [64]int8 + Blocksize uint32 + Maxauthsize uint32 + Ivsize uint32 +} + +type CryptoReportComp struct { + Type [64]int8 +} + +type CryptoReportRNG struct { + Type [64]int8 + Seedsize uint32 +} + +type CryptoReportAKCipher struct { + Type [64]int8 +} + +type CryptoReportKPP struct { + Type [64]int8 +} + +type CryptoReportAcomp struct { + Type [64]int8 +} + +type LoopInfo struct { + Number int32 + Device uint32 + Inode uint64 + Rdevice uint32 + Offset int32 + Encrypt_type int32 + Encrypt_key_size int32 + Flags int32 + Name [64]int8 + Encrypt_key [32]uint8 + Init [2]uint64 + Reserved [4]int8 + _ [4]byte +} + +type TIPCSubscr struct { + Seq TIPCServiceRange + Timeout uint32 + Filter uint32 + Handle [8]int8 +} + +type TIPCSIOCLNReq struct { + Peer uint32 + Id uint32 + Linkname [68]int8 +} + +type TIPCSIOCNodeIDReq struct { + Peer uint32 + Id [16]int8 +} + +type PPSKInfo struct { + Assert_sequence uint32 + Clear_sequence uint32 + Assert_tu PPSKTime + Clear_tu PPSKTime + Current_mode int32 + _ [4]byte +} + +const ( + PPS_GETPARAMS = 0x800870a1 + PPS_SETPARAMS = 0x400870a2 + PPS_GETCAP = 0x800870a3 + PPS_FETCH = 0xc00870a4 +) + +const ( + PIDFD_NONBLOCK = 0x800 +) + +type SysvIpcPerm struct { + Key int32 + Uid uint32 + Gid uint32 + Cuid uint32 + Cgid uint32 + Mode uint32 + _ [0]uint8 + Seq uint16 + _ uint16 + _ uint64 + _ uint64 +} +type SysvShmDesc struct { + Perm SysvIpcPerm + Segsz uint64 + Atime int64 + Dtime int64 + Ctime int64 + Cpid int32 + Lpid int32 + Nattch uint64 + _ uint64 + _ uint64 +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 68d387794b..d900cdc1bd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,15 +1,21 @@ # github.com/BurntSushi/toml v0.3.1 ## explicit github.com/BurntSushi/toml -# github.com/Microsoft/go-winio v0.5.2 -## explicit; go 1.13 +# github.com/Microsoft/go-winio v0.5.3-0.20220616180519-35837cff61c7 +## explicit; go 1.17 github.com/Microsoft/go-winio github.com/Microsoft/go-winio/backuptar github.com/Microsoft/go-winio/pkg/etw github.com/Microsoft/go-winio/pkg/etwlogrus github.com/Microsoft/go-winio/pkg/guid github.com/Microsoft/go-winio/pkg/process +github.com/Microsoft/go-winio/tools/mkwinsyscall github.com/Microsoft/go-winio/vhd +# github.com/akavel/rsrc v0.10.2 +## explicit; go 1.12 +github.com/akavel/rsrc/binutil +github.com/akavel/rsrc/coff +github.com/akavel/rsrc/ico # github.com/cenkalti/backoff/v4 v4.1.1 ## explicit; go 1.13 github.com/cenkalti/backoff/v4 @@ -129,6 +135,10 @@ github.com/google/go-containerregistry/pkg/v1/types # github.com/google/uuid v1.3.0 ## explicit github.com/google/uuid +# github.com/josephspurrier/goversioninfo v1.4.0 +## explicit; go 1.12 +github.com/josephspurrier/goversioninfo +github.com/josephspurrier/goversioninfo/cmd/goversioninfo # github.com/linuxkit/virtsock v0.0.0-20201010232012-f8cee7dfc7a3 ## explicit github.com/linuxkit/virtsock/pkg/vsock @@ -205,7 +215,7 @@ golang.org/x/net/trace # golang.org/x/sync v0.0.0-20210220032951-036812b2e83c ## explicit golang.org/x/sync/errgroup -# golang.org/x/sys v0.0.0-20220412211240-33da011f77ad +# golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 ## explicit; go 1.17 golang.org/x/sys/internal/unsafeheader golang.org/x/sys/unix diff --git a/zsyscall_windows.go b/zsyscall_windows.go index 8bed848573..9b619b6e62 100644 --- a/zsyscall_windows.go +++ b/zsyscall_windows.go @@ -1,4 +1,6 @@ -// Code generated mksyscall_windows.exe DO NOT EDIT +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. package hcsshim @@ -19,6 +21,7 @@ const ( var ( errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) + errERROR_EINVAL error = syscall.EINVAL ) // errnoErr returns common boxed Errno values, to prevent @@ -26,7 +29,7 @@ var ( func errnoErr(e syscall.Errno) error { switch e { case 0: - return nil + return errERROR_EINVAL case errnoERROR_IO_PENDING: return errERROR_IO_PENDING }