build(deps): bump the golang group with 5 updates
Bumps the golang group with 5 updates: | Package | From | To | | --- | --- | --- | | [github.com/Microsoft/hcsshim](https://github.com/Microsoft/hcsshim) | `0.11.4` | `0.12.0` | | [github.com/alexflint/go-filemutex](https://github.com/alexflint/go-filemutex) | `1.2.0` | `1.3.0` | | [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) | `2.13.2` | `2.16.0` | | [github.com/onsi/gomega](https://github.com/onsi/gomega) | `1.30.0` | `1.31.1` | | [golang.org/x/sys](https://github.com/golang/sys) | `0.15.0` | `0.17.0` | Updates `github.com/Microsoft/hcsshim` from 0.11.4 to 0.12.0 - [Release notes](https://github.com/Microsoft/hcsshim/releases) - [Commits](https://github.com/Microsoft/hcsshim/compare/v0.11.4...v0.12.0) Updates `github.com/alexflint/go-filemutex` from 1.2.0 to 1.3.0 - [Release notes](https://github.com/alexflint/go-filemutex/releases) - [Commits](https://github.com/alexflint/go-filemutex/compare/v1.2.0...v1.3.0) Updates `github.com/onsi/ginkgo/v2` from 2.13.2 to 2.16.0 - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.13.2...v2.16.0) Updates `github.com/onsi/gomega` from 1.30.0 to 1.31.1 - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.30.0...v1.31.1) Updates `golang.org/x/sys` from 0.15.0 to 0.17.0 - [Commits](https://github.com/golang/sys/compare/v0.15.0...v0.17.0) --- updated-dependencies: - dependency-name: github.com/Microsoft/hcsshim dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: github.com/alexflint/go-filemutex dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: github.com/onsi/gomega dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
28
vendor/github.com/Microsoft/hcsshim/.golangci.yml
generated
vendored
28
vendor/github.com/Microsoft/hcsshim/.golangci.yml
generated
vendored
@ -20,18 +20,33 @@ linters:
|
||||
# - typecheck
|
||||
# - unused
|
||||
|
||||
- errorlint # error wrapping (eg, not using `errors.Is`, using `%s` instead of `%w` in `fmt.Errorf`)
|
||||
- gofmt # whether code was gofmt-ed
|
||||
- govet # enabled by default, but just to be sure
|
||||
- nolintlint # ill-formed or insufficient nolint directives
|
||||
- stylecheck # golint replacement
|
||||
- thelper # test helpers without t.Helper()
|
||||
|
||||
linters-settings:
|
||||
govet:
|
||||
enable-all: true
|
||||
disable:
|
||||
# struct order is often for Win32 compat
|
||||
# also, ignore pointer bytes/GC issues for now until performance becomes an issue
|
||||
- fieldalignment
|
||||
check-shadowing: true
|
||||
|
||||
stylecheck:
|
||||
# https://staticcheck.io/docs/checks
|
||||
checks: ["all"]
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
# err is very often shadowed in nested scopes
|
||||
- linters:
|
||||
- govet
|
||||
text: '^shadow: declaration of "err" shadows declaration'
|
||||
|
||||
# path is relative to module root, which is ./test/
|
||||
- path: cri-containerd
|
||||
linters:
|
||||
@ -39,6 +54,12 @@ issues:
|
||||
text: "^ST1003: should not use underscores in package names$"
|
||||
source: "^package cri_containerd$"
|
||||
|
||||
# don't bother with propper error wrapping in test code
|
||||
- path: cri-containerd
|
||||
linters:
|
||||
- errorlint
|
||||
text: "non-wrapping format verb for fmt.Errorf"
|
||||
|
||||
# This repo has a LOT of generated schema files, operating system bindings, and other
|
||||
# things that ST1003 from stylecheck won't like (screaming case Windows api constants for example).
|
||||
# There's also some structs that we *could* change the initialisms to be Go friendly
|
||||
@ -135,7 +156,7 @@ issues:
|
||||
linters:
|
||||
- stylecheck
|
||||
Text: "ST1003:"
|
||||
|
||||
|
||||
# v0 APIs are deprecated, but still retained for backwards compatability
|
||||
- path: cmd\\ncproxy\\
|
||||
linters:
|
||||
@ -146,3 +167,8 @@ issues:
|
||||
linters:
|
||||
- staticcheck
|
||||
text: "^SA1019: .*nodenetsvc[/]?v0"
|
||||
|
||||
- path: internal\\vhdx\\info
|
||||
linters:
|
||||
- stylecheck
|
||||
Text: "ST1003:"
|
||||
|
87
vendor/github.com/Microsoft/hcsshim/Makefile
generated
vendored
87
vendor/github.com/Microsoft/hcsshim/Makefile
generated
vendored
@ -29,12 +29,23 @@ ifeq "$(DEV_BUILD)" "1"
|
||||
DELTA_TARGET=out/delta-dev.tar.gz
|
||||
endif
|
||||
|
||||
ifeq "$(SNP_BUILD)" "1"
|
||||
DELTA_TARGET=out/delta-snp.tar.gz
|
||||
endif
|
||||
|
||||
# The link aliases for gcstools
|
||||
GCS_TOOLS=\
|
||||
generichook \
|
||||
install-drivers
|
||||
|
||||
.PHONY: all always rootfs test
|
||||
# Common path prefix.
|
||||
PATH_PREFIX:=
|
||||
# These have PATH_PREFIX prepended to obtain the full path in recipies e.g. $(PATH_PREFIX)/$(VMGS_TOOL)
|
||||
VMGS_TOOL:=
|
||||
IGVM_TOOL:=
|
||||
KERNEL_PATH:=
|
||||
|
||||
.PHONY: all always rootfs test snp simple
|
||||
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
@ -49,9 +60,58 @@ test:
|
||||
|
||||
rootfs: out/rootfs.vhd
|
||||
|
||||
out/rootfs.vhd: out/rootfs.tar.gz bin/cmd/tar2ext4
|
||||
snp: out/kernelinitrd.vmgs out/rootfs.hash.vhd out/rootfs.vhd out/v2056.vmgs
|
||||
|
||||
simple: out/simple.vmgs snp
|
||||
|
||||
%.vmgs: %.bin
|
||||
rm -f $@
|
||||
# du -BM returns the size of the bin file in M, eg 7M. The sed command replaces the M with *1024*1024 and then bc does the math to convert to bytes
|
||||
$(PATH_PREFIX)/$(VMGS_TOOL) create --filepath $@ --filesize `du -BM $< | sed "s/M.*/*1024*1024/" | bc`
|
||||
$(PATH_PREFIX)/$(VMGS_TOOL) write --filepath $@ --datapath $< -i=8
|
||||
|
||||
# Simplest debug UVM used to test changes to the linux kernel. No dmverity protection. Boots an initramdisk rather than directly booting a vhd disk.
|
||||
out/simple.bin: out/initrd.img $(PATH_PREFIX)/$(KERNEL_PATH) boot/startup_simple.sh
|
||||
rm -f $@
|
||||
python3 $(PATH_PREFIX)/$(IGVM_TOOL) -o $@ -kernel $(PATH_PREFIX)/$(KERNEL_PATH) -append "8250_core.nr_uarts=0 panic=-1 debug loglevel=7 rdinit=/startup_simple.sh" -rdinit out/initrd.img -vtl 0
|
||||
|
||||
ROOTFS_DEVICE:=/dev/sda
|
||||
VERITY_DEVICE:=/dev/sdb
|
||||
# Debug build for use with uvmtester. UVM with dm-verity protected vhd disk mounted directly via the kernel command line. Ignores corruption in dm-verity protected disk. (Use dmesg to see if dm-verity is ignoring data corruption.)
|
||||
out/v2056.bin: out/rootfs.vhd out/rootfs.hash.vhd $(PATH_PREFIX)/$(KERNEL_PATH) out/rootfs.hash.datasectors out/rootfs.hash.datablocksize out/rootfs.hash.hashblocksize out/rootfs.hash.datablocks out/rootfs.hash.rootdigest out/rootfs.hash.salt boot/startup_v2056.sh
|
||||
rm -f $@
|
||||
python3 $(PATH_PREFIX)/$(IGVM_TOOL) -o $@ -kernel $(PATH_PREFIX)/$(KERNEL_PATH) -append "8250_core.nr_uarts=0 panic=-1 debug loglevel=7 root=/dev/dm-0 dm-mod.create=\"dmverity,,,ro,0 $(shell cat out/rootfs.hash.datasectors) verity 1 $(ROOTFS_DEVICE) $(VERITY_DEVICE) $(shell cat out/rootfs.hash.datablocksize) $(shell cat out/rootfs.hash.hashblocksize) $(shell cat out/rootfs.hash.datablocks) 0 sha256 $(shell cat out/rootfs.hash.rootdigest) $(shell cat out/rootfs.hash.salt) 1 ignore_corruption\" init=/startup_v2056.sh" -vtl 0
|
||||
|
||||
# Full UVM with dm-verity protected vhd disk mounted directly via the kernel command line.
|
||||
out/kernelinitrd.bin: out/rootfs.vhd out/rootfs.hash.vhd out/rootfs.hash.datasectors out/rootfs.hash.datablocksize out/rootfs.hash.hashblocksize out/rootfs.hash.datablocks out/rootfs.hash.rootdigest out/rootfs.hash.salt $(PATH_PREFIX)/$(KERNEL_PATH) boot/startup.sh
|
||||
rm -f $@
|
||||
python3 $(PATH_PREFIX)/$(IGVM_TOOL) -o $@ -kernel $(PATH_PREFIX)/$(KERNEL_PATH) -append "8250_core.nr_uarts=0 panic=-1 debug loglevel=7 root=/dev/dm-0 dm-mod.create=\"dmverity,,,ro,0 $(shell cat out/rootfs.hash.datasectors) verity 1 $(ROOTFS_DEVICE) $(VERITY_DEVICE) $(shell cat out/rootfs.hash.datablocksize) $(shell cat out/rootfs.hash.hashblocksize) $(shell cat out/rootfs.hash.datablocks) 0 sha256 $(shell cat out/rootfs.hash.rootdigest) $(shell cat out/rootfs.hash.salt)\" init=/startup.sh" -vtl 0
|
||||
|
||||
# Rule to make a vhd from a file. This is used to create the rootfs.hash.vhd from rootfs.hash.
|
||||
%.vhd: % bin/cmd/tar2ext4
|
||||
./bin/cmd/tar2ext4 -only-vhd -i $< -o $@
|
||||
|
||||
# Rule to make a vhd from an ext4 file. This is used to create the rootfs.vhd from rootfs.ext4.
|
||||
%.vhd: %.ext4 bin/cmd/tar2ext4
|
||||
./bin/cmd/tar2ext4 -only-vhd -i $< -o $@
|
||||
|
||||
%.hash %.hash.info %.hash.datablocks %.hash.rootdigest %hash.datablocksize %.hash.datasectors %.hash.hashblocksize: %.ext4 %.hash.salt
|
||||
veritysetup format --no-superblock --salt $(shell cat out/rootfs.hash.salt) $< $*.hash > $*.hash.info
|
||||
# Retrieve info required by dm-verity at boot time
|
||||
# Get the blocksize of rootfs
|
||||
cat $*.hash.info | awk '/^Root hash:/{ print $$3 }' > $*.hash.rootdigest
|
||||
cat $*.hash.info | awk '/^Salt:/{ print $$2 }' > $*.hash.salt
|
||||
cat $*.hash.info | awk '/^Data block size:/{ print $$4 }' > $*.hash.datablocksize
|
||||
cat $*.hash.info | awk '/^Hash block size:/{ print $$4 }' > $*.hash.hashblocksize
|
||||
cat $*.hash.info | awk '/^Data blocks:/{ print $$3 }' > $*.hash.datablocks
|
||||
echo $$(( $$(cat $*.hash.datablocks) * $$(cat $*.hash.datablocksize) / 512 )) > $*.hash.datasectors
|
||||
|
||||
out/rootfs.hash.salt:
|
||||
hexdump -vn32 -e'8/4 "%08X" 1 "\n"' /dev/random > $@
|
||||
|
||||
out/rootfs.ext4: out/rootfs.tar.gz bin/cmd/tar2ext4
|
||||
gzip -f -d ./out/rootfs.tar.gz
|
||||
bin/cmd/tar2ext4 -vhd -i ./out/rootfs.tar -o $@
|
||||
./bin/cmd/tar2ext4 -i ./out/rootfs.tar -o $@
|
||||
|
||||
out/rootfs.tar.gz: out/initrd.img
|
||||
rm -rf rootfs-conv
|
||||
@ -74,6 +134,20 @@ out/delta-dev.tar.gz: out/delta.tar.gz bin/internal/tools/snp-report
|
||||
tar -zcf $@ -C rootfs-dev .
|
||||
rm -rf rootfs-dev
|
||||
|
||||
out/delta-snp.tar.gz: out/delta.tar.gz bin/internal/tools/snp-report boot/startup_v2056.sh boot/startup_simple.sh boot/startup.sh
|
||||
rm -rf rootfs-snp
|
||||
mkdir rootfs-snp
|
||||
tar -xzf out/delta.tar.gz -C rootfs-snp
|
||||
cp boot/startup_v2056.sh rootfs-snp/startup_v2056.sh
|
||||
cp boot/startup_simple.sh rootfs-snp/startup_simple.sh
|
||||
cp boot/startup.sh rootfs-snp/startup.sh
|
||||
cp bin/internal/tools/snp-report rootfs-snp/bin/
|
||||
chmod a+x rootfs-snp/startup_v2056.sh
|
||||
chmod a+x rootfs-snp/startup_simple.sh
|
||||
chmod a+x rootfs-snp/startup.sh
|
||||
tar -zcf $@ -C rootfs-snp .
|
||||
rm -rf rootfs-snp
|
||||
|
||||
out/delta.tar.gz: bin/init bin/vsockexec bin/cmd/gcs bin/cmd/gcstools bin/cmd/hooks/wait-paths Makefile
|
||||
@mkdir -p out
|
||||
rm -rf rootfs
|
||||
@ -94,7 +168,10 @@ out/delta.tar.gz: bin/init bin/vsockexec bin/cmd/gcs bin/cmd/gcstools bin/cmd/ho
|
||||
tar -zcf $@ -C rootfs .
|
||||
rm -rf rootfs
|
||||
|
||||
bin/cmd/gcs bin/cmd/gcstools bin/cmd/hooks/wait-paths bin/cmd/tar2ext4 bin/internal/tools/snp-report:
|
||||
out/containerd-shim-runhcs-v1.exe:
|
||||
GOOS=windows $(GO_BUILD) -o $@ $(SRCROOT)/cmd/containerd-shim-runhcs-v1
|
||||
|
||||
bin/cmd/gcs bin/cmd/gcstools bin/cmd/hooks/wait-paths bin/cmd/tar2ext4 bin/internal/tools/snp-report bin/cmd/dmverity-vhd:
|
||||
@mkdir -p $(dir $@)
|
||||
GOOS=linux $(GO_BUILD) -o $@ $(SRCROOT)/$(@:bin/%=%)
|
||||
|
||||
@ -108,4 +185,4 @@ bin/init: init/init.o vsockexec/vsock.o
|
||||
|
||||
%.o: %.c
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
55
vendor/github.com/Microsoft/hcsshim/Protobuild.toml
generated
vendored
55
vendor/github.com/Microsoft/hcsshim/Protobuild.toml
generated
vendored
@ -1,52 +1,25 @@
|
||||
version = "1"
|
||||
generator = "gogoctrd"
|
||||
plugins = ["grpc", "fieldpath"]
|
||||
version = "2"
|
||||
generators = ["go", "go-grpc"]
|
||||
|
||||
# Control protoc include paths. Below are usually some good defaults, but feel
|
||||
# free to try it without them if it works for your project.
|
||||
# Control protoc include paths.
|
||||
[includes]
|
||||
# Include paths that will be added before all others. Typically, you want to
|
||||
# treat the root of the project as an include, but this may not be necessary.
|
||||
before = ["./protobuf"]
|
||||
|
||||
# defaults are "/usr/local/include" and "/usr/include", which don't exist on Windows.
|
||||
# override defaults to supress errors about non-existant directories.
|
||||
after = []
|
||||
|
||||
# Paths that should be treated as include roots in relation to the vendor
|
||||
# directory. These will be calculated with the vendor directory nearest the
|
||||
# target package.
|
||||
packages = ["github.com/gogo/protobuf"]
|
||||
|
||||
# This section maps protobuf imports to Go packages. These will become
|
||||
# `-M` directives in the call to the go protobuf generator.
|
||||
# This section maps protobuf imports to Go packages.
|
||||
[packages]
|
||||
"gogoproto/gogo.proto" = "github.com/gogo/protobuf/gogoproto"
|
||||
"google/protobuf/any.proto" = "github.com/gogo/protobuf/types"
|
||||
"google/protobuf/empty.proto" = "github.com/gogo/protobuf/types"
|
||||
"google/protobuf/struct.proto" = "github.com/gogo/protobuf/types"
|
||||
"google/protobuf/descriptor.proto" = "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||
"google/protobuf/field_mask.proto" = "github.com/gogo/protobuf/types"
|
||||
"google/protobuf/timestamp.proto" = "github.com/gogo/protobuf/types"
|
||||
"google/protobuf/duration.proto" = "github.com/gogo/protobuf/types"
|
||||
"github/containerd/cgroups/stats/v1/metrics.proto" = "github.com/containerd/cgroups/stats/v1"
|
||||
# github.com/containerd/cgroups protofiles still list their go path as "github.com/containerd/cgroups/cgroup1/stats"
|
||||
"github.com/containerd/cgroups/v3/cgroup1/stats/metrics.proto" = "github.com/containerd/cgroups/v3/cgroup1/stats"
|
||||
|
||||
[[overrides]]
|
||||
prefixes = ["github.com/Microsoft/hcsshim/internal/shimdiag"]
|
||||
plugins = ["ttrpc"]
|
||||
|
||||
[[overrides]]
|
||||
prefixes = ["github.com/Microsoft/hcsshim/internal/extendedtask"]
|
||||
plugins = ["ttrpc"]
|
||||
|
||||
[[overrides]]
|
||||
prefixes = ["github.com/Microsoft/hcsshim/internal/computeagent"]
|
||||
plugins = ["ttrpc"]
|
||||
|
||||
[[overrides]]
|
||||
prefixes = ["github.com/Microsoft/hcsshim/internal/ncproxyttrpc"]
|
||||
plugins = ["ttrpc"]
|
||||
|
||||
[[overrides]]
|
||||
prefixes = ["github.com/Microsoft/hcsshim/internal/vmservice"]
|
||||
plugins = ["ttrpc"]
|
||||
prefixes = [
|
||||
"github.com/Microsoft/hcsshim/internal/shimdiag",
|
||||
"github.com/Microsoft/hcsshim/internal/extendedtask",
|
||||
"github.com/Microsoft/hcsshim/internal/computeagent",
|
||||
"github.com/Microsoft/hcsshim/internal/ncproxyttrpc",
|
||||
"github.com/Microsoft/hcsshim/internal/vmservice",
|
||||
]
|
||||
generators = ["go", "go-ttrpc"]
|
||||
|
84
vendor/github.com/Microsoft/hcsshim/README.md
generated
vendored
84
vendor/github.com/Microsoft/hcsshim/README.md
generated
vendored
@ -9,15 +9,18 @@ It is primarily used in the [Moby](https://github.com/moby/moby) and [Containerd
|
||||
## Building
|
||||
|
||||
While this repository can be used as a library of sorts to call the HCS apis, there are a couple binaries built out of the repository as well. The main ones being the Linux guest agent, and an implementation of the [runtime v2 containerd shim api](https://github.com/containerd/containerd/blob/master/runtime/v2/README.md).
|
||||
|
||||
### Linux Hyper-V Container Guest Agent
|
||||
|
||||
To build the Linux guest agent itself all that's needed is to set your GOOS to "Linux" and build out of ./cmd/gcs.
|
||||
|
||||
```powershell
|
||||
C:\> $env:GOOS="linux"
|
||||
C:\> go build .\cmd\gcs\
|
||||
```
|
||||
|
||||
or on a Linux machine
|
||||
|
||||
```sh
|
||||
> go build ./cmd/gcs
|
||||
```
|
||||
@ -33,13 +36,15 @@ make all
|
||||
```
|
||||
|
||||
If the build is successful, in the `./out` folder you should see:
|
||||
|
||||
```sh
|
||||
> ls ./out/
|
||||
delta.tar.gz initrd.img rootfs.tar.gz
|
||||
```
|
||||
|
||||
### Containerd Shim
|
||||
For info on the Runtime V2 API: https://github.com/containerd/containerd/blob/master/runtime/v2/README.md.
|
||||
|
||||
For info on the [Runtime V2 API](https://github.com/containerd/containerd/blob/master/runtime/v2/README.md).
|
||||
|
||||
Contrary to the typical Linux architecture of shim -> runc, the runhcs shim is used both to launch and manage the lifetime of containers.
|
||||
|
||||
@ -48,7 +53,9 @@ C:\> $env:GOOS="windows"
|
||||
C:\> go build .\cmd\containerd-shim-runhcs-v1
|
||||
```
|
||||
|
||||
Then place the binary in the same directory that Containerd is located at in your environment. A default Containerd configuration file can be generated by running:
|
||||
Then place the binary in the same directory that Containerd is located at in your environment.
|
||||
A default Containerd configuration file can be generated by running:
|
||||
|
||||
```powershell
|
||||
.\containerd.exe config default | Out-File "C:\Program Files\containerd\config.toml" -Encoding ascii
|
||||
```
|
||||
@ -56,6 +63,7 @@ Then place the binary in the same directory that Containerd is located at in you
|
||||
This config file will already have the shim set as the default runtime for cri interactions.
|
||||
|
||||
To trial using the shim out with ctr.exe:
|
||||
|
||||
```powershell
|
||||
C:\> ctr.exe run --runtime io.containerd.runhcs.v1 --rm mcr.microsoft.com/windows/nanoserver:2004 windows-test cmd /c "echo Hello World!"
|
||||
```
|
||||
@ -64,16 +72,69 @@ C:\> ctr.exe run --runtime io.containerd.runhcs.v1 --rm mcr.microsoft.com/window
|
||||
|
||||
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
||||
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
||||
the rights to use your contribution. For details, visit https://cla.microsoft.com.
|
||||
the rights to use your contribution. For details, visit [Microsoft CLA](https://cla.microsoft.com).
|
||||
|
||||
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
|
||||
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
|
||||
provided by the bot. You will only need to do this once across all repos using our CLA.
|
||||
|
||||
We also require that contributors [sign their commits](https://git-scm.com/docs/git-commit) using `git commit -s` or `git commit --signoff` to
|
||||
certify they either authored the work themselves or otherwise have permission to use it in this project. Please see https://developercertificate.org/ for
|
||||
more info, as well as to make sure that you can attest to the rules listed. Our CI uses the [DCO Github app](https://github.com/apps/dco) to ensure
|
||||
that all commits in a given PR are signed-off.
|
||||
We require that contributors sign their commits
|
||||
to certify they either authored the work themselves or otherwise have permission to use it in this project.
|
||||
|
||||
We also require that contributors sign their commits using using [`git commit --signoff`][git-commit-s]
|
||||
to certify they either authored the work themselves or otherwise have permission to use it in this project.
|
||||
A range of commits can be signed off using [`git rebase --signoff`][git-rebase-s].
|
||||
|
||||
Please see [the developer certificate](https://developercertificate.org) for more info,
|
||||
as well as to make sure that you can attest to the rules listed.
|
||||
Our CI uses the [DCO Github app](https://github.com/apps/dco) to ensure that all commits in a given PR are signed-off.
|
||||
|
||||
### Linting
|
||||
|
||||
Code must pass a linting stage, which uses [`golangci-lint`][lint].
|
||||
Since `./test` is a separate Go module, the linter is run from both the root and the
|
||||
`test` directories. Additionally, the linter is run with `GOOS` set to both `windows` and
|
||||
`linux`.
|
||||
|
||||
The linting settings are stored in [`.golangci.yaml`](./.golangci.yaml), and can be run
|
||||
automatically with VSCode by adding the following to your workspace or folder settings:
|
||||
|
||||
```json
|
||||
"go.lintTool": "golangci-lint",
|
||||
"go.lintOnSave": "package",
|
||||
```
|
||||
|
||||
Additional editor [integrations options are also available][lint-ide].
|
||||
|
||||
Alternatively, `golangci-lint` can be [installed][lint-install] and run locally:
|
||||
|
||||
```shell
|
||||
# use . or specify a path to only lint a package
|
||||
# to show all lint errors, use flags "--max-issues-per-linter=0 --max-same-issues=0"
|
||||
> golangci-lint run
|
||||
```
|
||||
|
||||
To run across the entire repo for both `GOOS=windows` and `linux`:
|
||||
|
||||
```powershell
|
||||
> foreach ( $goos in ('windows', 'linux') ) {
|
||||
foreach ( $repo in ('.', 'test') ) {
|
||||
pwsh -Command "cd $repo && go env -w GOOS=$goos && golangci-lint.exe run --verbose"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Go Generate
|
||||
|
||||
The pipeline checks that auto-generated code, via `go generate`, are up to date.
|
||||
Similar to the [linting stage](#linting), `go generate` is run in both the root and test Go modules.
|
||||
|
||||
This can be done via:
|
||||
|
||||
```shell
|
||||
> go generate ./...
|
||||
> cd test && go generate ./...
|
||||
```
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
@ -83,7 +144,7 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio
|
||||
|
||||
## Dependencies
|
||||
|
||||
This project requires Golang 1.17 or newer to build.
|
||||
This project requires Golang 1.18 or newer to build.
|
||||
|
||||
For system requirements to run this project, see the Microsoft docs on [Windows Container requirements](https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/system-requirements).
|
||||
|
||||
@ -100,3 +161,10 @@ For additional details, see [Report a Computer Security Vulnerability](https://t
|
||||
|
||||
---------------
|
||||
Copyright (c) 2018 Microsoft Corp. All rights reserved.
|
||||
|
||||
[lint]: https://golangci-lint.run/
|
||||
[lint-ide]: https://golangci-lint.run/usage/integrations/#editor-integration
|
||||
[lint-install]: https://golangci-lint.run/usage/install/#local-installation
|
||||
|
||||
[git-commit-s]: https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--s
|
||||
[git-rebase-s]: https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt---signoff
|
||||
|
28
vendor/github.com/Microsoft/hcsshim/computestorage/attach.go
generated
vendored
28
vendor/github.com/Microsoft/hcsshim/computestorage/attach.go
generated
vendored
@ -38,3 +38,31 @@ func AttachLayerStorageFilter(ctx context.Context, layerPath string, layerData L
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AttachOverlayFilter sets up a filter of the given type on a writable container layer. Currently the only
|
||||
// supported filter types are WCIFS & UnionFS (defined in internal/hcs/schema2/layer.go)
|
||||
//
|
||||
// `volumePath` is volume path at which writable layer is mounted. If the
|
||||
// path does not end in a `\` the platform will append it automatically.
|
||||
//
|
||||
// `layerData` is the parent read-only layer data.
|
||||
func AttachOverlayFilter(ctx context.Context, volumePath string, layerData LayerData) (err error) {
|
||||
title := "hcsshim::AttachOverlayFilter"
|
||||
ctx, span := oc.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
|
||||
defer span.End()
|
||||
defer func() { oc.SetSpanStatus(span, err) }()
|
||||
span.AddAttributes(
|
||||
trace.StringAttribute("volumePath", volumePath),
|
||||
)
|
||||
|
||||
bytes, err := json.Marshal(layerData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = hcsAttachOverlayFilter(volumePath, string(bytes))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to attach overlay filter")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
26
vendor/github.com/Microsoft/hcsshim/computestorage/detach.go
generated
vendored
26
vendor/github.com/Microsoft/hcsshim/computestorage/detach.go
generated
vendored
@ -4,7 +4,9 @@ package computestorage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2"
|
||||
"github.com/Microsoft/hcsshim/internal/oc"
|
||||
"github.com/pkg/errors"
|
||||
"go.opencensus.io/trace"
|
||||
@ -26,3 +28,27 @@ func DetachLayerStorageFilter(ctx context.Context, layerPath string) (err error)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DetachOverlayFilter detaches the filter on a writable container layer.
|
||||
//
|
||||
// `volumePath` is a path to writable container volume.
|
||||
func DetachOverlayFilter(ctx context.Context, volumePath string, filterType hcsschema.FileSystemFilterType) (err error) {
|
||||
title := "hcsshim::DetachOverlayFilter"
|
||||
ctx, span := oc.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
|
||||
defer span.End()
|
||||
defer func() { oc.SetSpanStatus(span, err) }()
|
||||
span.AddAttributes(trace.StringAttribute("volumePath", volumePath))
|
||||
|
||||
layerData := LayerData{}
|
||||
layerData.FilterType = filterType
|
||||
bytes, err := json.Marshal(layerData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = hcsDetachOverlayFilter(volumePath, string(bytes))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to detach overlay filter")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
4
vendor/github.com/Microsoft/hcsshim/computestorage/helpers.go
generated
vendored
4
vendor/github.com/Microsoft/hcsshim/computestorage/helpers.go
generated
vendored
@ -16,7 +16,9 @@ import (
|
||||
"github.com/Microsoft/hcsshim/internal/security"
|
||||
)
|
||||
|
||||
const defaultVHDXBlockSizeInMB = 1
|
||||
const (
|
||||
defaultVHDXBlockSizeInMB = 1
|
||||
)
|
||||
|
||||
// SetupContainerBaseLayer is a helper to setup a containers scratch. It
|
||||
// will create and format the vhdx's inside and the size is configurable with the sizeInGB
|
||||
|
9
vendor/github.com/Microsoft/hcsshim/computestorage/storage.go
generated
vendored
9
vendor/github.com/Microsoft/hcsshim/computestorage/storage.go
generated
vendored
@ -11,7 +11,7 @@ import (
|
||||
|
||||
//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?
|
||||
//sys hcsDestroyLayer(layerPath string) (hr error) = computestorage.HcsDestoryLayer?
|
||||
//sys hcsDestroyLayer(layerPath string) (hr error) = computestorage.HcsDestroyLayer?
|
||||
//sys hcsSetupBaseOSLayer(layerPath string, handle windows.Handle, options string) (hr error) = computestorage.HcsSetupBaseOSLayer?
|
||||
//sys hcsInitializeWritableLayer(writableLayerPath string, layerData string, options string) (hr error) = computestorage.HcsInitializeWritableLayer?
|
||||
//sys hcsAttachLayerStorageFilter(layerPath string, layerData string) (hr error) = computestorage.HcsAttachLayerStorageFilter?
|
||||
@ -19,14 +19,17 @@ import (
|
||||
//sys hcsFormatWritableLayerVhd(handle windows.Handle) (hr error) = computestorage.HcsFormatWritableLayerVhd?
|
||||
//sys hcsGetLayerVhdMountPath(vhdHandle windows.Handle, mountPath **uint16) (hr error) = computestorage.HcsGetLayerVhdMountPath?
|
||||
//sys hcsSetupBaseOSVolume(layerPath string, volumePath string, options string) (hr error) = computestorage.HcsSetupBaseOSVolume?
|
||||
//sys hcsAttachOverlayFilter(volumePath string, layerData string) (hr error) = computestorage.HcsAttachOverlayFilter?
|
||||
//sys hcsDetachOverlayFilter(volumePath string, layerData string) (hr error) = computestorage.HcsDetachOverlayFilter?
|
||||
|
||||
type Version = hcsschema.Version
|
||||
type Layer = hcsschema.Layer
|
||||
|
||||
// LayerData is the data used to describe parent layer information.
|
||||
type LayerData struct {
|
||||
SchemaVersion Version `json:"SchemaVersion,omitempty"`
|
||||
Layers []Layer `json:"Layers,omitempty"`
|
||||
SchemaVersion Version `json:"SchemaVersion,omitempty"`
|
||||
Layers []Layer `json:"Layers,omitempty"`
|
||||
FilterType hcsschema.FileSystemFilterType `json:"FilterType,omitempty"`
|
||||
}
|
||||
|
||||
// ExportLayerOptions are the set of options that are used with the `computestorage.HcsExportLayer` syscall.
|
||||
|
66
vendor/github.com/Microsoft/hcsshim/computestorage/zsyscall_windows.go
generated
vendored
66
vendor/github.com/Microsoft/hcsshim/computestorage/zsyscall_windows.go
generated
vendored
@ -43,8 +43,10 @@ var (
|
||||
modcomputestorage = windows.NewLazySystemDLL("computestorage.dll")
|
||||
|
||||
procHcsAttachLayerStorageFilter = modcomputestorage.NewProc("HcsAttachLayerStorageFilter")
|
||||
procHcsDestoryLayer = modcomputestorage.NewProc("HcsDestoryLayer")
|
||||
procHcsAttachOverlayFilter = modcomputestorage.NewProc("HcsAttachOverlayFilter")
|
||||
procHcsDestroyLayer = modcomputestorage.NewProc("HcsDestroyLayer")
|
||||
procHcsDetachLayerStorageFilter = modcomputestorage.NewProc("HcsDetachLayerStorageFilter")
|
||||
procHcsDetachOverlayFilter = modcomputestorage.NewProc("HcsDetachOverlayFilter")
|
||||
procHcsExportLayer = modcomputestorage.NewProc("HcsExportLayer")
|
||||
procHcsFormatWritableLayerVhd = modcomputestorage.NewProc("HcsFormatWritableLayerVhd")
|
||||
procHcsGetLayerVhdMountPath = modcomputestorage.NewProc("HcsGetLayerVhdMountPath")
|
||||
@ -83,6 +85,35 @@ func _hcsAttachLayerStorageFilter(layerPath *uint16, layerData *uint16) (hr erro
|
||||
return
|
||||
}
|
||||
|
||||
func hcsAttachOverlayFilter(volumePath string, layerData string) (hr error) {
|
||||
var _p0 *uint16
|
||||
_p0, hr = syscall.UTF16PtrFromString(volumePath)
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
var _p1 *uint16
|
||||
_p1, hr = syscall.UTF16PtrFromString(layerData)
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
return _hcsAttachOverlayFilter(_p0, _p1)
|
||||
}
|
||||
|
||||
func _hcsAttachOverlayFilter(volumePath *uint16, layerData *uint16) (hr error) {
|
||||
hr = procHcsAttachOverlayFilter.Find()
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
r0, _, _ := syscall.Syscall(procHcsAttachOverlayFilter.Addr(), 2, uintptr(unsafe.Pointer(volumePath)), uintptr(unsafe.Pointer(layerData)), 0)
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func hcsDestroyLayer(layerPath string) (hr error) {
|
||||
var _p0 *uint16
|
||||
_p0, hr = syscall.UTF16PtrFromString(layerPath)
|
||||
@ -93,11 +124,11 @@ func hcsDestroyLayer(layerPath string) (hr error) {
|
||||
}
|
||||
|
||||
func _hcsDestroyLayer(layerPath *uint16) (hr error) {
|
||||
hr = procHcsDestoryLayer.Find()
|
||||
hr = procHcsDestroyLayer.Find()
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
r0, _, _ := syscall.Syscall(procHcsDestoryLayer.Addr(), 1, uintptr(unsafe.Pointer(layerPath)), 0, 0)
|
||||
r0, _, _ := syscall.Syscall(procHcsDestroyLayer.Addr(), 1, uintptr(unsafe.Pointer(layerPath)), 0, 0)
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
@ -131,6 +162,35 @@ func _hcsDetachLayerStorageFilter(layerPath *uint16) (hr error) {
|
||||
return
|
||||
}
|
||||
|
||||
func hcsDetachOverlayFilter(volumePath string, layerData string) (hr error) {
|
||||
var _p0 *uint16
|
||||
_p0, hr = syscall.UTF16PtrFromString(volumePath)
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
var _p1 *uint16
|
||||
_p1, hr = syscall.UTF16PtrFromString(layerData)
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
return _hcsDetachOverlayFilter(_p0, _p1)
|
||||
}
|
||||
|
||||
func _hcsDetachOverlayFilter(volumePath *uint16, layerData *uint16) (hr error) {
|
||||
hr = procHcsDetachOverlayFilter.Find()
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
r0, _, _ := syscall.Syscall(procHcsDetachOverlayFilter.Addr(), 2, uintptr(unsafe.Pointer(volumePath)), uintptr(unsafe.Pointer(layerData)), 0)
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func hcsExportLayer(layerPath string, exportFolderPath string, layerData string, options string) (hr error) {
|
||||
var _p0 *uint16
|
||||
_p0, hr = syscall.UTF16PtrFromString(layerPath)
|
||||
|
2
vendor/github.com/Microsoft/hcsshim/container.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/container.go
generated
vendored
@ -75,7 +75,7 @@ func init() {
|
||||
func CreateContainer(id string, c *ContainerConfig) (Container, error) {
|
||||
fullConfig, err := mergemaps.MergeJSON(c, createContainerAdditionalJSON)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to merge additional JSON '%s': %s", createContainerAdditionalJSON, err)
|
||||
return nil, fmt.Errorf("failed to merge additional JSON '%s': %w", createContainerAdditionalJSON, err)
|
||||
}
|
||||
|
||||
system, err := hcs.CreateComputeSystem(context.Background(), id, fullConfig)
|
||||
|
11
vendor/github.com/Microsoft/hcsshim/errors.go
generated
vendored
11
vendor/github.com/Microsoft/hcsshim/errors.go
generated
vendored
@ -115,6 +115,7 @@ func (e *ContainerError) Error() string {
|
||||
s += " encountered an error during " + e.Operation
|
||||
}
|
||||
|
||||
//nolint:errorlint // legacy code
|
||||
switch e.Err.(type) {
|
||||
case nil:
|
||||
break
|
||||
@ -145,6 +146,7 @@ func (e *ProcessError) Error() string {
|
||||
s += " encountered an error during " + e.Operation
|
||||
}
|
||||
|
||||
//nolint:errorlint // legacy code
|
||||
switch e.Err.(type) {
|
||||
case nil:
|
||||
break
|
||||
@ -166,10 +168,10 @@ func (e *ProcessError) Error() string {
|
||||
// already exited, or does not exist. Both IsAlreadyStopped and IsNotExist
|
||||
// will currently return true when the error is ErrElementNotFound.
|
||||
func IsNotExist(err error) bool {
|
||||
if _, ok := err.(EndpointNotFoundError); ok {
|
||||
if _, ok := err.(EndpointNotFoundError); ok { //nolint:errorlint // legacy code
|
||||
return true
|
||||
}
|
||||
if _, ok := err.(NetworkNotFoundError); ok {
|
||||
if _, ok := err.(NetworkNotFoundError); ok { //nolint:errorlint // legacy code
|
||||
return true
|
||||
}
|
||||
return hcs.IsNotExist(getInnerError(err))
|
||||
@ -224,6 +226,7 @@ func IsAccessIsDenied(err error) bool {
|
||||
}
|
||||
|
||||
func getInnerError(err error) error {
|
||||
//nolint:errorlint // legacy code
|
||||
switch pe := err.(type) {
|
||||
case nil:
|
||||
return nil
|
||||
@ -236,14 +239,14 @@ func getInnerError(err error) error {
|
||||
}
|
||||
|
||||
func convertSystemError(err error, c *container) error {
|
||||
if serr, ok := err.(*hcs.SystemError); ok {
|
||||
if serr, ok := err.(*hcs.SystemError); ok { //nolint:errorlint // legacy code
|
||||
return &ContainerError{Container: c, Operation: serr.Op, Err: serr.Err, Events: serr.Events}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func convertProcessError(err error, p *process) error {
|
||||
if perr, ok := err.(*hcs.ProcessError); ok {
|
||||
if perr, ok := err.(*hcs.ProcessError); ok { //nolint:errorlint // legacy code
|
||||
return &ProcessError{Process: p, Operation: perr.Op, Err: perr.Err, Events: perr.Events}
|
||||
}
|
||||
return err
|
||||
|
12
vendor/github.com/Microsoft/hcsshim/hcn/hcn.go
generated
vendored
12
vendor/github.com/Microsoft/hcsshim/hcn/hcn.go
generated
vendored
@ -312,6 +312,18 @@ func NestedIpSetSupported() error {
|
||||
return platformDoesNotSupportError("NestedIpSet")
|
||||
}
|
||||
|
||||
// DisableHostPortSupported returns an error if the HCN version does not support DisableHostPort flag
|
||||
func DisableHostPortSupported() error {
|
||||
supported, err := GetCachedSupportedFeatures()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if supported.DisableHostPort {
|
||||
return nil
|
||||
}
|
||||
return platformDoesNotSupportError("DisableHostPort")
|
||||
}
|
||||
|
||||
// RequestType are the different operations performed to settings.
|
||||
// Used to update the settings of Endpoint/Namespace objects.
|
||||
type RequestType string
|
||||
|
57
vendor/github.com/Microsoft/hcsshim/hcn/hcnerrors.go
generated
vendored
57
vendor/github.com/Microsoft/hcsshim/hcn/hcnerrors.go
generated
vendored
@ -6,11 +6,12 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sys/windows"
|
||||
|
||||
"github.com/Microsoft/hcsshim/internal/hcs"
|
||||
"github.com/Microsoft/hcsshim/internal/hcserror"
|
||||
"github.com/Microsoft/hcsshim/internal/interop"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -63,8 +64,8 @@ func (e *HcnError) Error() string {
|
||||
}
|
||||
|
||||
func CheckErrorWithCode(err error, code ErrorCode) bool {
|
||||
hcnError, ok := err.(*HcnError)
|
||||
if ok {
|
||||
var hcnError *HcnError
|
||||
if errors.As(err, &hcnError) {
|
||||
return hcnError.code == code
|
||||
}
|
||||
return false
|
||||
@ -81,7 +82,7 @@ func IsPortAlreadyExistsError(err error) bool {
|
||||
func new(hr error, title string, rest string) error {
|
||||
err := &HcnError{}
|
||||
hcsError := hcserror.New(hr, title, rest)
|
||||
err.HcsError = hcsError.(*hcserror.HcsError)
|
||||
err.HcsError = hcsError.(*hcserror.HcsError) //nolint:errorlint
|
||||
err.code = ErrorCode(hcserror.Win32FromError(hr))
|
||||
return err
|
||||
}
|
||||
@ -97,6 +98,8 @@ type NetworkNotFoundError struct {
|
||||
NetworkID string
|
||||
}
|
||||
|
||||
var _ error = NetworkNotFoundError{}
|
||||
|
||||
func (e NetworkNotFoundError) Error() string {
|
||||
if e.NetworkName != "" {
|
||||
return fmt.Sprintf("Network name %q not found", e.NetworkName)
|
||||
@ -110,6 +113,8 @@ type EndpointNotFoundError struct {
|
||||
EndpointID string
|
||||
}
|
||||
|
||||
var _ error = EndpointNotFoundError{}
|
||||
|
||||
func (e EndpointNotFoundError) Error() string {
|
||||
if e.EndpointName != "" {
|
||||
return fmt.Sprintf("Endpoint name %q not found", e.EndpointName)
|
||||
@ -122,6 +127,8 @@ type NamespaceNotFoundError struct {
|
||||
NamespaceID string
|
||||
}
|
||||
|
||||
var _ error = NamespaceNotFoundError{}
|
||||
|
||||
func (e NamespaceNotFoundError) Error() string {
|
||||
return fmt.Sprintf("Namespace ID %q not found", e.NamespaceID)
|
||||
}
|
||||
@ -131,6 +138,8 @@ type LoadBalancerNotFoundError struct {
|
||||
LoadBalancerId string
|
||||
}
|
||||
|
||||
var _ error = LoadBalancerNotFoundError{}
|
||||
|
||||
func (e LoadBalancerNotFoundError) Error() string {
|
||||
return fmt.Sprintf("LoadBalancer %q not found", e.LoadBalancerId)
|
||||
}
|
||||
@ -140,6 +149,8 @@ type RouteNotFoundError struct {
|
||||
RouteId string
|
||||
}
|
||||
|
||||
var _ error = RouteNotFoundError{}
|
||||
|
||||
func (e RouteNotFoundError) Error() string {
|
||||
return fmt.Sprintf("SDN Route %q not found", e.RouteId)
|
||||
}
|
||||
@ -147,19 +158,31 @@ func (e RouteNotFoundError) Error() string {
|
||||
// IsNotFoundError returns a boolean indicating whether the error was caused by
|
||||
// a resource not being found.
|
||||
func IsNotFoundError(err error) bool {
|
||||
switch pe := err.(type) {
|
||||
case NetworkNotFoundError:
|
||||
// Calling [errors.As] in a loop over `[]error{NetworkNotFoundError{}, ...}` will not work,
|
||||
// since the loop variable will be an interface type (ie, `error`) and `errors.As(error, *error)` will
|
||||
// always succeed.
|
||||
// Unless golang adds loops over (or arrays of) types, we need to manually call `errors.As` for
|
||||
// each potential error type.
|
||||
//
|
||||
// Also, for T = NetworkNotFoundError and co, the error implementation is for T, not *T
|
||||
if e := (NetworkNotFoundError{}); errors.As(err, &e) {
|
||||
return true
|
||||
case EndpointNotFoundError:
|
||||
return true
|
||||
case NamespaceNotFoundError:
|
||||
return true
|
||||
case LoadBalancerNotFoundError:
|
||||
return true
|
||||
case RouteNotFoundError:
|
||||
return true
|
||||
case *hcserror.HcsError:
|
||||
return pe.Err == hcs.ErrElementNotFound
|
||||
}
|
||||
if e := (EndpointNotFoundError{}); errors.As(err, &e) {
|
||||
return true
|
||||
}
|
||||
if e := (NamespaceNotFoundError{}); errors.As(err, &e) {
|
||||
return true
|
||||
}
|
||||
if e := (LoadBalancerNotFoundError{}); errors.As(err, &e) {
|
||||
return true
|
||||
}
|
||||
if e := (RouteNotFoundError{}); errors.As(err, &e) {
|
||||
return true
|
||||
}
|
||||
if e := (&hcserror.HcsError{}); errors.As(err, &e) {
|
||||
return errors.Is(e.Err, hcs.ErrElementNotFound)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
3
vendor/github.com/Microsoft/hcsshim/hcn/hcnglobals.go
generated
vendored
3
vendor/github.com/Microsoft/hcsshim/hcn/hcnglobals.go
generated
vendored
@ -84,6 +84,9 @@ var (
|
||||
|
||||
//HNS 15.0 allows for NestedIpSet support
|
||||
NestedIpSetVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 15, Minor: 0}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}}
|
||||
|
||||
//HNS 15.1 allows support for DisableHostPort flag.
|
||||
DisableHostPortVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 15, Minor: 1}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}}
|
||||
)
|
||||
|
||||
// GetGlobals returns the global properties of the HCN Service.
|
||||
|
4
vendor/github.com/Microsoft/hcsshim/hcn/hcnnamespace.go
generated
vendored
4
vendor/github.com/Microsoft/hcsshim/hcn/hcnnamespace.go
generated
vendored
@ -4,6 +4,7 @@ package hcn
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
@ -378,7 +379,8 @@ func (namespace *HostComputeNamespace) Sync() error {
|
||||
shimPath := runhcs.VMPipePath(cfg.HostUniqueID)
|
||||
if err := runhcs.IssueVMRequest(shimPath, &req); err != nil {
|
||||
// The shim is likely gone. Simply ignore the sync as if it didn't exist.
|
||||
if perr, ok := err.(*os.PathError); ok && perr.Err == syscall.ERROR_FILE_NOT_FOUND {
|
||||
var perr *os.PathError
|
||||
if errors.As(err, &perr) && errors.Is(perr.Err, syscall.ERROR_FILE_NOT_FOUND) {
|
||||
// Remove the reg key there is no point to try again
|
||||
_ = cfg.Remove()
|
||||
return nil
|
||||
|
1
vendor/github.com/Microsoft/hcsshim/hcn/hcnnetwork.go
generated
vendored
1
vendor/github.com/Microsoft/hcsshim/hcn/hcnnetwork.go
generated
vendored
@ -72,6 +72,7 @@ type NetworkFlags uint32
|
||||
const (
|
||||
None NetworkFlags = 0
|
||||
EnableNonPersistent NetworkFlags = 8
|
||||
DisableHostPort NetworkFlags = 1024
|
||||
)
|
||||
|
||||
// HostComputeNetwork represents a network
|
||||
|
2
vendor/github.com/Microsoft/hcsshim/hcn/hcnsupport.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/hcn/hcnsupport.go
generated
vendored
@ -37,6 +37,7 @@ type SupportedFeatures struct {
|
||||
TierAcl bool `json:"TierAcl"`
|
||||
NetworkACL bool `json:"NetworkACL"`
|
||||
NestedIpSet bool `json:"NestedIpSet"`
|
||||
DisableHostPort bool `json:"DisableHostPort"`
|
||||
}
|
||||
|
||||
// AclFeatures are the supported ACL possibilities.
|
||||
@ -114,6 +115,7 @@ func getSupportedFeatures() (SupportedFeatures, error) {
|
||||
features.TierAcl = isFeatureSupported(globals.Version, TierAclPolicyVersion)
|
||||
features.NetworkACL = isFeatureSupported(globals.Version, NetworkACLPolicyVersion)
|
||||
features.NestedIpSet = isFeatureSupported(globals.Version, NestedIpSetVersion)
|
||||
features.DisableHostPort = isFeatureSupported(globals.Version, DisableHostPortVersion)
|
||||
|
||||
log.L.WithFields(logrus.Fields{
|
||||
"version": globals.Version,
|
||||
|
56
vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
generated
vendored
56
vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
generated
vendored
@ -12,14 +12,16 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"go.opencensus.io/trace"
|
||||
|
||||
"github.com/Microsoft/hcsshim/internal/cow"
|
||||
hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2"
|
||||
"github.com/Microsoft/hcsshim/internal/log"
|
||||
"github.com/Microsoft/hcsshim/internal/oc"
|
||||
"github.com/Microsoft/hcsshim/internal/protocol/guestrequest"
|
||||
"github.com/Microsoft/hcsshim/internal/vmcompute"
|
||||
"go.opencensus.io/trace"
|
||||
)
|
||||
|
||||
// ContainerError is an error encountered in HCS
|
||||
type Process struct {
|
||||
handleLock sync.RWMutex
|
||||
handle vmcompute.HcsProcess
|
||||
@ -50,35 +52,6 @@ func newProcess(process vmcompute.HcsProcess, processID int, computeSystem *Syst
|
||||
}
|
||||
}
|
||||
|
||||
type processModifyRequest struct {
|
||||
Operation string
|
||||
ConsoleSize *consoleSize `json:",omitempty"`
|
||||
CloseHandle *closeHandle `json:",omitempty"`
|
||||
}
|
||||
|
||||
type consoleSize struct {
|
||||
Height uint16
|
||||
Width uint16
|
||||
}
|
||||
|
||||
type closeHandle struct {
|
||||
Handle string
|
||||
}
|
||||
|
||||
type processStatus struct {
|
||||
ProcessID uint32
|
||||
Exited bool
|
||||
ExitCode uint32
|
||||
LastWaitResult int32
|
||||
}
|
||||
|
||||
const stdIn string = "StdIn"
|
||||
|
||||
const (
|
||||
modifyConsoleSize string = "ConsoleSize"
|
||||
modifyCloseHandle string = "CloseHandle"
|
||||
)
|
||||
|
||||
// Pid returns the process ID of the process within the container.
|
||||
func (process *Process) Pid() int {
|
||||
return process.processID
|
||||
@ -90,7 +63,7 @@ func (process *Process) SystemID() string {
|
||||
}
|
||||
|
||||
func (process *Process) processSignalResult(ctx context.Context, err error) (bool, error) {
|
||||
switch err {
|
||||
switch err { //nolint:errorlint
|
||||
case nil:
|
||||
return true, nil
|
||||
case ErrVmcomputeOperationInvalidState, ErrComputeSystemDoesNotExist, ErrElementNotFound:
|
||||
@ -260,14 +233,14 @@ func (process *Process) waitBackground() {
|
||||
process.handleLock.RLock()
|
||||
defer process.handleLock.RUnlock()
|
||||
|
||||
// Make sure we didnt race with Close() here
|
||||
// Make sure we didn't race with Close() here
|
||||
if process.handle != 0 {
|
||||
propertiesJSON, resultJSON, err = vmcompute.HcsGetProcessProperties(ctx, process.handle)
|
||||
events := processHcsResult(ctx, resultJSON)
|
||||
if err != nil {
|
||||
err = makeProcessError(process, operation, err, events)
|
||||
} else {
|
||||
properties := &processStatus{}
|
||||
properties := &hcsschema.ProcessStatus{}
|
||||
err = json.Unmarshal([]byte(propertiesJSON), properties)
|
||||
if err != nil {
|
||||
err = makeProcessError(process, operation, err, nil)
|
||||
@ -318,10 +291,9 @@ func (process *Process) ResizeConsole(ctx context.Context, width, height uint16)
|
||||
if process.handle == 0 {
|
||||
return makeProcessError(process, operation, ErrAlreadyClosed, nil)
|
||||
}
|
||||
|
||||
modifyRequest := processModifyRequest{
|
||||
Operation: modifyConsoleSize,
|
||||
ConsoleSize: &consoleSize{
|
||||
modifyRequest := hcsschema.ProcessModifyRequest{
|
||||
Operation: guestrequest.ModifyProcessConsoleSize,
|
||||
ConsoleSize: &hcsschema.ConsoleSize{
|
||||
Height: height,
|
||||
Width: width,
|
||||
},
|
||||
@ -423,10 +395,10 @@ func (process *Process) CloseStdin(ctx context.Context) (err error) {
|
||||
|
||||
//HcsModifyProcess request to close stdin will fail if the process has already exited
|
||||
if !process.stopped() {
|
||||
modifyRequest := processModifyRequest{
|
||||
Operation: modifyCloseHandle,
|
||||
CloseHandle: &closeHandle{
|
||||
Handle: stdIn,
|
||||
modifyRequest := hcsschema.ProcessModifyRequest{
|
||||
Operation: guestrequest.CloseProcessHandle,
|
||||
CloseHandle: &hcsschema.CloseHandle{
|
||||
Handle: guestrequest.STDInHandle,
|
||||
},
|
||||
}
|
||||
|
||||
|
25
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/cim_mount.go
generated
vendored
Normal file
25
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/cim_mount.go
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* HCS API
|
||||
*
|
||||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
||||
*
|
||||
* API version: 2.5
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package hcsschema
|
||||
|
||||
const (
|
||||
CimMountFlagNone uint32 = 0x0
|
||||
CimMountFlagChildOnly uint32 = 0x1
|
||||
CimMountFlagEnableDax uint32 = 0x2
|
||||
CimMountFlagCacheFiles uint32 = 0x4
|
||||
CimMountFlagCacheRegions uint32 = 0x8
|
||||
)
|
||||
|
||||
type CimMount struct {
|
||||
ImagePath string `json:"ImagePath,omitempty"`
|
||||
FileSystemName string `json:"FileSystemName,omitempty"`
|
||||
VolumeGuid string `json:"VolumeGuid,omitempty"`
|
||||
MountFlags uint32 `json:"MountFlags,omitempty"`
|
||||
}
|
4
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/close_handle.go
generated
vendored
4
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/close_handle.go
generated
vendored
@ -9,6 +9,8 @@
|
||||
|
||||
package hcsschema
|
||||
|
||||
import "github.com/Microsoft/hcsshim/internal/protocol/guestrequest"
|
||||
|
||||
type CloseHandle struct {
|
||||
Handle string `json:"Handle,omitempty"`
|
||||
Handle guestrequest.STDIOHandle `json:"Handle,omitempty"` // NOTE: Swagger generated as string. Locally updated.
|
||||
}
|
||||
|
9
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/console_size.go
generated
vendored
9
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/console_size.go
generated
vendored
@ -9,8 +9,11 @@
|
||||
|
||||
package hcsschema
|
||||
|
||||
type ConsoleSize struct {
|
||||
Height int32 `json:"Height,omitempty"`
|
||||
// NOTE: Swagger generated fields as int32. Locally updated to uint16 to match documentation.
|
||||
// https://learn.microsoft.com/en-us/virtualization/api/hcs/schemareference#ConsoleSize
|
||||
|
||||
Width int32 `json:"Width,omitempty"`
|
||||
type ConsoleSize struct {
|
||||
Height uint16 `json:"Height,omitempty"`
|
||||
|
||||
Width uint16 `json:"Width,omitempty"`
|
||||
}
|
||||
|
2
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/isolation_settings.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/isolation_settings.go
generated
vendored
@ -17,5 +17,5 @@ type IsolationSettings struct {
|
||||
DebugPort int64 `json:"DebugPort,omitempty"`
|
||||
// Optional data passed by host on isolated virtual machine start
|
||||
LaunchData string `json:"LaunchData,omitempty"`
|
||||
HclEnabled bool `json:"HclEnabled,omitempty"`
|
||||
HclEnabled *bool `json:"HclEnabled,omitempty"`
|
||||
}
|
||||
|
7
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/layer.go
generated
vendored
7
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/layer.go
generated
vendored
@ -9,6 +9,13 @@
|
||||
|
||||
package hcsschema
|
||||
|
||||
type FileSystemFilterType string
|
||||
|
||||
const (
|
||||
UnionFS FileSystemFilterType = "UnionFS"
|
||||
WCIFS FileSystemFilterType = "WCIFS"
|
||||
)
|
||||
|
||||
type Layer struct {
|
||||
Id string `json:"Id,omitempty"`
|
||||
|
||||
|
6
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/process_modify_request.go
generated
vendored
6
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/process_modify_request.go
generated
vendored
@ -9,9 +9,11 @@
|
||||
|
||||
package hcsschema
|
||||
|
||||
// Passed to HcsRpc_ModifyProcess
|
||||
import "github.com/Microsoft/hcsshim/internal/protocol/guestrequest"
|
||||
|
||||
// Passed to HcsRpc_ModifyProcess
|
||||
type ProcessModifyRequest struct {
|
||||
Operation string `json:"Operation,omitempty"`
|
||||
Operation guestrequest.ProcessModifyOperation `json:"Operation,omitempty"` // NOTE: Swagger generated as string. Locally updated.
|
||||
|
||||
ConsoleSize *ConsoleSize `json:"ConsoleSize,omitempty"`
|
||||
|
||||
|
9
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/process_status.go
generated
vendored
9
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/process_status.go
generated
vendored
@ -9,13 +9,16 @@
|
||||
|
||||
package hcsschema
|
||||
|
||||
// Status of a process running in a container
|
||||
// NOTE: Swagger generated fields as int32. Locally updated to uint16 to match documentation.
|
||||
// https://learn.microsoft.com/en-us/virtualization/api/hcs/schemareference#ConsoleSize
|
||||
|
||||
// Status of a process running in a container
|
||||
type ProcessStatus struct {
|
||||
ProcessId int32 `json:"ProcessId,omitempty"`
|
||||
ProcessId uint32 `json:"ProcessId,omitempty"` // NOTE: Swagger generated as int32. Locally updated to match documentation.
|
||||
|
||||
Exited bool `json:"Exited,omitempty"`
|
||||
|
||||
ExitCode int32 `json:"ExitCode,omitempty"`
|
||||
ExitCode uint32 `json:"ExitCode,omitempty"` // NOTE: Swagger generated as int32. Locally updated to match documentation.
|
||||
|
||||
LastWaitResult int32 `json:"LastWaitResult,omitempty"`
|
||||
}
|
||||
|
2
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/properties.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/properties.go
generated
vendored
@ -10,7 +10,7 @@
|
||||
package hcsschema
|
||||
|
||||
import (
|
||||
v1 "github.com/containerd/cgroups/stats/v1"
|
||||
v1 "github.com/containerd/cgroups/v3/cgroup1/stats"
|
||||
)
|
||||
|
||||
type Properties struct {
|
||||
|
13
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/registry_hive.go
generated
vendored
Normal file
13
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/registry_hive.go
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
package hcsschema
|
||||
|
||||
// NOTE: manually added
|
||||
|
||||
type RegistryHive string
|
||||
|
||||
// List of RegistryHive
|
||||
const (
|
||||
RegistryHive_SYSTEM RegistryHive = "System"
|
||||
RegistryHive_SOFTWARE RegistryHive = "Software"
|
||||
RegistryHive_SECURITY RegistryHive = "Security"
|
||||
RegistryHive_SAM RegistryHive = "Sam"
|
||||
)
|
2
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/registry_key.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/registry_key.go
generated
vendored
@ -10,7 +10,7 @@
|
||||
package hcsschema
|
||||
|
||||
type RegistryKey struct {
|
||||
Hive string `json:"Hive,omitempty"`
|
||||
Hive RegistryHive `json:"Hive,omitempty"`
|
||||
|
||||
Name string `json:"Name,omitempty"`
|
||||
|
||||
|
2
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/registry_value.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/registry_value.go
generated
vendored
@ -14,7 +14,7 @@ type RegistryValue struct {
|
||||
|
||||
Name string `json:"Name,omitempty"`
|
||||
|
||||
Type_ string `json:"Type,omitempty"`
|
||||
Type_ RegistryValueType `json:"Type,omitempty"`
|
||||
|
||||
// One and only one value type must be set.
|
||||
StringValue string `json:"StringValue,omitempty"`
|
||||
|
17
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/registry_value_type.go
generated
vendored
Normal file
17
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/registry_value_type.go
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
package hcsschema
|
||||
|
||||
// NOTE: manually added
|
||||
|
||||
type RegistryValueType string
|
||||
|
||||
// List of RegistryValueType
|
||||
const (
|
||||
RegistryValueType_NONE RegistryValueType = "None"
|
||||
RegistryValueType_STRING RegistryValueType = "String"
|
||||
RegistryValueType_EXPANDED_STRING RegistryValueType = "ExpandedString"
|
||||
RegistryValueType_MULTI_STRING RegistryValueType = "MultiString"
|
||||
RegistryValueType_BINARY RegistryValueType = "Binary"
|
||||
RegistryValueType_D_WORD RegistryValueType = "DWord"
|
||||
RegistryValueType_Q_WORD RegistryValueType = "QWord"
|
||||
RegistryValueType_CUSTOM_TYPE RegistryValueType = "CustomType"
|
||||
)
|
39
vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
generated
vendored
39
vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
generated
vendored
@ -97,7 +97,7 @@ func CreateComputeSystem(ctx context.Context, id string, hcsDocumentInterface in
|
||||
events, err := processAsyncHcsResult(ctx, createError, resultJSON, computeSystem.callbackNumber,
|
||||
hcsNotificationSystemCreateCompleted, &timeout.SystemCreate)
|
||||
if err != nil {
|
||||
if err == ErrTimeout {
|
||||
if errors.Is(err, ErrTimeout) {
|
||||
// Terminate the compute system if it still exists. We're okay to
|
||||
// ignore a failure here.
|
||||
_ = computeSystem.Terminate(ctx)
|
||||
@ -238,7 +238,7 @@ func (computeSystem *System) Shutdown(ctx context.Context) error {
|
||||
|
||||
resultJSON, err := vmcompute.HcsShutdownComputeSystem(ctx, computeSystem.handle, "")
|
||||
events := processHcsResult(ctx, resultJSON)
|
||||
switch err {
|
||||
switch err { //nolint:errorlint
|
||||
case nil, ErrVmcomputeAlreadyStopped, ErrComputeSystemDoesNotExist, ErrVmcomputeOperationPending:
|
||||
default:
|
||||
return makeSystemError(computeSystem, operation, err, events)
|
||||
@ -259,7 +259,7 @@ func (computeSystem *System) Terminate(ctx context.Context) error {
|
||||
|
||||
resultJSON, err := vmcompute.HcsTerminateComputeSystem(ctx, computeSystem.handle, "")
|
||||
events := processHcsResult(ctx, resultJSON)
|
||||
switch err {
|
||||
switch err { //nolint:errorlint
|
||||
case nil, ErrVmcomputeAlreadyStopped, ErrComputeSystemDoesNotExist, ErrVmcomputeOperationPending:
|
||||
default:
|
||||
return makeSystemError(computeSystem, operation, err, events)
|
||||
@ -279,7 +279,7 @@ func (computeSystem *System) waitBackground() {
|
||||
span.AddAttributes(trace.StringAttribute("cid", computeSystem.id))
|
||||
|
||||
err := waitForNotification(ctx, computeSystem.callbackNumber, hcsNotificationSystemExited, nil)
|
||||
switch err {
|
||||
switch err { //nolint:errorlint
|
||||
case nil:
|
||||
log.G(ctx).Debug("system exited")
|
||||
case ErrVmcomputeUnexpectedExit:
|
||||
@ -304,11 +304,22 @@ func (computeSystem *System) WaitError() error {
|
||||
return computeSystem.waitError
|
||||
}
|
||||
|
||||
// Wait synchronously waits for the compute system to shutdown or terminate. If
|
||||
// the compute system has already exited returns the previous error (if any).
|
||||
// Wait synchronously waits for the compute system to shutdown or terminate.
|
||||
// If the compute system has already exited returns the previous error (if any).
|
||||
func (computeSystem *System) Wait() error {
|
||||
<-computeSystem.WaitChannel()
|
||||
return computeSystem.WaitError()
|
||||
return computeSystem.WaitCtx(context.Background())
|
||||
}
|
||||
|
||||
// WaitCtx synchronously waits for the compute system to shutdown or terminate, or the context to be cancelled.
|
||||
//
|
||||
// See [System.Wait] for more information.
|
||||
func (computeSystem *System) WaitCtx(ctx context.Context) error {
|
||||
select {
|
||||
case <-computeSystem.WaitChannel():
|
||||
return computeSystem.WaitError()
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
}
|
||||
}
|
||||
|
||||
// stopped returns true if the compute system stopped.
|
||||
@ -735,9 +746,17 @@ func (computeSystem *System) OpenProcess(ctx context.Context, pid int) (*Process
|
||||
}
|
||||
|
||||
// Close cleans up any state associated with the compute system but does not terminate or wait for it.
|
||||
func (computeSystem *System) Close() (err error) {
|
||||
func (computeSystem *System) Close() error {
|
||||
return computeSystem.CloseCtx(context.Background())
|
||||
}
|
||||
|
||||
// CloseCtx is similar to [System.Close], but accepts a context.
|
||||
//
|
||||
// The context is used for all operations, including waits, so timeouts/cancellations may prevent
|
||||
// proper system cleanup.
|
||||
func (computeSystem *System) CloseCtx(ctx context.Context) (err error) {
|
||||
operation := "hcs::System::Close"
|
||||
ctx, span := oc.StartSpan(context.Background(), operation)
|
||||
ctx, span := oc.StartSpan(ctx, operation)
|
||||
defer span.End()
|
||||
defer func() { oc.SetSpanStatus(span, err) }()
|
||||
span.AddAttributes(trace.StringAttribute("cid", computeSystem.id))
|
||||
|
2
vendor/github.com/Microsoft/hcsshim/internal/hns/hnsfuncs.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/internal/hns/hnsfuncs.go
generated
vendored
@ -31,7 +31,7 @@ func hnsCallRawResponse(method, path, request string) (*hnsResponse, error) {
|
||||
func hnsCall(method, path, request string, returnResponse interface{}) error {
|
||||
hnsresponse, err := hnsCallRawResponse(method, path, request)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed during hnsCallRawResponse: %v", err)
|
||||
return fmt.Errorf("failed during hnsCallRawResponse: %w", err)
|
||||
}
|
||||
if !hnsresponse.Success {
|
||||
return fmt.Errorf("hns failed with error : %s", hnsresponse.Error)
|
||||
|
4
vendor/github.com/Microsoft/hcsshim/internal/hns/namespace.go
generated
vendored
4
vendor/github.com/Microsoft/hcsshim/internal/hns/namespace.go
generated
vendored
@ -56,7 +56,7 @@ func issueNamespaceRequest(id *string, method, subpath string, request interface
|
||||
if strings.Contains(err.Error(), "Element not found.") {
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
return nil, fmt.Errorf("%s %s: %s", method, hnspath, err)
|
||||
return nil, fmt.Errorf("%s %s: %w", method, hnspath, err)
|
||||
}
|
||||
return &ns, err
|
||||
}
|
||||
@ -86,7 +86,7 @@ func GetNamespaceEndpoints(id string) ([]string, error) {
|
||||
var endpoint namespaceEndpointRequest
|
||||
err = json.Unmarshal(rsrc.Data, &endpoint)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unmarshal endpoint: %s", err)
|
||||
return nil, fmt.Errorf("unmarshal endpoint: %w", err)
|
||||
}
|
||||
endpoints = append(endpoints, endpoint.ID)
|
||||
}
|
||||
|
3
vendor/github.com/Microsoft/hcsshim/internal/jobobject/iocp.go
generated
vendored
3
vendor/github.com/Microsoft/hcsshim/internal/jobobject/iocp.go
generated
vendored
@ -4,6 +4,7 @@ package jobobject
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"unsafe"
|
||||
@ -59,7 +60,7 @@ func pollIOCP(ctx context.Context, iocpHandle windows.Handle) {
|
||||
}).Warn("failed to parse job object message")
|
||||
continue
|
||||
}
|
||||
if err := msq.Enqueue(notification); err == queue.ErrQueueClosed {
|
||||
if err := msq.Enqueue(notification); errors.Is(err, queue.ErrQueueClosed) {
|
||||
// Write will only return an error when the queue is closed.
|
||||
// The only time a queue would ever be closed is when we call `Close` on
|
||||
// the job it belongs to which also removes it from the jobMap, so something
|
||||
|
4
vendor/github.com/Microsoft/hcsshim/internal/jobobject/jobobject.go
generated
vendored
4
vendor/github.com/Microsoft/hcsshim/internal/jobobject/jobobject.go
generated
vendored
@ -167,7 +167,7 @@ func Create(ctx context.Context, options *Options) (_ *JobObject, err error) {
|
||||
//
|
||||
// Returns a JobObject structure and an error if there is one.
|
||||
func Open(ctx context.Context, options *Options) (_ *JobObject, err error) {
|
||||
if options == nil || (options != nil && options.Name == "") {
|
||||
if options == nil || options.Name == "" {
|
||||
return nil, errors.New("no job object name specified to open")
|
||||
}
|
||||
|
||||
@ -374,7 +374,7 @@ func (job *JobObject) Pids() ([]uint32, error) {
|
||||
return []uint32{}, nil
|
||||
}
|
||||
|
||||
if err != winapi.ERROR_MORE_DATA {
|
||||
if err != winapi.ERROR_MORE_DATA { //nolint:errorlint
|
||||
return nil, fmt.Errorf("failed initial query for PIDs in job object: %w", err)
|
||||
}
|
||||
|
||||
|
7
vendor/github.com/Microsoft/hcsshim/internal/jobobject/limits.go
generated
vendored
7
vendor/github.com/Microsoft/hcsshim/internal/jobobject/limits.go
generated
vendored
@ -143,6 +143,13 @@ func (job *JobObject) SetCPUAffinity(affinityBitMask uint64) error {
|
||||
return err
|
||||
}
|
||||
info.BasicLimitInformation.LimitFlags |= uint32(windows.JOB_OBJECT_LIMIT_AFFINITY)
|
||||
|
||||
// We really, really shouldn't be running on 32 bit, but just in case (and to satisfy CodeQL) ...
|
||||
const maxUintptr = ^uintptr(0)
|
||||
if affinityBitMask > uint64(maxUintptr) {
|
||||
return fmt.Errorf("affinity bitmask (%d) exceeds max allowable value (%d)", affinityBitMask, maxUintptr)
|
||||
}
|
||||
|
||||
info.BasicLimitInformation.Affinity = uintptr(affinityBitMask)
|
||||
return job.setExtendedInformation(info)
|
||||
}
|
||||
|
44
vendor/github.com/Microsoft/hcsshim/internal/log/format.go
generated
vendored
44
vendor/github.com/Microsoft/hcsshim/internal/log/format.go
generated
vendored
@ -8,6 +8,10 @@ import (
|
||||
"net"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// TimeFormat is [time.RFC3339Nano] with nanoseconds padded using
|
||||
@ -61,25 +65,49 @@ func formatAddr(a net.Addr) string {
|
||||
func Format(ctx context.Context, v interface{}) string {
|
||||
b, err := encode(v)
|
||||
if err != nil {
|
||||
G(ctx).WithError(err).Warning("could not format value")
|
||||
// logging errors aren't really warning worthy, and can potentially spam a lot of logs out
|
||||
G(ctx).WithFields(logrus.Fields{
|
||||
logrus.ErrorKey: err,
|
||||
"type": fmt.Sprintf("%T", v),
|
||||
}).Debug("could not format value")
|
||||
return ""
|
||||
}
|
||||
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func encode(v interface{}) ([]byte, error) {
|
||||
return encodeBuffer(&bytes.Buffer{}, v)
|
||||
}
|
||||
func encode(v interface{}) (_ []byte, err error) {
|
||||
if m, ok := v.(proto.Message); ok {
|
||||
// use canonical JSON encoding for protobufs (instead of [encoding/json])
|
||||
// https://protobuf.dev/programming-guides/proto3/#json
|
||||
var b []byte
|
||||
b, err = protojson.MarshalOptions{
|
||||
AllowPartial: true,
|
||||
// protobuf defaults to camel case for JSON encoding; use proto field name instead (snake case)
|
||||
UseProtoNames: true,
|
||||
}.Marshal(m)
|
||||
if err == nil {
|
||||
// the protojson marshaller tries to unmarshal anypb.Any fields, which can
|
||||
// fail for types encoded with "github.com/containerd/typeurl/v2"
|
||||
// we can try creating a dedicated protoregistry.MessageTypeResolver that uses typeurl, but, its
|
||||
// more robust to fall back on json marshalling for errors in general
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func encodeBuffer(buf *bytes.Buffer, v interface{}) ([]byte, error) {
|
||||
}
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
enc := json.NewEncoder(buf)
|
||||
enc.SetEscapeHTML(false)
|
||||
enc.SetIndent("", "")
|
||||
|
||||
if err := enc.Encode(v); err != nil {
|
||||
err = fmt.Errorf("could not marshall %T to JSON for logging: %w", v, err)
|
||||
return nil, err
|
||||
if jErr := enc.Encode(v); jErr != nil {
|
||||
if err != nil {
|
||||
// TODO (go1.20): use multierror via fmt.Errorf("...: %w; ...: %w", ...)
|
||||
//nolint:errorlint // non-wrapping format verb for fmt.Errorf
|
||||
return nil, fmt.Errorf("protojson encoding: %v; json encoding: %w", err, jErr)
|
||||
}
|
||||
return nil, fmt.Errorf("json encoding: %w", jErr)
|
||||
}
|
||||
|
||||
// encoder.Encode appends a newline to the end
|
||||
|
12
vendor/github.com/Microsoft/hcsshim/internal/log/nopformatter.go
generated
vendored
Normal file
12
vendor/github.com/Microsoft/hcsshim/internal/log/nopformatter.go
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type NopFormatter struct{}
|
||||
|
||||
var _ logrus.Formatter = NopFormatter{}
|
||||
|
||||
// Format does nothing and returns a nil slice.
|
||||
func (NopFormatter) Format(*logrus.Entry) ([]byte, error) { return nil, nil }
|
8
vendor/github.com/Microsoft/hcsshim/internal/log/scrub.go
generated
vendored
8
vendor/github.com/Microsoft/hcsshim/internal/log/scrub.go
generated
vendored
@ -55,7 +55,7 @@ func ScrubProcessParameters(s string) (string, error) {
|
||||
}
|
||||
pp.Environment = map[string]string{_scrubbedReplacement: _scrubbedReplacement}
|
||||
|
||||
b, err := encodeBuffer(bytes.NewBuffer(b[:0]), pp)
|
||||
b, err := encode(pp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -89,11 +89,11 @@ func scrubBridgeCreate(m genMap) error {
|
||||
}
|
||||
|
||||
func scrubLinuxHostedSystem(m genMap) error {
|
||||
if m, ok := index(m, "OciSpecification"); ok {
|
||||
if m, ok := index(m, "OciSpecification"); ok { //nolint:govet // shadow
|
||||
if _, ok := m["annotations"]; ok {
|
||||
m["annotations"] = map[string]string{_scrubbedReplacement: _scrubbedReplacement}
|
||||
}
|
||||
if m, ok := index(m, "process"); ok {
|
||||
if m, ok := index(m, "process"); ok { //nolint:govet // shadow
|
||||
if _, ok := m["env"]; ok {
|
||||
m["env"] = []string{_scrubbedReplacement}
|
||||
return nil
|
||||
@ -113,7 +113,7 @@ func scrubExecuteProcess(m genMap) error {
|
||||
if !isRequestBase(m) {
|
||||
return ErrUnknownType
|
||||
}
|
||||
if m, ok := index(m, "Settings"); ok {
|
||||
if m, ok := index(m, "Settings"); ok { //nolint:govet // shadow
|
||||
if ss, ok := m["ProcessParameters"]; ok {
|
||||
// ProcessParameters is a json encoded struct passed as a regular sting field
|
||||
s, ok := ss.(string)
|
||||
|
1
vendor/github.com/Microsoft/hcsshim/internal/logfields/fields.go
generated
vendored
1
vendor/github.com/Microsoft/hcsshim/internal/logfields/fields.go
generated
vendored
@ -46,6 +46,7 @@ const (
|
||||
|
||||
ExpectedType = "expected-type"
|
||||
Bool = "bool"
|
||||
Int32 = "int32"
|
||||
Uint32 = "uint32"
|
||||
Uint64 = "uint64"
|
||||
|
||||
|
6
vendor/github.com/Microsoft/hcsshim/internal/memory/pool.go
generated
vendored
6
vendor/github.com/Microsoft/hcsshim/internal/memory/pool.go
generated
vendored
@ -126,7 +126,7 @@ func (pa *PoolAllocator) Allocate(size uint64) (MappedRegion, error) {
|
||||
// this means that there are no more regions for the current class, try expanding
|
||||
if nextCls != memCls {
|
||||
if err := pa.split(memCls); err != nil {
|
||||
if err == ErrInvalidMemoryClass {
|
||||
if errors.Is(err, ErrInvalidMemoryClass) {
|
||||
return nil, ErrNotEnoughSpace
|
||||
}
|
||||
return nil, err
|
||||
@ -147,7 +147,7 @@ func (pa *PoolAllocator) Allocate(size uint64) (MappedRegion, error) {
|
||||
}
|
||||
|
||||
// Release marks a memory region of class `memCls` and offset `offset` as free and tries to merge smaller regions into
|
||||
// a bigger one
|
||||
// a bigger one.
|
||||
func (pa *PoolAllocator) Release(reg MappedRegion) error {
|
||||
mp := pa.pools[reg.Type()]
|
||||
if mp == nil {
|
||||
@ -164,7 +164,7 @@ func (pa *PoolAllocator) Release(reg MappedRegion) error {
|
||||
return ErrNotAllocated
|
||||
}
|
||||
if err := pa.merge(n.parent); err != nil {
|
||||
if err != ErrEarlyMerge {
|
||||
if !errors.Is(err, ErrEarlyMerge) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
4
vendor/github.com/Microsoft/hcsshim/internal/oc/errors.go
generated
vendored
4
vendor/github.com/Microsoft/hcsshim/internal/oc/errors.go
generated
vendored
@ -6,7 +6,7 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/errdefs"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
@ -16,7 +16,7 @@ import (
|
||||
|
||||
func toStatusCode(err error) codes.Code {
|
||||
// checks if err implements GRPCStatus() *"google.golang.org/grpc/status".Status,
|
||||
// wraps an error defined in "github.com/containerd/containerd/errdefs", or is a
|
||||
// wraps an error defined in "github.com/containerd/errdefs", or is a
|
||||
// context timeout or cancelled error
|
||||
if s, ok := status.FromError(errdefs.ToGRPC(err)); ok {
|
||||
return s.Code()
|
||||
|
22
vendor/github.com/Microsoft/hcsshim/internal/protocol/guestrequest/types.go
generated
vendored
22
vendor/github.com/Microsoft/hcsshim/internal/protocol/guestrequest/types.go
generated
vendored
@ -5,7 +5,7 @@ package guestrequest
|
||||
type RequestType string
|
||||
type ResourceType string
|
||||
|
||||
// RequestType const
|
||||
// RequestType const.
|
||||
const (
|
||||
RequestTypeAdd RequestType = "Add"
|
||||
RequestTypeRemove RequestType = "Remove"
|
||||
@ -54,3 +54,23 @@ var (
|
||||
"305891a9-b251-5dfe-91a2-c25d9212275b",
|
||||
}
|
||||
)
|
||||
|
||||
// constants for v2 schema ProcessModifyRequest
|
||||
|
||||
// Operation type for [hcsschema.ProcessModifyRequest].
|
||||
type ProcessModifyOperation string
|
||||
|
||||
const (
|
||||
ModifyProcessConsoleSize ProcessModifyOperation = "ConsoleSize"
|
||||
CloseProcessHandle ProcessModifyOperation = "CloseHandle"
|
||||
)
|
||||
|
||||
// Standard IO handle(s) to close for [hcsschema.CloseHandle] in [hcsschema.ProcessModifyRequest].
|
||||
type STDIOHandle string
|
||||
|
||||
const (
|
||||
STDInHandle STDIOHandle = "StdIn"
|
||||
STDOutHandle STDIOHandle = "StdOut"
|
||||
STDErrHandle STDIOHandle = "StdErr"
|
||||
AllHandles STDIOHandle = "All"
|
||||
)
|
||||
|
16
vendor/github.com/Microsoft/hcsshim/internal/regstate/regstate.go
generated
vendored
16
vendor/github.com/Microsoft/hcsshim/internal/regstate/regstate.go
generated
vendored
@ -4,6 +4,7 @@ package regstate
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -44,8 +45,8 @@ func (err *NotFoundError) Error() string {
|
||||
}
|
||||
|
||||
func IsNotFoundError(err error) bool {
|
||||
_, ok := err.(*NotFoundError)
|
||||
return ok
|
||||
var e *NotFoundError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
type NoStateError struct {
|
||||
@ -152,7 +153,8 @@ func (k *Key) openid(id string) (*Key, error) {
|
||||
escaped := url.PathEscape(id)
|
||||
fullpath := filepath.Join(k.Name, escaped)
|
||||
nk, err := k.open(escaped)
|
||||
if perr, ok := err.(*os.PathError); ok && perr.Err == syscall.ERROR_FILE_NOT_FOUND {
|
||||
var perr *os.PathError
|
||||
if errors.As(err, &perr) && errors.Is(perr.Err, syscall.ERROR_FILE_NOT_FOUND) {
|
||||
return nil, &NotFoundError{id}
|
||||
}
|
||||
if err != nil {
|
||||
@ -165,7 +167,7 @@ func (k *Key) Remove(id string) error {
|
||||
escaped := url.PathEscape(id)
|
||||
err := registry.DeleteKey(k.Key, escaped)
|
||||
if err != nil {
|
||||
if err == syscall.ERROR_FILE_NOT_FOUND {
|
||||
if err == syscall.ERROR_FILE_NOT_FOUND { //nolint:errorlint
|
||||
return &NotFoundError{id}
|
||||
}
|
||||
return &os.PathError{Op: "RegDeleteKey", Path: filepath.Join(k.Name, escaped), Err: err}
|
||||
@ -215,7 +217,7 @@ func (k *Key) set(id string, create bool, key string, state interface{}) error {
|
||||
err = sk.SetBinaryValue(key, js)
|
||||
}
|
||||
if err != nil {
|
||||
if err == syscall.ERROR_FILE_NOT_FOUND {
|
||||
if err == syscall.ERROR_FILE_NOT_FOUND { //nolint:errorlint
|
||||
return &NoStateError{id, key}
|
||||
}
|
||||
return &os.PathError{Op: "RegSetValueEx", Path: sk.Name + ":" + key, Err: err}
|
||||
@ -239,7 +241,7 @@ func (k *Key) Clear(id, key string) error {
|
||||
defer sk.Close()
|
||||
err = sk.DeleteValue(key)
|
||||
if err != nil {
|
||||
if err == syscall.ERROR_FILE_NOT_FOUND {
|
||||
if err == syscall.ERROR_FILE_NOT_FOUND { //nolint:errorlint
|
||||
return &NoStateError{id, key}
|
||||
}
|
||||
return &os.PathError{Op: "RegDeleteValue", Path: sk.Name + ":" + key, Err: err}
|
||||
@ -278,7 +280,7 @@ func (k *Key) Get(id, key string, state interface{}) error {
|
||||
js, _, err = sk.GetBinaryValue(key)
|
||||
}
|
||||
if err != nil {
|
||||
if err == syscall.ERROR_FILE_NOT_FOUND {
|
||||
if err == syscall.ERROR_FILE_NOT_FOUND { //nolint:errorlint
|
||||
return &NoStateError{id, key}
|
||||
}
|
||||
return &os.PathError{Op: "RegQueryValueEx", Path: sk.Name + ":" + key, Err: err}
|
||||
|
10
vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go
generated
vendored
10
vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go
generated
vendored
@ -243,7 +243,7 @@ func RemoveRelative(path string, root *os.File) error {
|
||||
if err == nil {
|
||||
defer f.Close()
|
||||
err = deleteOnClose(f)
|
||||
if err == syscall.ERROR_ACCESS_DENIED {
|
||||
if err == syscall.ERROR_ACCESS_DENIED { //nolint:errorlint
|
||||
// Maybe the file is marked readonly. Clear the bit and retry.
|
||||
_ = clearReadOnly(f)
|
||||
err = deleteOnClose(f)
|
||||
@ -276,7 +276,7 @@ func RemoveAllRelative(path string, root *os.File) error {
|
||||
}
|
||||
|
||||
// It is necessary to use os.Open as Readdirnames does not work with
|
||||
// OpenRelative. This is safe because the above lstatrelative fails
|
||||
// OpenRelative. This is safe because the above LstatRelative fails
|
||||
// if the target is outside the root, and we know this is not a
|
||||
// symlink from the above FILE_ATTRIBUTE_REPARSE_POINT check.
|
||||
fd, err := os.Open(filepath.Join(root.Name(), path))
|
||||
@ -293,12 +293,12 @@ func RemoveAllRelative(path string, root *os.File) error {
|
||||
for {
|
||||
names, err1 := fd.Readdirnames(100)
|
||||
for _, name := range names {
|
||||
err1 := RemoveAllRelative(path+string(os.PathSeparator)+name, root)
|
||||
if err == nil {
|
||||
err = err1
|
||||
if err2 := RemoveAllRelative(path+string(os.PathSeparator)+name, root); err == nil {
|
||||
err = err2
|
||||
}
|
||||
}
|
||||
if err1 == io.EOF {
|
||||
// Readdirnames has no more files to return
|
||||
break
|
||||
}
|
||||
// If Readdirnames returned an error, use it.
|
||||
|
16
vendor/github.com/Microsoft/hcsshim/internal/vmcompute/vmcompute.go
generated
vendored
16
vendor/github.com/Microsoft/hcsshim/internal/vmcompute/vmcompute.go
generated
vendored
@ -104,7 +104,7 @@ func execute(ctx gcontext.Context, timeout time.Duration, f func() error) error
|
||||
}()
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
if ctx.Err() == gcontext.DeadlineExceeded {
|
||||
if ctx.Err() == gcontext.DeadlineExceeded { //nolint:errorlint
|
||||
log.G(ctx).WithField(logfields.Timeout, trueTimeout).
|
||||
Warning("Syscall did not complete within operation timeout. This may indicate a platform issue. " +
|
||||
"If it appears to be making no forward progress, obtain the stacks and see if there is a syscall " +
|
||||
@ -150,7 +150,7 @@ func HcsCreateComputeSystem(ctx gcontext.Context, id string, configuration strin
|
||||
if result != "" {
|
||||
span.AddAttributes(trace.StringAttribute("result", result))
|
||||
}
|
||||
if hr != errVmcomputeOperationPending {
|
||||
if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned
|
||||
oc.SetSpanStatus(span, hr)
|
||||
}
|
||||
}()
|
||||
@ -205,7 +205,7 @@ func HcsStartComputeSystem(ctx gcontext.Context, computeSystem HcsSystem, option
|
||||
if result != "" {
|
||||
span.AddAttributes(trace.StringAttribute("result", result))
|
||||
}
|
||||
if hr != errVmcomputeOperationPending {
|
||||
if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned
|
||||
oc.SetSpanStatus(span, hr)
|
||||
}
|
||||
}()
|
||||
@ -228,7 +228,7 @@ func HcsShutdownComputeSystem(ctx gcontext.Context, computeSystem HcsSystem, opt
|
||||
if result != "" {
|
||||
span.AddAttributes(trace.StringAttribute("result", result))
|
||||
}
|
||||
if hr != errVmcomputeOperationPending {
|
||||
if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned
|
||||
oc.SetSpanStatus(span, hr)
|
||||
}
|
||||
}()
|
||||
@ -251,7 +251,7 @@ func HcsTerminateComputeSystem(ctx gcontext.Context, computeSystem HcsSystem, op
|
||||
if result != "" {
|
||||
span.AddAttributes(trace.StringAttribute("result", result))
|
||||
}
|
||||
if hr != errVmcomputeOperationPending {
|
||||
if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned
|
||||
oc.SetSpanStatus(span, hr)
|
||||
}
|
||||
}()
|
||||
@ -274,7 +274,7 @@ func HcsPauseComputeSystem(ctx gcontext.Context, computeSystem HcsSystem, option
|
||||
if result != "" {
|
||||
span.AddAttributes(trace.StringAttribute("result", result))
|
||||
}
|
||||
if hr != errVmcomputeOperationPending {
|
||||
if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned
|
||||
oc.SetSpanStatus(span, hr)
|
||||
}
|
||||
}()
|
||||
@ -297,7 +297,7 @@ func HcsResumeComputeSystem(ctx gcontext.Context, computeSystem HcsSystem, optio
|
||||
if result != "" {
|
||||
span.AddAttributes(trace.StringAttribute("result", result))
|
||||
}
|
||||
if hr != errVmcomputeOperationPending {
|
||||
if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned
|
||||
oc.SetSpanStatus(span, hr)
|
||||
}
|
||||
}()
|
||||
@ -621,7 +621,7 @@ func HcsSaveComputeSystem(ctx gcontext.Context, computeSystem HcsSystem, options
|
||||
if result != "" {
|
||||
span.AddAttributes(trace.StringAttribute("result", result))
|
||||
}
|
||||
if hr != errVmcomputeOperationPending {
|
||||
if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned
|
||||
oc.SetSpanStatus(span, hr)
|
||||
}
|
||||
}()
|
||||
|
10
vendor/github.com/Microsoft/hcsshim/internal/wclayer/baselayerreader.go
generated
vendored
10
vendor/github.com/Microsoft/hcsshim/internal/wclayer/baselayerreader.go
generated
vendored
@ -1,3 +1,5 @@
|
||||
//go:build windows
|
||||
|
||||
package wclayer
|
||||
|
||||
import (
|
||||
@ -64,7 +66,7 @@ func (r *baseLayerReader) walkUntilCancelled() error {
|
||||
return nil
|
||||
})
|
||||
|
||||
if err == errorIterationCanceled {
|
||||
if err == errorIterationCanceled { //nolint:errorlint // explicitly returned
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -72,8 +74,8 @@ func (r *baseLayerReader) walkUntilCancelled() error {
|
||||
return err
|
||||
}
|
||||
|
||||
utilityVMAbsPath := filepath.Join(r.root, utilityVMPath)
|
||||
utilityVMFilesAbsPath := filepath.Join(r.root, utilityVMFilesPath)
|
||||
utilityVMAbsPath := filepath.Join(r.root, UtilityVMPath)
|
||||
utilityVMFilesAbsPath := filepath.Join(r.root, UtilityVMFilesPath)
|
||||
|
||||
// Ignore a UtilityVM without Files, that's not _really_ a UtiltyVM
|
||||
if _, err = os.Lstat(utilityVMFilesAbsPath); err != nil {
|
||||
@ -103,7 +105,7 @@ func (r *baseLayerReader) walkUntilCancelled() error {
|
||||
return nil
|
||||
})
|
||||
|
||||
if err == errorIterationCanceled {
|
||||
if err == errorIterationCanceled { //nolint:errorlint // explicitly returned
|
||||
return nil
|
||||
}
|
||||
|
||||
|
15
vendor/github.com/Microsoft/hcsshim/internal/wclayer/converttobaselayer.go
generated
vendored
15
vendor/github.com/Microsoft/hcsshim/internal/wclayer/converttobaselayer.go
generated
vendored
@ -1,3 +1,5 @@
|
||||
//go:build windows
|
||||
|
||||
package wclayer
|
||||
|
||||
import (
|
||||
@ -5,7 +7,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
|
||||
"github.com/Microsoft/hcsshim/internal/hcserror"
|
||||
"github.com/Microsoft/hcsshim/internal/longpath"
|
||||
@ -37,7 +38,7 @@ func ensureHive(path string, root *os.File) (err error) {
|
||||
return fmt.Errorf("getting path: %w", err)
|
||||
}
|
||||
|
||||
var key syscall.Handle
|
||||
var key winapi.ORHKey
|
||||
err = winapi.ORCreateHive(&key)
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating hive: %w", err)
|
||||
@ -72,7 +73,7 @@ func ensureBaseLayer(root *os.File) (hasUtilityVM bool, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
stat, err := safefile.LstatRelative(utilityVMFilesPath, root)
|
||||
stat, err := safefile.LstatRelative(UtilityVMFilesPath, root)
|
||||
|
||||
if os.IsNotExist(err) {
|
||||
return false, nil
|
||||
@ -83,7 +84,7 @@ func ensureBaseLayer(root *os.File) (hasUtilityVM bool, err error) {
|
||||
}
|
||||
|
||||
if !stat.Mode().IsDir() {
|
||||
fullPath := filepath.Join(root.Name(), utilityVMFilesPath)
|
||||
fullPath := filepath.Join(root.Name(), UtilityVMFilesPath)
|
||||
return false, errors.Errorf("%s has unexpected file mode %s", fullPath, stat.Mode().String())
|
||||
}
|
||||
|
||||
@ -92,7 +93,7 @@ func ensureBaseLayer(root *os.File) (hasUtilityVM bool, err error) {
|
||||
// Just check that this exists as a regular file. If it exists but is not a valid registry hive,
|
||||
// ProcessUtilityVMImage will complain:
|
||||
// "The registry could not read in, or write out, or flush, one of the files that contain the system's image of the registry."
|
||||
bcdPath := filepath.Join(utilityVMFilesPath, bcdRelativePath)
|
||||
bcdPath := filepath.Join(UtilityVMFilesPath, bcdRelativePath)
|
||||
|
||||
stat, err = safefile.LstatRelative(bcdPath, root)
|
||||
if err != nil {
|
||||
@ -122,12 +123,12 @@ func convertToBaseLayer(ctx context.Context, root *os.File) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
err = safefile.EnsureNotReparsePointRelative(utilityVMPath, root)
|
||||
err = safefile.EnsureNotReparsePointRelative(UtilityVMPath, root)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
utilityVMPath := filepath.Join(root.Name(), utilityVMPath)
|
||||
utilityVMPath := filepath.Join(root.Name(), UtilityVMPath)
|
||||
return ProcessUtilityVMImage(ctx, utilityVMPath)
|
||||
}
|
||||
|
||||
|
18
vendor/github.com/Microsoft/hcsshim/internal/wclayer/expandscratchsize.go
generated
vendored
18
vendor/github.com/Microsoft/hcsshim/internal/wclayer/expandscratchsize.go
generated
vendored
@ -11,7 +11,6 @@ import (
|
||||
|
||||
"github.com/Microsoft/hcsshim/internal/hcserror"
|
||||
"github.com/Microsoft/hcsshim/internal/oc"
|
||||
"github.com/Microsoft/hcsshim/osversion"
|
||||
"go.opencensus.io/trace"
|
||||
)
|
||||
|
||||
@ -30,14 +29,17 @@ func ExpandScratchSize(ctx context.Context, path string, size uint64) (err error
|
||||
return hcserror.New(err, title, "")
|
||||
}
|
||||
|
||||
// Manually expand the volume now in order to work around bugs in 19H1 and
|
||||
// prerelease versions of Vb. Remove once this is fixed in Windows.
|
||||
if build := osversion.Build(); build >= osversion.V19H1 && build < 19020 {
|
||||
err = expandSandboxVolume(ctx, path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Always expand the volume too. In case of legacy layers not expanding the volume here works because
|
||||
// the PrepareLayer call internally handles the expansion. However, in other cases (like CimFS) we
|
||||
// don't call PrepareLayer and so the volume will never be expanded. This also means in case of
|
||||
// legacy layers, we might have a small perf hit because the VHD is mounted twice for expansion (once
|
||||
// here and once during the PrepareLayer call). But as long as the perf hit is minimal, we should be
|
||||
// okay.
|
||||
err = expandSandboxVolume(ctx, path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
24
vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go
generated
vendored
24
vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go
generated
vendored
@ -7,6 +7,10 @@ package wclayer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"github.com/Microsoft/go-winio/pkg/guid"
|
||||
@ -101,3 +105,23 @@ func layerPathsToDescriptors(ctx context.Context, parentLayerPaths []string) ([]
|
||||
|
||||
return layers, nil
|
||||
}
|
||||
|
||||
// GetLayerUvmBuild looks for a file named `uvmbuildversion` at `layerPath\uvmbuildversion` and returns the
|
||||
// build number of the UVM from that file.
|
||||
func GetLayerUvmBuild(layerPath string) (uint16, error) {
|
||||
data, err := os.ReadFile(filepath.Join(layerPath, UvmBuildFileName))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
ver, err := strconv.ParseUint(string(data), 10, 16)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uint16(ver), nil
|
||||
}
|
||||
|
||||
// WriteLayerUvmBuildFile writes a file at path `layerPath\uvmbuildversion` that contains the given `build`
|
||||
// version for future reference.
|
||||
func WriteLayerUvmBuildFile(layerPath string, build uint16) error {
|
||||
return os.WriteFile(filepath.Join(layerPath, UvmBuildFileName), []byte(fmt.Sprintf("%d", build)), 0777)
|
||||
}
|
||||
|
47
vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go
generated
vendored
47
vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go
generated
vendored
@ -29,10 +29,19 @@ var mutatedUtilityVMFiles = map[string]bool{
|
||||
}
|
||||
|
||||
const (
|
||||
filesPath = `Files`
|
||||
hivesPath = `Hives`
|
||||
utilityVMPath = `UtilityVM`
|
||||
utilityVMFilesPath = `UtilityVM\Files`
|
||||
filesPath = `Files`
|
||||
HivesPath = `Hives`
|
||||
UtilityVMPath = `UtilityVM`
|
||||
UtilityVMFilesPath = `UtilityVM\Files`
|
||||
RegFilesPath = `Files\Windows\System32\config`
|
||||
BcdFilePath = `UtilityVM\Files\EFI\Microsoft\Boot\BCD`
|
||||
BootMgrFilePath = `UtilityVM\Files\EFI\Microsoft\Boot\bootmgfw.efi`
|
||||
ContainerBaseVhd = `blank-base.vhdx`
|
||||
ContainerScratchVhd = `blank.vhdx`
|
||||
UtilityVMBaseVhd = `SystemTemplateBase.vhdx`
|
||||
UtilityVMScratchVhd = `SystemTemplate.vhdx`
|
||||
LayoutFileName = `layout`
|
||||
UvmBuildFileName = `uvmbuildversion`
|
||||
)
|
||||
|
||||
func openFileOrDir(path string, mode uint32, createDisposition uint32) (file *os.File, err error) {
|
||||
@ -145,7 +154,7 @@ func (r *legacyLayerReader) walkUntilCancelled() error {
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err == errorIterationCanceled {
|
||||
if err == errorIterationCanceled { //nolint:errorlint // explicitly returned
|
||||
return nil
|
||||
}
|
||||
if err == nil {
|
||||
@ -187,7 +196,7 @@ func findBackupStreamSize(r io.Reader) (int64, error) {
|
||||
for {
|
||||
hdr, err := br.Next()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
err = nil
|
||||
}
|
||||
return 0, err
|
||||
@ -243,11 +252,11 @@ func (r *legacyLayerReader) Next() (path string, size int64, fileInfo *winio.Fil
|
||||
if !hasPathPrefix(path, filesPath) {
|
||||
size = fe.fi.Size()
|
||||
r.backupReader = winio.NewBackupFileReader(f, false)
|
||||
if path == hivesPath || path == filesPath {
|
||||
if path == HivesPath || path == filesPath {
|
||||
// The Hives directory has a non-deterministic file time because of the
|
||||
// nature of the import process. Use the times from System_Delta.
|
||||
var g *os.File
|
||||
g, err = os.Open(filepath.Join(r.root, hivesPath, `System_Delta`))
|
||||
g, err = os.Open(filepath.Join(r.root, HivesPath, `System_Delta`))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -409,7 +418,7 @@ func (w *legacyLayerWriter) CloseRoots() {
|
||||
|
||||
func (w *legacyLayerWriter) initUtilityVM() error {
|
||||
if !w.HasUtilityVM {
|
||||
err := safefile.MkdirRelative(utilityVMPath, w.destRoot)
|
||||
err := safefile.MkdirRelative(UtilityVMPath, w.destRoot)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -417,9 +426,9 @@ func (w *legacyLayerWriter) initUtilityVM() error {
|
||||
// clone the utility VM from the parent layer into this layer. Use hard
|
||||
// links to avoid unnecessary copying, since most of the files are
|
||||
// immutable.
|
||||
err = cloneTree(w.parentRoots[0], w.destRoot, utilityVMFilesPath, mutatedUtilityVMFiles)
|
||||
err = cloneTree(w.parentRoots[0], w.destRoot, UtilityVMFilesPath, mutatedUtilityVMFiles)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cloning the parent utility VM image failed: %s", err)
|
||||
return fmt.Errorf("cloning the parent utility VM image failed: %w", err)
|
||||
}
|
||||
w.HasUtilityVM = true
|
||||
}
|
||||
@ -442,7 +451,7 @@ func (w *legacyLayerWriter) reset() error {
|
||||
|
||||
for {
|
||||
bhdr, err := br.Next()
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// end of backupstream data
|
||||
break
|
||||
}
|
||||
@ -592,7 +601,7 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro
|
||||
return err
|
||||
}
|
||||
|
||||
if name == utilityVMPath {
|
||||
if name == UtilityVMPath {
|
||||
return w.initUtilityVM()
|
||||
}
|
||||
|
||||
@ -601,11 +610,11 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro
|
||||
}
|
||||
|
||||
name = filepath.Clean(name)
|
||||
if hasPathPrefix(name, utilityVMPath) {
|
||||
if hasPathPrefix(name, UtilityVMPath) {
|
||||
if !w.HasUtilityVM {
|
||||
return errors.New("missing UtilityVM directory")
|
||||
}
|
||||
if !hasPathPrefix(name, utilityVMFilesPath) && name != utilityVMFilesPath {
|
||||
if !hasPathPrefix(name, UtilityVMFilesPath) && name != UtilityVMFilesPath {
|
||||
return errors.New("invalid UtilityVM layer")
|
||||
}
|
||||
createDisposition := uint32(winapi.FILE_OPEN)
|
||||
@ -699,7 +708,7 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro
|
||||
return err
|
||||
}
|
||||
|
||||
if hasPathPrefix(name, hivesPath) {
|
||||
if hasPathPrefix(name, HivesPath) {
|
||||
w.backupWriter = winio.NewBackupFileWriter(f, false)
|
||||
w.bufWriter.Reset(w.backupWriter)
|
||||
} else {
|
||||
@ -731,14 +740,14 @@ func (w *legacyLayerWriter) AddLink(name string, target string) error {
|
||||
// Look for cross-layer hard link targets in the parent layers, since
|
||||
// nothing is in the destination path yet.
|
||||
roots = w.parentRoots
|
||||
} else if hasPathPrefix(target, utilityVMFilesPath) {
|
||||
} else if hasPathPrefix(target, UtilityVMFilesPath) {
|
||||
// Since the utility VM is fully cloned into the destination path
|
||||
// already, look for cross-layer hard link targets directly in the
|
||||
// destination path.
|
||||
roots = []*os.File{w.destRoot}
|
||||
}
|
||||
|
||||
if roots == nil || (!hasPathPrefix(name, filesPath) && !hasPathPrefix(name, utilityVMFilesPath)) {
|
||||
if roots == nil || (!hasPathPrefix(name, filesPath) && !hasPathPrefix(name, UtilityVMFilesPath)) {
|
||||
return errors.New("invalid hard link in layer")
|
||||
}
|
||||
|
||||
@ -777,7 +786,7 @@ func (w *legacyLayerWriter) Remove(name string) error {
|
||||
name = filepath.Clean(name)
|
||||
if hasPathPrefix(name, filesPath) {
|
||||
w.Tombstones = append(w.Tombstones, name)
|
||||
} else if hasPathPrefix(name, utilityVMFilesPath) {
|
||||
} else if hasPathPrefix(name, UtilityVMFilesPath) {
|
||||
err := w.initUtilityVM()
|
||||
if err != nil {
|
||||
return err
|
||||
|
47
vendor/github.com/Microsoft/hcsshim/internal/winapi/cimfs.go
generated
vendored
Normal file
47
vendor/github.com/Microsoft/hcsshim/internal/winapi/cimfs.go
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
//go:build windows
|
||||
|
||||
package winapi
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/Microsoft/go-winio/pkg/guid"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
type g = guid.GUID
|
||||
type FsHandle uintptr
|
||||
type StreamHandle uintptr
|
||||
|
||||
type CimFsFileMetadata struct {
|
||||
Attributes uint32
|
||||
FileSize int64
|
||||
|
||||
CreationTime windows.Filetime
|
||||
LastWriteTime windows.Filetime
|
||||
ChangeTime windows.Filetime
|
||||
LastAccessTime windows.Filetime
|
||||
|
||||
SecurityDescriptorBuffer unsafe.Pointer
|
||||
SecurityDescriptorSize uint32
|
||||
|
||||
ReparseDataBuffer unsafe.Pointer
|
||||
ReparseDataSize uint32
|
||||
|
||||
ExtendedAttributes unsafe.Pointer
|
||||
EACount uint32
|
||||
}
|
||||
|
||||
//sys CimMountImage(imagePath string, fsName string, flags uint32, volumeID *g) (hr error) = cimfs.CimMountImage?
|
||||
//sys CimDismountImage(volumeID *g) (hr error) = cimfs.CimDismountImage?
|
||||
|
||||
//sys CimCreateImage(imagePath string, oldFSName *uint16, newFSName *uint16, cimFSHandle *FsHandle) (hr error) = cimfs.CimCreateImage?
|
||||
//sys CimCloseImage(cimFSHandle FsHandle) = cimfs.CimCloseImage?
|
||||
//sys CimCommitImage(cimFSHandle FsHandle) (hr error) = cimfs.CimCommitImage?
|
||||
|
||||
//sys CimCreateFile(cimFSHandle FsHandle, path string, file *CimFsFileMetadata, cimStreamHandle *StreamHandle) (hr error) = cimfs.CimCreateFile?
|
||||
//sys CimCloseStream(cimStreamHandle StreamHandle) (hr error) = cimfs.CimCloseStream?
|
||||
//sys CimWriteStream(cimStreamHandle StreamHandle, buffer uintptr, bufferSize uint32) (hr error) = cimfs.CimWriteStream?
|
||||
//sys CimDeletePath(cimFSHandle FsHandle, path string) (hr error) = cimfs.CimDeletePath?
|
||||
//sys CimCreateHardLink(cimFSHandle FsHandle, newPath string, oldPath string) (hr error) = cimfs.CimCreateHardLink?
|
||||
//sys CimCreateAlternateStream(cimFSHandle FsHandle, path string, size uint64, cimStreamHandle *StreamHandle) (hr error) = cimfs.CimCreateAlternateStream?
|
37
vendor/github.com/Microsoft/hcsshim/internal/winapi/offlinereg.go
generated
vendored
Normal file
37
vendor/github.com/Microsoft/hcsshim/internal/winapi/offlinereg.go
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
package winapi
|
||||
|
||||
// Offline registry management API
|
||||
|
||||
type ORHKey uintptr
|
||||
|
||||
type RegType uint32
|
||||
|
||||
const (
|
||||
// Registry value types: https://docs.microsoft.com/en-us/windows/win32/sysinfo/registry-value-types
|
||||
REG_TYPE_NONE RegType = 0
|
||||
REG_TYPE_SZ RegType = 1
|
||||
REG_TYPE_EXPAND_SZ RegType = 2
|
||||
REG_TYPE_BINARY RegType = 3
|
||||
REG_TYPE_DWORD RegType = 4
|
||||
REG_TYPE_DWORD_LITTLE_ENDIAN RegType = 4
|
||||
REG_TYPE_DWORD_BIG_ENDIAN RegType = 5
|
||||
REG_TYPE_LINK RegType = 6
|
||||
REG_TYPE_MULTI_SZ RegType = 7
|
||||
REG_TYPE_RESOURCE_LIST RegType = 8
|
||||
REG_TYPE_FULL_RESOURCE_DESCRIPTOR RegType = 9
|
||||
REG_TYPE_RESOURCE_REQUIREMENTS_LIST RegType = 10
|
||||
REG_TYPE_QWORD RegType = 11
|
||||
REG_TYPE_QWORD_LITTLE_ENDIAN RegType = 11
|
||||
)
|
||||
|
||||
//sys ORCreateHive(key *ORHKey) (win32err error) = offreg.ORCreateHive
|
||||
//sys ORMergeHives(hiveHandles []ORHKey, result *ORHKey) (win32err error) = offreg.ORMergeHives
|
||||
//sys OROpenHive(hivePath string, result *ORHKey) (win32err error) = offreg.OROpenHive
|
||||
//sys ORCloseHive(handle ORHKey) (win32err error) = offreg.ORCloseHive
|
||||
//sys ORSaveHive(handle ORHKey, hivePath string, osMajorVersion uint32, osMinorVersion uint32) (win32err error) = offreg.ORSaveHive
|
||||
//sys OROpenKey(handle ORHKey, subKey string, result *ORHKey) (win32err error) = offreg.OROpenKey
|
||||
//sys ORCloseKey(handle ORHKey) (win32err error) = offreg.ORCloseKey
|
||||
//sys ORCreateKey(handle ORHKey, subKey string, class uintptr, options uint32, securityDescriptor uintptr, result *ORHKey, disposition *uint32) (win32err error) = offreg.ORCreateKey
|
||||
//sys ORDeleteKey(handle ORHKey, subKey string) (win32err error) = offreg.ORDeleteKey
|
||||
//sys ORGetValue(handle ORHKey, subKey string, value string, valueType *uint32, data *byte, dataLen *uint32) (win32err error) = offreg.ORGetValue
|
||||
//sys ORSetValue(handle ORHKey, valueName string, valueType uint32, data *byte, dataLen uint32) (win32err error) = offreg.ORSetValue
|
5
vendor/github.com/Microsoft/hcsshim/internal/winapi/ofreg.go
generated
vendored
5
vendor/github.com/Microsoft/hcsshim/internal/winapi/ofreg.go
generated
vendored
@ -1,5 +0,0 @@
|
||||
package winapi
|
||||
|
||||
//sys ORCreateHive(key *syscall.Handle) (regerrno error) = offreg.ORCreateHive
|
||||
//sys ORSaveHive(key syscall.Handle, file string, OsMajorVersion uint32, OsMinorVersion uint32) (regerrno error) = offreg.ORSaveHive
|
||||
//sys ORCloseHive(key syscall.Handle) (regerrno error) = offreg.ORCloseHive
|
13
vendor/github.com/Microsoft/hcsshim/internal/winapi/utils.go
generated
vendored
13
vendor/github.com/Microsoft/hcsshim/internal/winapi/utils.go
generated
vendored
@ -4,7 +4,6 @@ package winapi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
@ -14,11 +13,7 @@ import (
|
||||
// Uint16BufferToSlice wraps a uint16 pointer-and-length into a slice
|
||||
// for easier interop with Go APIs
|
||||
func Uint16BufferToSlice(buffer *uint16, bufferLength int) (result []uint16) {
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&result))
|
||||
hdr.Data = uintptr(unsafe.Pointer(buffer))
|
||||
hdr.Cap = bufferLength
|
||||
hdr.Len = bufferLength
|
||||
|
||||
result = unsafe.Slice(buffer, bufferLength)
|
||||
return
|
||||
}
|
||||
|
||||
@ -80,3 +75,9 @@ func ConvertStringSetToSlice(buf []byte) ([]string, error) {
|
||||
}
|
||||
return nil, errors.New("string set malformed: missing null terminator at end of buffer")
|
||||
}
|
||||
|
||||
// ParseUtf16LE parses a UTF-16LE byte array into a string (without passing
|
||||
// through a uint16 or rune array).
|
||||
func ParseUtf16LE(b []byte) string {
|
||||
return windows.UTF16PtrToString((*uint16)(unsafe.Pointer(&b[0])))
|
||||
}
|
||||
|
394
vendor/github.com/Microsoft/hcsshim/internal/winapi/zsyscall_windows.go
generated
vendored
394
vendor/github.com/Microsoft/hcsshim/internal/winapi/zsyscall_windows.go
generated
vendored
@ -43,6 +43,7 @@ var (
|
||||
modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
|
||||
modbindfltapi = windows.NewLazySystemDLL("bindfltapi.dll")
|
||||
modcfgmgr32 = windows.NewLazySystemDLL("cfgmgr32.dll")
|
||||
modcimfs = windows.NewLazySystemDLL("cimfs.dll")
|
||||
modiphlpapi = windows.NewLazySystemDLL("iphlpapi.dll")
|
||||
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
||||
modnetapi32 = windows.NewLazySystemDLL("netapi32.dll")
|
||||
@ -55,6 +56,17 @@ var (
|
||||
procCM_Get_Device_ID_ListA = modcfgmgr32.NewProc("CM_Get_Device_ID_ListA")
|
||||
procCM_Get_Device_ID_List_SizeA = modcfgmgr32.NewProc("CM_Get_Device_ID_List_SizeA")
|
||||
procCM_Locate_DevNodeW = modcfgmgr32.NewProc("CM_Locate_DevNodeW")
|
||||
procCimCloseImage = modcimfs.NewProc("CimCloseImage")
|
||||
procCimCloseStream = modcimfs.NewProc("CimCloseStream")
|
||||
procCimCommitImage = modcimfs.NewProc("CimCommitImage")
|
||||
procCimCreateAlternateStream = modcimfs.NewProc("CimCreateAlternateStream")
|
||||
procCimCreateFile = modcimfs.NewProc("CimCreateFile")
|
||||
procCimCreateHardLink = modcimfs.NewProc("CimCreateHardLink")
|
||||
procCimCreateImage = modcimfs.NewProc("CimCreateImage")
|
||||
procCimDeletePath = modcimfs.NewProc("CimDeletePath")
|
||||
procCimDismountImage = modcimfs.NewProc("CimDismountImage")
|
||||
procCimMountImage = modcimfs.NewProc("CimMountImage")
|
||||
procCimWriteStream = modcimfs.NewProc("CimWriteStream")
|
||||
procSetJobCompartmentId = modiphlpapi.NewProc("SetJobCompartmentId")
|
||||
procClosePseudoConsole = modkernel32.NewProc("ClosePseudoConsole")
|
||||
procCopyFileW = modkernel32.NewProc("CopyFileW")
|
||||
@ -84,8 +96,16 @@ var (
|
||||
procNtSetInformationFile = modntdll.NewProc("NtSetInformationFile")
|
||||
procRtlNtStatusToDosError = modntdll.NewProc("RtlNtStatusToDosError")
|
||||
procORCloseHive = modoffreg.NewProc("ORCloseHive")
|
||||
procORCloseKey = modoffreg.NewProc("ORCloseKey")
|
||||
procORCreateHive = modoffreg.NewProc("ORCreateHive")
|
||||
procORCreateKey = modoffreg.NewProc("ORCreateKey")
|
||||
procORDeleteKey = modoffreg.NewProc("ORDeleteKey")
|
||||
procORGetValue = modoffreg.NewProc("ORGetValue")
|
||||
procORMergeHives = modoffreg.NewProc("ORMergeHives")
|
||||
procOROpenHive = modoffreg.NewProc("OROpenHive")
|
||||
procOROpenKey = modoffreg.NewProc("OROpenKey")
|
||||
procORSaveHive = modoffreg.NewProc("ORSaveHive")
|
||||
procORSetValue = modoffreg.NewProc("ORSetValue")
|
||||
)
|
||||
|
||||
func LogonUser(username *uint16, domain *uint16, password *uint16, logonType uint32, logonProvider uint32, token *windows.Token) (err error) {
|
||||
@ -164,6 +184,229 @@ func _CMLocateDevNode(pdnDevInst *uint32, pDeviceID *uint16, uFlags uint32) (hr
|
||||
return
|
||||
}
|
||||
|
||||
func CimCloseImage(cimFSHandle FsHandle) (err error) {
|
||||
err = procCimCloseImage.Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
syscall.Syscall(procCimCloseImage.Addr(), 1, uintptr(cimFSHandle), 0, 0)
|
||||
return
|
||||
}
|
||||
|
||||
func CimCloseStream(cimStreamHandle StreamHandle) (hr error) {
|
||||
hr = procCimCloseStream.Find()
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
r0, _, _ := syscall.Syscall(procCimCloseStream.Addr(), 1, uintptr(cimStreamHandle), 0, 0)
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CimCommitImage(cimFSHandle FsHandle) (hr error) {
|
||||
hr = procCimCommitImage.Find()
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
r0, _, _ := syscall.Syscall(procCimCommitImage.Addr(), 1, uintptr(cimFSHandle), 0, 0)
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CimCreateAlternateStream(cimFSHandle FsHandle, path string, size uint64, cimStreamHandle *StreamHandle) (hr error) {
|
||||
var _p0 *uint16
|
||||
_p0, hr = syscall.UTF16PtrFromString(path)
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
return _CimCreateAlternateStream(cimFSHandle, _p0, size, cimStreamHandle)
|
||||
}
|
||||
|
||||
func _CimCreateAlternateStream(cimFSHandle FsHandle, path *uint16, size uint64, cimStreamHandle *StreamHandle) (hr error) {
|
||||
hr = procCimCreateAlternateStream.Find()
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
r0, _, _ := syscall.Syscall6(procCimCreateAlternateStream.Addr(), 4, uintptr(cimFSHandle), uintptr(unsafe.Pointer(path)), uintptr(size), uintptr(unsafe.Pointer(cimStreamHandle)), 0, 0)
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CimCreateFile(cimFSHandle FsHandle, path string, file *CimFsFileMetadata, cimStreamHandle *StreamHandle) (hr error) {
|
||||
var _p0 *uint16
|
||||
_p0, hr = syscall.UTF16PtrFromString(path)
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
return _CimCreateFile(cimFSHandle, _p0, file, cimStreamHandle)
|
||||
}
|
||||
|
||||
func _CimCreateFile(cimFSHandle FsHandle, path *uint16, file *CimFsFileMetadata, cimStreamHandle *StreamHandle) (hr error) {
|
||||
hr = procCimCreateFile.Find()
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
r0, _, _ := syscall.Syscall6(procCimCreateFile.Addr(), 4, uintptr(cimFSHandle), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(file)), uintptr(unsafe.Pointer(cimStreamHandle)), 0, 0)
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CimCreateHardLink(cimFSHandle FsHandle, newPath string, oldPath string) (hr error) {
|
||||
var _p0 *uint16
|
||||
_p0, hr = syscall.UTF16PtrFromString(newPath)
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
var _p1 *uint16
|
||||
_p1, hr = syscall.UTF16PtrFromString(oldPath)
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
return _CimCreateHardLink(cimFSHandle, _p0, _p1)
|
||||
}
|
||||
|
||||
func _CimCreateHardLink(cimFSHandle FsHandle, newPath *uint16, oldPath *uint16) (hr error) {
|
||||
hr = procCimCreateHardLink.Find()
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
r0, _, _ := syscall.Syscall(procCimCreateHardLink.Addr(), 3, uintptr(cimFSHandle), uintptr(unsafe.Pointer(newPath)), uintptr(unsafe.Pointer(oldPath)))
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CimCreateImage(imagePath string, oldFSName *uint16, newFSName *uint16, cimFSHandle *FsHandle) (hr error) {
|
||||
var _p0 *uint16
|
||||
_p0, hr = syscall.UTF16PtrFromString(imagePath)
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
return _CimCreateImage(_p0, oldFSName, newFSName, cimFSHandle)
|
||||
}
|
||||
|
||||
func _CimCreateImage(imagePath *uint16, oldFSName *uint16, newFSName *uint16, cimFSHandle *FsHandle) (hr error) {
|
||||
hr = procCimCreateImage.Find()
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
r0, _, _ := syscall.Syscall6(procCimCreateImage.Addr(), 4, uintptr(unsafe.Pointer(imagePath)), uintptr(unsafe.Pointer(oldFSName)), uintptr(unsafe.Pointer(newFSName)), uintptr(unsafe.Pointer(cimFSHandle)), 0, 0)
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CimDeletePath(cimFSHandle FsHandle, path string) (hr error) {
|
||||
var _p0 *uint16
|
||||
_p0, hr = syscall.UTF16PtrFromString(path)
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
return _CimDeletePath(cimFSHandle, _p0)
|
||||
}
|
||||
|
||||
func _CimDeletePath(cimFSHandle FsHandle, path *uint16) (hr error) {
|
||||
hr = procCimDeletePath.Find()
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
r0, _, _ := syscall.Syscall(procCimDeletePath.Addr(), 2, uintptr(cimFSHandle), uintptr(unsafe.Pointer(path)), 0)
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CimDismountImage(volumeID *g) (hr error) {
|
||||
hr = procCimDismountImage.Find()
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
r0, _, _ := syscall.Syscall(procCimDismountImage.Addr(), 1, uintptr(unsafe.Pointer(volumeID)), 0, 0)
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CimMountImage(imagePath string, fsName string, flags uint32, volumeID *g) (hr error) {
|
||||
var _p0 *uint16
|
||||
_p0, hr = syscall.UTF16PtrFromString(imagePath)
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
var _p1 *uint16
|
||||
_p1, hr = syscall.UTF16PtrFromString(fsName)
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
return _CimMountImage(_p0, _p1, flags, volumeID)
|
||||
}
|
||||
|
||||
func _CimMountImage(imagePath *uint16, fsName *uint16, flags uint32, volumeID *g) (hr error) {
|
||||
hr = procCimMountImage.Find()
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
r0, _, _ := syscall.Syscall6(procCimMountImage.Addr(), 4, uintptr(unsafe.Pointer(imagePath)), uintptr(unsafe.Pointer(fsName)), uintptr(flags), uintptr(unsafe.Pointer(volumeID)), 0, 0)
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CimWriteStream(cimStreamHandle StreamHandle, buffer uintptr, bufferSize uint32) (hr error) {
|
||||
hr = procCimWriteStream.Find()
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
r0, _, _ := syscall.Syscall(procCimWriteStream.Addr(), 3, uintptr(cimStreamHandle), uintptr(buffer), uintptr(bufferSize))
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func SetJobCompartmentId(handle windows.Handle, compartmentId uint32) (win32Err error) {
|
||||
r0, _, _ := syscall.Syscall(procSetJobCompartmentId.Addr(), 2, uintptr(handle), uintptr(compartmentId), 0)
|
||||
if r0 != 0 {
|
||||
@ -381,35 +624,162 @@ func RtlNtStatusToDosError(status uint32) (winerr error) {
|
||||
return
|
||||
}
|
||||
|
||||
func ORCloseHive(key syscall.Handle) (regerrno error) {
|
||||
r0, _, _ := syscall.Syscall(procORCloseHive.Addr(), 1, uintptr(key), 0, 0)
|
||||
func ORCloseHive(handle ORHKey) (win32err error) {
|
||||
r0, _, _ := syscall.Syscall(procORCloseHive.Addr(), 1, uintptr(handle), 0, 0)
|
||||
if r0 != 0 {
|
||||
regerrno = syscall.Errno(r0)
|
||||
win32err = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ORCreateHive(key *syscall.Handle) (regerrno error) {
|
||||
func ORCloseKey(handle ORHKey) (win32err error) {
|
||||
r0, _, _ := syscall.Syscall(procORCloseKey.Addr(), 1, uintptr(handle), 0, 0)
|
||||
if r0 != 0 {
|
||||
win32err = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ORCreateHive(key *ORHKey) (win32err error) {
|
||||
r0, _, _ := syscall.Syscall(procORCreateHive.Addr(), 1, uintptr(unsafe.Pointer(key)), 0, 0)
|
||||
if r0 != 0 {
|
||||
regerrno = syscall.Errno(r0)
|
||||
win32err = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ORSaveHive(key syscall.Handle, file string, OsMajorVersion uint32, OsMinorVersion uint32) (regerrno error) {
|
||||
func ORCreateKey(handle ORHKey, subKey string, class uintptr, options uint32, securityDescriptor uintptr, result *ORHKey, disposition *uint32) (win32err error) {
|
||||
var _p0 *uint16
|
||||
_p0, regerrno = syscall.UTF16PtrFromString(file)
|
||||
if regerrno != nil {
|
||||
_p0, win32err = syscall.UTF16PtrFromString(subKey)
|
||||
if win32err != nil {
|
||||
return
|
||||
}
|
||||
return _ORSaveHive(key, _p0, OsMajorVersion, OsMinorVersion)
|
||||
return _ORCreateKey(handle, _p0, class, options, securityDescriptor, result, disposition)
|
||||
}
|
||||
|
||||
func _ORSaveHive(key syscall.Handle, file *uint16, OsMajorVersion uint32, OsMinorVersion uint32) (regerrno error) {
|
||||
r0, _, _ := syscall.Syscall6(procORSaveHive.Addr(), 4, uintptr(key), uintptr(unsafe.Pointer(file)), uintptr(OsMajorVersion), uintptr(OsMinorVersion), 0, 0)
|
||||
func _ORCreateKey(handle ORHKey, subKey *uint16, class uintptr, options uint32, securityDescriptor uintptr, result *ORHKey, disposition *uint32) (win32err error) {
|
||||
r0, _, _ := syscall.Syscall9(procORCreateKey.Addr(), 7, uintptr(handle), uintptr(unsafe.Pointer(subKey)), uintptr(class), uintptr(options), uintptr(securityDescriptor), uintptr(unsafe.Pointer(result)), uintptr(unsafe.Pointer(disposition)), 0, 0)
|
||||
if r0 != 0 {
|
||||
regerrno = syscall.Errno(r0)
|
||||
win32err = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ORDeleteKey(handle ORHKey, subKey string) (win32err error) {
|
||||
var _p0 *uint16
|
||||
_p0, win32err = syscall.UTF16PtrFromString(subKey)
|
||||
if win32err != nil {
|
||||
return
|
||||
}
|
||||
return _ORDeleteKey(handle, _p0)
|
||||
}
|
||||
|
||||
func _ORDeleteKey(handle ORHKey, subKey *uint16) (win32err error) {
|
||||
r0, _, _ := syscall.Syscall(procORDeleteKey.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(subKey)), 0)
|
||||
if r0 != 0 {
|
||||
win32err = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ORGetValue(handle ORHKey, subKey string, value string, valueType *uint32, data *byte, dataLen *uint32) (win32err error) {
|
||||
var _p0 *uint16
|
||||
_p0, win32err = syscall.UTF16PtrFromString(subKey)
|
||||
if win32err != nil {
|
||||
return
|
||||
}
|
||||
var _p1 *uint16
|
||||
_p1, win32err = syscall.UTF16PtrFromString(value)
|
||||
if win32err != nil {
|
||||
return
|
||||
}
|
||||
return _ORGetValue(handle, _p0, _p1, valueType, data, dataLen)
|
||||
}
|
||||
|
||||
func _ORGetValue(handle ORHKey, subKey *uint16, value *uint16, valueType *uint32, data *byte, dataLen *uint32) (win32err error) {
|
||||
r0, _, _ := syscall.Syscall6(procORGetValue.Addr(), 6, uintptr(handle), uintptr(unsafe.Pointer(subKey)), uintptr(unsafe.Pointer(value)), uintptr(unsafe.Pointer(valueType)), uintptr(unsafe.Pointer(data)), uintptr(unsafe.Pointer(dataLen)))
|
||||
if r0 != 0 {
|
||||
win32err = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ORMergeHives(hiveHandles []ORHKey, result *ORHKey) (win32err error) {
|
||||
var _p0 *ORHKey
|
||||
if len(hiveHandles) > 0 {
|
||||
_p0 = &hiveHandles[0]
|
||||
}
|
||||
r0, _, _ := syscall.Syscall(procORMergeHives.Addr(), 3, uintptr(unsafe.Pointer(_p0)), uintptr(len(hiveHandles)), uintptr(unsafe.Pointer(result)))
|
||||
if r0 != 0 {
|
||||
win32err = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func OROpenHive(hivePath string, result *ORHKey) (win32err error) {
|
||||
var _p0 *uint16
|
||||
_p0, win32err = syscall.UTF16PtrFromString(hivePath)
|
||||
if win32err != nil {
|
||||
return
|
||||
}
|
||||
return _OROpenHive(_p0, result)
|
||||
}
|
||||
|
||||
func _OROpenHive(hivePath *uint16, result *ORHKey) (win32err error) {
|
||||
r0, _, _ := syscall.Syscall(procOROpenHive.Addr(), 2, uintptr(unsafe.Pointer(hivePath)), uintptr(unsafe.Pointer(result)), 0)
|
||||
if r0 != 0 {
|
||||
win32err = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func OROpenKey(handle ORHKey, subKey string, result *ORHKey) (win32err error) {
|
||||
var _p0 *uint16
|
||||
_p0, win32err = syscall.UTF16PtrFromString(subKey)
|
||||
if win32err != nil {
|
||||
return
|
||||
}
|
||||
return _OROpenKey(handle, _p0, result)
|
||||
}
|
||||
|
||||
func _OROpenKey(handle ORHKey, subKey *uint16, result *ORHKey) (win32err error) {
|
||||
r0, _, _ := syscall.Syscall(procOROpenKey.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(subKey)), uintptr(unsafe.Pointer(result)))
|
||||
if r0 != 0 {
|
||||
win32err = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ORSaveHive(handle ORHKey, hivePath string, osMajorVersion uint32, osMinorVersion uint32) (win32err error) {
|
||||
var _p0 *uint16
|
||||
_p0, win32err = syscall.UTF16PtrFromString(hivePath)
|
||||
if win32err != nil {
|
||||
return
|
||||
}
|
||||
return _ORSaveHive(handle, _p0, osMajorVersion, osMinorVersion)
|
||||
}
|
||||
|
||||
func _ORSaveHive(handle ORHKey, hivePath *uint16, osMajorVersion uint32, osMinorVersion uint32) (win32err error) {
|
||||
r0, _, _ := syscall.Syscall6(procORSaveHive.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(hivePath)), uintptr(osMajorVersion), uintptr(osMinorVersion), 0, 0)
|
||||
if r0 != 0 {
|
||||
win32err = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ORSetValue(handle ORHKey, valueName string, valueType uint32, data *byte, dataLen uint32) (win32err error) {
|
||||
var _p0 *uint16
|
||||
_p0, win32err = syscall.UTF16PtrFromString(valueName)
|
||||
if win32err != nil {
|
||||
return
|
||||
}
|
||||
return _ORSetValue(handle, _p0, valueType, data, dataLen)
|
||||
}
|
||||
|
||||
func _ORSetValue(handle ORHKey, valueName *uint16, valueType uint32, data *byte, dataLen uint32) (win32err error) {
|
||||
r0, _, _ := syscall.Syscall6(procORSetValue.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(valueName)), uintptr(valueType), uintptr(unsafe.Pointer(data)), uintptr(dataLen), 0)
|
||||
if r0 != 0 {
|
||||
win32err = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
1
vendor/github.com/Microsoft/hcsshim/layer.go
generated
vendored
1
vendor/github.com/Microsoft/hcsshim/layer.go
generated
vendored
@ -32,6 +32,7 @@ func CreateScratchLayer(info DriverInfo, layerId, parentId string, parentLayerPa
|
||||
func DeactivateLayer(info DriverInfo, id string) error {
|
||||
return wclayer.DeactivateLayer(context.Background(), layerPath(&info, id))
|
||||
}
|
||||
|
||||
func DestroyLayer(info DriverInfo, id string) error {
|
||||
return wclayer.DestroyLayer(context.Background(), layerPath(&info, id))
|
||||
}
|
||||
|
33
vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go
generated
vendored
33
vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go
generated
vendored
@ -5,6 +5,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
// OSVersion is a wrapper for Windows version information
|
||||
@ -25,16 +26,15 @@ var (
|
||||
// The calling application must be manifested to get the correct version information.
|
||||
func Get() OSVersion {
|
||||
once.Do(func() {
|
||||
var err error
|
||||
v := *windows.RtlGetVersion()
|
||||
osv = OSVersion{}
|
||||
osv.Version, err = windows.GetVersion()
|
||||
if err != nil {
|
||||
// GetVersion never fails.
|
||||
panic(err)
|
||||
}
|
||||
osv.MajorVersion = uint8(osv.Version & 0xFF)
|
||||
osv.MinorVersion = uint8(osv.Version >> 8 & 0xFF)
|
||||
osv.Build = uint16(osv.Version >> 16)
|
||||
osv.MajorVersion = uint8(v.MajorVersion)
|
||||
osv.MinorVersion = uint8(v.MinorVersion)
|
||||
osv.Build = uint16(v.BuildNumber)
|
||||
// Fill version value so that existing clients don't break
|
||||
osv.Version = v.BuildNumber << 16
|
||||
osv.Version = osv.Version | (uint32(v.MinorVersion) << 8)
|
||||
osv.Version = osv.Version | v.MajorVersion
|
||||
})
|
||||
return osv
|
||||
}
|
||||
@ -57,3 +57,18 @@ func (osv OSVersion) String() string {
|
||||
func (osv OSVersion) ToString() string {
|
||||
return osv.String()
|
||||
}
|
||||
|
||||
// Running `cmd /c ver` shows something like "10.0.20348.1000". The last component ("1000") is the revision
|
||||
// number
|
||||
func BuildRevision() (uint32, error) {
|
||||
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("open `CurrentVersion` registry key: %w", err)
|
||||
}
|
||||
defer k.Close()
|
||||
s, _, err := k.GetIntegerValue("UBR")
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("read `UBR` from registry: %w", err)
|
||||
}
|
||||
return uint32(s), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user