Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Jul 2010 15:52:31 -0600
From:      Scott Long <scottl@samsco.org>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        amd64@freebsd.org, arch@freebsd.org
Subject:   Re: uname -m/-p for compat32 binaries
Message-ID:  <BC1D5EFF-3B2E-4358-A8E9-29B3CCD25DE4@samsco.org>
In-Reply-To: <20100719213054.GB2381@deviant.kiev.zoral.com.ua>
References:  <20100719213054.GB2381@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
We do something similar at yahoo, and it's code that we're working on =
packaging up to put back into FreeBSD.  I don't know how your code =
differs from ours, and I obviously cannot stop you from committing =
yours, but you're welcome to look at our code.

Scott

On Jul 19, 2010, at 3:30 PM, Kostik Belousov wrote:

> Hi,
> I intend to commit the following change, that makes sysctls
> hw.machine_arch and hw.machine to return "i386" for 32 bit
> binaries run on amd64. In particular, 32 bit uname -m and uname -p
> print "i386", that is good for i386 jails on amd64 kernels.
>=20
> I find the change very useful for me, but I wonder why such trivial
> modification is not yet done. Can anybody note a possible fallout from
> it ?
>=20
> diff --git a/sys/amd64/amd64/identcpu.c b/sys/amd64/amd64/identcpu.c
> index 52e7568..68de22b 100644
> --- a/sys/amd64/amd64/identcpu.c
> +++ b/sys/amd64/amd64/identcpu.c
> @@ -76,8 +76,26 @@ static void print_via_padlock_info(void);
>=20
> int	cpu_class;
> char machine[] =3D "amd64";
> -SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,=20
> -    machine, 0, "Machine class");
> +
> +static int
> +sysctl_hw_machine(SYSCTL_HANDLER_ARGS)
> +{
> +#ifdef SCTL_MASK32
> +	static const char machine32[] =3D "i386";
> +#endif
> +	int error;
> +
> +#ifdef SCTL_MASK32
> +	if ((req->flags & SCTL_MASK32) !=3D 0)
> +		error =3D SYSCTL_OUT(req, machine32, sizeof(machine32));
> +	else
> +#endif
> +		error =3D SYSCTL_OUT(req, machine, sizeof(machine));
> +	return (error);
> +
> +}
> +SYSCTL_PROC(_hw, HW_MACHINE, machine, CTLTYPE_STRING | CTLFLAG_RD,
> +    NULL, 0, sysctl_hw_machine, "A", "Machine class");
>=20
> static char cpu_model[128];
> SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,=20
> diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c
> index 7ef580f..0b7d27f 100644
> --- a/sys/kern/kern_mib.c
> +++ b/sys/kern/kern_mib.c
> @@ -232,9 +232,31 @@ sysctl_hw_pagesizes(SYSCTL_HANDLER_ARGS)
> SYSCTL_PROC(_hw, OID_AUTO, pagesizes, CTLTYPE_ULONG | CTLFLAG_RD,
>     NULL, 0, sysctl_hw_pagesizes, "LU", "Supported page sizes");
>=20
> -static char	machine_arch[] =3D MACHINE_ARCH;
> -SYSCTL_STRING(_hw, HW_MACHINE_ARCH, machine_arch, CTLFLAG_RD,
> -    machine_arch, 0, "System architecture");
> +static int
> +sysctl_hw_machine_arch(SYSCTL_HANDLER_ARGS)
> +{
> +	static const char machine_arch[] =3D MACHINE_ARCH;
> +#ifdef SCTL_MASK32
> +	static const char machine_arch32[] =3D=20
> +#if defined(__amd64__) || defined(__ia64__)
> +		"i386";
> +#else
> +		MACHINE_ARCH;
> +#endif
> +#endif
> +	int error;
> +
> +#ifdef SCTL_MASK32
> +	if ((req->flags & SCTL_MASK32) !=3D 0)
> +		error =3D SYSCTL_OUT(req, machine_arch32, =
sizeof(machine_arch32));
> +	else
> +#endif
> +		error =3D SYSCTL_OUT(req, machine_arch, =
sizeof(machine_arch));
> +	return (error);
> +
> +}
> +SYSCTL_PROC(_hw, HW_MACHINE_ARCH, machine_arch, CTLTYPE_STRING | =
CTLFLAG_RD,
> +    NULL, 0, sysctl_hw_machine_arch, "A", "System architecture");
>=20
> static int
> sysctl_hostname(SYSCTL_HANDLER_ARGS)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BC1D5EFF-3B2E-4358-A8E9-29B3CCD25DE4>