Merge pull request #7028 from AkihiroSuda/continuity-0.3.0

go.mod: github.com/containerd/continuity v0.3.0
This commit is contained in:
Kazuyoshi Kato 2022-06-07 20:10:13 -07:00 committed by GitHub
commit a35fbb7ec7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 659 additions and 419 deletions

4
go.mod
View File

@ -4,14 +4,14 @@ go 1.18
require ( require (
github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8 github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8
github.com/Microsoft/go-winio v0.5.1 github.com/Microsoft/go-winio v0.5.2
github.com/Microsoft/hcsshim v0.9.2 github.com/Microsoft/hcsshim v0.9.2
github.com/container-orchestrated-devices/container-device-interface v0.3.1 github.com/container-orchestrated-devices/container-device-interface v0.3.1
github.com/containerd/aufs v1.0.0 github.com/containerd/aufs v1.0.0
github.com/containerd/btrfs v1.0.0 github.com/containerd/btrfs v1.0.0
github.com/containerd/cgroups v1.0.3 github.com/containerd/cgroups v1.0.3
github.com/containerd/console v1.0.3 github.com/containerd/console v1.0.3
github.com/containerd/continuity v0.2.2 github.com/containerd/continuity v0.3.0
github.com/containerd/fifo v1.0.0 github.com/containerd/fifo v1.0.0
github.com/containerd/go-cni v1.1.6 github.com/containerd/go-cni v1.1.6
github.com/containerd/go-runc v1.0.0 github.com/containerd/go-runc v1.0.0

6
go.sum
View File

@ -69,8 +69,9 @@ github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugX
github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.4.17-0.20210324224401-5516f17a5958/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.4.17-0.20210324224401-5516f17a5958/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.4.17/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.4.17/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY=
github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg=
github.com/Microsoft/hcsshim v0.8.7-0.20190325164909-8abdbb8205e4/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= github.com/Microsoft/hcsshim v0.8.7-0.20190325164909-8abdbb8205e4/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg=
github.com/Microsoft/hcsshim v0.8.7/go.mod h1:OHd7sQqRFrYd3RmSgbgji+ctCwkbq2wbEYNSzOYtcBQ= github.com/Microsoft/hcsshim v0.8.7/go.mod h1:OHd7sQqRFrYd3RmSgbgji+ctCwkbq2wbEYNSzOYtcBQ=
@ -223,8 +224,9 @@ github.com/containerd/continuity v0.0.0-20200710164510-efbc4488d8fe/go.mod h1:cE
github.com/containerd/continuity v0.0.0-20201208142359-180525291bb7/go.mod h1:kR3BEg7bDFaEddKm54WSmrol1fKWDU1nKYkgrcgZT7Y= github.com/containerd/continuity v0.0.0-20201208142359-180525291bb7/go.mod h1:kR3BEg7bDFaEddKm54WSmrol1fKWDU1nKYkgrcgZT7Y=
github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ= github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ=
github.com/containerd/continuity v0.1.0/go.mod h1:ICJu0PwR54nI0yPEnJ6jcS+J7CZAUXrLh8lPo2knzsM= github.com/containerd/continuity v0.1.0/go.mod h1:ICJu0PwR54nI0yPEnJ6jcS+J7CZAUXrLh8lPo2knzsM=
github.com/containerd/continuity v0.2.2 h1:QSqfxcn8c+12slxwu00AtzXrsami0MJb/MQs9lOLHLA=
github.com/containerd/continuity v0.2.2/go.mod h1:pWygW9u7LtS1o4N/Tn0FoCFDIXZ7rxcMX7HX1Dmibvk= github.com/containerd/continuity v0.2.2/go.mod h1:pWygW9u7LtS1o4N/Tn0FoCFDIXZ7rxcMX7HX1Dmibvk=
github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg=
github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM=
github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI=
github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI=
github.com/containerd/fifo v0.0.0-20200410184934-f15a3290365b/go.mod h1:jPQ2IAeZRCYxpS/Cm1495vGFww6ecHmMk1YJH2Q5ln0= github.com/containerd/fifo v0.0.0-20200410184934-f15a3290365b/go.mod h1:jPQ2IAeZRCYxpS/Cm1495vGFww6ecHmMk1YJH2Q5ln0=

View File

@ -20,12 +20,12 @@ require (
) )
require ( require (
github.com/Microsoft/go-winio v0.5.1 // indirect github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect github.com/blang/semver v3.5.1+incompatible // indirect
github.com/cilium/ebpf v0.7.0 // indirect github.com/cilium/ebpf v0.7.0 // indirect
github.com/container-orchestrated-devices/container-device-interface v0.3.1 // indirect github.com/container-orchestrated-devices/container-device-interface v0.3.1 // indirect
github.com/containerd/console v1.0.3 // indirect github.com/containerd/console v1.0.3 // indirect
github.com/containerd/continuity v0.2.2 // indirect github.com/containerd/continuity v0.3.0 // indirect
github.com/containerd/fifo v1.0.0 // indirect github.com/containerd/fifo v1.0.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect

View File

@ -1,5 +1,4 @@
bazil.org/fuse v0.0.0-20160811212531-371fbbdaa898/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8= bazil.org/fuse v0.0.0-20160811212531-371fbbdaa898/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8=
bazil.org/fuse v0.0.0-20200407214033-5883e5a4b512/go.mod h1:FbcW6z/2VytnFDhZfumh8Ss8zxHE6qpMP5sHTRe0EaM=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
@ -54,8 +53,9 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.4.17/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.4.17/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY=
github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Microsoft/hcsshim v0.8.15/go.mod h1:x38A4YbHbdxJtc0sF6oIz+RG0npwSCAvn69iY6URG00= github.com/Microsoft/hcsshim v0.8.15/go.mod h1:x38A4YbHbdxJtc0sF6oIz+RG0npwSCAvn69iY6URG00=
github.com/Microsoft/hcsshim v0.8.20/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4= github.com/Microsoft/hcsshim v0.8.20/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4=
github.com/Microsoft/hcsshim v0.9.2 h1:wB06W5aYFfUB3IvootYAY2WnOmIdgPGfqSI6tufQNnY= github.com/Microsoft/hcsshim v0.9.2 h1:wB06W5aYFfUB3IvootYAY2WnOmIdgPGfqSI6tufQNnY=
@ -140,8 +140,8 @@ github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8a
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw= github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ= github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ=
github.com/containerd/continuity v0.2.2 h1:QSqfxcn8c+12slxwu00AtzXrsami0MJb/MQs9lOLHLA= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg=
github.com/containerd/continuity v0.2.2/go.mod h1:pWygW9u7LtS1o4N/Tn0FoCFDIXZ7rxcMX7HX1Dmibvk= github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM=
github.com/containerd/fifo v1.0.0 h1:6PirWBr9/L7GDamKr+XM0IeUFXu5mf3M/BPpH9gaLBU= github.com/containerd/fifo v1.0.0 h1:6PirWBr9/L7GDamKr+XM0IeUFXu5mf3M/BPpH9gaLBU=
github.com/containerd/fifo v1.0.0/go.mod h1:ocF/ME1SX5b1AOlWi9r677YJmCPSwwWnQ9O123vzpE4= github.com/containerd/fifo v1.0.0/go.mod h1:ocF/ME1SX5b1AOlWi9r677YJmCPSwwWnQ9O123vzpE4=
github.com/containerd/go-cni v1.1.3/go.mod h1:Rflh2EJ/++BA2/vY5ao3K6WJRR/bZKsX123aPk+kUtA= github.com/containerd/go-cni v1.1.3/go.mod h1:Rflh2EJ/++BA2/vY5ao3K6WJRR/bZKsX123aPk+kUtA=
@ -642,7 +642,6 @@ github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG
github.com/tchap/go-patricia/v2 v2.3.1/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k= github.com/tchap/go-patricia/v2 v2.3.1/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
@ -935,6 +934,7 @@ golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220405210540-1e041c57c461/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc= golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc=
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

View File

@ -113,6 +113,69 @@ func BasicInfoHeader(name string, size int64, fileInfo *winio.FileBasicInfo) *ta
return hdr return hdr
} }
// SecurityDescriptorFromTarHeader reads the SDDL associated with the header of the current file
// from the tar header and returns the security descriptor into a byte slice.
func SecurityDescriptorFromTarHeader(hdr *tar.Header) ([]byte, error) {
// Maintaining old SDDL-based behavior for backward
// compatibility. All new tar headers written by this library
// will have raw binary for the security descriptor.
var sd []byte
var err error
if sddl, ok := hdr.PAXRecords[hdrSecurityDescriptor]; ok {
sd, err = winio.SddlToSecurityDescriptor(sddl)
if err != nil {
return nil, err
}
}
if sdraw, ok := hdr.PAXRecords[hdrRawSecurityDescriptor]; ok {
sd, err = base64.StdEncoding.DecodeString(sdraw)
if err != nil {
return nil, err
}
}
return sd, nil
}
// ExtendedAttributesFromTarHeader reads the EAs associated with the header of the
// current file from the tar header and returns it as a byte slice.
func ExtendedAttributesFromTarHeader(hdr *tar.Header) ([]byte, error) {
var eas []winio.ExtendedAttribute
var eadata []byte
var err error
for k, v := range hdr.PAXRecords {
if !strings.HasPrefix(k, hdrEaPrefix) {
continue
}
data, err := base64.StdEncoding.DecodeString(v)
if err != nil {
return nil, err
}
eas = append(eas, winio.ExtendedAttribute{
Name: k[len(hdrEaPrefix):],
Value: data,
})
}
if len(eas) != 0 {
eadata, err = winio.EncodeExtendedAttributes(eas)
if err != nil {
return nil, err
}
}
return eadata, nil
}
// EncodeReparsePointFromTarHeader reads the ReparsePoint structure from the tar header
// and encodes it into a byte slice. The file for which this function is called must be a
// symlink.
func EncodeReparsePointFromTarHeader(hdr *tar.Header) []byte {
_, isMountPoint := hdr.PAXRecords[hdrMountPoint]
rp := winio.ReparsePoint{
Target: filepath.FromSlash(hdr.Linkname),
IsMountPoint: isMountPoint,
}
return winio.EncodeReparsePoint(&rp)
}
// WriteTarFileFromBackupStream writes a file to a tar writer using data from a Win32 backup stream. // WriteTarFileFromBackupStream writes a file to a tar writer using data from a Win32 backup stream.
// //
// This encodes Win32 metadata as tar pax vendor extensions starting with MSWINDOWS. // This encodes Win32 metadata as tar pax vendor extensions starting with MSWINDOWS.
@ -358,22 +421,11 @@ func FileInfoFromHeader(hdr *tar.Header) (name string, size int64, fileInfo *win
// tar file that was not processed, or io.EOF is there are no more. // tar file that was not processed, or io.EOF is there are no more.
func WriteBackupStreamFromTarFile(w io.Writer, t *tar.Reader, hdr *tar.Header) (*tar.Header, error) { func WriteBackupStreamFromTarFile(w io.Writer, t *tar.Reader, hdr *tar.Header) (*tar.Header, error) {
bw := winio.NewBackupStreamWriter(w) bw := winio.NewBackupStreamWriter(w)
var sd []byte
var err error sd, err := SecurityDescriptorFromTarHeader(hdr)
// Maintaining old SDDL-based behavior for backward compatibility. All new tar headers written
// by this library will have raw binary for the security descriptor.
if sddl, ok := hdr.PAXRecords[hdrSecurityDescriptor]; ok {
sd, err = winio.SddlToSecurityDescriptor(sddl)
if err != nil { if err != nil {
return nil, err return nil, err
} }
}
if sdraw, ok := hdr.PAXRecords[hdrRawSecurityDescriptor]; ok {
sd, err = base64.StdEncoding.DecodeString(sdraw)
if err != nil {
return nil, err
}
}
if len(sd) != 0 { if len(sd) != 0 {
bhdr := winio.BackupHeader{ bhdr := winio.BackupHeader{
Id: winio.BackupSecurity, Id: winio.BackupSecurity,
@ -388,25 +440,12 @@ func WriteBackupStreamFromTarFile(w io.Writer, t *tar.Reader, hdr *tar.Header) (
return nil, err return nil, err
} }
} }
var eas []winio.ExtendedAttribute
for k, v := range hdr.PAXRecords { eadata, err := ExtendedAttributesFromTarHeader(hdr)
if !strings.HasPrefix(k, hdrEaPrefix) {
continue
}
data, err := base64.StdEncoding.DecodeString(v)
if err != nil {
return nil, err
}
eas = append(eas, winio.ExtendedAttribute{
Name: k[len(hdrEaPrefix):],
Value: data,
})
}
if len(eas) != 0 {
eadata, err := winio.EncodeExtendedAttributes(eas)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(eadata) != 0 {
bhdr := winio.BackupHeader{ bhdr := winio.BackupHeader{
Id: winio.BackupEaData, Id: winio.BackupEaData,
Size: int64(len(eadata)), Size: int64(len(eadata)),
@ -420,13 +459,9 @@ func WriteBackupStreamFromTarFile(w io.Writer, t *tar.Reader, hdr *tar.Header) (
return nil, err return nil, err
} }
} }
if hdr.Typeflag == tar.TypeSymlink { if hdr.Typeflag == tar.TypeSymlink {
_, isMountPoint := hdr.PAXRecords[hdrMountPoint] reparse := EncodeReparsePointFromTarHeader(hdr)
rp := winio.ReparsePoint{
Target: filepath.FromSlash(hdr.Linkname),
IsMountPoint: isMountPoint,
}
reparse := winio.EncodeReparsePoint(&rp)
bhdr := winio.BackupHeader{ bhdr := winio.BackupHeader{
Id: winio.BackupReparseData, Id: winio.BackupReparseData,
Size: int64(len(reparse)), Size: int64(len(reparse)),
@ -439,7 +474,9 @@ func WriteBackupStreamFromTarFile(w io.Writer, t *tar.Reader, hdr *tar.Header) (
if err != nil { if err != nil {
return nil, err return nil, err
} }
} }
if hdr.Typeflag == tar.TypeReg || hdr.Typeflag == tar.TypeRegA { if hdr.Typeflag == tar.TypeReg || hdr.Typeflag == tar.TypeRegA {
bhdr := winio.BackupHeader{ bhdr := winio.BackupHeader{
Id: winio.BackupData, Id: winio.BackupData,

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows // +build windows
package winio package winio
@ -143,6 +144,11 @@ func (f *win32File) Close() error {
return nil return nil
} }
// IsClosed checks if the file has been closed
func (f *win32File) IsClosed() bool {
return f.closing.isSet()
}
// prepareIo prepares for a new IO operation. // prepareIo prepares for a new IO operation.
// The caller must call f.wg.Done() when the IO is finished, prior to Close() returning. // The caller must call f.wg.Done() when the IO is finished, prior to Close() returning.
func (f *win32File) prepareIo() (*ioOperation, error) { func (f *win32File) prepareIo() (*ioOperation, error) {

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows // +build windows
package winio package winio
@ -252,15 +253,23 @@ func (conn *HvsockConn) Close() error {
return conn.sock.Close() return conn.sock.Close()
} }
func (conn *HvsockConn) IsClosed() bool {
return conn.sock.IsClosed()
}
func (conn *HvsockConn) shutdown(how int) error { func (conn *HvsockConn) shutdown(how int) error {
err := syscall.Shutdown(conn.sock.handle, syscall.SHUT_RD) if conn.IsClosed() {
return ErrFileClosed
}
err := syscall.Shutdown(conn.sock.handle, how)
if err != nil { if err != nil {
return os.NewSyscallError("shutdown", err) return os.NewSyscallError("shutdown", err)
} }
return nil return nil
} }
// CloseRead shuts down the read end of the socket. // CloseRead shuts down the read end of the socket, preventing future read operations.
func (conn *HvsockConn) CloseRead() error { func (conn *HvsockConn) CloseRead() error {
err := conn.shutdown(syscall.SHUT_RD) err := conn.shutdown(syscall.SHUT_RD)
if err != nil { if err != nil {
@ -269,8 +278,8 @@ func (conn *HvsockConn) CloseRead() error {
return nil return nil
} }
// CloseWrite shuts down the write end of the socket, notifying the other endpoint that // CloseWrite shuts down the write end of the socket, preventing future write operations and
// no more data will be written. // notifying the other endpoint that no more data will be written.
func (conn *HvsockConn) CloseWrite() error { func (conn *HvsockConn) CloseWrite() error {
err := conn.shutdown(syscall.SHUT_WR) err := conn.shutdown(syscall.SHUT_WR)
if err != nil { if err != nil {

View File

@ -14,8 +14,6 @@ import (
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"strconv" "strconv"
"golang.org/x/sys/windows"
) )
// Variant specifies which GUID variant (or "type") of the GUID. It determines // Variant specifies which GUID variant (or "type") of the GUID. It determines
@ -41,13 +39,6 @@ type Version uint8
var _ = (encoding.TextMarshaler)(GUID{}) var _ = (encoding.TextMarshaler)(GUID{})
var _ = (encoding.TextUnmarshaler)(&GUID{}) var _ = (encoding.TextUnmarshaler)(&GUID{})
// GUID represents a GUID/UUID. It has the same structure as
// golang.org/x/sys/windows.GUID so that it can be used with functions expecting
// that type. It is defined as its own type so that stringification and
// marshaling can be supported. The representation matches that used by native
// Windows code.
type GUID windows.GUID
// NewV4 returns a new version 4 (pseudorandom) GUID, as defined by RFC 4122. // NewV4 returns a new version 4 (pseudorandom) GUID, as defined by RFC 4122.
func NewV4() (GUID, error) { func NewV4() (GUID, error) {
var b [16]byte var b [16]byte

View File

@ -0,0 +1,15 @@
// +build !windows
package guid
// GUID represents a GUID/UUID. It has the same structure as
// golang.org/x/sys/windows.GUID so that it can be used with functions expecting
// that type. It is defined as its own type as that is only available to builds
// targeted at `windows`. The representation matches that used by native Windows
// code.
type GUID struct {
Data1 uint32
Data2 uint16
Data3 uint16
Data4 [8]byte
}

View File

@ -0,0 +1,10 @@
package guid
import "golang.org/x/sys/windows"
// GUID represents a GUID/UUID. It has the same structure as
// golang.org/x/sys/windows.GUID so that it can be used with functions expecting
// that type. It is defined as its own type so that stringification and
// marshaling can be supported. The representation matches that used by native
// Windows code.
type GUID windows.GUID

View File

@ -3,11 +3,10 @@
package security package security
import ( import (
"fmt"
"os" "os"
"syscall" "syscall"
"unsafe" "unsafe"
"github.com/pkg/errors"
) )
type ( type (
@ -72,7 +71,7 @@ func GrantVmGroupAccess(name string) error {
// Stat (to determine if `name` is a directory). // Stat (to determine if `name` is a directory).
s, err := os.Stat(name) s, err := os.Stat(name)
if err != nil { if err != nil {
return errors.Wrapf(err, "%s os.Stat %s", gvmga, name) return fmt.Errorf("%s os.Stat %s: %w", gvmga, name, err)
} }
// Get a handle to the file/directory. Must defer Close on success. // Get a handle to the file/directory. Must defer Close on success.
@ -88,7 +87,7 @@ func GrantVmGroupAccess(name string) error {
sd := uintptr(0) sd := uintptr(0)
origDACL := uintptr(0) origDACL := uintptr(0)
if err := getSecurityInfo(fd, uint32(ot), uint32(si), nil, nil, &origDACL, nil, &sd); err != nil { if err := getSecurityInfo(fd, uint32(ot), uint32(si), nil, nil, &origDACL, nil, &sd); err != nil {
return errors.Wrapf(err, "%s GetSecurityInfo %s", gvmga, name) return fmt.Errorf("%s GetSecurityInfo %s: %w", gvmga, name, err)
} }
defer syscall.LocalFree((syscall.Handle)(unsafe.Pointer(sd))) defer syscall.LocalFree((syscall.Handle)(unsafe.Pointer(sd)))
@ -102,7 +101,7 @@ func GrantVmGroupAccess(name string) error {
// And finally use SetSecurityInfo to apply the updated DACL. // And finally use SetSecurityInfo to apply the updated DACL.
if err := setSecurityInfo(fd, uint32(ot), uint32(si), uintptr(0), uintptr(0), newDACL, uintptr(0)); err != nil { if err := setSecurityInfo(fd, uint32(ot), uint32(si), uintptr(0), uintptr(0), newDACL, uintptr(0)); err != nil {
return errors.Wrapf(err, "%s SetSecurityInfo %s", gvmga, name) return fmt.Errorf("%s SetSecurityInfo %s: %w", gvmga, name, err)
} }
return nil return nil
@ -120,7 +119,7 @@ func createFile(name string, isDir bool) (syscall.Handle, error) {
} }
fd, err := syscall.CreateFile(&namep[0], da, sm, nil, syscall.OPEN_EXISTING, fa, 0) fd, err := syscall.CreateFile(&namep[0], da, sm, nil, syscall.OPEN_EXISTING, fa, 0)
if err != nil { if err != nil {
return 0, errors.Wrapf(err, "%s syscall.CreateFile %s", gvmga, name) return 0, fmt.Errorf("%s syscall.CreateFile %s: %w", gvmga, name, err)
} }
return fd, nil return fd, nil
} }
@ -131,7 +130,7 @@ func generateDACLWithAcesAdded(name string, isDir bool, origDACL uintptr) (uintp
// Generate pointers to the SIDs based on the string SIDs // Generate pointers to the SIDs based on the string SIDs
sid, err := syscall.StringToSid(sidVmGroup) sid, err := syscall.StringToSid(sidVmGroup)
if err != nil { if err != nil {
return 0, errors.Wrapf(err, "%s syscall.StringToSid %s %s", gvmga, name, sidVmGroup) return 0, fmt.Errorf("%s syscall.StringToSid %s %s: %w", gvmga, name, sidVmGroup, err)
} }
inheritance := inheritModeNoInheritance inheritance := inheritModeNoInheritance
@ -154,7 +153,7 @@ func generateDACLWithAcesAdded(name string, isDir bool, origDACL uintptr) (uintp
modifiedDACL := uintptr(0) modifiedDACL := uintptr(0)
if err := setEntriesInAcl(uintptr(uint32(1)), uintptr(unsafe.Pointer(&eaArray[0])), origDACL, &modifiedDACL); err != nil { if err := setEntriesInAcl(uintptr(uint32(1)), uintptr(unsafe.Pointer(&eaArray[0])), origDACL, &modifiedDACL); err != nil {
return 0, errors.Wrapf(err, "%s SetEntriesInAcl %s", gvmga, name) return 0, fmt.Errorf("%s SetEntriesInAcl %s: %w", gvmga, name, err)
} }
return modifiedDACL, nil return modifiedDACL, nil

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows // +build windows
package vhd package vhd
@ -7,14 +8,13 @@ import (
"syscall" "syscall"
"github.com/Microsoft/go-winio/pkg/guid" "github.com/Microsoft/go-winio/pkg/guid"
"github.com/pkg/errors"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )
//go:generate go run mksyscall_windows.go -output zvhd_windows.go vhd.go //go:generate go run mksyscall_windows.go -output zvhd_windows.go vhd.go
//sys createVirtualDisk(virtualStorageType *VirtualStorageType, path string, virtualDiskAccessMask uint32, securityDescriptor *uintptr, createVirtualDiskFlags uint32, providerSpecificFlags uint32, parameters *CreateVirtualDiskParameters, overlapped *syscall.Overlapped, handle *syscall.Handle) (win32err error) = virtdisk.CreateVirtualDisk //sys createVirtualDisk(virtualStorageType *VirtualStorageType, path string, virtualDiskAccessMask uint32, securityDescriptor *uintptr, createVirtualDiskFlags uint32, providerSpecificFlags uint32, parameters *CreateVirtualDiskParameters, overlapped *syscall.Overlapped, handle *syscall.Handle) (win32err error) = virtdisk.CreateVirtualDisk
//sys openVirtualDisk(virtualStorageType *VirtualStorageType, path string, virtualDiskAccessMask uint32, openVirtualDiskFlags uint32, parameters *OpenVirtualDiskParameters, handle *syscall.Handle) (win32err error) = virtdisk.OpenVirtualDisk //sys openVirtualDisk(virtualStorageType *VirtualStorageType, path string, virtualDiskAccessMask uint32, openVirtualDiskFlags uint32, parameters *openVirtualDiskParameters, handle *syscall.Handle) (win32err error) = virtdisk.OpenVirtualDisk
//sys attachVirtualDisk(handle syscall.Handle, securityDescriptor *uintptr, attachVirtualDiskFlag uint32, providerSpecificFlags uint32, parameters *AttachVirtualDiskParameters, overlapped *syscall.Overlapped) (win32err error) = virtdisk.AttachVirtualDisk //sys attachVirtualDisk(handle syscall.Handle, securityDescriptor *uintptr, attachVirtualDiskFlag uint32, providerSpecificFlags uint32, parameters *AttachVirtualDiskParameters, overlapped *syscall.Overlapped) (win32err error) = virtdisk.AttachVirtualDisk
//sys detachVirtualDisk(handle syscall.Handle, detachVirtualDiskFlags uint32, providerSpecificFlags uint32) (win32err error) = virtdisk.DetachVirtualDisk //sys detachVirtualDisk(handle syscall.Handle, detachVirtualDiskFlags uint32, providerSpecificFlags uint32) (win32err error) = virtdisk.DetachVirtualDisk
//sys getVirtualDiskPhysicalPath(handle syscall.Handle, diskPathSizeInBytes *uint32, buffer *uint16) (win32err error) = virtdisk.GetVirtualDiskPhysicalPath //sys getVirtualDiskPhysicalPath(handle syscall.Handle, diskPathSizeInBytes *uint32, buffer *uint16) (win32err error) = virtdisk.GetVirtualDiskPhysicalPath
@ -62,13 +62,27 @@ type OpenVirtualDiskParameters struct {
Version2 OpenVersion2 Version2 OpenVersion2
} }
// The higher level `OpenVersion2` struct uses bools to refer to `GetInfoOnly` and `ReadOnly` for ease of use. However,
// the internal windows structure uses `BOOLS` aka int32s for these types. `openVersion2` is used for translating
// `OpenVersion2` fields to the correct windows internal field types on the `Open____` methods.
type openVersion2 struct {
getInfoOnly int32
readOnly int32
resiliencyGUID guid.GUID
}
type openVirtualDiskParameters struct {
version uint32
version2 openVersion2
}
type AttachVersion2 struct { type AttachVersion2 struct {
RestrictedOffset uint64 RestrictedOffset uint64
RestrictedLength uint64 RestrictedLength uint64
} }
type AttachVirtualDiskParameters struct { type AttachVirtualDiskParameters struct {
Version uint32 // Must always be set to 2 Version uint32
Version2 AttachVersion2 Version2 AttachVersion2
} }
@ -146,16 +160,13 @@ func CreateVhdx(path string, maxSizeInGb, blockSizeInMb uint32) error {
return err return err
} }
if err := syscall.CloseHandle(handle); err != nil { return syscall.CloseHandle(handle)
return err
}
return nil
} }
// DetachVirtualDisk detaches a virtual hard disk by handle. // DetachVirtualDisk detaches a virtual hard disk by handle.
func DetachVirtualDisk(handle syscall.Handle) (err error) { func DetachVirtualDisk(handle syscall.Handle) (err error) {
if err := detachVirtualDisk(handle, 0, 0); err != nil { if err := detachVirtualDisk(handle, 0, 0); err != nil {
return errors.Wrap(err, "failed to detach virtual disk") return fmt.Errorf("failed to detach virtual disk: %w", err)
} }
return nil return nil
} }
@ -185,7 +196,7 @@ func AttachVirtualDisk(handle syscall.Handle, attachVirtualDiskFlag AttachVirtua
parameters, parameters,
nil, nil,
); err != nil { ); err != nil {
return errors.Wrap(err, "failed to attach virtual disk") return fmt.Errorf("failed to attach virtual disk: %w", err)
} }
return nil return nil
} }
@ -209,7 +220,7 @@ func AttachVhd(path string) (err error) {
AttachVirtualDiskFlagNone, AttachVirtualDiskFlagNone,
&params, &params,
); err != nil { ); err != nil {
return errors.Wrap(err, "failed to attach virtual disk") return fmt.Errorf("failed to attach virtual disk: %w", err)
} }
return nil return nil
} }
@ -234,19 +245,35 @@ func OpenVirtualDiskWithParameters(vhdPath string, virtualDiskAccessMask Virtual
var ( var (
handle syscall.Handle handle syscall.Handle
defaultType VirtualStorageType defaultType VirtualStorageType
getInfoOnly int32
readOnly int32
) )
if parameters.Version != 2 { if parameters.Version != 2 {
return handle, fmt.Errorf("only version 2 VHDs are supported, found version: %d", parameters.Version) return handle, fmt.Errorf("only version 2 VHDs are supported, found version: %d", parameters.Version)
} }
if parameters.Version2.GetInfoOnly {
getInfoOnly = 1
}
if parameters.Version2.ReadOnly {
readOnly = 1
}
params := &openVirtualDiskParameters{
version: parameters.Version,
version2: openVersion2{
getInfoOnly,
readOnly,
parameters.Version2.ResiliencyGUID,
},
}
if err := openVirtualDisk( if err := openVirtualDisk(
&defaultType, &defaultType,
vhdPath, vhdPath,
uint32(virtualDiskAccessMask), uint32(virtualDiskAccessMask),
uint32(openVirtualDiskFlags), uint32(openVirtualDiskFlags),
parameters, params,
&handle, &handle,
); err != nil { ); err != nil {
return 0, errors.Wrap(err, "failed to open virtual disk") return 0, fmt.Errorf("failed to open virtual disk: %w", err)
} }
return handle, nil return handle, nil
} }
@ -272,7 +299,7 @@ func CreateVirtualDisk(path string, virtualDiskAccessMask VirtualDiskAccessMask,
nil, nil,
&handle, &handle,
); err != nil { ); err != nil {
return handle, errors.Wrap(err, "failed to create virtual disk") return handle, fmt.Errorf("failed to create virtual disk: %w", err)
} }
return handle, nil return handle, nil
} }
@ -290,7 +317,7 @@ func GetVirtualDiskPhysicalPath(handle syscall.Handle) (_ string, err error) {
&diskPathSizeInBytes, &diskPathSizeInBytes,
&diskPhysicalPathBuf[0], &diskPhysicalPathBuf[0],
); err != nil { ); err != nil {
return "", errors.Wrap(err, "failed to get disk physical path") return "", fmt.Errorf("failed to get disk physical path: %w", err)
} }
return windows.UTF16ToString(diskPhysicalPathBuf[:]), nil return windows.UTF16ToString(diskPhysicalPathBuf[:]), nil
} }
@ -314,10 +341,10 @@ func CreateDiffVhd(diffVhdPath, baseVhdPath string, blockSizeInMB uint32) error
createParams, createParams,
) )
if err != nil { if err != nil {
return fmt.Errorf("failed to create differencing vhd: %s", err) return fmt.Errorf("failed to create differencing vhd: %w", err)
} }
if err := syscall.CloseHandle(vhdHandle); err != nil { if err := syscall.CloseHandle(vhdHandle); err != nil {
return fmt.Errorf("failed to close differencing vhd handle: %s", err) return fmt.Errorf("failed to close differencing vhd handle: %w", err)
} }
return nil return nil
} }

View File

@ -88,7 +88,7 @@ func getVirtualDiskPhysicalPath(handle syscall.Handle, diskPathSizeInBytes *uint
return return
} }
func openVirtualDisk(virtualStorageType *VirtualStorageType, path string, virtualDiskAccessMask uint32, openVirtualDiskFlags uint32, parameters *OpenVirtualDiskParameters, handle *syscall.Handle) (win32err error) { func openVirtualDisk(virtualStorageType *VirtualStorageType, path string, virtualDiskAccessMask uint32, openVirtualDiskFlags uint32, parameters *openVirtualDiskParameters, handle *syscall.Handle) (win32err error) {
var _p0 *uint16 var _p0 *uint16
_p0, win32err = syscall.UTF16PtrFromString(path) _p0, win32err = syscall.UTF16PtrFromString(path)
if win32err != nil { if win32err != nil {
@ -97,7 +97,7 @@ func openVirtualDisk(virtualStorageType *VirtualStorageType, path string, virtua
return _openVirtualDisk(virtualStorageType, _p0, virtualDiskAccessMask, openVirtualDiskFlags, parameters, handle) return _openVirtualDisk(virtualStorageType, _p0, virtualDiskAccessMask, openVirtualDiskFlags, parameters, handle)
} }
func _openVirtualDisk(virtualStorageType *VirtualStorageType, path *uint16, virtualDiskAccessMask uint32, openVirtualDiskFlags uint32, parameters *OpenVirtualDiskParameters, handle *syscall.Handle) (win32err error) { func _openVirtualDisk(virtualStorageType *VirtualStorageType, path *uint16, virtualDiskAccessMask uint32, openVirtualDiskFlags uint32, parameters *openVirtualDiskParameters, handle *syscall.Handle) (win32err error) {
r0, _, _ := syscall.Syscall6(procOpenVirtualDisk.Addr(), 6, uintptr(unsafe.Pointer(virtualStorageType)), uintptr(unsafe.Pointer(path)), uintptr(virtualDiskAccessMask), uintptr(openVirtualDiskFlags), uintptr(unsafe.Pointer(parameters)), uintptr(unsafe.Pointer(handle))) r0, _, _ := syscall.Syscall6(procOpenVirtualDisk.Addr(), 6, uintptr(unsafe.Pointer(virtualStorageType)), uintptr(unsafe.Pointer(path)), uintptr(virtualDiskAccessMask), uintptr(openVirtualDiskFlags), uintptr(unsafe.Pointer(parameters)), uintptr(unsafe.Pointer(handle)))
if r0 != 0 { if r0 != 0 {
win32err = syscall.Errno(r0) win32err = syscall.Errno(r0)

View File

@ -6,8 +6,8 @@ linters:
- unconvert - unconvert
- gofmt - gofmt
- goimports - goimports
- golint
- ineffassign - ineffassign
- revive
- vet - vet
- unused - unused
- misspell - misspell

View File

@ -1 +1,10 @@
Stephen J Day <stephen.day@docker.com> Stephen Day <stevvooe@users.noreply.github.com> Aaron Lehmann <alehmann@netflix.com> <aaron.lehmann@docker.com>
Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp> <suda.akihiro@lab.ntt.co.jp>
Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp> <suda.kyoto@gmail.com>
Derek McGowan <derek@mcg.dev> <derek@mcgstyle.net>
Michael Crosby <crosbymichael@gmail.com> <michael@thepasture.io>
Phil Estes <estesp@gmail.com> <estesp@linux.vnet.ibm.com>
Phil Estes <estesp@gmail.com> <estesp@amazon.com>
Stephen J Day <stevvooe@gmail.com> <stephen.day@getcruise.com>
Stephen J Day <stevvooe@gmail.com> <stevvooe@users.noreply.github.com>
Stephen J Day <stevvooe@gmail.com> <stephen.day@docker.com>

View File

@ -1,8 +1,6 @@
Aaron Lehmann <aaron.lehmann@docker.com> Aaron Lehmann <alehmann@netflix.com>
Akash Gupta <akagup@microsoft.com> Akash Gupta <akagup@microsoft.com>
Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp> Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Akihiro Suda <suda.kyoto@gmail.com>
Andrew Pennebaker <apennebaker@datapipe.com> Andrew Pennebaker <apennebaker@datapipe.com>
Brandon Philips <brandon.philips@coreos.com> Brandon Philips <brandon.philips@coreos.com>
Brian Goff <cpuguy83@gmail.com> Brian Goff <cpuguy83@gmail.com>
@ -10,9 +8,9 @@ Christopher Jones <tophj@linux.vnet.ibm.com>
Daniel, Dao Quang Minh <dqminh89@gmail.com> Daniel, Dao Quang Minh <dqminh89@gmail.com>
Darren Stahl <darst@microsoft.com> Darren Stahl <darst@microsoft.com>
Derek McGowan <derek@mcg.dev> Derek McGowan <derek@mcg.dev>
Derek McGowan <derek@mcgstyle.net>
Edward Pilatowicz <edward.pilatowicz@oracle.com> Edward Pilatowicz <edward.pilatowicz@oracle.com>
Fu Wei <fuweid89@gmail.com> Fu Wei <fuweid89@gmail.com>
Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Hajime Tazaki <thehajime@gmail.com> Hajime Tazaki <thehajime@gmail.com>
Ian Campbell <ijc@docker.com> Ian Campbell <ijc@docker.com>
Ivan Markin <sw@nogoegst.net> Ivan Markin <sw@nogoegst.net>
@ -20,20 +18,18 @@ Jacob Blain Christen <jacob@rancher.com>
Justin Cormack <justin.cormack@docker.com> Justin Cormack <justin.cormack@docker.com>
Justin Cummins <sul3n3t@gmail.com> Justin Cummins <sul3n3t@gmail.com>
Kasper Fabæch Brandt <poizan@poizan.dk> Kasper Fabæch Brandt <poizan@poizan.dk>
Kazuyoshi Kato <katokazu@amazon.com>
Kir Kolyshkin <kolyshkin@gmail.com> Kir Kolyshkin <kolyshkin@gmail.com>
Michael Crosby <crosbymichael@gmail.com> Michael Crosby <crosbymichael@gmail.com>
Michael Crosby <michael@thepasture.io>
Michael Wan <zirenwan@gmail.com> Michael Wan <zirenwan@gmail.com>
Mike Brown <brownwm@us.ibm.com> Mike Brown <brownwm@us.ibm.com>
Niels de Vos <ndevos@redhat.com> Niels de Vos <ndevos@redhat.com>
Phil Estes <estesp@amazon.com>
Phil Estes <estesp@gmail.com> Phil Estes <estesp@gmail.com>
Phil Estes <estesp@linux.vnet.ibm.com>
Sam Whited <sam@samwhited.com> Sam Whited <sam@samwhited.com>
Samuel Karp <me@samuelkarp.com> Samuel Karp <me@samuelkarp.com>
Sebastiaan van Stijn <github@gone.nl> Sebastiaan van Stijn <github@gone.nl>
Shengjing Zhu <zhsj@debian.org> Shengjing Zhu <zhsj@debian.org>
Stephen J Day <stephen.day@docker.com> Stephen J Day <stevvooe@gmail.com>
Tibor Vass <tibor@docker.com> Tibor Vass <tibor@docker.com>
Tobias Klauser <tklauser@distanz.ch> Tobias Klauser <tklauser@distanz.ch>
Tom Faulhaber <tffaulha@amazon.com> Tom Faulhaber <tffaulha@amazon.com>

View File

@ -15,11 +15,6 @@
# Set an output prefix, which is the local directory if not specified # Set an output prefix, which is the local directory if not specified
PREFIX?=$(shell pwd) PREFIX?=$(shell pwd)
# Used to populate version variable in main package.
VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always)
GO_LDFLAGS=-ldflags "-X `go list -mod=vendor ./version`.Version=$(VERSION)"
PKG=github.com/containerd/continuity PKG=github.com/containerd/continuity
PACKAGES=$(shell go list -mod=vendor ./... | grep -v /vendor/) PACKAGES=$(shell go list -mod=vendor ./... | grep -v /vendor/)
@ -41,13 +36,9 @@ all: AUTHORS clean lint build test binaries
AUTHORS: .mailmap .git/HEAD AUTHORS: .mailmap .git/HEAD
git log --format='%aN <%aE>' | sort -fu > $@ git log --format='%aN <%aE>' | sort -fu > $@
# This only needs to be generated by hand when cutting full releases. ${PREFIX}/bin/continuity:
version/version.go:
./version/version.sh > $@
${PREFIX}/bin/continuity: version/version.go $(shell find . -type f -name '*.go')
@echo "+ $@" @echo "+ $@"
@go build -mod=vendor -o $@ ${GO_LDFLAGS} ${GO_GCFLAGS} ./cmd/continuity @(cd cmd/continuity && go build -mod=mod -o $@ ${GO_GCFLAGS} .)
generate: generate:
go generate -mod=vendor $(PACKAGES) go generate -mod=vendor $(PACKAGES)
@ -66,7 +57,7 @@ test:
root-test: root-test:
@echo "+ $@" @echo "+ $@"
@go test ${TEST_REQUIRES_ROOT_PACKAGES} -test.root @go test -exec sudo ${TEST_REQUIRES_ROOT_PACKAGES} -test.root
test-compile: test-compile:
@echo "+ $@" @echo "+ $@"

View File

@ -1,19 +1,20 @@
# continuity # continuity
[![GoDoc](https://godoc.org/github.com/containerd/continuity?status.svg)](https://godoc.org/github.com/containerd/continuity) [![Go Reference](https://pkg.go.dev/badge/github.com/containerd/continuity.svg)](https://pkg.go.dev/github.com/containerd/continuity)
[![Build Status](https://travis-ci.org/containerd/continuity.svg?branch=main)](https://travis-ci.org/containerd/continuity) [![Build Status](https://github.com/containerd/continuity/workflows/Continuity/badge.svg)](https://github.com/containerd/continuity/actions?query=workflow%3AContinuity+branch%3Amain)
A transport-agnostic, filesystem metadata manifest system A transport-agnostic, filesystem metadata manifest system
This project is a staging area for experiments in providing transport agnostic This project is a staging area for experiments in providing transport agnostic
metadata storage. metadata storage.
Please see https://github.com/opencontainers/specs/issues/11 for more details. See [opencontainers/runtime-spec#11](https://github.com/opencontainers/runtime-spec/issues/11)
for more details.
## Manifest Format ## Manifest Format
A continuity manifest encodes filesystem metadata in Protocol Buffers. A continuity manifest encodes filesystem metadata in Protocol Buffers.
Please refer to [proto/manifest.proto](proto/manifest.proto). Refer to [proto/manifest.proto](proto/manifest.proto) for more details.
## Usage ## Usage
@ -65,7 +66,7 @@ $ ./bin/continuity verify . /tmp/a.pb
## Platforms ## Platforms
continuity primarily targets Linux. continuity may compile for and work on continuity primarily targets Linux. Continuity may compile for and work on
other operating systems, but those platforms are not tested. other operating systems, but those platforms are not tested.
## Contribution Guide ## Contribution Guide

View File

@ -390,7 +390,7 @@ func (c *context) checkoutFile(fp string, rf RegularFile) error {
} }
} }
if err != nil { if err != nil {
return fmt.Errorf("file content could not be provided: %v", err) return fmt.Errorf("file content could not be provided: %w", err)
} }
defer r.Close() defer r.Close()
@ -422,7 +422,7 @@ func (c *context) Apply(resource Resource) error {
case RegularFile: case RegularFile:
if fi == nil { if fi == nil {
if err := c.checkoutFile(fp, r); err != nil { if err := c.checkoutFile(fp, r); err != nil {
return fmt.Errorf("error checking out file %q: %v", resource.Path(), err) return fmt.Errorf("error checking out file %q: %w", resource.Path(), err)
} }
chmod = false chmod = false
} else { } else {
@ -431,18 +431,18 @@ func (c *context) Apply(resource Resource) error {
} }
if fi.Size() != r.Size() { if fi.Size() != r.Size() {
if err := c.checkoutFile(fp, r); err != nil { if err := c.checkoutFile(fp, r); err != nil {
return fmt.Errorf("error checking out file %q: %v", resource.Path(), err) return fmt.Errorf("error checking out file %q: %w", resource.Path(), err)
} }
} else { } else {
for _, dgst := range r.Digests() { for _, dgst := range r.Digests() {
f, err := os.Open(fp) f, err := os.Open(fp)
if err != nil { if err != nil {
return fmt.Errorf("failure opening file for read %q: %v", resource.Path(), err) return fmt.Errorf("failure opening file for read %q: %w", resource.Path(), err)
} }
compared, err := dgst.Algorithm().FromReader(f) compared, err := dgst.Algorithm().FromReader(f)
if err == nil && dgst != compared { if err == nil && dgst != compared {
if err := c.checkoutFile(fp, r); err != nil { if err := c.checkoutFile(fp, r); err != nil {
return fmt.Errorf("error checking out file %q: %v", resource.Path(), err) return fmt.Errorf("error checking out file %q: %w", resource.Path(), err)
} }
break break
} }
@ -450,7 +450,7 @@ func (c *context) Apply(resource Resource) error {
err = err1 err = err1
} }
if err != nil { if err != nil {
return fmt.Errorf("error checking digest for %q: %v", resource.Path(), err) return fmt.Errorf("error checking digest for %q: %w", resource.Path(), err)
} }
} }
} }

View File

@ -54,7 +54,7 @@ func (d *driver) Mkfifo(path string, mode os.FileMode) error {
func (d *driver) Getxattr(p string) (map[string][]byte, error) { func (d *driver) Getxattr(p string) (map[string][]byte, error) {
xattrs, err := sysx.Listxattr(p) xattrs, err := sysx.Listxattr(p)
if err != nil { if err != nil {
return nil, fmt.Errorf("listing %s xattrs: %v", p, err) return nil, fmt.Errorf("listing %s xattrs: %w", p, err)
} }
sort.Strings(xattrs) sort.Strings(xattrs)
@ -63,7 +63,7 @@ func (d *driver) Getxattr(p string) (map[string][]byte, error) {
for _, attr := range xattrs { for _, attr := range xattrs {
value, err := sysx.Getxattr(p, attr) value, err := sysx.Getxattr(p, attr)
if err != nil { if err != nil {
return nil, fmt.Errorf("getting %q xattr on %s: %v", attr, p, err) return nil, fmt.Errorf("getting %q xattr on %s: %w", attr, p, err)
} }
// NOTE(stevvooe): This append/copy tricky relies on unique // NOTE(stevvooe): This append/copy tricky relies on unique
@ -82,7 +82,7 @@ func (d *driver) Getxattr(p string) (map[string][]byte, error) {
func (d *driver) Setxattr(path string, attrMap map[string][]byte) error { func (d *driver) Setxattr(path string, attrMap map[string][]byte) error {
for attr, value := range attrMap { for attr, value := range attrMap {
if err := sysx.Setxattr(path, attr, value, 0); err != nil { if err := sysx.Setxattr(path, attr, value, 0); err != nil {
return fmt.Errorf("error setting xattr %q on %s: %v", attr, path, err) return fmt.Errorf("error setting xattr %q on %s: %w", attr, path, err)
} }
} }
@ -94,7 +94,7 @@ func (d *driver) Setxattr(path string, attrMap map[string][]byte) error {
func (d *driver) LGetxattr(p string) (map[string][]byte, error) { func (d *driver) LGetxattr(p string) (map[string][]byte, error) {
xattrs, err := sysx.LListxattr(p) xattrs, err := sysx.LListxattr(p)
if err != nil { if err != nil {
return nil, fmt.Errorf("listing %s xattrs: %v", p, err) return nil, fmt.Errorf("listing %s xattrs: %w", p, err)
} }
sort.Strings(xattrs) sort.Strings(xattrs)
@ -103,7 +103,7 @@ func (d *driver) LGetxattr(p string) (map[string][]byte, error) {
for _, attr := range xattrs { for _, attr := range xattrs {
value, err := sysx.LGetxattr(p, attr) value, err := sysx.LGetxattr(p, attr)
if err != nil { if err != nil {
return nil, fmt.Errorf("getting %q xattr on %s: %v", attr, p, err) return nil, fmt.Errorf("getting %q xattr on %s: %w", attr, p, err)
} }
// NOTE(stevvooe): This append/copy tricky relies on unique // NOTE(stevvooe): This append/copy tricky relies on unique
@ -122,7 +122,7 @@ func (d *driver) LGetxattr(p string) (map[string][]byte, error) {
func (d *driver) LSetxattr(path string, attrMap map[string][]byte) error { func (d *driver) LSetxattr(path string, attrMap map[string][]byte) error {
for attr, value := range attrMap { for attr, value := range attrMap {
if err := sysx.LSetxattr(path, attr, value, 0); err != nil { if err := sysx.LSetxattr(path, attr, value, 0); err != nil {
return fmt.Errorf("error setting xattr %q on %s: %v", attr, path, err) return fmt.Errorf("error setting xattr %q on %s: %w", attr, path, err)
} }
} }

View File

@ -18,12 +18,11 @@ package driver
import ( import (
"io" "io"
"io/ioutil"
"os" "os"
"sort" "sort"
) )
// ReadFile works the same as ioutil.ReadFile with the Driver abstraction // ReadFile works the same as os.ReadFile with the Driver abstraction
func ReadFile(r Driver, filename string) ([]byte, error) { func ReadFile(r Driver, filename string) ([]byte, error) {
f, err := r.Open(filename) f, err := r.Open(filename)
if err != nil { if err != nil {
@ -31,7 +30,7 @@ func ReadFile(r Driver, filename string) ([]byte, error) {
} }
defer f.Close() defer f.Close()
data, err := ioutil.ReadAll(f) data, err := io.ReadAll(f)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -39,7 +38,7 @@ func ReadFile(r Driver, filename string) ([]byte, error) {
return data, nil return data, nil
} }
// WriteFile works the same as ioutil.WriteFile with the Driver abstraction // WriteFile works the same as os.WriteFile with the Driver abstraction
func WriteFile(r Driver, filename string, data []byte, perm os.FileMode) error { func WriteFile(r Driver, filename string, data []byte, perm os.FileMode) error {
f, err := r.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm) f, err := r.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
if err != nil { if err != nil {

View File

@ -22,6 +22,8 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"sync" "sync"
"github.com/sirupsen/logrus"
) )
var bufferPool = &sync.Pool{ var bufferPool = &sync.Pool{
@ -31,7 +33,7 @@ var bufferPool = &sync.Pool{
}, },
} }
// XAttrErrorHandlers transform a non-nil xattr error. // XAttrErrorHandler transform a non-nil xattr error.
// Return nil to ignore an error. // Return nil to ignore an error.
// xattrKey can be empty for listxattr operation. // xattrKey can be empty for listxattr operation.
type XAttrErrorHandler func(dst, src, xattrKey string, err error) error type XAttrErrorHandler func(dst, src, xattrKey string, err error) error
@ -152,13 +154,15 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er
if err := os.Symlink(link, target); err != nil { if err := os.Symlink(link, target); err != nil {
return fmt.Errorf("failed to create symlink: %s: %w", target, err) return fmt.Errorf("failed to create symlink: %s: %w", target, err)
} }
case (fi.Mode() & os.ModeDevice) == os.ModeDevice: case (fi.Mode() & os.ModeDevice) == os.ModeDevice,
if err := copyDevice(target, fi); err != nil { (fi.Mode() & os.ModeNamedPipe) == os.ModeNamedPipe,
return fmt.Errorf("failed to create device: %w", err) (fi.Mode() & os.ModeSocket) == os.ModeSocket:
if err := copyIrregular(target, fi); err != nil {
return fmt.Errorf("failed to create irregular file: %w", err)
} }
default: default:
// TODO: Support pipes and sockets logrus.Warnf("unsupported mode: %s: %s", source, fi.Mode())
return fmt.Errorf("unsupported mode %s: %w", fi.Mode(), err) continue
} }
if err := copyFileInfo(fi, source, target); err != nil { if err := copyFileInfo(fi, source, target); err != nil {

View File

@ -1,36 +0,0 @@
//go:build freebsd
// +build freebsd
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fs
import (
"errors"
"os"
"syscall"
"golang.org/x/sys/unix"
)
func copyDevice(dst string, fi os.FileInfo) error {
st, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return errors.New("unsupported stat type")
}
return unix.Mknod(dst, uint32(fi.Mode()), st.Rdev)
}

View File

@ -1,6 +1,3 @@
//go:build darwin
// +build darwin
/* /*
Copyright The containerd Authors. Copyright The containerd Authors.
@ -20,17 +17,20 @@
package fs package fs
import ( import (
"errors" "fmt"
"os" "os"
"syscall" "syscall"
"golang.org/x/sys/unix"
) )
func copyDevice(dst string, fi os.FileInfo) error { // copyIrregular covers devices, pipes, and sockets
st, ok := fi.Sys().(*syscall.Stat_t) func copyIrregular(dst string, fi os.FileInfo) error {
st, ok := fi.Sys().(*syscall.Stat_t) // not *unix.Stat_t
if !ok { if !ok {
return errors.New("unsupported stat type") return fmt.Errorf("unsupported stat type: %s: %v", dst, fi.Mode())
} }
return unix.Mknod(dst, uint32(fi.Mode()), int(st.Rdev)) var rDev uint64 // uint64 on FreeBSD, int on other unixen
if fi.Mode()&os.ModeDevice == os.ModeDevice {
rDev = st.Rdev
}
return syscall.Mknod(dst, uint32(st.Mode), rDev)
} }

View File

@ -1,5 +1,5 @@
//go:build openbsd || solaris || netbsd //go:build !windows && !freebsd
// +build openbsd solaris netbsd // +build !windows,!freebsd
/* /*
Copyright The containerd Authors. Copyright The containerd Authors.
@ -20,17 +20,21 @@
package fs package fs
import ( import (
"errors" "fmt"
"os" "os"
"syscall" "syscall"
"golang.org/x/sys/unix"
) )
func copyDevice(dst string, fi os.FileInfo) error { // copyIrregular covers devices, pipes, and sockets
st, ok := fi.Sys().(*syscall.Stat_t) func copyIrregular(dst string, fi os.FileInfo) error {
st, ok := fi.Sys().(*syscall.Stat_t) // not *unix.Stat_t
if !ok { if !ok {
return errors.New("unsupported stat type") return fmt.Errorf("unsupported stat type: %s: %v", dst, fi.Mode())
} }
return unix.Mknod(dst, uint32(fi.Mode()), int(st.Rdev)) var rDev int
if fi.Mode()&os.ModeDevice == os.ModeDevice {
rDev = int(st.Rdev)
}
//nolint:unconvert
return syscall.Mknod(dst, uint32(st.Mode), rDev)
} }

View File

@ -17,7 +17,6 @@
package fs package fs
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -144,11 +143,3 @@ func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAtt
return nil return nil
} }
func copyDevice(dst string, fi os.FileInfo) error {
st, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return errors.New("unsupported stat type")
}
return unix.Mknod(dst, uint32(fi.Mode()), int(st.Rdev))
}

View File

@ -85,6 +85,6 @@ func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAtt
return nil return nil
} }
func copyDevice(dst string, fi os.FileInfo) error { func copyIrregular(dst string, fi os.FileInfo) error {
return errors.New("device copy not supported") return errors.New("irregular copy not supported")
} }

View File

@ -22,9 +22,8 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"golang.org/x/sync/errgroup"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"golang.org/x/sync/errgroup"
) )
// ChangeKind is the type of modification that // ChangeKind is the type of modification that

View File

@ -35,7 +35,7 @@ func locateDummyIfEmpty(path string) (string, error) {
if len(children) != 0 { if len(children) != 0 {
return "", nil return "", nil
} }
dummyFile, err := ioutil.TempFile(path, "fsutils-dummy") dummyFile, err := os.CreateTemp(path, "fsutils-dummy")
if err != nil { if err != nil {
return "", err return "", err
} }

View File

@ -18,7 +18,6 @@ package fstest
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"github.com/containerd/continuity" "github.com/containerd/continuity"
@ -57,7 +56,7 @@ func CheckDirectoryEqual(d1, d2 string) error {
// CheckDirectoryEqualWithApplier compares directory against applier // CheckDirectoryEqualWithApplier compares directory against applier
func CheckDirectoryEqualWithApplier(root string, a Applier) error { func CheckDirectoryEqualWithApplier(root string, a Applier) error {
applied, err := ioutil.TempDir("", "fstest") applied, err := os.MkdirTemp("", "fstest")
if err != nil { if err != nil {
return err return err
} }

View File

@ -18,7 +18,6 @@ package fstest
import ( import (
"context" "context"
"io/ioutil"
"os" "os"
"testing" "testing"
) )
@ -49,7 +48,7 @@ func makeTest(t *testing.T, ta TestApplier, as []Applier) func(t *testing.T) {
} }
defer cleanup() defer cleanup()
applyDir, err := ioutil.TempDir("", "test-expected-") applyDir, err := os.MkdirTemp("", "test-expected-")
if err != nil { if err != nil {
t.Fatalf("Unable to make temp directory: %+v", err) t.Fatalf("Unable to make temp directory: %+v", err)
} }

View File

@ -63,7 +63,7 @@ func (hlm *hardlinkManager) Merge() ([]Resource, error) {
merged, err := Merge(linked...) merged, err := Merge(linked...)
if err != nil { if err != nil {
return nil, fmt.Errorf("error merging hardlink: %v", err) return nil, fmt.Errorf("error merging hardlink: %w", err)
} }
resources = append(resources, merged) resources = append(resources, merged)

View File

@ -19,7 +19,6 @@ package continuity
import ( import (
"bytes" "bytes"
"io" "io"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
) )
@ -34,7 +33,7 @@ func AtomicWriteFile(filename string, data []byte, perm os.FileMode) error {
// atomicWriteFile writes data to a file by first writing to a temp // atomicWriteFile writes data to a file by first writing to a temp
// file and calling rename. // file and calling rename.
func atomicWriteFile(filename string, r io.Reader, dataSize int64, perm os.FileMode) error { func atomicWriteFile(filename string, r io.Reader, dataSize int64, perm os.FileMode) error {
f, err := ioutil.TempFile(filepath.Dir(filename), ".tmp-"+filepath.Base(filename)) f, err := os.CreateTemp(filepath.Dir(filename), ".tmp-"+filepath.Base(filename))
if err != nil { if err != nil {
return err return err
} }

View File

@ -23,7 +23,8 @@ import (
"sort" "sort"
pb "github.com/containerd/continuity/proto" pb "github.com/containerd/continuity/proto"
"github.com/golang/protobuf/proto" "google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/proto"
) )
// Manifest provides the contents of a manifest. Users of this struct should // Manifest provides the contents of a manifest. Users of this struct should
@ -68,7 +69,12 @@ func MarshalText(w io.Writer, m *Manifest) error {
bm.Resource = append(bm.Resource, toProto(resource)) bm.Resource = append(bm.Resource, toProto(resource))
} }
return proto.MarshalText(w, &bm) b, err := prototext.Marshal(&bm)
if err != nil {
return err
}
_, err = w.Write(b)
return err
} }
// BuildManifest creates the manifest for the given context // BuildManifest creates the manifest for the given context
@ -78,7 +84,7 @@ func BuildManifest(ctx Context) (*Manifest, error) {
if err := ctx.Walk(func(p string, fi os.FileInfo, err error) error { if err := ctx.Walk(func(p string, fi os.FileInfo, err error) error {
if err != nil { if err != nil {
return fmt.Errorf("error walking %s: %v", p, err) return fmt.Errorf("error walking %s: %w", p, err)
} }
if p == string(os.PathSeparator) { if p == string(os.PathSeparator) {
@ -101,7 +107,7 @@ func BuildManifest(ctx Context) (*Manifest, error) {
return nil return nil
} else if err != errNotAHardLink { } else if err != errNotAHardLink {
// handle any other case where we have a proper error. // handle any other case where we have a proper error.
return fmt.Errorf("adding hardlink %s: %v", p, err) return fmt.Errorf("adding hardlink %s: %w", p, err)
} }
resourcesByPath[p] = resource resourcesByPath[p] = resource

View File

@ -17,3 +17,5 @@
package proto package proto
//go:generate protoc --go_out=. manifest.proto //go:generate protoc --go_out=. manifest.proto
//go:generate mv github.com/containerd/continuity/proto/manifest.pb.go .
//go:generate rmdir -p github.com/containerd/continuity/proto

View File

@ -1,223 +1,315 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc v3.12.4
// source: manifest.proto // source: manifest.proto
/*
Package proto is a generated protocol buffer package.
It is generated from these files:
manifest.proto
It has these top-level messages:
Manifest
Resource
XAttr
ADSEntry
*/
package proto package proto
import proto1 "github.com/golang/protobuf/proto" import (
import fmt "fmt" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
import math "math" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
// Reference imports to suppress errors if they are not otherwise used. const (
var _ = proto1.Marshal // Verify that this generated code is sufficiently up-to-date.
var _ = fmt.Errorf _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
var _ = math.Inf // Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
// This is a compile-time assertion to ensure that this generated file )
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto1.ProtoPackageIsVersion2 // please upgrade the proto package
// Manifest specifies the entries in a container bundle, keyed and sorted by // Manifest specifies the entries in a container bundle, keyed and sorted by
// path. // path.
type Manifest struct { type Manifest struct {
Resource []*Resource `protobuf:"bytes,1,rep,name=resource" json:"resource,omitempty"` state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Resource []*Resource `protobuf:"bytes,1,rep,name=resource,proto3" json:"resource,omitempty"`
} }
func (m *Manifest) Reset() { *m = Manifest{} } func (x *Manifest) Reset() {
func (m *Manifest) String() string { return proto1.CompactTextString(m) } *x = Manifest{}
func (*Manifest) ProtoMessage() {} if protoimpl.UnsafeEnabled {
func (*Manifest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } mi := &file_manifest_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (m *Manifest) GetResource() []*Resource { func (x *Manifest) String() string {
if m != nil { return protoimpl.X.MessageStringOf(x)
return m.Resource }
func (*Manifest) ProtoMessage() {}
func (x *Manifest) ProtoReflect() protoreflect.Message {
mi := &file_manifest_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Manifest.ProtoReflect.Descriptor instead.
func (*Manifest) Descriptor() ([]byte, []int) {
return file_manifest_proto_rawDescGZIP(), []int{0}
}
func (x *Manifest) GetResource() []*Resource {
if x != nil {
return x.Resource
} }
return nil return nil
} }
type Resource struct { type Resource struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Path specifies the path from the bundle root. If more than one // Path specifies the path from the bundle root. If more than one
// path is present, the entry may represent a hardlink, rather than using // path is present, the entry may represent a hardlink, rather than using
// a link target. The path format is operating system specific. // a link target. The path format is operating system specific.
Path []string `protobuf:"bytes,1,rep,name=path" json:"path,omitempty"` Path []string `protobuf:"bytes,1,rep,name=path,proto3" json:"path,omitempty"`
// Uid specifies the user id for the resource. // Uid specifies the user id for the resource.
Uid int64 `protobuf:"varint,2,opt,name=uid" json:"uid,omitempty"` Uid int64 `protobuf:"varint,2,opt,name=uid,proto3" json:"uid,omitempty"`
// Gid specifies the group id for the resource. // Gid specifies the group id for the resource.
Gid int64 `protobuf:"varint,3,opt,name=gid" json:"gid,omitempty"` Gid int64 `protobuf:"varint,3,opt,name=gid,proto3" json:"gid,omitempty"`
// user and group are not currently used but their field numbers have been // user and group are not currently used but their field numbers have been
// reserved for future use. As such, they are marked as deprecated. // reserved for future use. As such, they are marked as deprecated.
User string `protobuf:"bytes,4,opt,name=user" json:"user,omitempty"` //
Group string `protobuf:"bytes,5,opt,name=group" json:"group,omitempty"` // Deprecated: Do not use.
User string `protobuf:"bytes,4,opt,name=user,proto3" json:"user,omitempty"` // "deprecated" stands for "reserved" here
// Deprecated: Do not use.
Group string `protobuf:"bytes,5,opt,name=group,proto3" json:"group,omitempty"` // "deprecated" stands for "reserved" here
// Mode defines the file mode and permissions. We've used the same // Mode defines the file mode and permissions. We've used the same
// bit-packing from Go's os package, // bit-packing from Go's os package,
// http://golang.org/pkg/os/#FileMode, since they've done the work of // http://golang.org/pkg/os/#FileMode, since they've done the work of
// creating a cross-platform layout. // creating a cross-platform layout.
Mode uint32 `protobuf:"varint,6,opt,name=mode" json:"mode,omitempty"` Mode uint32 `protobuf:"varint,6,opt,name=mode,proto3" json:"mode,omitempty"`
// Size specifies the size in bytes of the resource. This is only valid // Size specifies the size in bytes of the resource. This is only valid
// for regular files. // for regular files.
Size uint64 `protobuf:"varint,7,opt,name=size" json:"size,omitempty"` Size uint64 `protobuf:"varint,7,opt,name=size,proto3" json:"size,omitempty"`
// Digest specifies the content digest of the target file. Only valid for // Digest specifies the content digest of the target file. Only valid for
// regular files. The strings are formatted in OCI style, i.e. <alg>:<encoded>. // regular files. The strings are formatted in OCI style, i.e. <alg>:<encoded>.
// For detailed information about the format, please refer to OCI Image Spec: // For detailed information about the format, please refer to OCI Image Spec:
// https://github.com/opencontainers/image-spec/blob/master/descriptor.md#digests-and-verification // https://github.com/opencontainers/image-spec/blob/master/descriptor.md#digests-and-verification
// The digests are sorted in lexical order and implementations may choose // The digests are sorted in lexical order and implementations may choose
// which algorithms they prefer. // which algorithms they prefer.
Digest []string `protobuf:"bytes,8,rep,name=digest" json:"digest,omitempty"` Digest []string `protobuf:"bytes,8,rep,name=digest,proto3" json:"digest,omitempty"`
// Target defines the target of a hard or soft link. Absolute links start // Target defines the target of a hard or soft link. Absolute links start
// with a slash and specify the resource relative to the bundle root. // with a slash and specify the resource relative to the bundle root.
// Relative links do not start with a slash and are relative to the // Relative links do not start with a slash and are relative to the
// resource path. // resource path.
Target string `protobuf:"bytes,9,opt,name=target" json:"target,omitempty"` Target string `protobuf:"bytes,9,opt,name=target,proto3" json:"target,omitempty"`
// Major specifies the major device number for character and block devices. // Major specifies the major device number for character and block devices.
Major uint64 `protobuf:"varint,10,opt,name=major" json:"major,omitempty"` Major uint64 `protobuf:"varint,10,opt,name=major,proto3" json:"major,omitempty"`
// Minor specifies the minor device number for character and block devices. // Minor specifies the minor device number for character and block devices.
Minor uint64 `protobuf:"varint,11,opt,name=minor" json:"minor,omitempty"` Minor uint64 `protobuf:"varint,11,opt,name=minor,proto3" json:"minor,omitempty"`
// Xattr provides storage for extended attributes for the target resource. // Xattr provides storage for extended attributes for the target resource.
Xattr []*XAttr `protobuf:"bytes,12,rep,name=xattr" json:"xattr,omitempty"` Xattr []*XAttr `protobuf:"bytes,12,rep,name=xattr,proto3" json:"xattr,omitempty"`
// Ads stores one or more alternate data streams for the target resource. // Ads stores one or more alternate data streams for the target resource.
Ads []*ADSEntry `protobuf:"bytes,13,rep,name=ads" json:"ads,omitempty"` Ads []*ADSEntry `protobuf:"bytes,13,rep,name=ads,proto3" json:"ads,omitempty"`
}
func (x *Resource) Reset() {
*x = Resource{}
if protoimpl.UnsafeEnabled {
mi := &file_manifest_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Resource) String() string {
return protoimpl.X.MessageStringOf(x)
} }
func (m *Resource) Reset() { *m = Resource{} }
func (m *Resource) String() string { return proto1.CompactTextString(m) }
func (*Resource) ProtoMessage() {} func (*Resource) ProtoMessage() {}
func (*Resource) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *Resource) GetPath() []string { func (x *Resource) ProtoReflect() protoreflect.Message {
if m != nil { mi := &file_manifest_proto_msgTypes[1]
return m.Path if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Resource.ProtoReflect.Descriptor instead.
func (*Resource) Descriptor() ([]byte, []int) {
return file_manifest_proto_rawDescGZIP(), []int{1}
}
func (x *Resource) GetPath() []string {
if x != nil {
return x.Path
} }
return nil return nil
} }
func (m *Resource) GetUid() int64 { func (x *Resource) GetUid() int64 {
if m != nil { if x != nil {
return m.Uid return x.Uid
} }
return 0 return 0
} }
func (m *Resource) GetGid() int64 { func (x *Resource) GetGid() int64 {
if m != nil { if x != nil {
return m.Gid return x.Gid
} }
return 0 return 0
} }
func (m *Resource) GetUser() string { // Deprecated: Do not use.
if m != nil { func (x *Resource) GetUser() string {
return m.User if x != nil {
return x.User
} }
return "" return ""
} }
func (m *Resource) GetGroup() string { // Deprecated: Do not use.
if m != nil { func (x *Resource) GetGroup() string {
return m.Group if x != nil {
return x.Group
} }
return "" return ""
} }
func (m *Resource) GetMode() uint32 { func (x *Resource) GetMode() uint32 {
if m != nil { if x != nil {
return m.Mode return x.Mode
} }
return 0 return 0
} }
func (m *Resource) GetSize() uint64 { func (x *Resource) GetSize() uint64 {
if m != nil { if x != nil {
return m.Size return x.Size
} }
return 0 return 0
} }
func (m *Resource) GetDigest() []string { func (x *Resource) GetDigest() []string {
if m != nil { if x != nil {
return m.Digest return x.Digest
} }
return nil return nil
} }
func (m *Resource) GetTarget() string { func (x *Resource) GetTarget() string {
if m != nil { if x != nil {
return m.Target return x.Target
} }
return "" return ""
} }
func (m *Resource) GetMajor() uint64 { func (x *Resource) GetMajor() uint64 {
if m != nil { if x != nil {
return m.Major return x.Major
} }
return 0 return 0
} }
func (m *Resource) GetMinor() uint64 { func (x *Resource) GetMinor() uint64 {
if m != nil { if x != nil {
return m.Minor return x.Minor
} }
return 0 return 0
} }
func (m *Resource) GetXattr() []*XAttr { func (x *Resource) GetXattr() []*XAttr {
if m != nil { if x != nil {
return m.Xattr return x.Xattr
} }
return nil return nil
} }
func (m *Resource) GetAds() []*ADSEntry { func (x *Resource) GetAds() []*ADSEntry {
if m != nil { if x != nil {
return m.Ads return x.Ads
} }
return nil return nil
} }
// XAttr encodes extended attributes for a resource. // XAttr encodes extended attributes for a resource.
type XAttr struct { type XAttr struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Name specifies the attribute name. // Name specifies the attribute name.
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// Data specifies the associated data for the attribute. // Data specifies the associated data for the attribute.
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
} }
func (m *XAttr) Reset() { *m = XAttr{} } func (x *XAttr) Reset() {
func (m *XAttr) String() string { return proto1.CompactTextString(m) } *x = XAttr{}
func (*XAttr) ProtoMessage() {} if protoimpl.UnsafeEnabled {
func (*XAttr) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } mi := &file_manifest_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (m *XAttr) GetName() string { func (x *XAttr) String() string {
if m != nil { return protoimpl.X.MessageStringOf(x)
return m.Name }
func (*XAttr) ProtoMessage() {}
func (x *XAttr) ProtoReflect() protoreflect.Message {
mi := &file_manifest_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use XAttr.ProtoReflect.Descriptor instead.
func (*XAttr) Descriptor() ([]byte, []int) {
return file_manifest_proto_rawDescGZIP(), []int{2}
}
func (x *XAttr) GetName() string {
if x != nil {
return x.Name
} }
return "" return ""
} }
func (m *XAttr) GetData() []byte { func (x *XAttr) GetData() []byte {
if m != nil { if x != nil {
return m.Data return x.Data
} }
return nil return nil
} }
// ADSEntry encodes information for a Windows Alternate Data Stream. // ADSEntry encodes information for a Windows Alternate Data Stream.
type ADSEntry struct { type ADSEntry struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Name specifices the stream name. // Name specifices the stream name.
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// Data specifies the stream data. // Data specifies the stream data.
// See also the description about the digest below. // See also the description about the digest below.
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
@ -229,64 +321,205 @@ type ADSEntry struct {
// How to access the actual data using the digest is implementation-specific, // How to access the actual data using the digest is implementation-specific,
// and implementations can choose not to implement digest. // and implementations can choose not to implement digest.
// So, digest SHOULD be used only when the stream data is large. // So, digest SHOULD be used only when the stream data is large.
Digest string `protobuf:"bytes,3,opt,name=digest" json:"digest,omitempty"` Digest string `protobuf:"bytes,3,opt,name=digest,proto3" json:"digest,omitempty"`
} }
func (m *ADSEntry) Reset() { *m = ADSEntry{} } func (x *ADSEntry) Reset() {
func (m *ADSEntry) String() string { return proto1.CompactTextString(m) } *x = ADSEntry{}
func (*ADSEntry) ProtoMessage() {} if protoimpl.UnsafeEnabled {
func (*ADSEntry) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } mi := &file_manifest_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (m *ADSEntry) GetName() string { func (x *ADSEntry) String() string {
if m != nil { return protoimpl.X.MessageStringOf(x)
return m.Name }
func (*ADSEntry) ProtoMessage() {}
func (x *ADSEntry) ProtoReflect() protoreflect.Message {
mi := &file_manifest_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ADSEntry.ProtoReflect.Descriptor instead.
func (*ADSEntry) Descriptor() ([]byte, []int) {
return file_manifest_proto_rawDescGZIP(), []int{3}
}
func (x *ADSEntry) GetName() string {
if x != nil {
return x.Name
} }
return "" return ""
} }
func (m *ADSEntry) GetData() []byte { func (x *ADSEntry) GetData() []byte {
if m != nil { if x != nil {
return m.Data return x.Data
} }
return nil return nil
} }
func (m *ADSEntry) GetDigest() string { func (x *ADSEntry) GetDigest() string {
if m != nil { if x != nil {
return m.Digest return x.Digest
} }
return "" return ""
} }
func init() { var File_manifest_proto protoreflect.FileDescriptor
proto1.RegisterType((*Manifest)(nil), "proto.Manifest")
proto1.RegisterType((*Resource)(nil), "proto.Resource") var file_manifest_proto_rawDesc = []byte{
proto1.RegisterType((*XAttr)(nil), "proto.XAttr") 0x0a, 0x0e, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
proto1.RegisterType((*ADSEntry)(nil), "proto.ADSEntry") 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x37, 0x0a, 0x08, 0x4d, 0x61, 0x6e, 0x69, 0x66,
0x65, 0x73, 0x74, 0x12, 0x2b, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18,
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65,
0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
0x22, 0xbf, 0x02, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12, 0x0a,
0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74,
0x68, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03,
0x75, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x67, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03,
0x52, 0x03, 0x67, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x04, 0x20,
0x01, 0x28, 0x09, 0x42, 0x02, 0x18, 0x01, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x18, 0x0a,
0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x02, 0x18, 0x01,
0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18,
0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73,
0x69, 0x7a, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12,
0x16, 0x0a, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52,
0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65,
0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12,
0x14, 0x0a, 0x05, 0x6d, 0x61, 0x6a, 0x6f, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05,
0x6d, 0x61, 0x6a, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x18, 0x0b,
0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x12, 0x22, 0x0a, 0x05, 0x78,
0x61, 0x74, 0x74, 0x72, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x58, 0x41, 0x74, 0x74, 0x72, 0x52, 0x05, 0x78, 0x61, 0x74, 0x74, 0x72, 0x12,
0x21, 0x0a, 0x03, 0x61, 0x64, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x44, 0x53, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x03, 0x61,
0x64, 0x73, 0x22, 0x2f, 0x0a, 0x05, 0x58, 0x41, 0x74, 0x74, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,
0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64,
0x61, 0x74, 0x61, 0x22, 0x4a, 0x0a, 0x08, 0x41, 0x44, 0x53, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12,
0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28,
0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73,
0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x42,
0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f,
0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75,
0x69, 0x74, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
func init() { proto1.RegisterFile("manifest.proto", fileDescriptor0) } var (
file_manifest_proto_rawDescOnce sync.Once
file_manifest_proto_rawDescData = file_manifest_proto_rawDesc
)
var fileDescriptor0 = []byte{ func file_manifest_proto_rawDescGZIP() []byte {
// 317 bytes of a gzipped FileDescriptorProto file_manifest_proto_rawDescOnce.Do(func() {
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0x4f, 0x4b, 0xf3, 0x40, file_manifest_proto_rawDescData = protoimpl.X.CompressGZIP(file_manifest_proto_rawDescData)
0x10, 0xc6, 0x49, 0x93, 0xf4, 0x4d, 0xa7, 0xed, 0xab, 0x2c, 0x52, 0xe6, 0x18, 0x73, 0x0a, 0x08, })
0x15, 0xf4, 0xe0, 0xb9, 0xa2, 0x17, 0xc1, 0xcb, 0x7a, 0xf1, 0xba, 0xba, 0x6b, 0x5c, 0x21, 0xd9, return file_manifest_proto_rawDescData
0xb0, 0xd9, 0x80, 0xfa, 0xe5, 0xfc, 0x6a, 0x32, 0xb3, 0x69, 0xd1, 0x9b, 0xa7, 0x3c, 0xcf, 0x6f, }
0xfe, 0x64, 0xf6, 0x81, 0xff, 0xad, 0xea, 0xec, 0x8b, 0x19, 0xc2, 0xb6, 0xf7, 0x2e, 0x38, 0x91,
0xf3, 0xa7, 0xba, 0x82, 0xe2, 0x7e, 0x2a, 0x88, 0x33, 0x28, 0xbc, 0x19, 0xdc, 0xe8, 0x9f, 0x0d, var file_manifest_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
0x26, 0x65, 0x5a, 0x2f, 0x2f, 0x8e, 0x62, 0xf3, 0x56, 0x4e, 0x58, 0x1e, 0x1a, 0xaa, 0xaf, 0x19, var file_manifest_proto_goTypes = []interface{}{
0x14, 0x7b, 0x2c, 0x04, 0x64, 0xbd, 0x0a, 0xaf, 0x3c, 0xb5, 0x90, 0xac, 0xc5, 0x31, 0xa4, 0xa3, (*Manifest)(nil), // 0: proto.Manifest
0xd5, 0x38, 0x2b, 0x93, 0x3a, 0x95, 0x24, 0x89, 0x34, 0x56, 0x63, 0x1a, 0x49, 0x63, 0xb5, 0xd8, (*Resource)(nil), // 1: proto.Resource
0x40, 0x36, 0x0e, 0xc6, 0x63, 0x56, 0x26, 0xf5, 0xe2, 0x7a, 0x86, 0x89, 0x64, 0x2f, 0x10, 0xf2, (*XAttr)(nil), // 2: proto.XAttr
0xc6, 0xbb, 0xb1, 0xc7, 0xfc, 0x50, 0x88, 0x80, 0xfe, 0xd4, 0x3a, 0x6d, 0x70, 0x5e, 0x26, 0xf5, (*ADSEntry)(nil), // 3: proto.ADSEntry
0x5a, 0xb2, 0x26, 0x36, 0xd8, 0x4f, 0x83, 0xff, 0xca, 0xa4, 0xce, 0x24, 0x6b, 0xb1, 0x81, 0xb9, }
0xb6, 0x8d, 0x19, 0x02, 0x16, 0x7c, 0xd3, 0xe4, 0x88, 0x07, 0xe5, 0x1b, 0x13, 0x70, 0x41, 0xab, var file_manifest_proto_depIdxs = []int32{
0xe5, 0xe4, 0xc4, 0x09, 0xe4, 0xad, 0x7a, 0x73, 0x1e, 0x81, 0x97, 0x44, 0xc3, 0xd4, 0x76, 0xce, 1, // 0: proto.Manifest.resource:type_name -> proto.Resource
0xe3, 0x72, 0xa2, 0x64, 0x44, 0x05, 0xf9, 0xbb, 0x0a, 0xc1, 0xe3, 0x8a, 0x43, 0x5a, 0x4d, 0x21, 2, // 1: proto.Resource.xattr:type_name -> proto.XAttr
0x3d, 0xee, 0x42, 0xf0, 0x32, 0x96, 0xc4, 0x29, 0xa4, 0x4a, 0x0f, 0xb8, 0xfe, 0x15, 0xe3, 0xee, 3, // 2: proto.Resource.ads:type_name -> proto.ADSEntry
0xe6, 0xe1, 0xb6, 0x0b, 0xfe, 0x43, 0x52, 0xad, 0x3a, 0x87, 0x9c, 0x47, 0xe8, 0xfe, 0x4e, 0xb5, 3, // [3:3] is the sub-list for method output_type
0x94, 0x39, 0x5d, 0xc4, 0x9a, 0x98, 0x56, 0x41, 0x71, 0x7c, 0x2b, 0xc9, 0xba, 0xba, 0x83, 0x62, 3, // [3:3] is the sub-list for method input_type
0xbf, 0xe1, 0xaf, 0x33, 0x3f, 0x72, 0x48, 0xe3, 0x7b, 0xa3, 0x7b, 0x9a, 0xf3, 0x45, 0x97, 0xdf, 3, // [3:3] is the sub-list for extension type_name
0x01, 0x00, 0x00, 0xff, 0xff, 0xef, 0x27, 0x99, 0xf7, 0x17, 0x02, 0x00, 0x00, 3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_manifest_proto_init() }
func file_manifest_proto_init() {
if File_manifest_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_manifest_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Manifest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_manifest_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Resource); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_manifest_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*XAttr); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_manifest_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ADSEntry); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_manifest_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_manifest_proto_goTypes,
DependencyIndexes: file_manifest_proto_depIdxs,
MessageInfos: file_manifest_proto_msgTypes,
}.Build()
File_manifest_proto = out.File
file_manifest_proto_rawDesc = nil
file_manifest_proto_goTypes = nil
file_manifest_proto_depIdxs = nil
} }

View File

@ -1,6 +1,7 @@
syntax = "proto3"; syntax = "proto3";
package proto; package proto;
option go_package = "github.com/containerd/continuity/proto;proto";
// Manifest specifies the entries in a container bundle, keyed and sorted by // Manifest specifies the entries in a container bundle, keyed and sorted by
// path. // path.

View File

@ -1,52 +0,0 @@
#!/bin/bash
# Copyright The containerd Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
mksyscall="$(go env GOROOT)/src/syscall/mksyscall.pl"
fix() {
sed 's,^package syscall$,package sysx,' \
| sed 's,^import "unsafe"$,import (\n\t"syscall"\n\t"unsafe"\n),' \
| gofmt -r='BytePtrFromString -> syscall.BytePtrFromString' \
| gofmt -r='Syscall6 -> syscall.Syscall6' \
| gofmt -r='Syscall -> syscall.Syscall' \
| gofmt -r='SYS_GETXATTR -> syscall.SYS_GETXATTR' \
| gofmt -r='SYS_LISTXATTR -> syscall.SYS_LISTXATTR' \
| gofmt -r='SYS_SETXATTR -> syscall.SYS_SETXATTR' \
| gofmt -r='SYS_REMOVEXATTR -> syscall.SYS_REMOVEXATTR' \
| gofmt -r='SYS_LGETXATTR -> syscall.SYS_LGETXATTR' \
| gofmt -r='SYS_LLISTXATTR -> syscall.SYS_LLISTXATTR' \
| gofmt -r='SYS_LSETXATTR -> syscall.SYS_LSETXATTR' \
| gofmt -r='SYS_LREMOVEXATTR -> syscall.SYS_LREMOVEXATTR'
}
if [ "$GOARCH" == "" ] || [ "$GOOS" == "" ]; then
echo "Must specify \$GOARCH and \$GOOS"
exit 1
fi
mkargs=""
if [ "$GOARCH" == "386" ] || [ "$GOARCH" == "arm" ]; then
mkargs="-l32"
fi
for f in "$@"; do
$mksyscall $mkargs "${f}_${GOOS}.go" | fix > "${f}_${GOOS}_${GOARCH}.go"
done

View File

@ -23,7 +23,6 @@ import (
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"os/exec" "os/exec"
"strings" "strings"
@ -35,7 +34,7 @@ import (
// New creates a loopback device // New creates a loopback device
func New(size int64) (*Loopback, error) { func New(size int64) (*Loopback, error) {
// create temporary file for the disk image // create temporary file for the disk image
file, err := ioutil.TempFile("", "containerd-test-loopback") file, err := os.CreateTemp("", "containerd-test-loopback")
if err != nil { if err != nil {
return nil, fmt.Errorf("could not create temporary file for loopback: %w", err) return nil, fmt.Errorf("could not create temporary file for loopback: %w", err)
} }

8
vendor/modules.txt vendored
View File

@ -1,8 +1,8 @@
# github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8 # github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8
## explicit; go 1.13 ## explicit; go 1.13
github.com/AdaLogics/go-fuzz-headers github.com/AdaLogics/go-fuzz-headers
# github.com/Microsoft/go-winio v0.5.1 # github.com/Microsoft/go-winio v0.5.2
## explicit; go 1.12 ## explicit; go 1.13
github.com/Microsoft/go-winio github.com/Microsoft/go-winio
github.com/Microsoft/go-winio/backuptar github.com/Microsoft/go-winio/backuptar
github.com/Microsoft/go-winio/pkg/etw github.com/Microsoft/go-winio/pkg/etw
@ -89,8 +89,8 @@ github.com/containerd/cgroups/v2/stats
# github.com/containerd/console v1.0.3 # github.com/containerd/console v1.0.3
## explicit; go 1.13 ## explicit; go 1.13
github.com/containerd/console github.com/containerd/console
# github.com/containerd/continuity v0.2.2 # github.com/containerd/continuity v0.3.0
## explicit; go 1.13 ## explicit; go 1.17
github.com/containerd/continuity github.com/containerd/continuity
github.com/containerd/continuity/devices github.com/containerd/continuity/devices
github.com/containerd/continuity/driver github.com/containerd/continuity/driver