Merge remote-tracking branch 'upstream/master' into add-volume-parameter2
This commit is contained in:
		
						commit
						fb780fde35
					
				
							
								
								
									
										10
									
								
								CHANGELOG.md
								
								
								
								
							
							
						
						
									
										10
									
								
								CHANGELOG.md
								
								
								
								
							|  | @ -1,3 +1,13 @@ | |||
| # v4.0.3 | ||||
| 
 | ||||
| - Prevent mounting of root directory on empty customPath (https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/pull/83) | ||||
| - Upgrade k8s client to v1.23.4 (https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/pull/175) | ||||
| - Add error handling to chmod on volume creation (https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/pull/176) | ||||
| - Import GetPersistentVolumeClass from component-helpers (https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/pull/189) | ||||
| - Resolve CVE-2022-27191 in golang.org/x/crypto (https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/pull/207) | ||||
| - Fix onDelete option for subdirectories (https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/pull/221) | ||||
| - Resolve all trivy vulnerabilities up to 2024-01-25 (https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/pull/327) | ||||
| 
 | ||||
| # v4.0.2 | ||||
| - Add arm7 (32bit) support (https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/pull/58) | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										14
									
								
								go.mod
								
								
								
								
							
							
						
						
									
										14
									
								
								go.mod
								
								
								
								
							|  | @ -34,12 +34,12 @@ require ( | |||
| 	github.com/prometheus/common v0.26.0 // indirect | ||||
| 	github.com/prometheus/procfs v0.6.0 // indirect | ||||
| 	github.com/spf13/pflag v1.0.5 // indirect | ||||
| 	golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect | ||||
| 	golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect | ||||
| 	golang.org/x/crypto v0.14.0 // indirect | ||||
| 	golang.org/x/net v0.10.0 // indirect | ||||
| 	golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect | ||||
| 	golang.org/x/sys v0.5.0 // indirect | ||||
| 	golang.org/x/term v0.5.0 // indirect | ||||
| 	golang.org/x/text v0.7.0 // indirect | ||||
| 	golang.org/x/sys v0.15.0 // indirect | ||||
| 	golang.org/x/term v0.15.0 // indirect | ||||
| 	golang.org/x/text v0.14.0 // indirect | ||||
| 	golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect | ||||
| 	google.golang.org/appengine v1.6.7 // indirect | ||||
| 	google.golang.org/protobuf v1.27.1 // indirect | ||||
|  | @ -57,8 +57,8 @@ require ( | |||
| 
 | ||||
| replace ( | ||||
| 	github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.11.1 | ||||
| 	golang.org/x/crypto => golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd | ||||
| 	golang.org/x/net => golang.org/x/net v0.7.0 | ||||
| 	golang.org/x/crypto => golang.org/x/crypto v0.17.0 | ||||
| 	golang.org/x/net => golang.org/x/net v0.17.0 | ||||
| 	gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.0-20220521103104-8f96da9f5d5e | ||||
| 	k8s.io/api => k8s.io/api v0.23.4 | ||||
| 	k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.23.4 | ||||
|  |  | |||
							
								
								
									
										30
									
								
								go.sum
								
								
								
								
							
							
						
						
									
										30
									
								
								go.sum
								
								
								
								
							|  | @ -275,8 +275,8 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= | |||
| go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= | ||||
| go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= | ||||
| go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= | ||||
| golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38= | ||||
| golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= | ||||
| golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= | ||||
| golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= | ||||
| golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= | ||||
| golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= | ||||
| golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= | ||||
|  | @ -312,8 +312,9 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= | |||
| golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= | ||||
| golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= | ||||
| golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= | ||||
| golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= | ||||
| golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= | ||||
| golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= | ||||
| golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= | ||||
| golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= | ||||
| golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= | ||||
| golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= | ||||
| golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= | ||||
|  | @ -338,8 +339,9 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ | |||
| golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw= | ||||
| golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= | ||||
| golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||
| golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||
| golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||
|  | @ -373,7 +375,6 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w | |||
| golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
|  | @ -386,12 +387,14 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc | |||
| golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= | ||||
| golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||||
| golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= | ||||
| golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||||
| golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= | ||||
| golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= | ||||
| golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= | ||||
| golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= | ||||
| golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= | ||||
| golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= | ||||
| golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||||
| golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||||
| golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||||
|  | @ -399,10 +402,10 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= | |||
| golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||||
| golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||||
| golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||||
| golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||||
| golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | ||||
| golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= | ||||
| golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= | ||||
| golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= | ||||
| golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= | ||||
| golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= | ||||
| golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||||
| golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||||
| golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||||
|  | @ -460,6 +463,7 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f | |||
| golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= | ||||
| golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= | ||||
| golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= | ||||
| golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= | ||||
| golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
|  |  | |||
|  | @ -1,3 +0,0 @@ | |||
| # This source code refers to The Go Authors for copyright purposes. | ||||
| # The master list of authors is in the main Go distribution, | ||||
| # visible at https://tip.golang.org/AUTHORS. | ||||
|  | @ -1,3 +0,0 @@ | |||
| # This source code was written by the Go contributors. | ||||
| # The master list of contributors is in the main Go distribution, | ||||
| # visible at https://tip.golang.org/CONTRIBUTORS. | ||||
|  | @ -1,51 +0,0 @@ | |||
| # | ||||
| # This Dockerfile builds a recent curl with HTTP/2 client support, using | ||||
| # a recent nghttp2 build. | ||||
| # | ||||
| # See the Makefile for how to tag it. If Docker and that image is found, the | ||||
| # Go tests use this curl binary for integration tests. | ||||
| # | ||||
| 
 | ||||
| FROM ubuntu:trusty | ||||
| 
 | ||||
| RUN apt-get update && \ | ||||
|     apt-get upgrade -y && \ | ||||
|     apt-get install -y git-core build-essential wget | ||||
| 
 | ||||
| RUN apt-get install -y --no-install-recommends \ | ||||
|        autotools-dev libtool pkg-config zlib1g-dev \ | ||||
|        libcunit1-dev libssl-dev libxml2-dev libevent-dev \ | ||||
|        automake autoconf | ||||
| 
 | ||||
| # The list of packages nghttp2 recommends for h2load: | ||||
| RUN apt-get install -y --no-install-recommends make binutils \ | ||||
|         autoconf automake autotools-dev \ | ||||
|         libtool pkg-config zlib1g-dev libcunit1-dev libssl-dev libxml2-dev \ | ||||
|         libev-dev libevent-dev libjansson-dev libjemalloc-dev \ | ||||
|         cython python3.4-dev python-setuptools | ||||
| 
 | ||||
| # Note: setting NGHTTP2_VER before the git clone, so an old git clone isn't cached: | ||||
| ENV NGHTTP2_VER 895da9a | ||||
| RUN cd /root && git clone https://github.com/tatsuhiro-t/nghttp2.git | ||||
| 
 | ||||
| WORKDIR /root/nghttp2 | ||||
| RUN git reset --hard $NGHTTP2_VER | ||||
| RUN autoreconf -i | ||||
| RUN automake | ||||
| RUN autoconf | ||||
| RUN ./configure | ||||
| RUN make | ||||
| RUN make install | ||||
| 
 | ||||
| WORKDIR /root | ||||
| RUN wget https://curl.se/download/curl-7.45.0.tar.gz | ||||
| RUN tar -zxvf curl-7.45.0.tar.gz | ||||
| WORKDIR /root/curl-7.45.0 | ||||
| RUN ./configure --with-ssl --with-nghttp2=/usr/local | ||||
| RUN make | ||||
| RUN make install | ||||
| RUN ldconfig | ||||
| 
 | ||||
| CMD ["-h"] | ||||
| ENTRYPOINT ["/usr/local/bin/curl"] | ||||
| 
 | ||||
|  | @ -1,3 +0,0 @@ | |||
| curlimage: | ||||
| 	docker build -t gohttp2/curl . | ||||
| 
 | ||||
|  | @ -88,13 +88,9 @@ func (p *pipe) Write(d []byte) (n int, err error) { | |||
| 		p.c.L = &p.mu | ||||
| 	} | ||||
| 	defer p.c.Signal() | ||||
| 	if p.err != nil { | ||||
| 	if p.err != nil || p.breakErr != nil { | ||||
| 		return 0, errClosedPipeWrite | ||||
| 	} | ||||
| 	if p.breakErr != nil { | ||||
| 		p.unread += len(d) | ||||
| 		return len(d), nil // discard when there is no reader
 | ||||
| 	} | ||||
| 	return p.b.Write(d) | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -441,7 +441,7 @@ func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) { | |||
| 	if s.NewWriteScheduler != nil { | ||||
| 		sc.writeSched = s.NewWriteScheduler() | ||||
| 	} else { | ||||
| 		sc.writeSched = NewPriorityWriteScheduler(nil) | ||||
| 		sc.writeSched = newRoundRobinWriteScheduler() | ||||
| 	} | ||||
| 
 | ||||
| 	// These start at the RFC-specified defaults. If there is a higher
 | ||||
|  | @ -581,9 +581,11 @@ type serverConn struct { | |||
| 	advMaxStreams               uint32 // our SETTINGS_MAX_CONCURRENT_STREAMS advertised the client
 | ||||
| 	curClientStreams            uint32 // number of open streams initiated by the client
 | ||||
| 	curPushedStreams            uint32 // number of open streams initiated by server push
 | ||||
| 	curHandlers                 uint32 // number of running handler goroutines
 | ||||
| 	maxClientStreamID           uint32 // max ever seen from client (odd), or 0 if there have been no client requests
 | ||||
| 	maxPushPromiseID            uint32 // ID of the last push promise (even), or 0 if there have been no pushes
 | ||||
| 	streams                     map[uint32]*stream | ||||
| 	unstartedHandlers           []unstartedHandler | ||||
| 	initialStreamSendWindowSize int32 | ||||
| 	maxFrameSize                int32 | ||||
| 	peerMaxHeaderListSize       uint32            // zero means unknown (default)
 | ||||
|  | @ -981,6 +983,8 @@ func (sc *serverConn) serve() { | |||
| 					return | ||||
| 				case gracefulShutdownMsg: | ||||
| 					sc.startGracefulShutdownInternal() | ||||
| 				case handlerDoneMsg: | ||||
| 					sc.handlerDone() | ||||
| 				default: | ||||
| 					panic("unknown timer") | ||||
| 				} | ||||
|  | @ -1012,14 +1016,6 @@ func (sc *serverConn) serve() { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (sc *serverConn) awaitGracefulShutdown(sharedCh <-chan struct{}, privateCh chan struct{}) { | ||||
| 	select { | ||||
| 	case <-sc.doneServing: | ||||
| 	case <-sharedCh: | ||||
| 		close(privateCh) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| type serverMessage int | ||||
| 
 | ||||
| // Message values sent to serveMsgCh.
 | ||||
|  | @ -1028,6 +1024,7 @@ var ( | |||
| 	idleTimerMsg        = new(serverMessage) | ||||
| 	shutdownTimerMsg    = new(serverMessage) | ||||
| 	gracefulShutdownMsg = new(serverMessage) | ||||
| 	handlerDoneMsg      = new(serverMessage) | ||||
| ) | ||||
| 
 | ||||
| func (sc *serverConn) onSettingsTimer() { sc.sendServeMsg(settingsTimerMsg) } | ||||
|  | @ -1822,15 +1819,18 @@ func (sc *serverConn) processData(f *DataFrame) error { | |||
| 		} | ||||
| 
 | ||||
| 		if len(data) > 0 { | ||||
| 			st.bodyBytes += int64(len(data)) | ||||
| 			wrote, err := st.body.Write(data) | ||||
| 			if err != nil { | ||||
| 				// The handler has closed the request body.
 | ||||
| 				// Return the connection-level flow control for the discarded data,
 | ||||
| 				// but not the stream-level flow control.
 | ||||
| 				sc.sendWindowUpdate(nil, int(f.Length)-wrote) | ||||
| 				return sc.countError("body_write_err", streamError(id, ErrCodeStreamClosed)) | ||||
| 				return nil | ||||
| 			} | ||||
| 			if wrote != len(data) { | ||||
| 				panic("internal error: bad Writer") | ||||
| 			} | ||||
| 			st.bodyBytes += int64(len(data)) | ||||
| 		} | ||||
| 
 | ||||
| 		// Return any padded flow control now, since we won't
 | ||||
|  | @ -1897,9 +1897,11 @@ func (st *stream) copyTrailersToHandlerRequest() { | |||
| // onReadTimeout is run on its own goroutine (from time.AfterFunc)
 | ||||
| // when the stream's ReadTimeout has fired.
 | ||||
| func (st *stream) onReadTimeout() { | ||||
| 	// Wrap the ErrDeadlineExceeded to avoid callers depending on us
 | ||||
| 	// returning the bare error.
 | ||||
| 	st.body.CloseWithError(fmt.Errorf("%w", os.ErrDeadlineExceeded)) | ||||
| 	if st.body != nil { | ||||
| 		// Wrap the ErrDeadlineExceeded to avoid callers depending on us
 | ||||
| 		// returning the bare error.
 | ||||
| 		st.body.CloseWithError(fmt.Errorf("%w", os.ErrDeadlineExceeded)) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // onWriteTimeout is run on its own goroutine (from time.AfterFunc)
 | ||||
|  | @ -2017,13 +2019,10 @@ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error { | |||
| 	// (in Go 1.8), though. That's a more sane option anyway.
 | ||||
| 	if sc.hs.ReadTimeout != 0 { | ||||
| 		sc.conn.SetReadDeadline(time.Time{}) | ||||
| 		if st.body != nil { | ||||
| 			st.readDeadline = time.AfterFunc(sc.hs.ReadTimeout, st.onReadTimeout) | ||||
| 		} | ||||
| 		st.readDeadline = time.AfterFunc(sc.hs.ReadTimeout, st.onReadTimeout) | ||||
| 	} | ||||
| 
 | ||||
| 	go sc.runHandler(rw, req, handler) | ||||
| 	return nil | ||||
| 	return sc.scheduleHandler(id, rw, req, handler) | ||||
| } | ||||
| 
 | ||||
| func (sc *serverConn) upgradeRequest(req *http.Request) { | ||||
|  | @ -2043,6 +2042,10 @@ func (sc *serverConn) upgradeRequest(req *http.Request) { | |||
| 		sc.conn.SetReadDeadline(time.Time{}) | ||||
| 	} | ||||
| 
 | ||||
| 	// This is the first request on the connection,
 | ||||
| 	// so start the handler directly rather than going
 | ||||
| 	// through scheduleHandler.
 | ||||
| 	sc.curHandlers++ | ||||
| 	go sc.runHandler(rw, req, sc.handler.ServeHTTP) | ||||
| } | ||||
| 
 | ||||
|  | @ -2283,8 +2286,62 @@ func (sc *serverConn) newResponseWriter(st *stream, req *http.Request) *response | |||
| 	return &responseWriter{rws: rws} | ||||
| } | ||||
| 
 | ||||
| type unstartedHandler struct { | ||||
| 	streamID uint32 | ||||
| 	rw       *responseWriter | ||||
| 	req      *http.Request | ||||
| 	handler  func(http.ResponseWriter, *http.Request) | ||||
| } | ||||
| 
 | ||||
| // scheduleHandler starts a handler goroutine,
 | ||||
| // or schedules one to start as soon as an existing handler finishes.
 | ||||
| func (sc *serverConn) scheduleHandler(streamID uint32, rw *responseWriter, req *http.Request, handler func(http.ResponseWriter, *http.Request)) error { | ||||
| 	sc.serveG.check() | ||||
| 	maxHandlers := sc.advMaxStreams | ||||
| 	if sc.curHandlers < maxHandlers { | ||||
| 		sc.curHandlers++ | ||||
| 		go sc.runHandler(rw, req, handler) | ||||
| 		return nil | ||||
| 	} | ||||
| 	if len(sc.unstartedHandlers) > int(4*sc.advMaxStreams) { | ||||
| 		return sc.countError("too_many_early_resets", ConnectionError(ErrCodeEnhanceYourCalm)) | ||||
| 	} | ||||
| 	sc.unstartedHandlers = append(sc.unstartedHandlers, unstartedHandler{ | ||||
| 		streamID: streamID, | ||||
| 		rw:       rw, | ||||
| 		req:      req, | ||||
| 		handler:  handler, | ||||
| 	}) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (sc *serverConn) handlerDone() { | ||||
| 	sc.serveG.check() | ||||
| 	sc.curHandlers-- | ||||
| 	i := 0 | ||||
| 	maxHandlers := sc.advMaxStreams | ||||
| 	for ; i < len(sc.unstartedHandlers); i++ { | ||||
| 		u := sc.unstartedHandlers[i] | ||||
| 		if sc.streams[u.streamID] == nil { | ||||
| 			// This stream was reset before its goroutine had a chance to start.
 | ||||
| 			continue | ||||
| 		} | ||||
| 		if sc.curHandlers >= maxHandlers { | ||||
| 			break | ||||
| 		} | ||||
| 		sc.curHandlers++ | ||||
| 		go sc.runHandler(u.rw, u.req, u.handler) | ||||
| 		sc.unstartedHandlers[i] = unstartedHandler{} // don't retain references
 | ||||
| 	} | ||||
| 	sc.unstartedHandlers = sc.unstartedHandlers[i:] | ||||
| 	if len(sc.unstartedHandlers) == 0 { | ||||
| 		sc.unstartedHandlers = nil | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // Run on its own goroutine.
 | ||||
| func (sc *serverConn) runHandler(rw *responseWriter, req *http.Request, handler func(http.ResponseWriter, *http.Request)) { | ||||
| 	defer sc.sendServeMsg(handlerDoneMsg) | ||||
| 	didPanic := true | ||||
| 	defer func() { | ||||
| 		rw.rws.stream.cancelCtx() | ||||
|  | @ -2426,7 +2483,7 @@ type requestBody struct { | |||
| 	conn          *serverConn | ||||
| 	closeOnce     sync.Once // for use by Close only
 | ||||
| 	sawEOF        bool      // for use by Read only
 | ||||
| 	pipe          *pipe     // non-nil if we have a HTTP entity message body
 | ||||
| 	pipe          *pipe     // non-nil if we have an HTTP entity message body
 | ||||
| 	needsContinue bool      // need to send a 100-continue
 | ||||
| } | ||||
| 
 | ||||
|  | @ -2566,7 +2623,8 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { | |||
| 				clen = "" | ||||
| 			} | ||||
| 		} | ||||
| 		if clen == "" && rws.handlerDone && bodyAllowedForStatus(rws.status) && (len(p) > 0 || !isHeadResp) { | ||||
| 		_, hasContentLength := rws.snapHeader["Content-Length"] | ||||
| 		if !hasContentLength && clen == "" && rws.handlerDone && bodyAllowedForStatus(rws.status) && (len(p) > 0 || !isHeadResp) { | ||||
| 			clen = strconv.Itoa(len(p)) | ||||
| 		} | ||||
| 		_, hasContentType := rws.snapHeader["Content-Type"] | ||||
|  | @ -2771,7 +2829,7 @@ func (w *responseWriter) FlushError() error { | |||
| 		err = rws.bw.Flush() | ||||
| 	} else { | ||||
| 		// The bufio.Writer won't call chunkWriter.Write
 | ||||
| 		// (writeChunk with zero bytes, so we have to do it
 | ||||
| 		// (writeChunk with zero bytes), so we have to do it
 | ||||
| 		// ourselves to force the HTTP response header and/or
 | ||||
| 		// final DATA frame (with END_STREAM) to be sent.
 | ||||
| 		_, err = chunkWriter{rws}.Write(nil) | ||||
|  |  | |||
|  | @ -19,6 +19,7 @@ import ( | |||
| 	"io/fs" | ||||
| 	"log" | ||||
| 	"math" | ||||
| 	"math/bits" | ||||
| 	mathrand "math/rand" | ||||
| 	"net" | ||||
| 	"net/http" | ||||
|  | @ -290,8 +291,7 @@ func (t *Transport) initConnPool() { | |||
| // HTTP/2 server.
 | ||||
| type ClientConn struct { | ||||
| 	t             *Transport | ||||
| 	tconn         net.Conn // usually *tls.Conn, except specialized impls
 | ||||
| 	tconnClosed   bool | ||||
| 	tconn         net.Conn             // usually *tls.Conn, except specialized impls
 | ||||
| 	tlsState      *tls.ConnectionState // nil only for specialized impls
 | ||||
| 	reused        uint32               // whether conn is being reused; atomic
 | ||||
| 	singleUse     bool                 // whether being used for a single http.Request
 | ||||
|  | @ -518,11 +518,14 @@ func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { | |||
| func authorityAddr(scheme string, authority string) (addr string) { | ||||
| 	host, port, err := net.SplitHostPort(authority) | ||||
| 	if err != nil { // authority didn't have a port
 | ||||
| 		host = authority | ||||
| 		port = "" | ||||
| 	} | ||||
| 	if port == "" { // authority's port was empty
 | ||||
| 		port = "443" | ||||
| 		if scheme == "http" { | ||||
| 			port = "80" | ||||
| 		} | ||||
| 		host = authority | ||||
| 	} | ||||
| 	if a, err := idna.ToASCII(host); err == nil { | ||||
| 		host = a | ||||
|  | @ -560,10 +563,11 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res | |||
| 		traceGotConn(req, cc, reused) | ||||
| 		res, err := cc.RoundTrip(req) | ||||
| 		if err != nil && retry <= 6 { | ||||
| 			roundTripErr := err | ||||
| 			if req, err = shouldRetryRequest(req, err); err == nil { | ||||
| 				// After the first retry, do exponential backoff with 10% jitter.
 | ||||
| 				if retry == 0 { | ||||
| 					t.vlogf("RoundTrip retrying after failure: %v", err) | ||||
| 					t.vlogf("RoundTrip retrying after failure: %v", roundTripErr) | ||||
| 					continue | ||||
| 				} | ||||
| 				backoff := float64(uint(1) << (uint(retry) - 1)) | ||||
|  | @ -572,7 +576,7 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res | |||
| 				timer := backoffNewTimer(d) | ||||
| 				select { | ||||
| 				case <-timer.C: | ||||
| 					t.vlogf("RoundTrip retrying after failure: %v", err) | ||||
| 					t.vlogf("RoundTrip retrying after failure: %v", roundTripErr) | ||||
| 					continue | ||||
| 				case <-req.Context().Done(): | ||||
| 					timer.Stop() | ||||
|  | @ -1265,6 +1269,29 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { | |||
| 		return res, nil | ||||
| 	} | ||||
| 
 | ||||
| 	cancelRequest := func(cs *clientStream, err error) error { | ||||
| 		cs.cc.mu.Lock() | ||||
| 		bodyClosed := cs.reqBodyClosed | ||||
| 		cs.cc.mu.Unlock() | ||||
| 		// Wait for the request body to be closed.
 | ||||
| 		//
 | ||||
| 		// If nothing closed the body before now, abortStreamLocked
 | ||||
| 		// will have started a goroutine to close it.
 | ||||
| 		//
 | ||||
| 		// Closing the body before returning avoids a race condition
 | ||||
| 		// with net/http checking its readTrackingBody to see if the
 | ||||
| 		// body was read from or closed. See golang/go#60041.
 | ||||
| 		//
 | ||||
| 		// The body is closed in a separate goroutine without the
 | ||||
| 		// connection mutex held, but dropping the mutex before waiting
 | ||||
| 		// will keep us from holding it indefinitely if the body
 | ||||
| 		// close is slow for some reason.
 | ||||
| 		if bodyClosed != nil { | ||||
| 			<-bodyClosed | ||||
| 		} | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	for { | ||||
| 		select { | ||||
| 		case <-cs.respHeaderRecv: | ||||
|  | @ -1284,10 +1311,10 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { | |||
| 		case <-ctx.Done(): | ||||
| 			err := ctx.Err() | ||||
| 			cs.abortStream(err) | ||||
| 			return nil, err | ||||
| 			return nil, cancelRequest(cs, err) | ||||
| 		case <-cs.reqCancel: | ||||
| 			cs.abortStream(errRequestCanceled) | ||||
| 			return nil, errRequestCanceled | ||||
| 			return nil, cancelRequest(cs, errRequestCanceled) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | @ -1653,7 +1680,27 @@ func (cs *clientStream) frameScratchBufferLen(maxFrameSize int) int { | |||
| 	return int(n) // doesn't truncate; max is 512K
 | ||||
| } | ||||
| 
 | ||||
| var bufPool sync.Pool // of *[]byte
 | ||||
| // Seven bufPools manage different frame sizes. This helps to avoid scenarios where long-running
 | ||||
| // streaming requests using small frame sizes occupy large buffers initially allocated for prior
 | ||||
| // requests needing big buffers. The size ranges are as follows:
 | ||||
| // {0 KB, 16 KB], {16 KB, 32 KB], {32 KB, 64 KB], {64 KB, 128 KB], {128 KB, 256 KB],
 | ||||
| // {256 KB, 512 KB], {512 KB, infinity}
 | ||||
| // In practice, the maximum scratch buffer size should not exceed 512 KB due to
 | ||||
| // frameScratchBufferLen(maxFrameSize), thus the "infinity pool" should never be used.
 | ||||
| // It exists mainly as a safety measure, for potential future increases in max buffer size.
 | ||||
| var bufPools [7]sync.Pool // of *[]byte
 | ||||
| func bufPoolIndex(size int) int { | ||||
| 	if size <= 16384 { | ||||
| 		return 0 | ||||
| 	} | ||||
| 	size -= 1 | ||||
| 	bits := bits.Len(uint(size)) | ||||
| 	index := bits - 14 | ||||
| 	if index >= len(bufPools) { | ||||
| 		return len(bufPools) - 1 | ||||
| 	} | ||||
| 	return index | ||||
| } | ||||
| 
 | ||||
| func (cs *clientStream) writeRequestBody(req *http.Request) (err error) { | ||||
| 	cc := cs.cc | ||||
|  | @ -1671,12 +1718,13 @@ func (cs *clientStream) writeRequestBody(req *http.Request) (err error) { | |||
| 	// Scratch buffer for reading into & writing from.
 | ||||
| 	scratchLen := cs.frameScratchBufferLen(maxFrameSize) | ||||
| 	var buf []byte | ||||
| 	if bp, ok := bufPool.Get().(*[]byte); ok && len(*bp) >= scratchLen { | ||||
| 		defer bufPool.Put(bp) | ||||
| 	index := bufPoolIndex(scratchLen) | ||||
| 	if bp, ok := bufPools[index].Get().(*[]byte); ok && len(*bp) >= scratchLen { | ||||
| 		defer bufPools[index].Put(bp) | ||||
| 		buf = *bp | ||||
| 	} else { | ||||
| 		buf = make([]byte, scratchLen) | ||||
| 		defer bufPool.Put(&buf) | ||||
| 		defer bufPools[index].Put(&buf) | ||||
| 	} | ||||
| 
 | ||||
| 	var sawEOF bool | ||||
|  | @ -1844,6 +1892,9 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail | |||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if !httpguts.ValidHostHeader(host) { | ||||
| 		return nil, errors.New("http2: invalid Host header") | ||||
| 	} | ||||
| 
 | ||||
| 	var path string | ||||
| 	if req.Method != "CONNECT" { | ||||
|  | @ -1880,7 +1931,7 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail | |||
| 		// 8.1.2.3 Request Pseudo-Header Fields
 | ||||
| 		// The :path pseudo-header field includes the path and query parts of the
 | ||||
| 		// target URI (the path-absolute production and optionally a '?' character
 | ||||
| 		// followed by the query production (see Sections 3.3 and 3.4 of
 | ||||
| 		// followed by the query production, see Sections 3.3 and 3.4 of
 | ||||
| 		// [RFC3986]).
 | ||||
| 		f(":authority", host) | ||||
| 		m := req.Method | ||||
|  | @ -2555,6 +2606,9 @@ func (b transportResponseBody) Close() error { | |||
| 	cs := b.cs | ||||
| 	cc := cs.cc | ||||
| 
 | ||||
| 	cs.bufPipe.BreakWithError(errClosedResponseBody) | ||||
| 	cs.abortStream(errClosedResponseBody) | ||||
| 
 | ||||
| 	unread := cs.bufPipe.Len() | ||||
| 	if unread > 0 { | ||||
| 		cc.mu.Lock() | ||||
|  | @ -2573,9 +2627,6 @@ func (b transportResponseBody) Close() error { | |||
| 		cc.wmu.Unlock() | ||||
| 	} | ||||
| 
 | ||||
| 	cs.bufPipe.BreakWithError(errClosedResponseBody) | ||||
| 	cs.abortStream(errClosedResponseBody) | ||||
| 
 | ||||
| 	select { | ||||
| 	case <-cs.donec: | ||||
| 	case <-cs.ctx.Done(): | ||||
|  |  | |||
|  | @ -184,7 +184,8 @@ func (wr *FrameWriteRequest) replyToWriter(err error) { | |||
| 
 | ||||
| // writeQueue is used by implementations of WriteScheduler.
 | ||||
| type writeQueue struct { | ||||
| 	s []FrameWriteRequest | ||||
| 	s          []FrameWriteRequest | ||||
| 	prev, next *writeQueue | ||||
| } | ||||
| 
 | ||||
| func (q *writeQueue) empty() bool { return len(q.s) == 0 } | ||||
|  |  | |||
|  | @ -0,0 +1,119 @@ | |||
| // Copyright 2023 The Go Authors. All rights reserved.
 | ||||
| // Use of this source code is governed by a BSD-style
 | ||||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| package http2 | ||||
| 
 | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"math" | ||||
| ) | ||||
| 
 | ||||
| type roundRobinWriteScheduler struct { | ||||
| 	// control contains control frames (SETTINGS, PING, etc.).
 | ||||
| 	control writeQueue | ||||
| 
 | ||||
| 	// streams maps stream ID to a queue.
 | ||||
| 	streams map[uint32]*writeQueue | ||||
| 
 | ||||
| 	// stream queues are stored in a circular linked list.
 | ||||
| 	// head is the next stream to write, or nil if there are no streams open.
 | ||||
| 	head *writeQueue | ||||
| 
 | ||||
| 	// pool of empty queues for reuse.
 | ||||
| 	queuePool writeQueuePool | ||||
| } | ||||
| 
 | ||||
| // newRoundRobinWriteScheduler constructs a new write scheduler.
 | ||||
| // The round robin scheduler priorizes control frames
 | ||||
| // like SETTINGS and PING over DATA frames.
 | ||||
| // When there are no control frames to send, it performs a round-robin
 | ||||
| // selection from the ready streams.
 | ||||
| func newRoundRobinWriteScheduler() WriteScheduler { | ||||
| 	ws := &roundRobinWriteScheduler{ | ||||
| 		streams: make(map[uint32]*writeQueue), | ||||
| 	} | ||||
| 	return ws | ||||
| } | ||||
| 
 | ||||
| func (ws *roundRobinWriteScheduler) OpenStream(streamID uint32, options OpenStreamOptions) { | ||||
| 	if ws.streams[streamID] != nil { | ||||
| 		panic(fmt.Errorf("stream %d already opened", streamID)) | ||||
| 	} | ||||
| 	q := ws.queuePool.get() | ||||
| 	ws.streams[streamID] = q | ||||
| 	if ws.head == nil { | ||||
| 		ws.head = q | ||||
| 		q.next = q | ||||
| 		q.prev = q | ||||
| 	} else { | ||||
| 		// Queues are stored in a ring.
 | ||||
| 		// Insert the new stream before ws.head, putting it at the end of the list.
 | ||||
| 		q.prev = ws.head.prev | ||||
| 		q.next = ws.head | ||||
| 		q.prev.next = q | ||||
| 		q.next.prev = q | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (ws *roundRobinWriteScheduler) CloseStream(streamID uint32) { | ||||
| 	q := ws.streams[streamID] | ||||
| 	if q == nil { | ||||
| 		return | ||||
| 	} | ||||
| 	if q.next == q { | ||||
| 		// This was the only open stream.
 | ||||
| 		ws.head = nil | ||||
| 	} else { | ||||
| 		q.prev.next = q.next | ||||
| 		q.next.prev = q.prev | ||||
| 		if ws.head == q { | ||||
| 			ws.head = q.next | ||||
| 		} | ||||
| 	} | ||||
| 	delete(ws.streams, streamID) | ||||
| 	ws.queuePool.put(q) | ||||
| } | ||||
| 
 | ||||
| func (ws *roundRobinWriteScheduler) AdjustStream(streamID uint32, priority PriorityParam) {} | ||||
| 
 | ||||
| func (ws *roundRobinWriteScheduler) Push(wr FrameWriteRequest) { | ||||
| 	if wr.isControl() { | ||||
| 		ws.control.push(wr) | ||||
| 		return | ||||
| 	} | ||||
| 	q := ws.streams[wr.StreamID()] | ||||
| 	if q == nil { | ||||
| 		// This is a closed stream.
 | ||||
| 		// wr should not be a HEADERS or DATA frame.
 | ||||
| 		// We push the request onto the control queue.
 | ||||
| 		if wr.DataSize() > 0 { | ||||
| 			panic("add DATA on non-open stream") | ||||
| 		} | ||||
| 		ws.control.push(wr) | ||||
| 		return | ||||
| 	} | ||||
| 	q.push(wr) | ||||
| } | ||||
| 
 | ||||
| func (ws *roundRobinWriteScheduler) Pop() (FrameWriteRequest, bool) { | ||||
| 	// Control and RST_STREAM frames first.
 | ||||
| 	if !ws.control.empty() { | ||||
| 		return ws.control.shift(), true | ||||
| 	} | ||||
| 	if ws.head == nil { | ||||
| 		return FrameWriteRequest{}, false | ||||
| 	} | ||||
| 	q := ws.head | ||||
| 	for { | ||||
| 		if wr, ok := q.consume(math.MaxInt32); ok { | ||||
| 			ws.head = q.next | ||||
| 			return wr, true | ||||
| 		} | ||||
| 		q = q.next | ||||
| 		if q == ws.head { | ||||
| 			break | ||||
| 		} | ||||
| 	} | ||||
| 	return FrameWriteRequest{}, false | ||||
| } | ||||
|  | @ -121,7 +121,7 @@ func CheckJoiners(enable bool) Option { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| // StrictDomainName limits the set of permissable ASCII characters to those
 | ||||
| // StrictDomainName limits the set of permissible ASCII characters to those
 | ||||
| // allowed in domain names as defined in RFC 1034 (A-Z, a-z, 0-9 and the
 | ||||
| // hyphen). This is set by default for MapForLookup and ValidateForRegistration,
 | ||||
| // but is only useful if ValidateLabels is set.
 | ||||
|  |  | |||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							|  | @ -6,27 +6,6 @@ | |||
| 
 | ||||
| package idna | ||||
| 
 | ||||
| // appendMapping appends the mapping for the respective rune. isMapped must be
 | ||||
| // true. A mapping is a categorization of a rune as defined in UTS #46.
 | ||||
| func (c info) appendMapping(b []byte, s string) []byte { | ||||
| 	index := int(c >> indexShift) | ||||
| 	if c&xorBit == 0 { | ||||
| 		s := mappings[index:] | ||||
| 		return append(b, s[1:s[0]+1]...) | ||||
| 	} | ||||
| 	b = append(b, s...) | ||||
| 	if c&inlineXOR == inlineXOR { | ||||
| 		// TODO: support and handle two-byte inline masks
 | ||||
| 		b[len(b)-1] ^= byte(index) | ||||
| 	} else { | ||||
| 		for p := len(b) - int(xorData[index]); p < len(b); p++ { | ||||
| 			index++ | ||||
| 			b[p] ^= xorData[index] | ||||
| 		} | ||||
| 	} | ||||
| 	return b | ||||
| } | ||||
| 
 | ||||
| // Sparse block handling code.
 | ||||
| 
 | ||||
| type valueRange struct { | ||||
|  |  | |||
|  | @ -0,0 +1,31 @@ | |||
| // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
 | ||||
| 
 | ||||
| // Copyright 2016 The Go Authors. All rights reserved.
 | ||||
| // Use of this source code is governed by a BSD-style
 | ||||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build !go1.16
 | ||||
| // +build !go1.16
 | ||||
| 
 | ||||
| package idna | ||||
| 
 | ||||
| // appendMapping appends the mapping for the respective rune. isMapped must be
 | ||||
| // true. A mapping is a categorization of a rune as defined in UTS #46.
 | ||||
| func (c info) appendMapping(b []byte, s string) []byte { | ||||
| 	index := int(c >> indexShift) | ||||
| 	if c&xorBit == 0 { | ||||
| 		s := mappings[index:] | ||||
| 		return append(b, s[1:s[0]+1]...) | ||||
| 	} | ||||
| 	b = append(b, s...) | ||||
| 	if c&inlineXOR == inlineXOR { | ||||
| 		// TODO: support and handle two-byte inline masks
 | ||||
| 		b[len(b)-1] ^= byte(index) | ||||
| 	} else { | ||||
| 		for p := len(b) - int(xorData[index]); p < len(b); p++ { | ||||
| 			index++ | ||||
| 			b[p] ^= xorData[index] | ||||
| 		} | ||||
| 	} | ||||
| 	return b | ||||
| } | ||||
|  | @ -0,0 +1,31 @@ | |||
| // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
 | ||||
| 
 | ||||
| // Copyright 2016 The Go Authors. All rights reserved.
 | ||||
| // Use of this source code is governed by a BSD-style
 | ||||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build go1.16
 | ||||
| // +build go1.16
 | ||||
| 
 | ||||
| package idna | ||||
| 
 | ||||
| // appendMapping appends the mapping for the respective rune. isMapped must be
 | ||||
| // true. A mapping is a categorization of a rune as defined in UTS #46.
 | ||||
| func (c info) appendMapping(b []byte, s string) []byte { | ||||
| 	index := int(c >> indexShift) | ||||
| 	if c&xorBit == 0 { | ||||
| 		p := index | ||||
| 		return append(b, mappings[mappingIndex[p]:mappingIndex[p+1]]...) | ||||
| 	} | ||||
| 	b = append(b, s...) | ||||
| 	if c&inlineXOR == inlineXOR { | ||||
| 		// TODO: support and handle two-byte inline masks
 | ||||
| 		b[len(b)-1] ^= byte(index) | ||||
| 	} else { | ||||
| 		for p := len(b) - int(xorData[index]); p < len(b); p++ { | ||||
| 			index++ | ||||
| 			b[p] ^= xorData[index] | ||||
| 		} | ||||
| 	} | ||||
| 	return b | ||||
| } | ||||
|  | @ -1,30 +0,0 @@ | |||
| // Copyright 2020 The Go Authors. All rights reserved.
 | ||||
| // Use of this source code is governed by a BSD-style
 | ||||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| // Package unsafeheader contains header declarations for the Go runtime's
 | ||||
| // slice and string implementations.
 | ||||
| //
 | ||||
| // This package allows x/sys to use types equivalent to
 | ||||
| // reflect.SliceHeader and reflect.StringHeader without introducing
 | ||||
| // a dependency on the (relatively heavy) "reflect" package.
 | ||||
| package unsafeheader | ||||
| 
 | ||||
| import ( | ||||
| 	"unsafe" | ||||
| ) | ||||
| 
 | ||||
| // Slice is the runtime representation of a slice.
 | ||||
| // It cannot be used safely or portably and its representation may change in a later release.
 | ||||
| type Slice struct { | ||||
| 	Data unsafe.Pointer | ||||
| 	Len  int | ||||
| 	Cap  int | ||||
| } | ||||
| 
 | ||||
| // String is the runtime representation of a string.
 | ||||
| // It cannot be used safely or portably and its representation may change in a later release.
 | ||||
| type String struct { | ||||
| 	Data unsafe.Pointer | ||||
| 	Len  int | ||||
| } | ||||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build go1.5
 | ||||
| // +build go1.5
 | ||||
| 
 | ||||
| package plan9 | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build !go1.5
 | ||||
| // +build !go1.5
 | ||||
| 
 | ||||
| package plan9 | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build plan9 && race
 | ||||
| // +build plan9,race
 | ||||
| 
 | ||||
| package plan9 | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build plan9 && !race
 | ||||
| // +build plan9,!race
 | ||||
| 
 | ||||
| package plan9 | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build plan9
 | ||||
| // +build plan9
 | ||||
| 
 | ||||
| package plan9 | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build plan9
 | ||||
| // +build plan9
 | ||||
| 
 | ||||
| // Package plan9 contains an interface to the low-level operating system
 | ||||
| // primitives. OS details vary depending on the underlying system, and
 | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
| // Code generated by the command above; see README.md. DO NOT EDIT.
 | ||||
| 
 | ||||
| //go:build plan9 && 386
 | ||||
| // +build plan9,386
 | ||||
| 
 | ||||
| package plan9 | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
| // Code generated by the command above; see README.md. DO NOT EDIT.
 | ||||
| 
 | ||||
| //go:build plan9 && amd64
 | ||||
| // +build plan9,amd64
 | ||||
| 
 | ||||
| package plan9 | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
| // Code generated by the command above; see README.md. DO NOT EDIT.
 | ||||
| 
 | ||||
| //go:build plan9 && arm
 | ||||
| // +build plan9,arm
 | ||||
| 
 | ||||
| package plan9 | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,8 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos) && go1.9
 | ||||
| // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
 | ||||
| // +build go1.9
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build gc | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,8 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build (freebsd || netbsd || openbsd) && gc | ||||
| // +build freebsd netbsd openbsd | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,8 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && gc | ||||
| // +build darwin dragonfly freebsd netbsd openbsd | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,8 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build (freebsd || netbsd || openbsd) && gc | ||||
| // +build freebsd netbsd openbsd | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,8 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build (darwin || freebsd || netbsd || openbsd) && gc | ||||
| // +build darwin freebsd netbsd openbsd | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,8 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build (darwin || freebsd || netbsd || openbsd) && gc | ||||
| // +build darwin freebsd netbsd openbsd | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,8 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build (darwin || freebsd || netbsd || openbsd) && gc | ||||
| // +build darwin freebsd netbsd openbsd | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build gc | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build gc | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build gc | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,9 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build linux && arm64 && gc | ||||
| // +build linux | ||||
| // +build arm64 | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,9 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build linux && loong64 && gc | ||||
| // +build linux | ||||
| // +build loong64 | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,9 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build linux && (mips64 || mips64le) && gc | ||||
| // +build linux | ||||
| // +build mips64 mips64le | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,9 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build linux && (mips || mipsle) && gc | ||||
| // +build linux | ||||
| // +build mips mipsle | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,9 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build linux && (ppc64 || ppc64le) && gc | ||||
| // +build linux | ||||
| // +build ppc64 ppc64le | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,8 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build riscv64 && gc | ||||
| // +build riscv64 | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,9 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build linux && s390x && gc | ||||
| // +build linux | ||||
| // +build s390x | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build gc | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build gc | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,9 +3,6 @@ | |||
| // license that can be found in the LICENSE file. | ||||
| 
 | ||||
| //go:build zos && s390x && gc | ||||
| // +build zos | ||||
| // +build s390x | ||||
| // +build gc | ||||
| 
 | ||||
| #include "textflag.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build freebsd
 | ||||
| // +build freebsd
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
 | ||||
| // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix && ppc
 | ||||
| // +build aix,ppc
 | ||||
| 
 | ||||
| // Functions to access/create device major and minor numbers matching the
 | ||||
| // encoding used by AIX.
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix && ppc64
 | ||||
| // +build aix,ppc64
 | ||||
| 
 | ||||
| // Functions to access/create device major and minor numbers matching the
 | ||||
| // encoding used AIX.
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build zos && s390x
 | ||||
| // +build zos,s390x
 | ||||
| 
 | ||||
| // Functions to access/create device major and minor numbers matching the
 | ||||
| // encoding used by z/OS.
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
 | ||||
| // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| //
 | ||||
| //go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64
 | ||||
| // +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| //
 | ||||
| //go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh
 | ||||
| // +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
 | ||||
| // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
 | ||||
| 
 | ||||
| // Unix environment variables.
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build zos && s390x
 | ||||
| // +build zos,s390x
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,8 +2,7 @@ | |||
| // Use of this source code is governed by a BSD-style
 | ||||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build dragonfly || freebsd || linux || netbsd || openbsd
 | ||||
| // +build dragonfly freebsd linux netbsd openbsd
 | ||||
| //go:build dragonfly || freebsd || linux || netbsd
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle) || (linux && ppc)
 | ||||
| // +build linux,386 linux,arm linux,mips linux,mipsle linux,ppc
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
 | ||||
| // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build zos && s390x
 | ||||
| // +build zos,s390x
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build gccgo && !aix && !hurd
 | ||||
| // +build gccgo,!aix,!hurd
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build gccgo && !aix && !hurd
 | ||||
| // +build gccgo,!aix,!hurd
 | ||||
| 
 | ||||
| #include <errno.h> | ||||
| #include <stdint.h> | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build gccgo && linux && amd64
 | ||||
| // +build gccgo,linux,amd64
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build linux
 | ||||
| // +build linux
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -231,3 +231,8 @@ func IoctlLoopGetStatus64(fd int) (*LoopInfo64, error) { | |||
| func IoctlLoopSetStatus64(fd int, value *LoopInfo64) error { | ||||
| 	return ioctlPtr(fd, LOOP_SET_STATUS64, unsafe.Pointer(value)) | ||||
| } | ||||
| 
 | ||||
| // IoctlLoopConfigure configures all loop device parameters in a single step
 | ||||
| func IoctlLoopConfigure(fd int, value *LoopConfig) error { | ||||
| 	return ioctlPtr(fd, LOOP_CONFIGURE, unsafe.Pointer(value)) | ||||
| } | ||||
|  |  | |||
|  | @ -0,0 +1,69 @@ | |||
| // Copyright 2018 The Go Authors. All rights reserved.
 | ||||
| // Use of this source code is governed by a BSD-style
 | ||||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix || solaris
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
| import ( | ||||
| 	"unsafe" | ||||
| ) | ||||
| 
 | ||||
| // ioctl itself should not be exposed directly, but additional get/set
 | ||||
| // functions for specific types are permissible.
 | ||||
| 
 | ||||
| // IoctlSetInt performs an ioctl operation which sets an integer value
 | ||||
| // on fd, using the specified request number.
 | ||||
| func IoctlSetInt(fd int, req int, value int) error { | ||||
| 	return ioctl(fd, req, uintptr(value)) | ||||
| } | ||||
| 
 | ||||
| // IoctlSetPointerInt performs an ioctl operation which sets an
 | ||||
| // integer value on fd, using the specified request number. The ioctl
 | ||||
| // argument is called with a pointer to the integer value, rather than
 | ||||
| // passing the integer value directly.
 | ||||
| func IoctlSetPointerInt(fd int, req int, value int) error { | ||||
| 	v := int32(value) | ||||
| 	return ioctlPtr(fd, req, unsafe.Pointer(&v)) | ||||
| } | ||||
| 
 | ||||
| // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
 | ||||
| //
 | ||||
| // To change fd's window size, the req argument should be TIOCSWINSZ.
 | ||||
| func IoctlSetWinsize(fd int, req int, value *Winsize) error { | ||||
| 	// TODO: if we get the chance, remove the req parameter and
 | ||||
| 	// hardcode TIOCSWINSZ.
 | ||||
| 	return ioctlPtr(fd, req, unsafe.Pointer(value)) | ||||
| } | ||||
| 
 | ||||
| // IoctlSetTermios performs an ioctl on fd with a *Termios.
 | ||||
| //
 | ||||
| // The req value will usually be TCSETA or TIOCSETA.
 | ||||
| func IoctlSetTermios(fd int, req int, value *Termios) error { | ||||
| 	// TODO: if we get the chance, remove the req parameter.
 | ||||
| 	return ioctlPtr(fd, req, unsafe.Pointer(value)) | ||||
| } | ||||
| 
 | ||||
| // IoctlGetInt performs an ioctl operation which gets an integer value
 | ||||
| // from fd, using the specified request number.
 | ||||
| //
 | ||||
| // A few ioctl requests use the return value as an output parameter;
 | ||||
| // for those, IoctlRetInt should be used instead of this function.
 | ||||
| func IoctlGetInt(fd int, req int) (int, error) { | ||||
| 	var value int | ||||
| 	err := ioctlPtr(fd, req, unsafe.Pointer(&value)) | ||||
| 	return value, err | ||||
| } | ||||
| 
 | ||||
| func IoctlGetWinsize(fd int, req int) (*Winsize, error) { | ||||
| 	var value Winsize | ||||
| 	err := ioctlPtr(fd, req, unsafe.Pointer(&value)) | ||||
| 	return &value, err | ||||
| } | ||||
| 
 | ||||
| func IoctlGetTermios(fd int, req int) (*Termios, error) { | ||||
| 	var value Termios | ||||
| 	err := ioctlPtr(fd, req, unsafe.Pointer(&value)) | ||||
| 	return &value, err | ||||
| } | ||||
							
								
								
									
										20
									
								
								vendor/golang.org/x/sys/unix/ioctl.go → vendor/golang.org/x/sys/unix/ioctl_unsigned.go
								
								
									generated
								
								
									vendored
								
								
							
							
						
						
									
										20
									
								
								vendor/golang.org/x/sys/unix/ioctl.go → vendor/golang.org/x/sys/unix/ioctl_unsigned.go
								
								
									generated
								
								
									vendored
								
								
							|  | @ -2,13 +2,11 @@ | |||
| // Use of this source code is governed by a BSD-style
 | ||||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix || darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd || solaris
 | ||||
| // +build aix darwin dragonfly freebsd hurd linux netbsd openbsd solaris
 | ||||
| //go:build darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
| import ( | ||||
| 	"runtime" | ||||
| 	"unsafe" | ||||
| ) | ||||
| 
 | ||||
|  | @ -27,7 +25,7 @@ func IoctlSetInt(fd int, req uint, value int) error { | |||
| // passing the integer value directly.
 | ||||
| func IoctlSetPointerInt(fd int, req uint, value int) error { | ||||
| 	v := int32(value) | ||||
| 	return ioctl(fd, req, uintptr(unsafe.Pointer(&v))) | ||||
| 	return ioctlPtr(fd, req, unsafe.Pointer(&v)) | ||||
| } | ||||
| 
 | ||||
| // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
 | ||||
|  | @ -36,9 +34,7 @@ func IoctlSetPointerInt(fd int, req uint, value int) error { | |||
| func IoctlSetWinsize(fd int, req uint, value *Winsize) error { | ||||
| 	// TODO: if we get the chance, remove the req parameter and
 | ||||
| 	// hardcode TIOCSWINSZ.
 | ||||
| 	err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) | ||||
| 	runtime.KeepAlive(value) | ||||
| 	return err | ||||
| 	return ioctlPtr(fd, req, unsafe.Pointer(value)) | ||||
| } | ||||
| 
 | ||||
| // IoctlSetTermios performs an ioctl on fd with a *Termios.
 | ||||
|  | @ -46,9 +42,7 @@ func IoctlSetWinsize(fd int, req uint, value *Winsize) error { | |||
| // The req value will usually be TCSETA or TIOCSETA.
 | ||||
| func IoctlSetTermios(fd int, req uint, value *Termios) error { | ||||
| 	// TODO: if we get the chance, remove the req parameter.
 | ||||
| 	err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) | ||||
| 	runtime.KeepAlive(value) | ||||
| 	return err | ||||
| 	return ioctlPtr(fd, req, unsafe.Pointer(value)) | ||||
| } | ||||
| 
 | ||||
| // IoctlGetInt performs an ioctl operation which gets an integer value
 | ||||
|  | @ -58,18 +52,18 @@ func IoctlSetTermios(fd int, req uint, value *Termios) error { | |||
| // for those, IoctlRetInt should be used instead of this function.
 | ||||
| func IoctlGetInt(fd int, req uint) (int, error) { | ||||
| 	var value int | ||||
| 	err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) | ||||
| 	err := ioctlPtr(fd, req, unsafe.Pointer(&value)) | ||||
| 	return value, err | ||||
| } | ||||
| 
 | ||||
| func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { | ||||
| 	var value Winsize | ||||
| 	err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) | ||||
| 	err := ioctlPtr(fd, req, unsafe.Pointer(&value)) | ||||
| 	return &value, err | ||||
| } | ||||
| 
 | ||||
| func IoctlGetTermios(fd int, req uint) (*Termios, error) { | ||||
| 	var value Termios | ||||
| 	err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) | ||||
| 	err := ioctlPtr(fd, req, unsafe.Pointer(&value)) | ||||
| 	return &value, err | ||||
| } | ||||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build zos && s390x
 | ||||
| // +build zos,s390x
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  | @ -17,25 +16,23 @@ import ( | |||
| 
 | ||||
| // IoctlSetInt performs an ioctl operation which sets an integer value
 | ||||
| // on fd, using the specified request number.
 | ||||
| func IoctlSetInt(fd int, req uint, value int) error { | ||||
| func IoctlSetInt(fd int, req int, value int) error { | ||||
| 	return ioctl(fd, req, uintptr(value)) | ||||
| } | ||||
| 
 | ||||
| // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
 | ||||
| //
 | ||||
| // To change fd's window size, the req argument should be TIOCSWINSZ.
 | ||||
| func IoctlSetWinsize(fd int, req uint, value *Winsize) error { | ||||
| func IoctlSetWinsize(fd int, req int, value *Winsize) error { | ||||
| 	// TODO: if we get the chance, remove the req parameter and
 | ||||
| 	// hardcode TIOCSWINSZ.
 | ||||
| 	err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) | ||||
| 	runtime.KeepAlive(value) | ||||
| 	return err | ||||
| 	return ioctlPtr(fd, req, unsafe.Pointer(value)) | ||||
| } | ||||
| 
 | ||||
| // IoctlSetTermios performs an ioctl on fd with a *Termios.
 | ||||
| //
 | ||||
| // The req value is expected to be TCSETS, TCSETSW, or TCSETSF
 | ||||
| func IoctlSetTermios(fd int, req uint, value *Termios) error { | ||||
| func IoctlSetTermios(fd int, req int, value *Termios) error { | ||||
| 	if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) { | ||||
| 		return ENOSYS | ||||
| 	} | ||||
|  | @ -49,22 +46,22 @@ func IoctlSetTermios(fd int, req uint, value *Termios) error { | |||
| //
 | ||||
| // A few ioctl requests use the return value as an output parameter;
 | ||||
| // for those, IoctlRetInt should be used instead of this function.
 | ||||
| func IoctlGetInt(fd int, req uint) (int, error) { | ||||
| func IoctlGetInt(fd int, req int) (int, error) { | ||||
| 	var value int | ||||
| 	err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) | ||||
| 	err := ioctlPtr(fd, req, unsafe.Pointer(&value)) | ||||
| 	return value, err | ||||
| } | ||||
| 
 | ||||
| func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { | ||||
| func IoctlGetWinsize(fd int, req int) (*Winsize, error) { | ||||
| 	var value Winsize | ||||
| 	err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) | ||||
| 	err := ioctlPtr(fd, req, unsafe.Pointer(&value)) | ||||
| 	return &value, err | ||||
| } | ||||
| 
 | ||||
| // IoctlGetTermios performs an ioctl on fd with a *Termios.
 | ||||
| //
 | ||||
| // The req value is expected to be TCGETS
 | ||||
| func IoctlGetTermios(fd int, req uint) (*Termios, error) { | ||||
| func IoctlGetTermios(fd int, req int) (*Termios, error) { | ||||
| 	var value Termios | ||||
| 	if req != TCGETS { | ||||
| 		return &value, ENOSYS | ||||
|  |  | |||
|  | @ -50,7 +50,7 @@ if [[ "$GOOS" = "linux" ]]; then | |||
| 	# Use the Docker-based build system | ||||
| 	# Files generated through docker (use $cmd so you can Ctl-C the build or run) | ||||
| 	$cmd docker build --tag generate:$GOOS $GOOS | ||||
| 	$cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && /bin/pwd):/build generate:$GOOS | ||||
| 	$cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && pwd):/build generate:$GOOS | ||||
| 	exit | ||||
| fi | ||||
| 
 | ||||
|  |  | |||
|  | @ -66,6 +66,7 @@ includes_Darwin=' | |||
| #include <sys/ptrace.h> | ||||
| #include <sys/select.h> | ||||
| #include <sys/socket.h> | ||||
| #include <sys/stat.h> | ||||
| #include <sys/un.h> | ||||
| #include <sys/sockio.h> | ||||
| #include <sys/sys_domain.h> | ||||
|  | @ -203,6 +204,7 @@ struct ltchars { | |||
| #include <sys/timerfd.h> | ||||
| #include <sys/uio.h> | ||||
| #include <sys/xattr.h> | ||||
| #include <netinet/udp.h> | ||||
| #include <linux/audit.h> | ||||
| #include <linux/bpf.h> | ||||
| #include <linux/can.h> | ||||
|  | @ -517,10 +519,12 @@ ccflags="$@" | |||
| 		$2 ~ /^LOCK_(SH|EX|NB|UN)$/ || | ||||
| 		$2 ~ /^LO_(KEY|NAME)_SIZE$/ || | ||||
| 		$2 ~ /^LOOP_(CLR|CTL|GET|SET)_/ || | ||||
| 		$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT)_/ || | ||||
| 		$2 == "LOOP_CONFIGURE" || | ||||
| 		$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MREMAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ || | ||||
| 		$2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ || | ||||
| 		$2 ~ /^NFC_.*_(MAX)?SIZE$/ || | ||||
| 		$2 ~ /^RAW_PAYLOAD_/ || | ||||
| 		$2 ~ /^[US]F_/ || | ||||
| 		$2 ~ /^TP_STATUS_/ || | ||||
| 		$2 ~ /^FALLOC_/ || | ||||
| 		$2 ~ /^ICMPV?6?_(FILTER|SEC)/ || | ||||
|  | @ -557,7 +561,7 @@ ccflags="$@" | |||
| 		$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|LOCKS|MEMLOCK|MSGQUEUE|NICE|NOFILE|NPROC|RSS|RTPRIO|RTTIME|SIGPENDING|STACK)|RLIM_INFINITY/ || | ||||
| 		$2 ~ /^PRIO_(PROCESS|PGRP|USER)/ || | ||||
| 		$2 ~ /^CLONE_[A-Z_]+/ || | ||||
| 		$2 !~ /^(BPF_TIMEVAL|BPF_FIB_LOOKUP_[A-Z]+)$/ && | ||||
| 		$2 !~ /^(BPF_TIMEVAL|BPF_FIB_LOOKUP_[A-Z]+|BPF_F_LINK)$/ && | ||||
| 		$2 ~ /^(BPF|DLT)_/ || | ||||
| 		$2 ~ /^AUDIT_/ || | ||||
| 		$2 ~ /^(CLOCK|TIMER)_/ || | ||||
|  | @ -580,6 +584,7 @@ ccflags="$@" | |||
| 		$2 ~ /^PERF_/ || | ||||
| 		$2 ~ /^SECCOMP_MODE_/ || | ||||
| 		$2 ~ /^SEEK_/ || | ||||
| 		$2 ~ /^SCHED_/ || | ||||
| 		$2 ~ /^SPLICE_/ || | ||||
| 		$2 ~ /^SYNC_FILE_RANGE_/ || | ||||
| 		$2 !~ /IOC_MAGIC/ && | ||||
|  | @ -621,7 +626,7 @@ ccflags="$@" | |||
| 		$2 ~ /^MEM/ || | ||||
| 		$2 ~ /^WG/ || | ||||
| 		$2 ~ /^FIB_RULE_/ || | ||||
| 		$2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)} | ||||
| 		$2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE|IOMIN$|IOOPT$|ALIGNOFF$|DISCARD|ROTATIONAL$|ZEROOUT$|GETDISKSEQ$)/ {printf("\t%s = C.%s\n", $2, $2)} | ||||
| 		$2 ~ /^__WCOREFLAG$/ {next} | ||||
| 		$2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)} | ||||
| 
 | ||||
|  | @ -659,7 +664,6 @@ echo '// mkerrors.sh' "$@" | |||
| echo '// Code generated by the command above; see README.md. DO NOT EDIT.' | ||||
| echo | ||||
| echo "//go:build ${GOARCH} && ${GOOS}" | ||||
| echo "// +build ${GOARCH},${GOOS}" | ||||
| echo | ||||
| go tool cgo -godefs -- "$@" _const.go >_error.out | ||||
| cat _error.out | grep -vf _error.grep | grep -vf _signal.grep | ||||
|  | @ -738,7 +742,8 @@ main(void) | |||
| 		e = errors[i].num; | ||||
| 		if(i > 0 && errors[i-1].num == e) | ||||
| 			continue; | ||||
| 		strcpy(buf, strerror(e)); | ||||
| 		strncpy(buf, strerror(e), sizeof(buf) - 1); | ||||
| 		buf[sizeof(buf) - 1] = '\0'; | ||||
| 		// lowercase first letter: Bad -> bad, but STREAM -> STREAM. | ||||
| 		if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z) | ||||
| 			buf[0] += a - A; | ||||
|  | @ -757,7 +762,8 @@ main(void) | |||
| 		e = signals[i].num; | ||||
| 		if(i > 0 && signals[i-1].num == e) | ||||
| 			continue; | ||||
| 		strcpy(buf, strsignal(e)); | ||||
| 		strncpy(buf, strsignal(e), sizeof(buf) - 1); | ||||
| 		buf[sizeof(buf) - 1] = '\0'; | ||||
| 		// lowercase first letter: Bad -> bad, but STREAM -> STREAM. | ||||
| 		if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z) | ||||
| 			buf[0] += a - A; | ||||
|  |  | |||
|  | @ -0,0 +1,13 @@ | |||
| // Copyright 2023 The Go Authors. All rights reserved.
 | ||||
| // Use of this source code is governed by a BSD-style
 | ||||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix || darwin || dragonfly || freebsd || openbsd || solaris
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
| var mapper = &mmapper{ | ||||
| 	active: make(map[*byte][]byte), | ||||
| 	mmap:   mmap, | ||||
| 	munmap: munmap, | ||||
| } | ||||
|  | @ -0,0 +1,52 @@ | |||
| // Copyright 2023 The Go Authors. All rights reserved.
 | ||||
| // Use of this source code is governed by a BSD-style
 | ||||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build linux || netbsd
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
| import "unsafe" | ||||
| 
 | ||||
| type mremapMmapper struct { | ||||
| 	mmapper | ||||
| 	mremap func(oldaddr uintptr, oldlength uintptr, newlength uintptr, flags int, newaddr uintptr) (xaddr uintptr, err error) | ||||
| } | ||||
| 
 | ||||
| var mapper = &mremapMmapper{ | ||||
| 	mmapper: mmapper{ | ||||
| 		active: make(map[*byte][]byte), | ||||
| 		mmap:   mmap, | ||||
| 		munmap: munmap, | ||||
| 	}, | ||||
| 	mremap: mremap, | ||||
| } | ||||
| 
 | ||||
| func (m *mremapMmapper) Mremap(oldData []byte, newLength int, flags int) (data []byte, err error) { | ||||
| 	if newLength <= 0 || len(oldData) == 0 || len(oldData) != cap(oldData) || flags&mremapFixed != 0 { | ||||
| 		return nil, EINVAL | ||||
| 	} | ||||
| 
 | ||||
| 	pOld := &oldData[cap(oldData)-1] | ||||
| 	m.Lock() | ||||
| 	defer m.Unlock() | ||||
| 	bOld := m.active[pOld] | ||||
| 	if bOld == nil || &bOld[0] != &oldData[0] { | ||||
| 		return nil, EINVAL | ||||
| 	} | ||||
| 	newAddr, errno := m.mremap(uintptr(unsafe.Pointer(&bOld[0])), uintptr(len(bOld)), uintptr(newLength), flags, 0) | ||||
| 	if errno != nil { | ||||
| 		return nil, errno | ||||
| 	} | ||||
| 	bNew := unsafe.Slice((*byte)(unsafe.Pointer(newAddr)), newLength) | ||||
| 	pNew := &bNew[cap(bNew)-1] | ||||
| 	if flags&mremapDontunmap == 0 { | ||||
| 		delete(m.active, pOld) | ||||
| 	} | ||||
| 	m.active[pNew] = bNew | ||||
| 	return bNew, nil | ||||
| } | ||||
| 
 | ||||
| func Mremap(oldData []byte, newLength int, flags int) (data []byte, err error) { | ||||
| 	return mapper.Mremap(oldData, newLength, flags) | ||||
| } | ||||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
 | ||||
| // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
 | ||||
| 
 | ||||
| // For Unix, get the pagesize from the runtime.
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -8,54 +8,31 @@ import ( | |||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"strconv" | ||||
| 	"syscall" | ||||
| 	"unsafe" | ||||
| ) | ||||
| 
 | ||||
| // Pledge implements the pledge syscall.
 | ||||
| //
 | ||||
| // The pledge syscall does not accept execpromises on OpenBSD releases
 | ||||
| // before 6.3.
 | ||||
| //
 | ||||
| // execpromises must be empty when Pledge is called on OpenBSD
 | ||||
| // releases predating 6.3, otherwise an error will be returned.
 | ||||
| // This changes both the promises and execpromises; use PledgePromises or
 | ||||
| // PledgeExecpromises to only change the promises or execpromises
 | ||||
| // respectively.
 | ||||
| //
 | ||||
| // For more information see pledge(2).
 | ||||
| func Pledge(promises, execpromises string) error { | ||||
| 	maj, min, err := majmin() | ||||
| 	if err := pledgeAvailable(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	pptr, err := BytePtrFromString(promises) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	err = pledgeAvailable(maj, min, execpromises) | ||||
| 	exptr, err := BytePtrFromString(execpromises) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	pptr, err := syscall.BytePtrFromString(promises) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	// This variable will hold either a nil unsafe.Pointer or
 | ||||
| 	// an unsafe.Pointer to a string (execpromises).
 | ||||
| 	var expr unsafe.Pointer | ||||
| 
 | ||||
| 	// If we're running on OpenBSD > 6.2, pass execpromises to the syscall.
 | ||||
| 	if maj > 6 || (maj == 6 && min > 2) { | ||||
| 		exptr, err := syscall.BytePtrFromString(execpromises) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		expr = unsafe.Pointer(exptr) | ||||
| 	} | ||||
| 
 | ||||
| 	_, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(unsafe.Pointer(pptr)), uintptr(expr), 0) | ||||
| 	if e != 0 { | ||||
| 		return e | ||||
| 	} | ||||
| 
 | ||||
| 	return nil | ||||
| 	return pledge(pptr, exptr) | ||||
| } | ||||
| 
 | ||||
| // PledgePromises implements the pledge syscall.
 | ||||
|  | @ -64,30 +41,16 @@ func Pledge(promises, execpromises string) error { | |||
| //
 | ||||
| // For more information see pledge(2).
 | ||||
| func PledgePromises(promises string) error { | ||||
| 	maj, min, err := majmin() | ||||
| 	if err := pledgeAvailable(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	pptr, err := BytePtrFromString(promises) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	err = pledgeAvailable(maj, min, "") | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	// This variable holds the execpromises and is always nil.
 | ||||
| 	var expr unsafe.Pointer | ||||
| 
 | ||||
| 	pptr, err := syscall.BytePtrFromString(promises) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	_, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(unsafe.Pointer(pptr)), uintptr(expr), 0) | ||||
| 	if e != 0 { | ||||
| 		return e | ||||
| 	} | ||||
| 
 | ||||
| 	return nil | ||||
| 	return pledge(pptr, nil) | ||||
| } | ||||
| 
 | ||||
| // PledgeExecpromises implements the pledge syscall.
 | ||||
|  | @ -96,30 +59,16 @@ func PledgePromises(promises string) error { | |||
| //
 | ||||
| // For more information see pledge(2).
 | ||||
| func PledgeExecpromises(execpromises string) error { | ||||
| 	maj, min, err := majmin() | ||||
| 	if err := pledgeAvailable(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	exptr, err := BytePtrFromString(execpromises) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	err = pledgeAvailable(maj, min, execpromises) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	// This variable holds the promises and is always nil.
 | ||||
| 	var pptr unsafe.Pointer | ||||
| 
 | ||||
| 	exptr, err := syscall.BytePtrFromString(execpromises) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	_, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(pptr), uintptr(unsafe.Pointer(exptr)), 0) | ||||
| 	if e != 0 { | ||||
| 		return e | ||||
| 	} | ||||
| 
 | ||||
| 	return nil | ||||
| 	return pledge(nil, exptr) | ||||
| } | ||||
| 
 | ||||
| // majmin returns major and minor version number for an OpenBSD system.
 | ||||
|  | @ -147,16 +96,15 @@ func majmin() (major int, minor int, err error) { | |||
| 
 | ||||
| // pledgeAvailable checks for availability of the pledge(2) syscall
 | ||||
| // based on the running OpenBSD version.
 | ||||
| func pledgeAvailable(maj, min int, execpromises string) error { | ||||
| 	// If OpenBSD <= 5.9, pledge is not available.
 | ||||
| 	if (maj == 5 && min != 9) || maj < 5 { | ||||
| 		return fmt.Errorf("pledge syscall is not available on OpenBSD %d.%d", maj, min) | ||||
| func pledgeAvailable() error { | ||||
| 	maj, min, err := majmin() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	// If OpenBSD <= 6.2 and execpromises is not empty,
 | ||||
| 	// return an error - execpromises is not available before 6.3
 | ||||
| 	if (maj < 6 || (maj == 6 && min <= 2)) && execpromises != "" { | ||||
| 		return fmt.Errorf("cannot use execpromises on OpenBSD %d.%d", maj, min) | ||||
| 	// Require OpenBSD 6.4 as a minimum.
 | ||||
| 	if maj < 6 || (maj == 6 && min <= 3) { | ||||
| 		return fmt.Errorf("cannot call Pledge on OpenBSD %d.%d", maj, min) | ||||
| 	} | ||||
| 
 | ||||
| 	return nil | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build darwin && !ios
 | ||||
| // +build darwin,!ios
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build ios
 | ||||
| // +build ios
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build (darwin && race) || (linux && race) || (freebsd && race)
 | ||||
| // +build darwin,race linux,race freebsd,race
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix || (darwin && !race) || (linux && !race) || (freebsd && !race) || netbsd || openbsd || solaris || dragonfly || zos
 | ||||
| // +build aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly zos
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix || dragonfly || freebsd || linux || netbsd || openbsd
 | ||||
| // +build aix dragonfly freebsd linux netbsd openbsd
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build darwin
 | ||||
| // +build darwin
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
 | ||||
| // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
 | ||||
| 
 | ||||
| // Socket control messages
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix || darwin || freebsd || linux || netbsd || openbsd || solaris || zos
 | ||||
| // +build aix darwin freebsd linux netbsd openbsd solaris zos
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
 | ||||
| // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
 | ||||
| 
 | ||||
| // Package unix contains an interface to the low-level operating system
 | ||||
| // primitives. OS details vary depending on the underlying system, and
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix
 | ||||
| // +build aix
 | ||||
| 
 | ||||
| // Aix system calls.
 | ||||
| // This file is compiled as ordinary Go code,
 | ||||
|  | @ -107,7 +106,8 @@ func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) { | |||
| 	if n > 0 { | ||||
| 		sl += _Socklen(n) + 1 | ||||
| 	} | ||||
| 	if sa.raw.Path[0] == '@' { | ||||
| 	if sa.raw.Path[0] == '@' || (sa.raw.Path[0] == 0 && sl > 3) { | ||||
| 		// Check sl > 3 so we don't change unnamed socket behavior.
 | ||||
| 		sa.raw.Path[0] = 0 | ||||
| 		// Don't count trailing NUL for abstract address.
 | ||||
| 		sl-- | ||||
|  | @ -292,9 +292,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { | |||
| 				break | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] | ||||
| 		sa.Name = string(bytes) | ||||
| 		sa.Name = string(unsafe.Slice((*byte)(unsafe.Pointer(&pp.Path[0])), n)) | ||||
| 		return sa, nil | ||||
| 
 | ||||
| 	case AF_INET: | ||||
|  | @ -410,7 +408,8 @@ func (w WaitStatus) CoreDump() bool { return w&0x80 == 0x80 } | |||
| 
 | ||||
| func (w WaitStatus) TrapCause() int { return -1 } | ||||
| 
 | ||||
| //sys	ioctl(fd int, req uint, arg uintptr) (err error)
 | ||||
| //sys	ioctl(fd int, req int, arg uintptr) (err error)
 | ||||
| //sys	ioctlPtr(fd int, req int, arg unsafe.Pointer) (err error) = ioctl
 | ||||
| 
 | ||||
| // fcntl must never be called with cmd=F_DUP2FD because it doesn't work on AIX
 | ||||
| // There is no way to create a custom fcntl and to keep //sys fcntl easily,
 | ||||
|  | @ -488,8 +487,6 @@ func Fsync(fd int) error { | |||
| //sys	Unlinkat(dirfd int, path string, flags int) (err error)
 | ||||
| //sys	Ustat(dev int, ubuf *Ustat_t) (err error)
 | ||||
| //sys	write(fd int, p []byte) (n int, err error)
 | ||||
| //sys	readlen(fd int, p *byte, np int) (n int, err error) = read
 | ||||
| //sys	writelen(fd int, p *byte, np int) (n int, err error) = write
 | ||||
| 
 | ||||
| //sys	Dup2(oldfd int, newfd int) (err error)
 | ||||
| //sys	Fadvise(fd int, offset int64, length int64, advice int) (err error) = posix_fadvise64
 | ||||
|  | @ -536,21 +533,6 @@ func Fsync(fd int) error { | |||
| //sys	sendmsg(s int, msg *Msghdr, flags int) (n int, err error) = nsendmsg
 | ||||
| 
 | ||||
| //sys	munmap(addr uintptr, length uintptr) (err error)
 | ||||
| 
 | ||||
| var mapper = &mmapper{ | ||||
| 	active: make(map[*byte][]byte), | ||||
| 	mmap:   mmap, | ||||
| 	munmap: munmap, | ||||
| } | ||||
| 
 | ||||
| func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { | ||||
| 	return mapper.Mmap(fd, offset, length, prot, flags) | ||||
| } | ||||
| 
 | ||||
| func Munmap(b []byte) (err error) { | ||||
| 	return mapper.Munmap(b) | ||||
| } | ||||
| 
 | ||||
| //sys	Madvise(b []byte, advice int) (err error)
 | ||||
| //sys	Mprotect(b []byte, prot int) (err error)
 | ||||
| //sys	Mlock(b []byte) (err error)
 | ||||
|  |  | |||
|  | @ -3,12 +3,10 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix && ppc
 | ||||
| // +build aix,ppc
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
| //sysnb	Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64
 | ||||
| //sysnb	Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64
 | ||||
| //sys	Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64
 | ||||
| 
 | ||||
| //sys	mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
 | ||||
|  |  | |||
|  | @ -3,12 +3,10 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build aix && ppc64
 | ||||
| // +build aix,ppc64
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
| //sysnb	Getrlimit(resource int, rlim *Rlimit) (err error)
 | ||||
| //sysnb	Setrlimit(resource int, rlim *Rlimit) (err error)
 | ||||
| //sys	Seek(fd int, offset int64, whence int) (off int64, err error) = lseek
 | ||||
| 
 | ||||
| //sys	mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build darwin || dragonfly || freebsd || netbsd || openbsd
 | ||||
| // +build darwin dragonfly freebsd netbsd openbsd
 | ||||
| 
 | ||||
| // BSD system call wrappers shared by *BSD based systems
 | ||||
| // including OS X (Darwin) and FreeBSD.  Like the other
 | ||||
|  | @ -245,8 +244,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { | |||
| 				break | ||||
| 			} | ||||
| 		} | ||||
| 		bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] | ||||
| 		sa.Name = string(bytes) | ||||
| 		sa.Name = string(unsafe.Slice((*byte)(unsafe.Pointer(&pp.Path[0])), n)) | ||||
| 		return sa, nil | ||||
| 
 | ||||
| 	case AF_INET: | ||||
|  | @ -318,7 +316,7 @@ func GetsockoptString(fd, level, opt int) (string, error) { | |||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| 	return string(buf[:vallen-1]), nil | ||||
| 	return ByteSliceToString(buf[:vallen]), nil | ||||
| } | ||||
| 
 | ||||
| //sys	recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
 | ||||
|  | @ -602,20 +600,6 @@ func Poll(fds []PollFd, timeout int) (n int, err error) { | |||
| //	Gethostuuid(uuid *byte, timeout *Timespec) (err error)
 | ||||
| //	Ptrace(req int, pid int, addr uintptr, data int) (ret uintptr, err error)
 | ||||
| 
 | ||||
| var mapper = &mmapper{ | ||||
| 	active: make(map[*byte][]byte), | ||||
| 	mmap:   mmap, | ||||
| 	munmap: munmap, | ||||
| } | ||||
| 
 | ||||
| func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { | ||||
| 	return mapper.Mmap(fd, offset, length, prot, flags) | ||||
| } | ||||
| 
 | ||||
| func Munmap(b []byte) (err error) { | ||||
| 	return mapper.Munmap(b) | ||||
| } | ||||
| 
 | ||||
| //sys	Madvise(b []byte, behav int) (err error)
 | ||||
| //sys	Mlock(b []byte) (err error)
 | ||||
| //sys	Mlockall(flags int) (err error)
 | ||||
|  |  | |||
|  | @ -14,7 +14,6 @@ package unix | |||
| 
 | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"runtime" | ||||
| 	"syscall" | ||||
| 	"unsafe" | ||||
| ) | ||||
|  | @ -376,11 +375,10 @@ func Flistxattr(fd int, dest []byte) (sz int, err error) { | |||
| func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) } | ||||
| 
 | ||||
| //sys	ioctl(fd int, req uint, arg uintptr) (err error)
 | ||||
| //sys	ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = SYS_IOCTL
 | ||||
| 
 | ||||
| func IoctlCtlInfo(fd int, ctlInfo *CtlInfo) error { | ||||
| 	err := ioctl(fd, CTLIOCGINFO, uintptr(unsafe.Pointer(ctlInfo))) | ||||
| 	runtime.KeepAlive(ctlInfo) | ||||
| 	return err | ||||
| 	return ioctlPtr(fd, CTLIOCGINFO, unsafe.Pointer(ctlInfo)) | ||||
| } | ||||
| 
 | ||||
| // IfreqMTU is struct ifreq used to get or set a network device's MTU.
 | ||||
|  | @ -394,16 +392,14 @@ type IfreqMTU struct { | |||
| func IoctlGetIfreqMTU(fd int, ifname string) (*IfreqMTU, error) { | ||||
| 	var ifreq IfreqMTU | ||||
| 	copy(ifreq.Name[:], ifname) | ||||
| 	err := ioctl(fd, SIOCGIFMTU, uintptr(unsafe.Pointer(&ifreq))) | ||||
| 	err := ioctlPtr(fd, SIOCGIFMTU, unsafe.Pointer(&ifreq)) | ||||
| 	return &ifreq, err | ||||
| } | ||||
| 
 | ||||
| // IoctlSetIfreqMTU performs the SIOCSIFMTU ioctl operation on fd to set the MTU
 | ||||
| // of the network device specified by ifreq.Name.
 | ||||
| func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error { | ||||
| 	err := ioctl(fd, SIOCSIFMTU, uintptr(unsafe.Pointer(ifreq))) | ||||
| 	runtime.KeepAlive(ifreq) | ||||
| 	return err | ||||
| 	return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq)) | ||||
| } | ||||
| 
 | ||||
| //sys	sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL
 | ||||
|  | @ -514,30 +510,36 @@ func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) { | |||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	// Find size.
 | ||||
| 	n := uintptr(0) | ||||
| 	if err := sysctl(mib, nil, &n, nil, 0); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if n == 0 { | ||||
| 		return nil, nil | ||||
| 	} | ||||
| 	if n%SizeofKinfoProc != 0 { | ||||
| 		return nil, fmt.Errorf("sysctl() returned a size of %d, which is not a multiple of %d", n, SizeofKinfoProc) | ||||
| 	} | ||||
| 	for { | ||||
| 		// Find size.
 | ||||
| 		n := uintptr(0) | ||||
| 		if err := sysctl(mib, nil, &n, nil, 0); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		if n == 0 { | ||||
| 			return nil, nil | ||||
| 		} | ||||
| 		if n%SizeofKinfoProc != 0 { | ||||
| 			return nil, fmt.Errorf("sysctl() returned a size of %d, which is not a multiple of %d", n, SizeofKinfoProc) | ||||
| 		} | ||||
| 
 | ||||
| 	// Read into buffer of that size.
 | ||||
| 	buf := make([]KinfoProc, n/SizeofKinfoProc) | ||||
| 	if err := sysctl(mib, (*byte)(unsafe.Pointer(&buf[0])), &n, nil, 0); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if n%SizeofKinfoProc != 0 { | ||||
| 		return nil, fmt.Errorf("sysctl() returned a size of %d, which is not a multiple of %d", n, SizeofKinfoProc) | ||||
| 	} | ||||
| 		// Read into buffer of that size.
 | ||||
| 		buf := make([]KinfoProc, n/SizeofKinfoProc) | ||||
| 		if err := sysctl(mib, (*byte)(unsafe.Pointer(&buf[0])), &n, nil, 0); err != nil { | ||||
| 			if err == ENOMEM { | ||||
| 				// Process table grew. Try again.
 | ||||
| 				continue | ||||
| 			} | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		if n%SizeofKinfoProc != 0 { | ||||
| 			return nil, fmt.Errorf("sysctl() returned a size of %d, which is not a multiple of %d", n, SizeofKinfoProc) | ||||
| 		} | ||||
| 
 | ||||
| 	// The actual call may return less than the original reported required
 | ||||
| 	// size so ensure we deal with that.
 | ||||
| 	return buf[:n/SizeofKinfoProc], nil | ||||
| 		// The actual call may return less than the original reported required
 | ||||
| 		// size so ensure we deal with that.
 | ||||
| 		return buf[:n/SizeofKinfoProc], nil | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| //sys	sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
 | ||||
|  | @ -617,6 +619,7 @@ func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) { | |||
| //sys	Rmdir(path string) (err error)
 | ||||
| //sys	Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
 | ||||
| //sys	Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
 | ||||
| //sys	Setattrlist(path string, attrlist *Attrlist, attrBuf []byte, options int) (err error)
 | ||||
| //sys	Setegid(egid int) (err error)
 | ||||
| //sysnb	Seteuid(euid int) (err error)
 | ||||
| //sysnb	Setgid(gid int) (err error)
 | ||||
|  | @ -626,7 +629,6 @@ func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) { | |||
| //sys	Setprivexec(flag int) (err error)
 | ||||
| //sysnb	Setregid(rgid int, egid int) (err error)
 | ||||
| //sysnb	Setreuid(ruid int, euid int) (err error)
 | ||||
| //sysnb	Setrlimit(which int, lim *Rlimit) (err error)
 | ||||
| //sysnb	Setsid() (pid int, err error)
 | ||||
| //sysnb	Settimeofday(tp *Timeval) (err error)
 | ||||
| //sysnb	Setuid(uid int) (err error)
 | ||||
|  | @ -642,190 +644,3 @@ func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) { | |||
| //sys	write(fd int, p []byte) (n int, err error)
 | ||||
| //sys	mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
 | ||||
| //sys	munmap(addr uintptr, length uintptr) (err error)
 | ||||
| //sys	readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
 | ||||
| //sys	writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
 | ||||
| 
 | ||||
| /* | ||||
|  * Unimplemented | ||||
|  */ | ||||
| // Profil
 | ||||
| // Sigaction
 | ||||
| // Sigprocmask
 | ||||
| // Getlogin
 | ||||
| // Sigpending
 | ||||
| // Sigaltstack
 | ||||
| // Ioctl
 | ||||
| // Reboot
 | ||||
| // Execve
 | ||||
| // Vfork
 | ||||
| // Sbrk
 | ||||
| // Sstk
 | ||||
| // Ovadvise
 | ||||
| // Mincore
 | ||||
| // Setitimer
 | ||||
| // Swapon
 | ||||
| // Select
 | ||||
| // Sigsuspend
 | ||||
| // Readv
 | ||||
| // Writev
 | ||||
| // Nfssvc
 | ||||
| // Getfh
 | ||||
| // Quotactl
 | ||||
| // Csops
 | ||||
| // Waitid
 | ||||
| // Add_profil
 | ||||
| // Kdebug_trace
 | ||||
| // Sigreturn
 | ||||
| // Atsocket
 | ||||
| // Kqueue_from_portset_np
 | ||||
| // Kqueue_portset
 | ||||
| // Getattrlist
 | ||||
| // Setattrlist
 | ||||
| // Getdirentriesattr
 | ||||
| // Searchfs
 | ||||
| // Delete
 | ||||
| // Copyfile
 | ||||
| // Watchevent
 | ||||
| // Waitevent
 | ||||
| // Modwatch
 | ||||
| // Fsctl
 | ||||
| // Initgroups
 | ||||
| // Posix_spawn
 | ||||
| // Nfsclnt
 | ||||
| // Fhopen
 | ||||
| // Minherit
 | ||||
| // Semsys
 | ||||
| // Msgsys
 | ||||
| // Shmsys
 | ||||
| // Semctl
 | ||||
| // Semget
 | ||||
| // Semop
 | ||||
| // Msgctl
 | ||||
| // Msgget
 | ||||
| // Msgsnd
 | ||||
| // Msgrcv
 | ||||
| // Shm_open
 | ||||
| // Shm_unlink
 | ||||
| // Sem_open
 | ||||
| // Sem_close
 | ||||
| // Sem_unlink
 | ||||
| // Sem_wait
 | ||||
| // Sem_trywait
 | ||||
| // Sem_post
 | ||||
| // Sem_getvalue
 | ||||
| // Sem_init
 | ||||
| // Sem_destroy
 | ||||
| // Open_extended
 | ||||
| // Umask_extended
 | ||||
| // Stat_extended
 | ||||
| // Lstat_extended
 | ||||
| // Fstat_extended
 | ||||
| // Chmod_extended
 | ||||
| // Fchmod_extended
 | ||||
| // Access_extended
 | ||||
| // Settid
 | ||||
| // Gettid
 | ||||
| // Setsgroups
 | ||||
| // Getsgroups
 | ||||
| // Setwgroups
 | ||||
| // Getwgroups
 | ||||
| // Mkfifo_extended
 | ||||
| // Mkdir_extended
 | ||||
| // Identitysvc
 | ||||
| // Shared_region_check_np
 | ||||
| // Shared_region_map_np
 | ||||
| // __pthread_mutex_destroy
 | ||||
| // __pthread_mutex_init
 | ||||
| // __pthread_mutex_lock
 | ||||
| // __pthread_mutex_trylock
 | ||||
| // __pthread_mutex_unlock
 | ||||
| // __pthread_cond_init
 | ||||
| // __pthread_cond_destroy
 | ||||
| // __pthread_cond_broadcast
 | ||||
| // __pthread_cond_signal
 | ||||
| // Setsid_with_pid
 | ||||
| // __pthread_cond_timedwait
 | ||||
| // Aio_fsync
 | ||||
| // Aio_return
 | ||||
| // Aio_suspend
 | ||||
| // Aio_cancel
 | ||||
| // Aio_error
 | ||||
| // Aio_read
 | ||||
| // Aio_write
 | ||||
| // Lio_listio
 | ||||
| // __pthread_cond_wait
 | ||||
| // Iopolicysys
 | ||||
| // __pthread_kill
 | ||||
| // __pthread_sigmask
 | ||||
| // __sigwait
 | ||||
| // __disable_threadsignal
 | ||||
| // __pthread_markcancel
 | ||||
| // __pthread_canceled
 | ||||
| // __semwait_signal
 | ||||
| // Proc_info
 | ||||
| // sendfile
 | ||||
| // Stat64_extended
 | ||||
| // Lstat64_extended
 | ||||
| // Fstat64_extended
 | ||||
| // __pthread_chdir
 | ||||
| // __pthread_fchdir
 | ||||
| // Audit
 | ||||
| // Auditon
 | ||||
| // Getauid
 | ||||
| // Setauid
 | ||||
| // Getaudit
 | ||||
| // Setaudit
 | ||||
| // Getaudit_addr
 | ||||
| // Setaudit_addr
 | ||||
| // Auditctl
 | ||||
| // Bsdthread_create
 | ||||
| // Bsdthread_terminate
 | ||||
| // Stack_snapshot
 | ||||
| // Bsdthread_register
 | ||||
| // Workq_open
 | ||||
| // Workq_ops
 | ||||
| // __mac_execve
 | ||||
| // __mac_syscall
 | ||||
| // __mac_get_file
 | ||||
| // __mac_set_file
 | ||||
| // __mac_get_link
 | ||||
| // __mac_set_link
 | ||||
| // __mac_get_proc
 | ||||
| // __mac_set_proc
 | ||||
| // __mac_get_fd
 | ||||
| // __mac_set_fd
 | ||||
| // __mac_get_pid
 | ||||
| // __mac_get_lcid
 | ||||
| // __mac_get_lctx
 | ||||
| // __mac_set_lctx
 | ||||
| // Setlcid
 | ||||
| // Read_nocancel
 | ||||
| // Write_nocancel
 | ||||
| // Open_nocancel
 | ||||
| // Close_nocancel
 | ||||
| // Wait4_nocancel
 | ||||
| // Recvmsg_nocancel
 | ||||
| // Sendmsg_nocancel
 | ||||
| // Recvfrom_nocancel
 | ||||
| // Accept_nocancel
 | ||||
| // Fcntl_nocancel
 | ||||
| // Select_nocancel
 | ||||
| // Fsync_nocancel
 | ||||
| // Connect_nocancel
 | ||||
| // Sigsuspend_nocancel
 | ||||
| // Readv_nocancel
 | ||||
| // Writev_nocancel
 | ||||
| // Sendto_nocancel
 | ||||
| // Pread_nocancel
 | ||||
| // Pwrite_nocancel
 | ||||
| // Waitid_nocancel
 | ||||
| // Poll_nocancel
 | ||||
| // Msgsnd_nocancel
 | ||||
| // Msgrcv_nocancel
 | ||||
| // Sem_wait_nocancel
 | ||||
| // Aio_suspend_nocancel
 | ||||
| // __sigwait_nocancel
 | ||||
| // __semwait_signal_nocancel
 | ||||
| // __mac_mount
 | ||||
| // __mac_get_mount
 | ||||
| // __mac_getfsstat
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build amd64 && darwin
 | ||||
| // +build amd64,darwin
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build arm64 && darwin
 | ||||
| // +build arm64,darwin
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build darwin && go1.12
 | ||||
| // +build darwin,go1.12
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -172,6 +172,7 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { | |||
| } | ||||
| 
 | ||||
| //sys	ioctl(fd int, req uint, arg uintptr) (err error)
 | ||||
| //sys	ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = SYS_IOCTL
 | ||||
| 
 | ||||
| //sys	sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
 | ||||
| 
 | ||||
|  | @ -325,7 +326,6 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e | |||
| //sysnb	Setreuid(ruid int, euid int) (err error)
 | ||||
| //sysnb	Setresgid(rgid int, egid int, sgid int) (err error)
 | ||||
| //sysnb	Setresuid(ruid int, euid int, suid int) (err error)
 | ||||
| //sysnb	Setrlimit(which int, lim *Rlimit) (err error)
 | ||||
| //sysnb	Setsid() (pid int, err error)
 | ||||
| //sysnb	Settimeofday(tp *Timeval) (err error)
 | ||||
| //sysnb	Setuid(uid int) (err error)
 | ||||
|  | @ -343,203 +343,5 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e | |||
| //sys	write(fd int, p []byte) (n int, err error)
 | ||||
| //sys	mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
 | ||||
| //sys	munmap(addr uintptr, length uintptr) (err error)
 | ||||
| //sys	readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
 | ||||
| //sys	writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
 | ||||
| //sys	accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error)
 | ||||
| //sys	utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error)
 | ||||
| 
 | ||||
| /* | ||||
|  * Unimplemented | ||||
|  * TODO(jsing): Update this list for DragonFly. | ||||
|  */ | ||||
| // Profil
 | ||||
| // Sigaction
 | ||||
| // Sigprocmask
 | ||||
| // Getlogin
 | ||||
| // Sigpending
 | ||||
| // Sigaltstack
 | ||||
| // Reboot
 | ||||
| // Execve
 | ||||
| // Vfork
 | ||||
| // Sbrk
 | ||||
| // Sstk
 | ||||
| // Ovadvise
 | ||||
| // Mincore
 | ||||
| // Setitimer
 | ||||
| // Swapon
 | ||||
| // Select
 | ||||
| // Sigsuspend
 | ||||
| // Readv
 | ||||
| // Writev
 | ||||
| // Nfssvc
 | ||||
| // Getfh
 | ||||
| // Quotactl
 | ||||
| // Mount
 | ||||
| // Csops
 | ||||
| // Waitid
 | ||||
| // Add_profil
 | ||||
| // Kdebug_trace
 | ||||
| // Sigreturn
 | ||||
| // Atsocket
 | ||||
| // Kqueue_from_portset_np
 | ||||
| // Kqueue_portset
 | ||||
| // Getattrlist
 | ||||
| // Setattrlist
 | ||||
| // Getdirentriesattr
 | ||||
| // Searchfs
 | ||||
| // Delete
 | ||||
| // Copyfile
 | ||||
| // Watchevent
 | ||||
| // Waitevent
 | ||||
| // Modwatch
 | ||||
| // Getxattr
 | ||||
| // Fgetxattr
 | ||||
| // Setxattr
 | ||||
| // Fsetxattr
 | ||||
| // Removexattr
 | ||||
| // Fremovexattr
 | ||||
| // Listxattr
 | ||||
| // Flistxattr
 | ||||
| // Fsctl
 | ||||
| // Initgroups
 | ||||
| // Posix_spawn
 | ||||
| // Nfsclnt
 | ||||
| // Fhopen
 | ||||
| // Minherit
 | ||||
| // Semsys
 | ||||
| // Msgsys
 | ||||
| // Shmsys
 | ||||
| // Semctl
 | ||||
| // Semget
 | ||||
| // Semop
 | ||||
| // Msgctl
 | ||||
| // Msgget
 | ||||
| // Msgsnd
 | ||||
| // Msgrcv
 | ||||
| // Shmat
 | ||||
| // Shmctl
 | ||||
| // Shmdt
 | ||||
| // Shmget
 | ||||
| // Shm_open
 | ||||
| // Shm_unlink
 | ||||
| // Sem_open
 | ||||
| // Sem_close
 | ||||
| // Sem_unlink
 | ||||
| // Sem_wait
 | ||||
| // Sem_trywait
 | ||||
| // Sem_post
 | ||||
| // Sem_getvalue
 | ||||
| // Sem_init
 | ||||
| // Sem_destroy
 | ||||
| // Open_extended
 | ||||
| // Umask_extended
 | ||||
| // Stat_extended
 | ||||
| // Lstat_extended
 | ||||
| // Fstat_extended
 | ||||
| // Chmod_extended
 | ||||
| // Fchmod_extended
 | ||||
| // Access_extended
 | ||||
| // Settid
 | ||||
| // Gettid
 | ||||
| // Setsgroups
 | ||||
| // Getsgroups
 | ||||
| // Setwgroups
 | ||||
| // Getwgroups
 | ||||
| // Mkfifo_extended
 | ||||
| // Mkdir_extended
 | ||||
| // Identitysvc
 | ||||
| // Shared_region_check_np
 | ||||
| // Shared_region_map_np
 | ||||
| // __pthread_mutex_destroy
 | ||||
| // __pthread_mutex_init
 | ||||
| // __pthread_mutex_lock
 | ||||
| // __pthread_mutex_trylock
 | ||||
| // __pthread_mutex_unlock
 | ||||
| // __pthread_cond_init
 | ||||
| // __pthread_cond_destroy
 | ||||
| // __pthread_cond_broadcast
 | ||||
| // __pthread_cond_signal
 | ||||
| // Setsid_with_pid
 | ||||
| // __pthread_cond_timedwait
 | ||||
| // Aio_fsync
 | ||||
| // Aio_return
 | ||||
| // Aio_suspend
 | ||||
| // Aio_cancel
 | ||||
| // Aio_error
 | ||||
| // Aio_read
 | ||||
| // Aio_write
 | ||||
| // Lio_listio
 | ||||
| // __pthread_cond_wait
 | ||||
| // Iopolicysys
 | ||||
| // __pthread_kill
 | ||||
| // __pthread_sigmask
 | ||||
| // __sigwait
 | ||||
| // __disable_threadsignal
 | ||||
| // __pthread_markcancel
 | ||||
| // __pthread_canceled
 | ||||
| // __semwait_signal
 | ||||
| // Proc_info
 | ||||
| // Stat64_extended
 | ||||
| // Lstat64_extended
 | ||||
| // Fstat64_extended
 | ||||
| // __pthread_chdir
 | ||||
| // __pthread_fchdir
 | ||||
| // Audit
 | ||||
| // Auditon
 | ||||
| // Getauid
 | ||||
| // Setauid
 | ||||
| // Getaudit
 | ||||
| // Setaudit
 | ||||
| // Getaudit_addr
 | ||||
| // Setaudit_addr
 | ||||
| // Auditctl
 | ||||
| // Bsdthread_create
 | ||||
| // Bsdthread_terminate
 | ||||
| // Stack_snapshot
 | ||||
| // Bsdthread_register
 | ||||
| // Workq_open
 | ||||
| // Workq_ops
 | ||||
| // __mac_execve
 | ||||
| // __mac_syscall
 | ||||
| // __mac_get_file
 | ||||
| // __mac_set_file
 | ||||
| // __mac_get_link
 | ||||
| // __mac_set_link
 | ||||
| // __mac_get_proc
 | ||||
| // __mac_set_proc
 | ||||
| // __mac_get_fd
 | ||||
| // __mac_set_fd
 | ||||
| // __mac_get_pid
 | ||||
| // __mac_get_lcid
 | ||||
| // __mac_get_lctx
 | ||||
| // __mac_set_lctx
 | ||||
| // Setlcid
 | ||||
| // Read_nocancel
 | ||||
| // Write_nocancel
 | ||||
| // Open_nocancel
 | ||||
| // Close_nocancel
 | ||||
| // Wait4_nocancel
 | ||||
| // Recvmsg_nocancel
 | ||||
| // Sendmsg_nocancel
 | ||||
| // Recvfrom_nocancel
 | ||||
| // Accept_nocancel
 | ||||
| // Fcntl_nocancel
 | ||||
| // Select_nocancel
 | ||||
| // Fsync_nocancel
 | ||||
| // Connect_nocancel
 | ||||
| // Sigsuspend_nocancel
 | ||||
| // Readv_nocancel
 | ||||
| // Writev_nocancel
 | ||||
| // Sendto_nocancel
 | ||||
| // Pread_nocancel
 | ||||
| // Pwrite_nocancel
 | ||||
| // Waitid_nocancel
 | ||||
| // Msgsnd_nocancel
 | ||||
| // Msgrcv_nocancel
 | ||||
| // Sem_wait_nocancel
 | ||||
| // Aio_suspend_nocancel
 | ||||
| // __sigwait_nocancel
 | ||||
| // __semwait_signal_nocancel
 | ||||
| // __mac_mount
 | ||||
| // __mac_get_mount
 | ||||
| // __mac_getfsstat
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build amd64 && dragonfly
 | ||||
| // +build amd64,dragonfly
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  |  | |||
|  | @ -161,7 +161,8 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { | |||
| 	return | ||||
| } | ||||
| 
 | ||||
| //sys	ioctl(fd int, req uint, arg uintptr) (err error)
 | ||||
| //sys	ioctl(fd int, req uint, arg uintptr) (err error) = SYS_IOCTL
 | ||||
| //sys	ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = SYS_IOCTL
 | ||||
| 
 | ||||
| //sys	sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
 | ||||
| 
 | ||||
|  | @ -253,6 +254,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e | |||
| } | ||||
| 
 | ||||
| //sys	ptrace(request int, pid int, addr uintptr, data int) (err error)
 | ||||
| //sys	ptracePtr(request int, pid int, addr unsafe.Pointer, data int) (err error) = SYS_PTRACE
 | ||||
| 
 | ||||
| func PtraceAttach(pid int) (err error) { | ||||
| 	return ptrace(PT_ATTACH, pid, 0, 0) | ||||
|  | @ -267,19 +269,36 @@ func PtraceDetach(pid int) (err error) { | |||
| } | ||||
| 
 | ||||
| func PtraceGetFpRegs(pid int, fpregsout *FpReg) (err error) { | ||||
| 	return ptrace(PT_GETFPREGS, pid, uintptr(unsafe.Pointer(fpregsout)), 0) | ||||
| 	return ptracePtr(PT_GETFPREGS, pid, unsafe.Pointer(fpregsout), 0) | ||||
| } | ||||
| 
 | ||||
| func PtraceGetRegs(pid int, regsout *Reg) (err error) { | ||||
| 	return ptrace(PT_GETREGS, pid, uintptr(unsafe.Pointer(regsout)), 0) | ||||
| 	return ptracePtr(PT_GETREGS, pid, unsafe.Pointer(regsout), 0) | ||||
| } | ||||
| 
 | ||||
| func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) { | ||||
| 	ioDesc := PtraceIoDesc{ | ||||
| 		Op:   int32(req), | ||||
| 		Offs: offs, | ||||
| 	} | ||||
| 	if countin > 0 { | ||||
| 		_ = out[:countin] // check bounds
 | ||||
| 		ioDesc.Addr = &out[0] | ||||
| 	} else if out != nil { | ||||
| 		ioDesc.Addr = (*byte)(unsafe.Pointer(&_zero)) | ||||
| 	} | ||||
| 	ioDesc.SetLen(countin) | ||||
| 
 | ||||
| 	err = ptracePtr(PT_IO, pid, unsafe.Pointer(&ioDesc), 0) | ||||
| 	return int(ioDesc.Len), err | ||||
| } | ||||
| 
 | ||||
| func PtraceLwpEvents(pid int, enable int) (err error) { | ||||
| 	return ptrace(PT_LWP_EVENTS, pid, 0, enable) | ||||
| } | ||||
| 
 | ||||
| func PtraceLwpInfo(pid int, info uintptr) (err error) { | ||||
| 	return ptrace(PT_LWPINFO, pid, info, int(unsafe.Sizeof(PtraceLwpInfoStruct{}))) | ||||
| func PtraceLwpInfo(pid int, info *PtraceLwpInfoStruct) (err error) { | ||||
| 	return ptracePtr(PT_LWPINFO, pid, unsafe.Pointer(info), int(unsafe.Sizeof(*info))) | ||||
| } | ||||
| 
 | ||||
| func PtracePeekData(pid int, addr uintptr, out []byte) (count int, err error) { | ||||
|  | @ -299,13 +318,25 @@ func PtracePokeText(pid int, addr uintptr, data []byte) (count int, err error) { | |||
| } | ||||
| 
 | ||||
| func PtraceSetRegs(pid int, regs *Reg) (err error) { | ||||
| 	return ptrace(PT_SETREGS, pid, uintptr(unsafe.Pointer(regs)), 0) | ||||
| 	return ptracePtr(PT_SETREGS, pid, unsafe.Pointer(regs), 0) | ||||
| } | ||||
| 
 | ||||
| func PtraceSingleStep(pid int) (err error) { | ||||
| 	return ptrace(PT_STEP, pid, 1, 0) | ||||
| } | ||||
| 
 | ||||
| func Dup3(oldfd, newfd, flags int) error { | ||||
| 	if oldfd == newfd || flags&^O_CLOEXEC != 0 { | ||||
| 		return EINVAL | ||||
| 	} | ||||
| 	how := F_DUP2FD | ||||
| 	if flags&O_CLOEXEC != 0 { | ||||
| 		how = F_DUP2FD_CLOEXEC | ||||
| 	} | ||||
| 	_, err := fcntl(oldfd, how, newfd) | ||||
| 	return err | ||||
| } | ||||
| 
 | ||||
| /* | ||||
|  * Exposed directly | ||||
|  */ | ||||
|  | @ -402,7 +433,6 @@ func PtraceSingleStep(pid int) (err error) { | |||
| //sysnb	Setreuid(ruid int, euid int) (err error)
 | ||||
| //sysnb	Setresgid(rgid int, egid int, sgid int) (err error)
 | ||||
| //sysnb	Setresuid(ruid int, euid int, suid int) (err error)
 | ||||
| //sysnb	Setrlimit(which int, lim *Rlimit) (err error)
 | ||||
| //sysnb	Setsid() (pid int, err error)
 | ||||
| //sysnb	Settimeofday(tp *Timeval) (err error)
 | ||||
| //sysnb	Setuid(uid int) (err error)
 | ||||
|  | @ -419,197 +449,5 @@ func PtraceSingleStep(pid int) (err error) { | |||
| //sys	write(fd int, p []byte) (n int, err error)
 | ||||
| //sys	mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
 | ||||
| //sys	munmap(addr uintptr, length uintptr) (err error)
 | ||||
| //sys	readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
 | ||||
| //sys	writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
 | ||||
| //sys	accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error)
 | ||||
| //sys	utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error)
 | ||||
| 
 | ||||
| /* | ||||
|  * Unimplemented | ||||
|  */ | ||||
| // Profil
 | ||||
| // Sigaction
 | ||||
| // Sigprocmask
 | ||||
| // Getlogin
 | ||||
| // Sigpending
 | ||||
| // Sigaltstack
 | ||||
| // Ioctl
 | ||||
| // Reboot
 | ||||
| // Execve
 | ||||
| // Vfork
 | ||||
| // Sbrk
 | ||||
| // Sstk
 | ||||
| // Ovadvise
 | ||||
| // Mincore
 | ||||
| // Setitimer
 | ||||
| // Swapon
 | ||||
| // Select
 | ||||
| // Sigsuspend
 | ||||
| // Readv
 | ||||
| // Writev
 | ||||
| // Nfssvc
 | ||||
| // Getfh
 | ||||
| // Quotactl
 | ||||
| // Mount
 | ||||
| // Csops
 | ||||
| // Waitid
 | ||||
| // Add_profil
 | ||||
| // Kdebug_trace
 | ||||
| // Sigreturn
 | ||||
| // Atsocket
 | ||||
| // Kqueue_from_portset_np
 | ||||
| // Kqueue_portset
 | ||||
| // Getattrlist
 | ||||
| // Setattrlist
 | ||||
| // Getdents
 | ||||
| // Getdirentriesattr
 | ||||
| // Searchfs
 | ||||
| // Delete
 | ||||
| // Copyfile
 | ||||
| // Watchevent
 | ||||
| // Waitevent
 | ||||
| // Modwatch
 | ||||
| // Fsctl
 | ||||
| // Initgroups
 | ||||
| // Posix_spawn
 | ||||
| // Nfsclnt
 | ||||
| // Fhopen
 | ||||
| // Minherit
 | ||||
| // Semsys
 | ||||
| // Msgsys
 | ||||
| // Shmsys
 | ||||
| // Semctl
 | ||||
| // Semget
 | ||||
| // Semop
 | ||||
| // Msgctl
 | ||||
| // Msgget
 | ||||
| // Msgsnd
 | ||||
| // Msgrcv
 | ||||
| // Shmat
 | ||||
| // Shmctl
 | ||||
| // Shmdt
 | ||||
| // Shmget
 | ||||
| // Shm_open
 | ||||
| // Shm_unlink
 | ||||
| // Sem_open
 | ||||
| // Sem_close
 | ||||
| // Sem_unlink
 | ||||
| // Sem_wait
 | ||||
| // Sem_trywait
 | ||||
| // Sem_post
 | ||||
| // Sem_getvalue
 | ||||
| // Sem_init
 | ||||
| // Sem_destroy
 | ||||
| // Open_extended
 | ||||
| // Umask_extended
 | ||||
| // Stat_extended
 | ||||
| // Lstat_extended
 | ||||
| // Fstat_extended
 | ||||
| // Chmod_extended
 | ||||
| // Fchmod_extended
 | ||||
| // Access_extended
 | ||||
| // Settid
 | ||||
| // Gettid
 | ||||
| // Setsgroups
 | ||||
| // Getsgroups
 | ||||
| // Setwgroups
 | ||||
| // Getwgroups
 | ||||
| // Mkfifo_extended
 | ||||
| // Mkdir_extended
 | ||||
| // Identitysvc
 | ||||
| // Shared_region_check_np
 | ||||
| // Shared_region_map_np
 | ||||
| // __pthread_mutex_destroy
 | ||||
| // __pthread_mutex_init
 | ||||
| // __pthread_mutex_lock
 | ||||
| // __pthread_mutex_trylock
 | ||||
| // __pthread_mutex_unlock
 | ||||
| // __pthread_cond_init
 | ||||
| // __pthread_cond_destroy
 | ||||
| // __pthread_cond_broadcast
 | ||||
| // __pthread_cond_signal
 | ||||
| // Setsid_with_pid
 | ||||
| // __pthread_cond_timedwait
 | ||||
| // Aio_fsync
 | ||||
| // Aio_return
 | ||||
| // Aio_suspend
 | ||||
| // Aio_cancel
 | ||||
| // Aio_error
 | ||||
| // Aio_read
 | ||||
| // Aio_write
 | ||||
| // Lio_listio
 | ||||
| // __pthread_cond_wait
 | ||||
| // Iopolicysys
 | ||||
| // __pthread_kill
 | ||||
| // __pthread_sigmask
 | ||||
| // __sigwait
 | ||||
| // __disable_threadsignal
 | ||||
| // __pthread_markcancel
 | ||||
| // __pthread_canceled
 | ||||
| // __semwait_signal
 | ||||
| // Proc_info
 | ||||
| // Stat64_extended
 | ||||
| // Lstat64_extended
 | ||||
| // Fstat64_extended
 | ||||
| // __pthread_chdir
 | ||||
| // __pthread_fchdir
 | ||||
| // Audit
 | ||||
| // Auditon
 | ||||
| // Getauid
 | ||||
| // Setauid
 | ||||
| // Getaudit
 | ||||
| // Setaudit
 | ||||
| // Getaudit_addr
 | ||||
| // Setaudit_addr
 | ||||
| // Auditctl
 | ||||
| // Bsdthread_create
 | ||||
| // Bsdthread_terminate
 | ||||
| // Stack_snapshot
 | ||||
| // Bsdthread_register
 | ||||
| // Workq_open
 | ||||
| // Workq_ops
 | ||||
| // __mac_execve
 | ||||
| // __mac_syscall
 | ||||
| // __mac_get_file
 | ||||
| // __mac_set_file
 | ||||
| // __mac_get_link
 | ||||
| // __mac_set_link
 | ||||
| // __mac_get_proc
 | ||||
| // __mac_set_proc
 | ||||
| // __mac_get_fd
 | ||||
| // __mac_set_fd
 | ||||
| // __mac_get_pid
 | ||||
| // __mac_get_lcid
 | ||||
| // __mac_get_lctx
 | ||||
| // __mac_set_lctx
 | ||||
| // Setlcid
 | ||||
| // Read_nocancel
 | ||||
| // Write_nocancel
 | ||||
| // Open_nocancel
 | ||||
| // Close_nocancel
 | ||||
| // Wait4_nocancel
 | ||||
| // Recvmsg_nocancel
 | ||||
| // Sendmsg_nocancel
 | ||||
| // Recvfrom_nocancel
 | ||||
| // Accept_nocancel
 | ||||
| // Fcntl_nocancel
 | ||||
| // Select_nocancel
 | ||||
| // Fsync_nocancel
 | ||||
| // Connect_nocancel
 | ||||
| // Sigsuspend_nocancel
 | ||||
| // Readv_nocancel
 | ||||
| // Writev_nocancel
 | ||||
| // Sendto_nocancel
 | ||||
| // Pread_nocancel
 | ||||
| // Pwrite_nocancel
 | ||||
| // Waitid_nocancel
 | ||||
| // Poll_nocancel
 | ||||
| // Msgsnd_nocancel
 | ||||
| // Msgrcv_nocancel
 | ||||
| // Sem_wait_nocancel
 | ||||
| // Aio_suspend_nocancel
 | ||||
| // __sigwait_nocancel
 | ||||
| // __semwait_signal_nocancel
 | ||||
| // __mac_mount
 | ||||
| // __mac_get_mount
 | ||||
| // __mac_getfsstat
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build 386 && freebsd
 | ||||
| // +build 386,freebsd
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  | @ -42,6 +41,10 @@ func (cmsg *Cmsghdr) SetLen(length int) { | |||
| 	cmsg.Len = uint32(length) | ||||
| } | ||||
| 
 | ||||
| func (d *PtraceIoDesc) SetLen(length int) { | ||||
| 	d.Len = uint32(length) | ||||
| } | ||||
| 
 | ||||
| func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { | ||||
| 	var writtenOut uint64 = 0 | ||||
| 	_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) | ||||
|  | @ -57,16 +60,5 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e | |||
| func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) | ||||
| 
 | ||||
| func PtraceGetFsBase(pid int, fsbase *int64) (err error) { | ||||
| 	return ptrace(PT_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0) | ||||
| } | ||||
| 
 | ||||
| func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) { | ||||
| 	ioDesc := PtraceIoDesc{ | ||||
| 		Op:   int32(req), | ||||
| 		Offs: offs, | ||||
| 		Addr: uintptr(unsafe.Pointer(&out[0])), // TODO(#58351): this is not safe.
 | ||||
| 		Len:  uint32(countin), | ||||
| 	} | ||||
| 	err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) | ||||
| 	return int(ioDesc.Len), err | ||||
| 	return ptracePtr(PT_GETFSBASE, pid, unsafe.Pointer(fsbase), 0) | ||||
| } | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build amd64 && freebsd
 | ||||
| // +build amd64,freebsd
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  | @ -42,6 +41,10 @@ func (cmsg *Cmsghdr) SetLen(length int) { | |||
| 	cmsg.Len = uint32(length) | ||||
| } | ||||
| 
 | ||||
| func (d *PtraceIoDesc) SetLen(length int) { | ||||
| 	d.Len = uint64(length) | ||||
| } | ||||
| 
 | ||||
| func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { | ||||
| 	var writtenOut uint64 = 0 | ||||
| 	_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) | ||||
|  | @ -57,16 +60,5 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e | |||
| func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) | ||||
| 
 | ||||
| func PtraceGetFsBase(pid int, fsbase *int64) (err error) { | ||||
| 	return ptrace(PT_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0) | ||||
| } | ||||
| 
 | ||||
| func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) { | ||||
| 	ioDesc := PtraceIoDesc{ | ||||
| 		Op:   int32(req), | ||||
| 		Offs: offs, | ||||
| 		Addr: uintptr(unsafe.Pointer(&out[0])), // TODO(#58351): this is not safe.
 | ||||
| 		Len:  uint64(countin), | ||||
| 	} | ||||
| 	err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) | ||||
| 	return int(ioDesc.Len), err | ||||
| 	return ptracePtr(PT_GETFSBASE, pid, unsafe.Pointer(fsbase), 0) | ||||
| } | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| // license that can be found in the LICENSE file.
 | ||||
| 
 | ||||
| //go:build arm && freebsd
 | ||||
| // +build arm,freebsd
 | ||||
| 
 | ||||
| package unix | ||||
| 
 | ||||
|  | @ -42,6 +41,10 @@ func (cmsg *Cmsghdr) SetLen(length int) { | |||
| 	cmsg.Len = uint32(length) | ||||
| } | ||||
| 
 | ||||
| func (d *PtraceIoDesc) SetLen(length int) { | ||||
| 	d.Len = uint32(length) | ||||
| } | ||||
| 
 | ||||
| func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { | ||||
| 	var writtenOut uint64 = 0 | ||||
| 	_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) | ||||
|  | @ -55,14 +58,3 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e | |||
| } | ||||
| 
 | ||||
| func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) | ||||
| 
 | ||||
| func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) { | ||||
| 	ioDesc := PtraceIoDesc{ | ||||
| 		Op:   int32(req), | ||||
| 		Offs: offs, | ||||
| 		Addr: uintptr(unsafe.Pointer(&out[0])), // TODO(#58351): this is not safe.
 | ||||
| 		Len:  uint32(countin), | ||||
| 	} | ||||
| 	err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) | ||||
| 	return int(ioDesc.Len), err | ||||
| } | ||||
|  |  | |||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
		Reference in New Issue