Subject: Re: cgd failure since hackathon
To: brad harder <bharder@methodlogic.net>
From: Quentin Garnier <cube@cubidou.net>
List: current-users
Date: 11/30/2006 20:06:23
--EmwFttYoLalE/5Ab
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Nov 30, 2006 at 10:38:38AM -0800, brad harder wrote:
>=20
>=20
>  I've been running -current since it was announced that 4 was being re-br=
anched, and had no major problems to speak of. One of the things I'm runnin=
g succesfully is cgd(4), and an encrypted /home and swap. Kernels build fro=
m updated sources (since hackathon) yield however, yield this:
>=20
> cgd: large blocksize 4294967295
> ioctl: Cannot allocate memory
> cgdconfig: action failed on "/etc/cgd/cgd.conf" line 1
>=20
>=20
> Does anybody have an idea what's going on with this, and if it requires a=
 work-around on my part, or is a cgd failing.

The following patch should fix it.

Anyone objects?  The size_t -> ssize_t is necessary to avoid
signed/unsigned mismatch, if we ever want to warn on that (I thought we
did, though).

Also, why the magic number 4096?

[Cc Christos]

Index: cgd.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /rep/NetBSD-src/cvs/src/sys/dev/cgd.c,v
retrieving revision 1.41
diff -u -r1.41 cgd.c
--- cgd.c	2006/11/25 21:13:23	1.41
+++ cgd.c	2006/11/30 19:03:33
@@ -542,8 +542,8 @@
 	if (ret)
 		goto bail;
=20
-	if (ci->ci_blocksize > 4096) {
-		printf("cgd: large blocksize %zu\n", ci->ci_blocksize);
+	if (ci->ci_blocksize > 4096 || ci->ci_blocksize < -1) {
+		printf("cgd: large blocksize %zd\n", ci->ci_blocksize);
 		ret =3D ENOMEM;
 		goto bail;
 	}
Index: cgdvar.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /rep/NetBSD-src/cvs/src/sys/dev/cgdvar.h,v
retrieving revision 1.5
diff -u -r1.5 cgdvar.h
--- cgdvar.h	2005/12/11 12:20:53	1.5
+++ cgdvar.h	2006/11/30 19:03:08
@@ -49,7 +49,7 @@
 	const char	*ci_ivmethod;
 	size_t		 ci_keylen;
 	const char	*ci_key;
-	size_t		 ci_blocksize;
+	ssize_t		 ci_blocksize;
 };
=20
 #ifdef _KERNEL

--=20
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"You could have made it, spitting out benchmarks
Owe it to yourself not to fail"
Amplifico, Spitting Out Benchmarks, Hometakes Vol. 2, 2005.

--EmwFttYoLalE/5Ab
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (NetBSD)

iQEVAwUBRW8rr9goQloHrPnoAQJn5wf/ZGdixLi9RB0amgEXOj12zfm0kKSsY59B
uQOoe17du4L2H53zt1O3R3P88oOquTj/440rzWyOF9A3WChFrFRUOevYKKojY5dg
Ih0XK0K7uXlEpzRSsrm34vkNurpln1Sw0JgddtdZLW69ilX4r7LX2XpFWWv0el+I
vGXtqM83jJO2Ddd7TSfPGgzlUKNzjwJEntijHTerGDbzvLkn+dBxVvb6NsNDeWtJ
5JCmIVAchs3OLJjk46wCQYDmkH8/W1j+1TsTs+GGe7PiUIz2599Ol7pBqrLLQiYb
EaC6b5x+++N4gEMBNBTAYAX8S7HHLc3NpPJ7Zq4pl+/AepbhLZFqiQ==
=fqzg
-----END PGP SIGNATURE-----

--EmwFttYoLalE/5Ab--