Fix use of infra image to clarify default
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
		
							parent
							
								
									271867263c
								
							
						
					
					
						commit
						6609bb73aa
					
				|  | @ -75,7 +75,7 @@ func init() { | ||||||
| 	if !registry.IsRemote() { | 	if !registry.IsRemote() { | ||||||
| 		defInfraImage = containerConfig.Engine.InfraImage | 		defInfraImage = containerConfig.Engine.InfraImage | ||||||
| 	} | 	} | ||||||
| 	flags.StringVar(&infraImage, infraImageFlagName, defInfraImage, "The image of the infra container to associate with the pod") | 	flags.StringVar(&infraImage, infraImageFlagName, defInfraImage, "Image to use to override builtin infra container") | ||||||
| 	_ = createCommand.RegisterFlagCompletionFunc(infraImageFlagName, common.AutocompleteImages) | 	_ = createCommand.RegisterFlagCompletionFunc(infraImageFlagName, common.AutocompleteImages) | ||||||
| 
 | 
 | ||||||
| 	podIDFileFlagName := "pod-id-file" | 	podIDFileFlagName := "pod-id-file" | ||||||
|  |  | ||||||
							
								
								
									
										6
									
								
								go.mod
								
								
								
								
							
							
						
						
									
										6
									
								
								go.mod
								
								
								
								
							|  | @ -12,12 +12,12 @@ require ( | ||||||
| 	github.com/containernetworking/cni v1.0.1 | 	github.com/containernetworking/cni v1.0.1 | ||||||
| 	github.com/containernetworking/plugins v1.0.1 | 	github.com/containernetworking/plugins v1.0.1 | ||||||
| 	github.com/containers/buildah v1.24.0 | 	github.com/containers/buildah v1.24.0 | ||||||
| 	github.com/containers/common v0.47.1 | 	github.com/containers/common v0.47.2 | ||||||
| 	github.com/containers/conmon v2.0.20+incompatible | 	github.com/containers/conmon v2.0.20+incompatible | ||||||
| 	github.com/containers/image/v5 v5.19.0 | 	github.com/containers/image/v5 v5.19.0 | ||||||
| 	github.com/containers/ocicrypt v1.1.2 | 	github.com/containers/ocicrypt v1.1.2 | ||||||
| 	github.com/containers/psgo v1.7.2 | 	github.com/containers/psgo v1.7.2 | ||||||
| 	github.com/containers/storage v1.38.1 | 	github.com/containers/storage v1.38.2 | ||||||
| 	github.com/coreos/go-systemd/v22 v22.3.2 | 	github.com/coreos/go-systemd/v22 v22.3.2 | ||||||
| 	github.com/coreos/stream-metadata-go v0.0.0-20210225230131-70edb9eb47b3 | 	github.com/coreos/stream-metadata-go v0.0.0-20210225230131-70edb9eb47b3 | ||||||
| 	github.com/cyphar/filepath-securejoin v0.2.3 | 	github.com/cyphar/filepath-securejoin v0.2.3 | ||||||
|  | @ -44,7 +44,7 @@ require ( | ||||||
| 	github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 | 	github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 | ||||||
| 	github.com/mrunalp/fileutils v0.5.0 | 	github.com/mrunalp/fileutils v0.5.0 | ||||||
| 	github.com/onsi/ginkgo v1.16.5 | 	github.com/onsi/ginkgo v1.16.5 | ||||||
| 	github.com/onsi/gomega v1.18.0 | 	github.com/onsi/gomega v1.18.1 | ||||||
| 	github.com/opencontainers/go-digest v1.0.0 | 	github.com/opencontainers/go-digest v1.0.0 | ||||||
| 	github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 | 	github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 | ||||||
| 	github.com/opencontainers/runc v1.1.0 | 	github.com/opencontainers/runc v1.1.0 | ||||||
|  |  | ||||||
							
								
								
									
										12
									
								
								go.sum
								
								
								
								
							
							
						
						
									
										12
									
								
								go.sum
								
								
								
								
							|  | @ -296,8 +296,9 @@ github.com/containerd/nri v0.0.0-20210316161719-dbaa18c31c14/go.mod h1:lmxnXF6oM | ||||||
| github.com/containerd/nri v0.1.0/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY= | github.com/containerd/nri v0.1.0/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY= | ||||||
| github.com/containerd/stargz-snapshotter/estargz v0.4.1/go.mod h1:x7Q9dg9QYb4+ELgxmo4gBUeJB0tl5dqH1Sdz0nJU1QM= | github.com/containerd/stargz-snapshotter/estargz v0.4.1/go.mod h1:x7Q9dg9QYb4+ELgxmo4gBUeJB0tl5dqH1Sdz0nJU1QM= | ||||||
| github.com/containerd/stargz-snapshotter/estargz v0.9.0/go.mod h1:aE5PCyhFMwR8sbrErO5eM2GcvkyXTTJremG883D4qF0= | github.com/containerd/stargz-snapshotter/estargz v0.9.0/go.mod h1:aE5PCyhFMwR8sbrErO5eM2GcvkyXTTJremG883D4qF0= | ||||||
| github.com/containerd/stargz-snapshotter/estargz v0.10.1 h1:hd1EoVjI2Ax8Cr64tdYqnJ4i4pZU49FkEf5kU8KxQng= |  | ||||||
| github.com/containerd/stargz-snapshotter/estargz v0.10.1/go.mod h1:aE5PCyhFMwR8sbrErO5eM2GcvkyXTTJremG883D4qF0= | github.com/containerd/stargz-snapshotter/estargz v0.10.1/go.mod h1:aE5PCyhFMwR8sbrErO5eM2GcvkyXTTJremG883D4qF0= | ||||||
|  | github.com/containerd/stargz-snapshotter/estargz v0.11.0 h1:t0IW5kOmY7AXDAWRUs2uVzDhijAUOAYVr/dyRhOQvBg= | ||||||
|  | github.com/containerd/stargz-snapshotter/estargz v0.11.0/go.mod h1:/KsZXsJRllMbTKFfG0miFQWViQKdI9+9aSXs+HN0+ac= | ||||||
| github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= | github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= | ||||||
| github.com/containerd/ttrpc v0.0.0-20190828172938-92c8520ef9f8/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= | github.com/containerd/ttrpc v0.0.0-20190828172938-92c8520ef9f8/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= | ||||||
| github.com/containerd/ttrpc v0.0.0-20191028202541-4f1b8fe65a5c/go.mod h1:LPm1u0xBw8r8NOKoOdNMeVHSawSsltak+Ihv+etqsE8= | github.com/containerd/ttrpc v0.0.0-20191028202541-4f1b8fe65a5c/go.mod h1:LPm1u0xBw8r8NOKoOdNMeVHSawSsltak+Ihv+etqsE8= | ||||||
|  | @ -324,8 +325,9 @@ github.com/containernetworking/plugins v1.0.1 h1:wwCfYbTCj5FC0EJgyzyjTXmqysOiJE9 | ||||||
| github.com/containernetworking/plugins v1.0.1/go.mod h1:QHCfGpaTwYTbbH+nZXKVTxNBDZcxSOplJT5ico8/FLE= | github.com/containernetworking/plugins v1.0.1/go.mod h1:QHCfGpaTwYTbbH+nZXKVTxNBDZcxSOplJT5ico8/FLE= | ||||||
| github.com/containers/buildah v1.24.0 h1:2FThqm48DsmwoRvxDaRrujZCCRjmSytY4mnURAqWRww= | github.com/containers/buildah v1.24.0 h1:2FThqm48DsmwoRvxDaRrujZCCRjmSytY4mnURAqWRww= | ||||||
| github.com/containers/buildah v1.24.0/go.mod h1:logytKk6YhSHuxGa4vc/vRgXACnMQgOD4ONoYgWaUWA= | github.com/containers/buildah v1.24.0/go.mod h1:logytKk6YhSHuxGa4vc/vRgXACnMQgOD4ONoYgWaUWA= | ||||||
| github.com/containers/common v0.47.1 h1:/TKIvnIDXvy9VdzWj1L9WLhe3ZEX9sRaA6L0It8ZyTM= |  | ||||||
| github.com/containers/common v0.47.1/go.mod h1:vRjkTRres+O4i1k5brS7k2IV8uuiluCzmFRTMRZoyts= | github.com/containers/common v0.47.1/go.mod h1:vRjkTRres+O4i1k5brS7k2IV8uuiluCzmFRTMRZoyts= | ||||||
|  | github.com/containers/common v0.47.2 h1:WQtErA6lsWZ8KNtByXO3lEV0nNX5TjQju2O2ZoDNv4o= | ||||||
|  | github.com/containers/common v0.47.2/go.mod h1:PlcgaXuZYI8sUg0rkg81EOLT2ljzt0m1Ug810GCCAbc= | ||||||
| github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg= | github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg= | ||||||
| github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I= | github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I= | ||||||
| github.com/containers/image/v5 v5.19.0 h1:aEwc33qYjr2MpmBZlOgkCLu6dH465JTpWnFUCrjAXiQ= | github.com/containers/image/v5 v5.19.0 h1:aEwc33qYjr2MpmBZlOgkCLu6dH465JTpWnFUCrjAXiQ= | ||||||
|  | @ -341,8 +343,9 @@ github.com/containers/psgo v1.7.2 h1:WbCvsY9w+nCv3j4der0mbD3PSRUv/W8l+G0YrZrdSDc | ||||||
| github.com/containers/psgo v1.7.2/go.mod h1:SLpqxsPOHtTqRygjutCPXmeU2PoEFzV3gzJplN4BMx0= | github.com/containers/psgo v1.7.2/go.mod h1:SLpqxsPOHtTqRygjutCPXmeU2PoEFzV3gzJplN4BMx0= | ||||||
| github.com/containers/storage v1.37.0/go.mod h1:kqeJeS0b7DO2ZT1nVWs0XufrmPFbgV3c+Q/45RlH6r4= | github.com/containers/storage v1.37.0/go.mod h1:kqeJeS0b7DO2ZT1nVWs0XufrmPFbgV3c+Q/45RlH6r4= | ||||||
| github.com/containers/storage v1.38.0/go.mod h1:lBzt28gAk5ADZuRtwdndRJyqX22vnRaXmlF+7ktfMYc= | github.com/containers/storage v1.38.0/go.mod h1:lBzt28gAk5ADZuRtwdndRJyqX22vnRaXmlF+7ktfMYc= | ||||||
| github.com/containers/storage v1.38.1 h1:gg7YhHcxER0sh+kjXQcCZD6enu4VwAzliXq9JyM0g/Q= |  | ||||||
| github.com/containers/storage v1.38.1/go.mod h1:lBzt28gAk5ADZuRtwdndRJyqX22vnRaXmlF+7ktfMYc= | github.com/containers/storage v1.38.1/go.mod h1:lBzt28gAk5ADZuRtwdndRJyqX22vnRaXmlF+7ktfMYc= | ||||||
|  | github.com/containers/storage v1.38.2 h1:8bAIxnVBGKzMw5EWCivVj24bztQT6IkDp4uHiyhnzwE= | ||||||
|  | github.com/containers/storage v1.38.2/go.mod h1:INP0RPLHWBxx+pTsO5uiHlDUGHDFvWZPWprAbAlQWPQ= | ||||||
| github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= | github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= | ||||||
| github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= | github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= | ||||||
| github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= | github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= | ||||||
|  | @ -807,8 +810,9 @@ github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdY | ||||||
| github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= | github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= | ||||||
| github.com/klauspost/compress v1.13.5/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= | github.com/klauspost/compress v1.13.5/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= | ||||||
| github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= | github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= | ||||||
| github.com/klauspost/compress v1.14.1 h1:hLQYb23E8/fO+1u53d02A97a8UnsddcvYzq4ERRU4ds= |  | ||||||
| github.com/klauspost/compress v1.14.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= | github.com/klauspost/compress v1.14.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= | ||||||
|  | github.com/klauspost/compress v1.14.2 h1:S0OHlFk/Gbon/yauFJ4FfJJF5V0fc5HbBTJazi28pRw= | ||||||
|  | github.com/klauspost/compress v1.14.2/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= | ||||||
| github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE= | github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE= | ||||||
| github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= | github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= | ||||||
| github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | ||||||
|  |  | ||||||
|  | @ -82,7 +82,7 @@ func pullOrBuildInfraImage(p *entities.PodSpec, rt *libpod.Runtime) error { | ||||||
| 		imageName = rtConfig.Engine.InfraImage | 		imageName = rtConfig.Engine.InfraImage | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if imageName != config.DefaultInfraImage { | 	if imageName != "" { | ||||||
| 		_, err := rt.LibimageRuntime().Pull(context.Background(), imageName, config.PullPolicyMissing, nil) | 		_, err := rt.LibimageRuntime().Pull(context.Background(), imageName, config.PullPolicyMissing, nil) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return err | 			return err | ||||||
|  | @ -278,8 +278,6 @@ func MapSpec(p *specgen.PodSpecGenerator) (*specgen.SpecGenerator, error) { | ||||||
| 		p.InfraContainerSpec.ConmonPidFile = p.InfraConmonPidFile | 		p.InfraContainerSpec.ConmonPidFile = p.InfraConmonPidFile | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if p.InfraImage != config.DefaultInfraImage { | 	p.InfraContainerSpec.Image = p.InfraImage | ||||||
| 		p.InfraContainerSpec.Image = p.InfraImage |  | ||||||
| 	} |  | ||||||
| 	return p.InfraContainerSpec, nil | 	return p.InfraContainerSpec, nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -29,8 +29,7 @@ function teardown() { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @test "podman pod top - containers in different PID namespaces" { | @test "podman pod top - containers in different PID namespaces" { | ||||||
|     # With infra=false, we don't get a /pause container (we also |     # With infra=false, we don't get a /pause container | ||||||
|     # don't pull k8s.gcr.io/pause ) |  | ||||||
|     no_infra='--infra=false' |     no_infra='--infra=false' | ||||||
|     run_podman pod create $no_infra |     run_podman pod create $no_infra | ||||||
|     podid="$output" |     podid="$output" | ||||||
|  | @ -148,9 +147,6 @@ EOF | ||||||
|     # Pod no longer exists |     # Pod no longer exists | ||||||
|     run_podman 1 pod exists $podid |     run_podman 1 pod exists $podid | ||||||
|     run_podman 1 pod exists $podname |     run_podman 1 pod exists $podname | ||||||
| 
 |  | ||||||
|     # Pause image hasn't been pulled |  | ||||||
|     run_podman 1 image exists k8s.gcr.io/pause:3.5 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| # Random byte | # Random byte | ||||||
|  | @ -329,8 +325,6 @@ EOF | ||||||
|     local infra_name="infra_container_$(random_string 10 | tr A-Z a-z)" |     local infra_name="infra_container_$(random_string 10 | tr A-Z a-z)" | ||||||
|     local pod_name="$(random_string 10 | tr A-Z a-z)" |     local pod_name="$(random_string 10 | tr A-Z a-z)" | ||||||
| 
 | 
 | ||||||
|     # Note that the internal pause image is built even when --infra-image is |  | ||||||
|     # set to the K8s one. |  | ||||||
|     run_podman --noout pod create --name $pod_name --infra-name "$infra_name" --infra-image "k8s.gcr.io/pause:3.5" |     run_podman --noout pod create --name $pod_name --infra-name "$infra_name" --infra-image "k8s.gcr.io/pause:3.5" | ||||||
|     is "$output" "" "output should be empty" |     is "$output" "" "output should be empty" | ||||||
|     run_podman '?' pod create --infra-name "$infra_name" |     run_podman '?' pod create --infra-name "$infra_name" | ||||||
|  | @ -339,9 +333,6 @@ EOF | ||||||
|     fi |     fi | ||||||
|     run_podman pod rm -f $pod_name |     run_podman pod rm -f $pod_name | ||||||
|     run_podman images -a |     run_podman images -a | ||||||
| 
 |  | ||||||
|     # Pause image hasn't been pulled |  | ||||||
|     run_podman 1 image exists k8s.gcr.io/pause:3.5 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @test "podman pod create --share" { | @test "podman pod create --share" { | ||||||
|  |  | ||||||
|  | @ -107,7 +107,7 @@ type Telemetry struct { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Open opens a stargz file for reading.
 | // Open opens a stargz file for reading.
 | ||||||
| // The behaviour is configurable using options.
 | // The behavior is configurable using options.
 | ||||||
| //
 | //
 | ||||||
| // Note that each entry name is normalized as the path that is relative to root.
 | // Note that each entry name is normalized as the path that is relative to root.
 | ||||||
| func Open(sr *io.SectionReader, opt ...OpenOption) (*Reader, error) { | func Open(sr *io.SectionReader, opt ...OpenOption) (*Reader, error) { | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ module github.com/containerd/stargz-snapshotter/estargz | ||||||
| go 1.16 | go 1.16 | ||||||
| 
 | 
 | ||||||
| require ( | require ( | ||||||
| 	github.com/klauspost/compress v1.13.6 | 	github.com/klauspost/compress v1.14.2 | ||||||
| 	github.com/opencontainers/go-digest v1.0.0 | 	github.com/opencontainers/go-digest v1.0.0 | ||||||
| 	github.com/pkg/errors v0.9.1 | 	github.com/pkg/errors v0.9.1 | ||||||
| 	github.com/vbatts/tar-split v0.11.2 | 	github.com/vbatts/tar-split v0.11.2 | ||||||
|  |  | ||||||
|  | @ -1,8 +1,8 @@ | ||||||
| github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= | ||||||
| github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= | ||||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||||
| github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= | github.com/klauspost/compress v1.14.2 h1:S0OHlFk/Gbon/yauFJ4FfJJF5V0fc5HbBTJazi28pRw= | ||||||
| github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= | github.com/klauspost/compress v1.14.2/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= | ||||||
| github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= | github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= | ||||||
| github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= | github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= | ||||||
| github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | ||||||
|  |  | ||||||
|  | @ -399,14 +399,16 @@ default_sysctls = [ | ||||||
| # Infra (pause) container image name for pod infra containers.  When running a | # Infra (pause) container image name for pod infra containers.  When running a | ||||||
| # pod, we start a `pause` process in a container to hold open the namespaces | # pod, we start a `pause` process in a container to hold open the namespaces | ||||||
| # associated with the  pod.  This container does nothing other then sleep, | # associated with the  pod.  This container does nothing other then sleep, | ||||||
| # reserving the pods resources for the lifetime of the pod. | # reserving the pods resources for the lifetime of the pod. By default container | ||||||
|  | # engines run a builtin container using the pause executable. If you want override | ||||||
|  | # specify an image to pull. | ||||||
| # | # | ||||||
| #infra_image = "k8s.gcr.io/pause:3.4.1" | #infra_image = "" | ||||||
| 
 | 
 | ||||||
| # Specify the locking mechanism to use; valid values are "shm" and "file". | # Specify the locking mechanism to use; valid values are "shm" and "file". | ||||||
| # Change the default only if you are sure of what you are doing, in general | # Change the default only if you are sure of what you are doing, in general | ||||||
| # "file" is useful only on platforms where cgo is not available for using the | # "file" is useful only on platforms where cgo is not available for using the | ||||||
| # faster "shm" lock type.  You may need to run "podman system renumber" after | # faster "shm" lock type. You may need to run "podman system renumber" after | ||||||
| # you change the lock type. | # you change the lock type. | ||||||
| # | # | ||||||
| #lock_type** = "shm" | #lock_type** = "shm" | ||||||
|  | @ -465,7 +467,7 @@ default_sysctls = [ | ||||||
| # | # | ||||||
| #runtime = "crun" | #runtime = "crun" | ||||||
| 
 | 
 | ||||||
| # List of the OCI runtimes that support --format=json.  When json is supported | # List of the OCI runtimes that support --format=json. When json is supported | ||||||
| # engine will use it for reporting nicer errors. | # engine will use it for reporting nicer errors. | ||||||
| # | # | ||||||
| #runtime_supports_json = ["crun", "runc", "kata", "runsc", "krun"] | #runtime_supports_json = ["crun", "runc", "kata", "runsc", "krun"] | ||||||
|  | @ -478,8 +480,8 @@ default_sysctls = [ | ||||||
| # | # | ||||||
| #runtime_supports_nocgroups = ["crun", "krun"] | #runtime_supports_nocgroups = ["crun", "krun"] | ||||||
| 
 | 
 | ||||||
| # Default location for storing temporary container image content.  Can be overridden with the TMPDIR environment | # Default location for storing temporary container image content. Can be overridden with the TMPDIR environment | ||||||
| # variable.  If you specify "storage", then the location of the | # variable. If you specify "storage", then the location of the | ||||||
| # container/storage tmp directory will be used. | # container/storage tmp directory will be used. | ||||||
| # image_copy_tmp_dir="/var/tmp" | # image_copy_tmp_dir="/var/tmp" | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -46,7 +46,7 @@ var ( | ||||||
| 	// DefaultInitPath is the default path to the container-init binary
 | 	// DefaultInitPath is the default path to the container-init binary
 | ||||||
| 	DefaultInitPath = "/usr/libexec/podman/catatonit" | 	DefaultInitPath = "/usr/libexec/podman/catatonit" | ||||||
| 	// DefaultInfraImage to use for infra container
 | 	// DefaultInfraImage to use for infra container
 | ||||||
| 	DefaultInfraImage = "k8s.gcr.io/pause:3.5" | 	DefaultInfraImage = "" | ||||||
| 	// DefaultRootlessSHMLockPath is the default path for rootless SHM locks
 | 	// DefaultRootlessSHMLockPath is the default path for rootless SHM locks
 | ||||||
| 	DefaultRootlessSHMLockPath = "/libpod_rootless_lock" | 	DefaultRootlessSHMLockPath = "/libpod_rootless_lock" | ||||||
| 	// DefaultDetachKeys is the default keys sequence for detaching a
 | 	// DefaultDetachKeys is the default keys sequence for detaching a
 | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| package version | package version | ||||||
| 
 | 
 | ||||||
| // Version is the version of the build.
 | // Version is the version of the build.
 | ||||||
| const Version = "0.47.1" | const Version = "0.47.2" | ||||||
|  |  | ||||||
|  | @ -52,7 +52,7 @@ containers-storage: $(sources) ## build using gc on the host | ||||||
| 	$(GO) build $(MOD_VENDOR) -compiler gc $(BUILDFLAGS) ./cmd/containers-storage | 	$(GO) build $(MOD_VENDOR) -compiler gc $(BUILDFLAGS) ./cmd/containers-storage | ||||||
| 
 | 
 | ||||||
| codespell: | codespell: | ||||||
| 	codespell -S Makefile,build,buildah,buildah.spec,imgtype,copy,AUTHORS,bin,vendor,.git,go.sum,CHANGELOG.md,changelog.txt,seccomp.json,.cirrus.yml,"*.xz,*.gz,*.tar,*.tgz,*ico,*.png,*.1,*.5,*.orig,*.rej" -L uint,iff,od,ERRO -w | 	codespell -S Makefile,build,buildah,buildah.spec,imgtype,copy,AUTHORS,bin,vendor,.git,go.sum,CHANGELOG.md,changelog.txt,seccomp.json,.cirrus.yml,"*.xz,*.gz,*.tar,*.tgz,*ico,*.png,*.1,*.5,*.orig,*.rej" -L flate,uint,iff,od,ERRO -w | ||||||
| 
 | 
 | ||||||
| binary local-binary: containers-storage | binary local-binary: containers-storage | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1 +1 @@ | ||||||
| 1.38.1 | 1.38.2 | ||||||
|  |  | ||||||
|  | @ -138,6 +138,7 @@ func (gdw *NaiveDiffDriver) Changes(id string, idMappings *idtools.IDMappings, p | ||||||
| 	if parent != "" { | 	if parent != "" { | ||||||
| 		options := MountOpts{ | 		options := MountOpts{ | ||||||
| 			MountLabel: mountLabel, | 			MountLabel: mountLabel, | ||||||
|  | 			Options:    []string{"ro"}, | ||||||
| 		} | 		} | ||||||
| 		parentFs, err = driver.Get(parent, options) | 		parentFs, err = driver.Get(parent, options) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  |  | ||||||
|  | @ -1055,17 +1055,22 @@ func (d *Driver) getLower(parent string) (string, error) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (d *Driver) dir(id string) string { | func (d *Driver) dir(id string) string { | ||||||
|  | 	p, _ := d.dir2(id) | ||||||
|  | 	return p | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (d *Driver) dir2(id string) (string, bool) { | ||||||
| 	newpath := path.Join(d.home, id) | 	newpath := path.Join(d.home, id) | ||||||
| 	if _, err := os.Stat(newpath); err != nil { | 	if _, err := os.Stat(newpath); err != nil { | ||||||
| 		for _, p := range d.AdditionalImageStores() { | 		for _, p := range d.AdditionalImageStores() { | ||||||
| 			l := path.Join(p, d.name, id) | 			l := path.Join(p, d.name, id) | ||||||
| 			_, err = os.Stat(l) | 			_, err = os.Stat(l) | ||||||
| 			if err == nil { | 			if err == nil { | ||||||
| 				return l | 				return l, true | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	return newpath | 	return newpath, false | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (d *Driver) getLowerDirs(id string) ([]string, error) { | func (d *Driver) getLowerDirs(id string) ([]string, error) { | ||||||
|  | @ -1260,11 +1265,11 @@ func (d *Driver) Get(id string, options graphdriver.MountOpts) (_ string, retErr | ||||||
| func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountOpts) (_ string, retErr error) { | func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountOpts) (_ string, retErr error) { | ||||||
| 	d.locker.Lock(id) | 	d.locker.Lock(id) | ||||||
| 	defer d.locker.Unlock(id) | 	defer d.locker.Unlock(id) | ||||||
| 	dir := d.dir(id) | 	dir, inAdditionalStore := d.dir2(id) | ||||||
| 	if _, err := os.Stat(dir); err != nil { | 	if _, err := os.Stat(dir); err != nil { | ||||||
| 		return "", err | 		return "", err | ||||||
| 	} | 	} | ||||||
| 	readWrite := true | 	readWrite := !inAdditionalStore | ||||||
| 
 | 
 | ||||||
| 	if !d.SupportsShifting() || options.DisableShifting { | 	if !d.SupportsShifting() || options.DisableShifting { | ||||||
| 		disableShifting = true | 		disableShifting = true | ||||||
|  |  | ||||||
|  | @ -6,13 +6,13 @@ require ( | ||||||
| 	github.com/BurntSushi/toml v1.0.0 | 	github.com/BurntSushi/toml v1.0.0 | ||||||
| 	github.com/Microsoft/go-winio v0.5.1 | 	github.com/Microsoft/go-winio v0.5.1 | ||||||
| 	github.com/Microsoft/hcsshim v0.9.2 | 	github.com/Microsoft/hcsshim v0.9.2 | ||||||
| 	github.com/containerd/stargz-snapshotter/estargz v0.10.1 | 	github.com/containerd/stargz-snapshotter/estargz v0.11.0 | ||||||
| 	github.com/cyphar/filepath-securejoin v0.2.3 | 	github.com/cyphar/filepath-securejoin v0.2.3 | ||||||
| 	github.com/docker/go-units v0.4.0 | 	github.com/docker/go-units v0.4.0 | ||||||
| 	github.com/google/go-intervals v0.0.2 | 	github.com/google/go-intervals v0.0.2 | ||||||
| 	github.com/hashicorp/go-multierror v1.1.1 | 	github.com/hashicorp/go-multierror v1.1.1 | ||||||
| 	github.com/json-iterator/go v1.1.12 | 	github.com/json-iterator/go v1.1.12 | ||||||
| 	github.com/klauspost/compress v1.14.1 | 	github.com/klauspost/compress v1.14.2 | ||||||
| 	github.com/klauspost/pgzip v1.2.5 | 	github.com/klauspost/pgzip v1.2.5 | ||||||
| 	github.com/mattn/go-shellwords v1.0.12 | 	github.com/mattn/go-shellwords v1.0.12 | ||||||
| 	github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible | 	github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible | ||||||
|  |  | ||||||
|  | @ -176,8 +176,8 @@ github.com/containerd/nri v0.0.0-20201007170849-eb1350a75164/go.mod h1:+2wGSDGFY | ||||||
| github.com/containerd/nri v0.0.0-20210316161719-dbaa18c31c14/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY= | github.com/containerd/nri v0.0.0-20210316161719-dbaa18c31c14/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY= | ||||||
| github.com/containerd/nri v0.1.0/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY= | github.com/containerd/nri v0.1.0/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY= | ||||||
| github.com/containerd/stargz-snapshotter/estargz v0.4.1/go.mod h1:x7Q9dg9QYb4+ELgxmo4gBUeJB0tl5dqH1Sdz0nJU1QM= | github.com/containerd/stargz-snapshotter/estargz v0.4.1/go.mod h1:x7Q9dg9QYb4+ELgxmo4gBUeJB0tl5dqH1Sdz0nJU1QM= | ||||||
| github.com/containerd/stargz-snapshotter/estargz v0.10.1 h1:hd1EoVjI2Ax8Cr64tdYqnJ4i4pZU49FkEf5kU8KxQng= | github.com/containerd/stargz-snapshotter/estargz v0.11.0 h1:t0IW5kOmY7AXDAWRUs2uVzDhijAUOAYVr/dyRhOQvBg= | ||||||
| github.com/containerd/stargz-snapshotter/estargz v0.10.1/go.mod h1:aE5PCyhFMwR8sbrErO5eM2GcvkyXTTJremG883D4qF0= | github.com/containerd/stargz-snapshotter/estargz v0.11.0/go.mod h1:/KsZXsJRllMbTKFfG0miFQWViQKdI9+9aSXs+HN0+ac= | ||||||
| github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= | github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= | ||||||
| github.com/containerd/ttrpc v0.0.0-20190828172938-92c8520ef9f8/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= | github.com/containerd/ttrpc v0.0.0-20190828172938-92c8520ef9f8/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= | ||||||
| github.com/containerd/ttrpc v0.0.0-20191028202541-4f1b8fe65a5c/go.mod h1:LPm1u0xBw8r8NOKoOdNMeVHSawSsltak+Ihv+etqsE8= | github.com/containerd/ttrpc v0.0.0-20191028202541-4f1b8fe65a5c/go.mod h1:LPm1u0xBw8r8NOKoOdNMeVHSawSsltak+Ihv+etqsE8= | ||||||
|  | @ -424,9 +424,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI | ||||||
| github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | ||||||
| github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= | github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= | ||||||
| github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= | github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= | ||||||
| github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= | github.com/klauspost/compress v1.14.2 h1:S0OHlFk/Gbon/yauFJ4FfJJF5V0fc5HbBTJazi28pRw= | ||||||
| github.com/klauspost/compress v1.14.1 h1:hLQYb23E8/fO+1u53d02A97a8UnsddcvYzq4ERRU4ds= | github.com/klauspost/compress v1.14.2/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= | ||||||
| github.com/klauspost/compress v1.14.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= |  | ||||||
| github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE= | github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE= | ||||||
| github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= | github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= | ||||||
| github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | ||||||
|  |  | ||||||
|  | @ -973,7 +973,10 @@ func Unpack(decompressedArchive io.Reader, dest string, options *TarOptions) err | ||||||
| 	whiteoutConverter := GetWhiteoutConverter(options.WhiteoutFormat, options.WhiteoutData) | 	whiteoutConverter := GetWhiteoutConverter(options.WhiteoutFormat, options.WhiteoutData) | ||||||
| 	buffer := make([]byte, 1<<20) | 	buffer := make([]byte, 1<<20) | ||||||
| 
 | 
 | ||||||
|  | 	doChown := !options.NoLchown | ||||||
| 	if options.ForceMask != nil { | 	if options.ForceMask != nil { | ||||||
|  | 		// if ForceMask is in place, make sure lchown is disabled.
 | ||||||
|  | 		doChown = false | ||||||
| 		uid, gid, mode, err := GetFileOwner(dest) | 		uid, gid, mode, err := GetFileOwner(dest) | ||||||
| 		if err == nil { | 		if err == nil { | ||||||
| 			value := fmt.Sprintf("%d:%d:0%o", uid, gid, mode) | 			value := fmt.Sprintf("%d:%d:0%o", uid, gid, mode) | ||||||
|  | @ -1078,7 +1081,7 @@ loop: | ||||||
| 			chownOpts = &idtools.IDPair{UID: hdr.Uid, GID: hdr.Gid} | 			chownOpts = &idtools.IDPair{UID: hdr.Uid, GID: hdr.Gid} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if err := createTarFile(path, dest, hdr, trBuf, !options.NoLchown, chownOpts, options.InUserNS, options.IgnoreChownErrors, options.ForceMask, buffer); err != nil { | 		if err = createTarFile(path, dest, hdr, trBuf, doChown, chownOpts, options.InUserNS, options.IgnoreChownErrors, options.ForceMask, buffer); err != nil { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -87,7 +87,7 @@ func readEstargzChunkedManifest(blobStream ImageSourceSeekable, blobSize int64, | ||||||
| 	   - 2  bytes  Extra: SI1 = 'S', SI2 = 'G' | 	   - 2  bytes  Extra: SI1 = 'S', SI2 = 'G' | ||||||
| 	   - 2  bytes  Extra: LEN = 22 (16 hex digits + len("STARGZ")) | 	   - 2  bytes  Extra: LEN = 22 (16 hex digits + len("STARGZ")) | ||||||
| 	   - 22 bytes  Extra: subfield = fmt.Sprintf("%016xSTARGZ", offsetOfTOC) | 	   - 22 bytes  Extra: subfield = fmt.Sprintf("%016xSTARGZ", offsetOfTOC) | ||||||
| 	   - 5  bytes  flat header: BFINAL = 1(last block), BTYPE = 0(non-compressed block), LEN = 0 | 	   - 5  bytes  flate header: BFINAL = 1(last block), BTYPE = 0(non-compressed block), LEN = 0 | ||||||
| 	   - 8  bytes  gzip footer | 	   - 8  bytes  gzip footer | ||||||
| 	*/ | 	*/ | ||||||
| 	tocOffset, err := strconv.ParseInt(string(footer[16:16+22-6]), 16, 64) | 	tocOffset, err := strconv.ParseInt(string(footer[16:16+22-6]), 16, 64) | ||||||
|  |  | ||||||
|  | @ -10,9 +10,6 @@ import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"math" | 	"math" | ||||||
| 	"math/bits" |  | ||||||
| 
 |  | ||||||
| 	comp "github.com/klauspost/compress" |  | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const ( | const ( | ||||||
|  | @ -76,8 +73,8 @@ var levels = []compressionLevel{ | ||||||
| 	{0, 0, 0, 0, 0, 6}, | 	{0, 0, 0, 0, 0, 6}, | ||||||
| 	// Levels 7-9 use increasingly more lazy matching
 | 	// Levels 7-9 use increasingly more lazy matching
 | ||||||
| 	// and increasingly stringent conditions for "good enough".
 | 	// and increasingly stringent conditions for "good enough".
 | ||||||
| 	{6, 10, 12, 16, skipNever, 7}, | 	{8, 12, 16, 24, skipNever, 7}, | ||||||
| 	{10, 24, 32, 64, skipNever, 8}, | 	{16, 30, 40, 64, skipNever, 8}, | ||||||
| 	{32, 258, 258, 1024, skipNever, 9}, | 	{32, 258, 258, 1024, skipNever, 9}, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -110,6 +107,7 @@ type advancedState struct { | ||||||
| type compressor struct { | type compressor struct { | ||||||
| 	compressionLevel | 	compressionLevel | ||||||
| 
 | 
 | ||||||
|  | 	h *huffmanEncoder | ||||||
| 	w *huffmanBitWriter | 	w *huffmanBitWriter | ||||||
| 
 | 
 | ||||||
| 	// compression algorithm
 | 	// compression algorithm
 | ||||||
|  | @ -271,7 +269,7 @@ func (d *compressor) fillWindow(b []byte) { | ||||||
| // Try to find a match starting at index whose length is greater than prevSize.
 | // Try to find a match starting at index whose length is greater than prevSize.
 | ||||||
| // We only look at chainCount possibilities before giving up.
 | // We only look at chainCount possibilities before giving up.
 | ||||||
| // pos = s.index, prevHead = s.chainHead-s.hashOffset, prevLength=minMatchLength-1, lookahead
 | // pos = s.index, prevHead = s.chainHead-s.hashOffset, prevLength=minMatchLength-1, lookahead
 | ||||||
| func (d *compressor) findMatch(pos int, prevHead int, lookahead, bpb int) (length, offset int, ok bool) { | func (d *compressor) findMatch(pos int, prevHead int, lookahead int) (length, offset int, ok bool) { | ||||||
| 	minMatchLook := maxMatchLength | 	minMatchLook := maxMatchLength | ||||||
| 	if lookahead < minMatchLook { | 	if lookahead < minMatchLook { | ||||||
| 		minMatchLook = lookahead | 		minMatchLook = lookahead | ||||||
|  | @ -297,14 +295,46 @@ func (d *compressor) findMatch(pos int, prevHead int, lookahead, bpb int) (lengt | ||||||
| 	} | 	} | ||||||
| 	offset = 0 | 	offset = 0 | ||||||
| 
 | 
 | ||||||
|  | 	cGain := 0 | ||||||
|  | 	if d.chain < 100 { | ||||||
|  | 		for i := prevHead; tries > 0; tries-- { | ||||||
|  | 			if wEnd == win[i+length] { | ||||||
|  | 				n := matchLen(win[i:i+minMatchLook], wPos) | ||||||
|  | 				if n > length { | ||||||
|  | 					length = n | ||||||
|  | 					offset = pos - i | ||||||
|  | 					ok = true | ||||||
|  | 					if n >= nice { | ||||||
|  | 						// The match is good enough that we don't try to find a better one.
 | ||||||
|  | 						break | ||||||
|  | 					} | ||||||
|  | 					wEnd = win[pos+n] | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			if i <= minIndex { | ||||||
|  | 				// hashPrev[i & windowMask] has already been overwritten, so stop now.
 | ||||||
|  | 				break | ||||||
|  | 			} | ||||||
|  | 			i = int(d.state.hashPrev[i&windowMask]) - d.state.hashOffset | ||||||
|  | 			if i < minIndex { | ||||||
|  | 				break | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	// Some like it higher (CSV), some like it lower (JSON)
 | ||||||
|  | 	const baseCost = 6 | ||||||
| 	// Base is 4 bytes at with an additional cost.
 | 	// Base is 4 bytes at with an additional cost.
 | ||||||
| 	// Matches must be better than this.
 | 	// Matches must be better than this.
 | ||||||
| 	cGain := minMatchLength*bpb - 12 |  | ||||||
| 	for i := prevHead; tries > 0; tries-- { | 	for i := prevHead; tries > 0; tries-- { | ||||||
| 		if wEnd == win[i+length] { | 		if wEnd == win[i+length] { | ||||||
| 			n := matchLen(win[i:i+minMatchLook], wPos) | 			n := matchLen(win[i:i+minMatchLook], wPos) | ||||||
| 			if n > length { | 			if n > length { | ||||||
| 				newGain := n*bpb - bits.Len32(uint32(pos-i)) | 				// Calculate gain. Estimate
 | ||||||
|  | 				newGain := d.h.bitLengthRaw(wPos[:n]) - int(offsetExtraBits[offsetCode(uint32(pos-i))]) - baseCost - int(lengthExtraBits[lengthCodes[(n-3)&255]]) | ||||||
|  | 
 | ||||||
|  | 				//fmt.Println(n, "gain:", newGain, "prev:", cGain, "raw:", d.h.bitLengthRaw(wPos[:n]))
 | ||||||
| 				if newGain > cGain { | 				if newGain > cGain { | ||||||
| 					length = n | 					length = n | ||||||
| 					offset = pos - i | 					offset = pos - i | ||||||
|  | @ -389,10 +419,16 @@ func (d *compressor) deflateLazy() { | ||||||
| 	if d.windowEnd-s.index < minMatchLength+maxMatchLength && !d.sync { | 	if d.windowEnd-s.index < minMatchLength+maxMatchLength && !d.sync { | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	s.estBitsPerByte = 8 | 	if d.windowEnd != s.index && d.chain > 100 { | ||||||
| 	if !d.sync { | 		// Get literal huffman coder.
 | ||||||
| 		s.estBitsPerByte = comp.ShannonEntropyBits(d.window[s.index:d.windowEnd]) | 		if d.h == nil { | ||||||
| 		s.estBitsPerByte = int(1 + float64(s.estBitsPerByte)/float64(d.windowEnd-s.index)) | 			d.h = newHuffmanEncoder(maxFlateBlockTokens) | ||||||
|  | 		} | ||||||
|  | 		var tmp [256]uint16 | ||||||
|  | 		for _, v := range d.window[s.index:d.windowEnd] { | ||||||
|  | 			tmp[v]++ | ||||||
|  | 		} | ||||||
|  | 		d.h.generate(tmp[:], 15) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	s.maxInsertIndex = d.windowEnd - (minMatchLength - 1) | 	s.maxInsertIndex = d.windowEnd - (minMatchLength - 1) | ||||||
|  | @ -446,7 +482,7 @@ func (d *compressor) deflateLazy() { | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if s.chainHead-s.hashOffset >= minIndex && lookahead > prevLength && prevLength < d.lazy { | 		if s.chainHead-s.hashOffset >= minIndex && lookahead > prevLength && prevLength < d.lazy { | ||||||
| 			if newLength, newOffset, ok := d.findMatch(s.index, s.chainHead-s.hashOffset, lookahead, s.estBitsPerByte); ok { | 			if newLength, newOffset, ok := d.findMatch(s.index, s.chainHead-s.hashOffset, lookahead); ok { | ||||||
| 				s.length = newLength | 				s.length = newLength | ||||||
| 				s.offset = newOffset | 				s.offset = newOffset | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -52,18 +52,18 @@ var lengthBase = [32]uint8{ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // offset code word extra bits.
 | // offset code word extra bits.
 | ||||||
| var offsetExtraBits = [64]int8{ | var offsetExtraBits = [32]int8{ | ||||||
| 	0, 0, 0, 0, 1, 1, 2, 2, 3, 3, | 	0, 0, 0, 0, 1, 1, 2, 2, 3, 3, | ||||||
| 	4, 4, 5, 5, 6, 6, 7, 7, 8, 8, | 	4, 4, 5, 5, 6, 6, 7, 7, 8, 8, | ||||||
| 	9, 9, 10, 10, 11, 11, 12, 12, 13, 13, | 	9, 9, 10, 10, 11, 11, 12, 12, 13, 13, | ||||||
| 	/* extended window */ | 	/* extended window */ | ||||||
| 	14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, | 	14, 14, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| var offsetCombined = [32]uint32{} | var offsetCombined = [32]uint32{} | ||||||
| 
 | 
 | ||||||
| func init() { | func init() { | ||||||
| 	var offsetBase = [64]uint32{ | 	var offsetBase = [32]uint32{ | ||||||
| 		/* normal deflate */ | 		/* normal deflate */ | ||||||
| 		0x000000, 0x000001, 0x000002, 0x000003, 0x000004, | 		0x000000, 0x000001, 0x000002, 0x000003, 0x000004, | ||||||
| 		0x000006, 0x000008, 0x00000c, 0x000010, 0x000018, | 		0x000006, 0x000008, 0x00000c, 0x000010, 0x000018, | ||||||
|  | @ -73,9 +73,7 @@ func init() { | ||||||
| 		0x001800, 0x002000, 0x003000, 0x004000, 0x006000, | 		0x001800, 0x002000, 0x003000, 0x004000, 0x006000, | ||||||
| 
 | 
 | ||||||
| 		/* extended window */ | 		/* extended window */ | ||||||
| 		0x008000, 0x00c000, 0x010000, 0x018000, 0x020000, | 		0x008000, 0x00c000, | ||||||
| 		0x030000, 0x040000, 0x060000, 0x080000, 0x0c0000, |  | ||||||
| 		0x100000, 0x180000, 0x200000, 0x300000, |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	for i := range offsetCombined[:] { | 	for i := range offsetCombined[:] { | ||||||
|  |  | ||||||
|  | @ -129,9 +129,7 @@ func (h *huffmanEncoder) bitLength(freq []uint16) int { | ||||||
| func (h *huffmanEncoder) bitLengthRaw(b []byte) int { | func (h *huffmanEncoder) bitLengthRaw(b []byte) int { | ||||||
| 	var total int | 	var total int | ||||||
| 	for _, f := range b { | 	for _, f := range b { | ||||||
| 		if f != 0 { | 		total += int(h.codes[f].len) | ||||||
| 			total += int(h.codes[f].len) |  | ||||||
| 		} |  | ||||||
| 	} | 	} | ||||||
| 	return total | 	return total | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -129,11 +129,11 @@ var offsetCodes14 = [256]uint32{ | ||||||
| type token uint32 | type token uint32 | ||||||
| 
 | 
 | ||||||
| type tokens struct { | type tokens struct { | ||||||
| 	nLits     int |  | ||||||
| 	extraHist [32]uint16  // codes 256->maxnumlit
 | 	extraHist [32]uint16  // codes 256->maxnumlit
 | ||||||
| 	offHist   [32]uint16  // offset codes
 | 	offHist   [32]uint16  // offset codes
 | ||||||
| 	litHist   [256]uint16 // codes 0->255
 | 	litHist   [256]uint16 // codes 0->255
 | ||||||
| 	n         uint16      // Must be able to contain maxStoreBlockSize
 | 	nFilled   int | ||||||
|  | 	n         uint16 // Must be able to contain maxStoreBlockSize
 | ||||||
| 	tokens    [maxStoreBlockSize + 1]token | 	tokens    [maxStoreBlockSize + 1]token | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -142,7 +142,7 @@ func (t *tokens) Reset() { | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	t.n = 0 | 	t.n = 0 | ||||||
| 	t.nLits = 0 | 	t.nFilled = 0 | ||||||
| 	for i := range t.litHist[:] { | 	for i := range t.litHist[:] { | ||||||
| 		t.litHist[i] = 0 | 		t.litHist[i] = 0 | ||||||
| 	} | 	} | ||||||
|  | @ -161,12 +161,12 @@ func (t *tokens) Fill() { | ||||||
| 	for i, v := range t.litHist[:] { | 	for i, v := range t.litHist[:] { | ||||||
| 		if v == 0 { | 		if v == 0 { | ||||||
| 			t.litHist[i] = 1 | 			t.litHist[i] = 1 | ||||||
| 			t.nLits++ | 			t.nFilled++ | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	for i, v := range t.extraHist[:literalCount-256] { | 	for i, v := range t.extraHist[:literalCount-256] { | ||||||
| 		if v == 0 { | 		if v == 0 { | ||||||
| 			t.nLits++ | 			t.nFilled++ | ||||||
| 			t.extraHist[i] = 1 | 			t.extraHist[i] = 1 | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | @ -202,14 +202,12 @@ func emitLiteral(dst *tokens, lit []byte) { | ||||||
| 		dst.litHist[v]++ | 		dst.litHist[v]++ | ||||||
| 	} | 	} | ||||||
| 	dst.n += uint16(len(lit)) | 	dst.n += uint16(len(lit)) | ||||||
| 	dst.nLits += len(lit) |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (t *tokens) AddLiteral(lit byte) { | func (t *tokens) AddLiteral(lit byte) { | ||||||
| 	t.tokens[t.n] = token(lit) | 	t.tokens[t.n] = token(lit) | ||||||
| 	t.litHist[lit]++ | 	t.litHist[lit]++ | ||||||
| 	t.n++ | 	t.n++ | ||||||
| 	t.nLits++ |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // from https://stackoverflow.com/a/28730362
 | // from https://stackoverflow.com/a/28730362
 | ||||||
|  | @ -230,8 +228,9 @@ func (t *tokens) EstimatedBits() int { | ||||||
| 	shannon := float32(0) | 	shannon := float32(0) | ||||||
| 	bits := int(0) | 	bits := int(0) | ||||||
| 	nMatches := 0 | 	nMatches := 0 | ||||||
| 	if t.nLits > 0 { | 	total := int(t.n) + t.nFilled | ||||||
| 		invTotal := 1.0 / float32(t.nLits) | 	if total > 0 { | ||||||
|  | 		invTotal := 1.0 / float32(total) | ||||||
| 		for _, v := range t.litHist[:] { | 		for _, v := range t.litHist[:] { | ||||||
| 			if v > 0 { | 			if v > 0 { | ||||||
| 				n := float32(v) | 				n := float32(v) | ||||||
|  | @ -275,7 +274,6 @@ func (t *tokens) AddMatch(xlength uint32, xoffset uint32) { | ||||||
| 	} | 	} | ||||||
| 	oCode := offsetCode(xoffset) | 	oCode := offsetCode(xoffset) | ||||||
| 	xoffset |= oCode << 16 | 	xoffset |= oCode << 16 | ||||||
| 	t.nLits++ |  | ||||||
| 
 | 
 | ||||||
| 	t.extraHist[lengthCodes1[uint8(xlength)]]++ | 	t.extraHist[lengthCodes1[uint8(xlength)]]++ | ||||||
| 	t.offHist[oCode]++ | 	t.offHist[oCode]++ | ||||||
|  | @ -301,7 +299,6 @@ func (t *tokens) AddMatchLong(xlength int32, xoffset uint32) { | ||||||
| 		} | 		} | ||||||
| 		xlength -= xl | 		xlength -= xl | ||||||
| 		xl -= baseMatchLength | 		xl -= baseMatchLength | ||||||
| 		t.nLits++ |  | ||||||
| 		t.extraHist[lengthCodes1[uint8(xl)]]++ | 		t.extraHist[lengthCodes1[uint8(xl)]]++ | ||||||
| 		t.offHist[oc]++ | 		t.offHist[oc]++ | ||||||
| 		t.tokens[t.n] = token(matchType | uint32(xl)<<lengthShift | xoffset) | 		t.tokens[t.n] = token(matchType | uint32(xl)<<lengthShift | xoffset) | ||||||
|  |  | ||||||
|  | @ -76,12 +76,11 @@ type blockDec struct { | ||||||
| 	// Window size of the block.
 | 	// Window size of the block.
 | ||||||
| 	WindowSize uint64 | 	WindowSize uint64 | ||||||
| 
 | 
 | ||||||
| 	history     chan *history | 	history chan *history | ||||||
| 	input       chan struct{} | 	input   chan struct{} | ||||||
| 	result      chan decodeOutput | 	result  chan decodeOutput | ||||||
| 	sequenceBuf []seq | 	err     error | ||||||
| 	err         error | 	decWG   sync.WaitGroup | ||||||
| 	decWG       sync.WaitGroup |  | ||||||
| 
 | 
 | ||||||
| 	// Frame to use for singlethreaded decoding.
 | 	// Frame to use for singlethreaded decoding.
 | ||||||
| 	// Should not be used by the decoder itself since parent may be another frame.
 | 	// Should not be used by the decoder itself since parent may be another frame.
 | ||||||
|  | @ -512,18 +511,7 @@ func (b *blockDec) decodeCompressed(hist *history) error { | ||||||
| 		nSeqs = 0x7f00 + int(in[1]) + (int(in[2]) << 8) | 		nSeqs = 0x7f00 + int(in[1]) + (int(in[2]) << 8) | ||||||
| 		in = in[3:] | 		in = in[3:] | ||||||
| 	} | 	} | ||||||
| 	// Allocate sequences
 | 
 | ||||||
| 	if cap(b.sequenceBuf) < nSeqs { |  | ||||||
| 		if b.lowMem { |  | ||||||
| 			b.sequenceBuf = make([]seq, nSeqs) |  | ||||||
| 		} else { |  | ||||||
| 			// Allocate max
 |  | ||||||
| 			b.sequenceBuf = make([]seq, nSeqs, maxSequences) |  | ||||||
| 		} |  | ||||||
| 	} else { |  | ||||||
| 		// Reuse buffer
 |  | ||||||
| 		b.sequenceBuf = b.sequenceBuf[:nSeqs] |  | ||||||
| 	} |  | ||||||
| 	var seqs = &sequenceDecs{} | 	var seqs = &sequenceDecs{} | ||||||
| 	if nSeqs > 0 { | 	if nSeqs > 0 { | ||||||
| 		if len(in) < 1 { | 		if len(in) < 1 { | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ package zstd | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
|  | 	"encoding/binary" | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"io" | 	"io" | ||||||
| ) | ) | ||||||
|  | @ -15,18 +16,50 @@ const HeaderMaxSize = 14 + 3 | ||||||
| 
 | 
 | ||||||
| // Header contains information about the first frame and block within that.
 | // Header contains information about the first frame and block within that.
 | ||||||
| type Header struct { | type Header struct { | ||||||
| 	// Window Size the window of data to keep while decoding.
 | 	// SingleSegment specifies whether the data is to be decompressed into a
 | ||||||
| 	// Will only be set if HasFCS is false.
 | 	// single contiguous memory segment.
 | ||||||
| 	WindowSize uint64 | 	// It implies that WindowSize is invalid and that FrameContentSize is valid.
 | ||||||
|  | 	SingleSegment bool | ||||||
| 
 | 
 | ||||||
| 	// Frame content size.
 | 	// WindowSize is the window of data to keep while decoding.
 | ||||||
| 	// Expected size of the entire frame.
 | 	// Will only be set if SingleSegment is false.
 | ||||||
| 	FrameContentSize uint64 | 	WindowSize uint64 | ||||||
| 
 | 
 | ||||||
| 	// Dictionary ID.
 | 	// Dictionary ID.
 | ||||||
| 	// If 0, no dictionary.
 | 	// If 0, no dictionary.
 | ||||||
| 	DictionaryID uint32 | 	DictionaryID uint32 | ||||||
| 
 | 
 | ||||||
|  | 	// HasFCS specifies whether FrameContentSize has a valid value.
 | ||||||
|  | 	HasFCS bool | ||||||
|  | 
 | ||||||
|  | 	// FrameContentSize is the expected uncompressed size of the entire frame.
 | ||||||
|  | 	FrameContentSize uint64 | ||||||
|  | 
 | ||||||
|  | 	// Skippable will be true if the frame is meant to be skipped.
 | ||||||
|  | 	// This implies that FirstBlock.OK is false.
 | ||||||
|  | 	Skippable bool | ||||||
|  | 
 | ||||||
|  | 	// SkippableID is the user-specific ID for the skippable frame.
 | ||||||
|  | 	// Valid values are between 0 to 15, inclusive.
 | ||||||
|  | 	SkippableID int | ||||||
|  | 
 | ||||||
|  | 	// SkippableSize is the length of the user data to skip following
 | ||||||
|  | 	// the header.
 | ||||||
|  | 	SkippableSize uint32 | ||||||
|  | 
 | ||||||
|  | 	// HeaderSize is the raw size of the frame header.
 | ||||||
|  | 	//
 | ||||||
|  | 	// For normal frames, it includes the size of the magic number and
 | ||||||
|  | 	// the size of the header (per section 3.1.1.1).
 | ||||||
|  | 	// It does not include the size for any data blocks (section 3.1.1.2) nor
 | ||||||
|  | 	// the size for the trailing content checksum.
 | ||||||
|  | 	//
 | ||||||
|  | 	// For skippable frames, this counts the size of the magic number
 | ||||||
|  | 	// along with the size of the size field of the payload.
 | ||||||
|  | 	// It does not include the size of the skippable payload itself.
 | ||||||
|  | 	// The total frame size is the HeaderSize plus the SkippableSize.
 | ||||||
|  | 	HeaderSize int | ||||||
|  | 
 | ||||||
| 	// First block information.
 | 	// First block information.
 | ||||||
| 	FirstBlock struct { | 	FirstBlock struct { | ||||||
| 		// OK will be set if first block could be decoded.
 | 		// OK will be set if first block could be decoded.
 | ||||||
|  | @ -51,17 +84,9 @@ type Header struct { | ||||||
| 		CompressedSize int | 		CompressedSize int | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// Skippable will be true if the frame is meant to be skipped.
 |  | ||||||
| 	// No other information will be populated.
 |  | ||||||
| 	Skippable bool |  | ||||||
| 
 |  | ||||||
| 	// If set there is a checksum present for the block content.
 | 	// If set there is a checksum present for the block content.
 | ||||||
|  | 	// The checksum field at the end is always 4 bytes long.
 | ||||||
| 	HasCheckSum bool | 	HasCheckSum bool | ||||||
| 
 |  | ||||||
| 	// If this is true FrameContentSize will have a valid value
 |  | ||||||
| 	HasFCS bool |  | ||||||
| 
 |  | ||||||
| 	SingleSegment bool |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Decode the header from the beginning of the stream.
 | // Decode the header from the beginning of the stream.
 | ||||||
|  | @ -71,39 +96,46 @@ type Header struct { | ||||||
| // If there isn't enough input, io.ErrUnexpectedEOF is returned.
 | // If there isn't enough input, io.ErrUnexpectedEOF is returned.
 | ||||||
| // The FirstBlock.OK will indicate if enough information was available to decode the first block header.
 | // The FirstBlock.OK will indicate if enough information was available to decode the first block header.
 | ||||||
| func (h *Header) Decode(in []byte) error { | func (h *Header) Decode(in []byte) error { | ||||||
|  | 	*h = Header{} | ||||||
| 	if len(in) < 4 { | 	if len(in) < 4 { | ||||||
| 		return io.ErrUnexpectedEOF | 		return io.ErrUnexpectedEOF | ||||||
| 	} | 	} | ||||||
|  | 	h.HeaderSize += 4 | ||||||
| 	b, in := in[:4], in[4:] | 	b, in := in[:4], in[4:] | ||||||
| 	if !bytes.Equal(b, frameMagic) { | 	if !bytes.Equal(b, frameMagic) { | ||||||
| 		if !bytes.Equal(b[1:4], skippableFrameMagic) || b[0]&0xf0 != 0x50 { | 		if !bytes.Equal(b[1:4], skippableFrameMagic) || b[0]&0xf0 != 0x50 { | ||||||
| 			return ErrMagicMismatch | 			return ErrMagicMismatch | ||||||
| 		} | 		} | ||||||
| 		*h = Header{Skippable: true} | 		if len(in) < 4 { | ||||||
|  | 			return io.ErrUnexpectedEOF | ||||||
|  | 		} | ||||||
|  | 		h.HeaderSize += 4 | ||||||
|  | 		h.Skippable = true | ||||||
|  | 		h.SkippableID = int(b[0] & 0xf) | ||||||
|  | 		h.SkippableSize = binary.LittleEndian.Uint32(in) | ||||||
| 		return nil | 		return nil | ||||||
| 	} | 	} | ||||||
| 	if len(in) < 1 { |  | ||||||
| 		return io.ErrUnexpectedEOF |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	// Clear output
 |  | ||||||
| 	*h = Header{} |  | ||||||
| 	fhd, in := in[0], in[1:] |  | ||||||
| 	h.SingleSegment = fhd&(1<<5) != 0 |  | ||||||
| 	h.HasCheckSum = fhd&(1<<2) != 0 |  | ||||||
| 
 |  | ||||||
| 	if fhd&(1<<3) != 0 { |  | ||||||
| 		return errors.New("reserved bit set on frame header") |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	// Read Window_Descriptor
 | 	// Read Window_Descriptor
 | ||||||
| 	// https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#window_descriptor
 | 	// https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#window_descriptor
 | ||||||
|  | 	if len(in) < 1 { | ||||||
|  | 		return io.ErrUnexpectedEOF | ||||||
|  | 	} | ||||||
|  | 	fhd, in := in[0], in[1:] | ||||||
|  | 	h.HeaderSize++ | ||||||
|  | 	h.SingleSegment = fhd&(1<<5) != 0 | ||||||
|  | 	h.HasCheckSum = fhd&(1<<2) != 0 | ||||||
|  | 	if fhd&(1<<3) != 0 { | ||||||
|  | 		return errors.New("reserved bit set on frame header") | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	if !h.SingleSegment { | 	if !h.SingleSegment { | ||||||
| 		if len(in) < 1 { | 		if len(in) < 1 { | ||||||
| 			return io.ErrUnexpectedEOF | 			return io.ErrUnexpectedEOF | ||||||
| 		} | 		} | ||||||
| 		var wd byte | 		var wd byte | ||||||
| 		wd, in = in[0], in[1:] | 		wd, in = in[0], in[1:] | ||||||
|  | 		h.HeaderSize++ | ||||||
| 		windowLog := 10 + (wd >> 3) | 		windowLog := 10 + (wd >> 3) | ||||||
| 		windowBase := uint64(1) << windowLog | 		windowBase := uint64(1) << windowLog | ||||||
| 		windowAdd := (windowBase / 8) * uint64(wd&0x7) | 		windowAdd := (windowBase / 8) * uint64(wd&0x7) | ||||||
|  | @ -120,9 +152,7 @@ func (h *Header) Decode(in []byte) error { | ||||||
| 			return io.ErrUnexpectedEOF | 			return io.ErrUnexpectedEOF | ||||||
| 		} | 		} | ||||||
| 		b, in = in[:size], in[size:] | 		b, in = in[:size], in[size:] | ||||||
| 		if b == nil { | 		h.HeaderSize += int(size) | ||||||
| 			return io.ErrUnexpectedEOF |  | ||||||
| 		} |  | ||||||
| 		switch size { | 		switch size { | ||||||
| 		case 1: | 		case 1: | ||||||
| 			h.DictionaryID = uint32(b[0]) | 			h.DictionaryID = uint32(b[0]) | ||||||
|  | @ -152,9 +182,7 @@ func (h *Header) Decode(in []byte) error { | ||||||
| 			return io.ErrUnexpectedEOF | 			return io.ErrUnexpectedEOF | ||||||
| 		} | 		} | ||||||
| 		b, in = in[:fcsSize], in[fcsSize:] | 		b, in = in[:fcsSize], in[fcsSize:] | ||||||
| 		if b == nil { | 		h.HeaderSize += int(fcsSize) | ||||||
| 			return io.ErrUnexpectedEOF |  | ||||||
| 		} |  | ||||||
| 		switch fcsSize { | 		switch fcsSize { | ||||||
| 		case 1: | 		case 1: | ||||||
| 			h.FrameContentSize = uint64(b[0]) | 			h.FrameContentSize = uint64(b[0]) | ||||||
|  |  | ||||||
|  | @ -24,6 +24,7 @@ type encoderOptions struct { | ||||||
| 	allLitEntropy   bool | 	allLitEntropy   bool | ||||||
| 	customWindow    bool | 	customWindow    bool | ||||||
| 	customALEntropy bool | 	customALEntropy bool | ||||||
|  | 	customBlockSize bool | ||||||
| 	lowMem          bool | 	lowMem          bool | ||||||
| 	dict            *dict | 	dict            *dict | ||||||
| } | } | ||||||
|  | @ -33,7 +34,7 @@ func (o *encoderOptions) setDefault() { | ||||||
| 		concurrent:    runtime.GOMAXPROCS(0), | 		concurrent:    runtime.GOMAXPROCS(0), | ||||||
| 		crc:           true, | 		crc:           true, | ||||||
| 		single:        nil, | 		single:        nil, | ||||||
| 		blockSize:     1 << 16, | 		blockSize:     maxCompressedBlockSize, | ||||||
| 		windowSize:    8 << 20, | 		windowSize:    8 << 20, | ||||||
| 		level:         SpeedDefault, | 		level:         SpeedDefault, | ||||||
| 		allLitEntropy: true, | 		allLitEntropy: true, | ||||||
|  | @ -106,6 +107,7 @@ func WithWindowSize(n int) EOption { | ||||||
| 		o.customWindow = true | 		o.customWindow = true | ||||||
| 		if o.blockSize > o.windowSize { | 		if o.blockSize > o.windowSize { | ||||||
| 			o.blockSize = o.windowSize | 			o.blockSize = o.windowSize | ||||||
|  | 			o.customBlockSize = true | ||||||
| 		} | 		} | ||||||
| 		return nil | 		return nil | ||||||
| 	} | 	} | ||||||
|  | @ -188,10 +190,9 @@ func EncoderLevelFromZstd(level int) EncoderLevel { | ||||||
| 		return SpeedDefault | 		return SpeedDefault | ||||||
| 	case level >= 6 && level < 10: | 	case level >= 6 && level < 10: | ||||||
| 		return SpeedBetterCompression | 		return SpeedBetterCompression | ||||||
| 	case level >= 10: | 	default: | ||||||
| 		return SpeedBestCompression | 		return SpeedBestCompression | ||||||
| 	} | 	} | ||||||
| 	return SpeedDefault |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // String provides a string representation of the compression level.
 | // String provides a string representation of the compression level.
 | ||||||
|  | @ -222,6 +223,9 @@ func WithEncoderLevel(l EncoderLevel) EOption { | ||||||
| 			switch o.level { | 			switch o.level { | ||||||
| 			case SpeedFastest: | 			case SpeedFastest: | ||||||
| 				o.windowSize = 4 << 20 | 				o.windowSize = 4 << 20 | ||||||
|  | 				if !o.customBlockSize { | ||||||
|  | 					o.blockSize = 1 << 16 | ||||||
|  | 				} | ||||||
| 			case SpeedDefault: | 			case SpeedDefault: | ||||||
| 				o.windowSize = 8 << 20 | 				o.windowSize = 8 << 20 | ||||||
| 			case SpeedBetterCompression: | 			case SpeedBetterCompression: | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| // +build !appengine | // +build !appengine | ||||||
| // +build gc | // +build gc | ||||||
| // +build !purego | // +build !purego | ||||||
|  | // +build !noasm | ||||||
| 
 | 
 | ||||||
| #include "textflag.h" | #include "textflag.h" | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,13 +1,13 @@ | ||||||
| // +build gc,!purego | // +build gc,!purego,!noasm | ||||||
| 
 | 
 | ||||||
| #include "textflag.h" | #include "textflag.h" | ||||||
| 
 | 
 | ||||||
| // Register allocation. | // Register allocation. | ||||||
| #define digest	R1 | #define digest	R1 | ||||||
| #define h	R2	// Return value. | #define h	R2 // Return value. | ||||||
| #define p	R3	// Input pointer. | #define p	R3 // Input pointer. | ||||||
| #define len	R4 | #define len	R4 | ||||||
| #define nblocks	R5	// len / 32. | #define nblocks	R5 // len / 32. | ||||||
| #define prime1	R7 | #define prime1	R7 | ||||||
| #define prime2	R8 | #define prime2	R8 | ||||||
| #define prime3	R9 | #define prime3	R9 | ||||||
|  | @ -22,50 +22,48 @@ | ||||||
| #define x3	R22 | #define x3	R22 | ||||||
| #define x4	R23 | #define x4	R23 | ||||||
| 
 | 
 | ||||||
| #define round(acc, x) 			\ | #define round(acc, x) \ | ||||||
| 	MADD prime2, acc, x, acc	\ | 	MADD prime2, acc, x, acc \ | ||||||
| 	ROR  $64-31, acc		\ | 	ROR  $64-31, acc         \ | ||||||
| 	MUL  prime1, acc		\ | 	MUL  prime1, acc         \ | ||||||
| 
 | 
 | ||||||
| // x = round(0, x). | // x = round(0, x). | ||||||
| #define round0(x)	\ | #define round0(x) \ | ||||||
| 	MUL prime2, x	\ | 	MUL prime2, x \ | ||||||
| 	ROR $64-31, x	\ | 	ROR $64-31, x \ | ||||||
| 	MUL prime1, x	\ | 	MUL prime1, x \ | ||||||
| 
 | 
 | ||||||
| #define mergeRound(x)			\ | #define mergeRound(x) \ | ||||||
| 	round0(x)			\ | 	round0(x)                 \ | ||||||
| 	EOR  x, h			\ | 	EOR  x, h                 \ | ||||||
| 	MADD h, prime4, prime1, h	\ | 	MADD h, prime4, prime1, h \ | ||||||
| 
 | 
 | ||||||
| // Update v[1-4] with 32-byte blocks. Assumes len >= 32. | // Update v[1-4] with 32-byte blocks. Assumes len >= 32. | ||||||
| #define blocksLoop()		\ | #define blocksLoop() \ | ||||||
| 	LSR  $5, len, nblocks	\ | 	LSR     $5, len, nblocks \ | ||||||
| 	PCALIGN $16		\ | 	PCALIGN $16              \ | ||||||
| loop:				\ | 	loop:                    \ | ||||||
| 	LDP.P 32(p), (x1, x2)	\ | 	LDP.P   32(p), (x1, x2)  \ | ||||||
| 	round(v1, x1)		\ | 	round(v1, x1)            \ | ||||||
| 	LDP  -16(p), (x3, x4)	\ | 	LDP     -16(p), (x3, x4) \ | ||||||
| 	round(v2, x2)		\ | 	round(v2, x2)            \ | ||||||
| 	SUB  $1, nblocks	\ | 	SUB     $1, nblocks      \ | ||||||
| 	round(v3, x3)		\ | 	round(v3, x3)            \ | ||||||
| 	round(v4, x4)		\ | 	round(v4, x4)            \ | ||||||
| 	CBNZ nblocks, loop	\ | 	CBNZ    nblocks, loop    \ | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| // The primes are repeated here to ensure that they're stored | // The primes are repeated here to ensure that they're stored | ||||||
| // in a contiguous array, so we can load them with LDP. | // in a contiguous array, so we can load them with LDP. | ||||||
| DATA  primes<> +0(SB)/8, $11400714785074694791 | DATA primes<> +0(SB)/8, $11400714785074694791 | ||||||
| DATA  primes<> +8(SB)/8, $14029467366897019727 | DATA primes<> +8(SB)/8, $14029467366897019727 | ||||||
| DATA  primes<>+16(SB)/8, $1609587929392839161 | DATA primes<>+16(SB)/8, $1609587929392839161 | ||||||
| DATA  primes<>+24(SB)/8, $9650029242287828579 | DATA primes<>+24(SB)/8, $9650029242287828579 | ||||||
| DATA  primes<>+32(SB)/8, $2870177450012600261 | DATA primes<>+32(SB)/8, $2870177450012600261 | ||||||
| GLOBL primes<>(SB), NOPTR+RODATA, $40 | GLOBL primes<>(SB), NOPTR+RODATA, $40 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| // func Sum64(b []byte) uint64 | // func Sum64(b []byte) uint64 | ||||||
| TEXT ·Sum64(SB), NOFRAME+NOSPLIT, $0-32 | TEXT ·Sum64(SB), NOFRAME+NOSPLIT, $0-32 | ||||||
| 	LDP  b_base+0(FP), (p, len) | 	LDP b_base+0(FP), (p, len) | ||||||
| 
 | 
 | ||||||
| 	LDP  primes<> +0(SB), (prime1, prime2) | 	LDP  primes<> +0(SB), (prime1, prime2) | ||||||
| 	LDP  primes<>+16(SB), (prime3, prime4) | 	LDP  primes<>+16(SB), (prime3, prime4) | ||||||
|  | @ -156,24 +154,23 @@ try1: | ||||||
| 
 | 
 | ||||||
| end: | end: | ||||||
| 	EOR h >> 33, h | 	EOR h >> 33, h | ||||||
| 	MUL prime2,  h | 	MUL prime2, h | ||||||
| 	EOR h >> 29, h | 	EOR h >> 29, h | ||||||
| 	MUL prime3,  h | 	MUL prime3, h | ||||||
| 	EOR h >> 32, h | 	EOR h >> 32, h | ||||||
| 
 | 
 | ||||||
| 	MOVD h, ret+24(FP) | 	MOVD h, ret+24(FP) | ||||||
| 	RET | 	RET | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| // func writeBlocks(d *Digest, b []byte) int | // func writeBlocks(d *Digest, b []byte) int | ||||||
| // | // | ||||||
| // Assumes len(b) >= 32. | // Assumes len(b) >= 32. | ||||||
| TEXT ·writeBlocks(SB), NOFRAME+NOSPLIT, $0-40 | TEXT ·writeBlocks(SB), NOFRAME+NOSPLIT, $0-40 | ||||||
| 	LDP  primes<>(SB), (prime1, prime2) | 	LDP primes<>(SB), (prime1, prime2) | ||||||
| 
 | 
 | ||||||
| 	// Load state. Assume v[1-4] are stored contiguously. | 	// Load state. Assume v[1-4] are stored contiguously. | ||||||
| 	MOVD d+0(FP), digest | 	MOVD d+0(FP), digest | ||||||
| 	LDP   0(digest), (v1, v2) | 	LDP  0(digest), (v1, v2) | ||||||
| 	LDP  16(digest), (v3, v4) | 	LDP  16(digest), (v3, v4) | ||||||
| 
 | 
 | ||||||
| 	LDP b_base+8(FP), (p, len) | 	LDP b_base+8(FP), (p, len) | ||||||
|  | @ -181,7 +178,7 @@ TEXT ·writeBlocks(SB), NOFRAME+NOSPLIT, $0-40 | ||||||
| 	blocksLoop() | 	blocksLoop() | ||||||
| 
 | 
 | ||||||
| 	// Store updated state. | 	// Store updated state. | ||||||
| 	STP (v1, v2),  0(digest) | 	STP (v1, v2), 0(digest) | ||||||
| 	STP (v3, v4), 16(digest) | 	STP (v3, v4), 16(digest) | ||||||
| 
 | 
 | ||||||
| 	BIC  $31, len | 	BIC  $31, len | ||||||
|  |  | ||||||
|  | @ -1,8 +1,9 @@ | ||||||
| //go:build (amd64 || arm64) && !appengine && gc && !purego
 | //go:build (amd64 || arm64) && !appengine && gc && !purego && !noasm
 | ||||||
| // +build amd64 arm64
 | // +build amd64 arm64
 | ||||||
| // +build !appengine
 | // +build !appengine
 | ||||||
| // +build gc
 | // +build gc
 | ||||||
| // +build !purego
 | // +build !purego
 | ||||||
|  | // +build !noasm
 | ||||||
| 
 | 
 | ||||||
| package xxhash | package xxhash | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| //go:build (!amd64 && !arm64) || appengine || !gc || purego
 | //go:build (!amd64 && !arm64) || appengine || !gc || purego || noasm
 | ||||||
| // +build !amd64,!arm64 appengine !gc purego
 | // +build !amd64,!arm64 appengine !gc purego noasm
 | ||||||
| 
 | 
 | ||||||
| package xxhash | package xxhash | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -69,7 +69,7 @@ github.com/containerd/containerd/log | ||||||
| github.com/containerd/containerd/pkg/userns | github.com/containerd/containerd/pkg/userns | ||||||
| github.com/containerd/containerd/platforms | github.com/containerd/containerd/platforms | ||||||
| github.com/containerd/containerd/sys | github.com/containerd/containerd/sys | ||||||
| # github.com/containerd/stargz-snapshotter/estargz v0.10.1 | # github.com/containerd/stargz-snapshotter/estargz v0.11.0 | ||||||
| github.com/containerd/stargz-snapshotter/estargz | github.com/containerd/stargz-snapshotter/estargz | ||||||
| github.com/containerd/stargz-snapshotter/estargz/errorutil | github.com/containerd/stargz-snapshotter/estargz/errorutil | ||||||
| # github.com/containernetworking/cni v1.0.1 | # github.com/containernetworking/cni v1.0.1 | ||||||
|  | @ -109,7 +109,7 @@ github.com/containers/buildah/pkg/rusage | ||||||
| github.com/containers/buildah/pkg/sshagent | github.com/containers/buildah/pkg/sshagent | ||||||
| github.com/containers/buildah/pkg/util | github.com/containers/buildah/pkg/util | ||||||
| github.com/containers/buildah/util | github.com/containers/buildah/util | ||||||
| # github.com/containers/common v0.47.1 | # github.com/containers/common v0.47.2 | ||||||
| ## explicit | ## explicit | ||||||
| github.com/containers/common/libimage | github.com/containers/common/libimage | ||||||
| github.com/containers/common/libimage/manifests | github.com/containers/common/libimage/manifests | ||||||
|  | @ -231,7 +231,7 @@ github.com/containers/psgo/internal/dev | ||||||
| github.com/containers/psgo/internal/host | github.com/containers/psgo/internal/host | ||||||
| github.com/containers/psgo/internal/proc | github.com/containers/psgo/internal/proc | ||||||
| github.com/containers/psgo/internal/process | github.com/containers/psgo/internal/process | ||||||
| # github.com/containers/storage v1.38.1 | # github.com/containers/storage v1.38.2 | ||||||
| ## explicit | ## explicit | ||||||
| github.com/containers/storage | github.com/containers/storage | ||||||
| github.com/containers/storage/drivers | github.com/containers/storage/drivers | ||||||
|  | @ -456,7 +456,7 @@ github.com/jinzhu/copier | ||||||
| # github.com/json-iterator/go v1.1.12 | # github.com/json-iterator/go v1.1.12 | ||||||
| ## explicit | ## explicit | ||||||
| github.com/json-iterator/go | github.com/json-iterator/go | ||||||
| # github.com/klauspost/compress v1.14.1 | # github.com/klauspost/compress v1.14.2 | ||||||
| github.com/klauspost/compress | github.com/klauspost/compress | ||||||
| github.com/klauspost/compress/flate | github.com/klauspost/compress/flate | ||||||
| github.com/klauspost/compress/fse | github.com/klauspost/compress/fse | ||||||
|  | @ -539,7 +539,7 @@ github.com/onsi/ginkgo/reporters/stenographer | ||||||
| github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable | github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable | ||||||
| github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty | github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty | ||||||
| github.com/onsi/ginkgo/types | github.com/onsi/ginkgo/types | ||||||
| # github.com/onsi/gomega v1.18.0 => github.com/onsi/gomega v1.16.0 | # github.com/onsi/gomega v1.18.1 => github.com/onsi/gomega v1.16.0 | ||||||
| ## explicit | ## explicit | ||||||
| github.com/onsi/gomega | github.com/onsi/gomega | ||||||
| github.com/onsi/gomega/format | github.com/onsi/gomega/format | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue