diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2010-07-22 09:13:49 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2010-07-22 09:13:49 +0000 |
commit | 87d45a03921c39304b7fe7407f026dd5aea1d005 (patch) | |
tree | a1e7b78633c799b8be45f7c7e0bf35589eceef96 /sys/kern/kern_mib.c | |
parent | 1a517c3ec572555fe09cdcb5f0e68749953c0b83 (diff) | |
download | src-87d45a03921c39304b7fe7407f026dd5aea1d005.tar.gz src-87d45a03921c39304b7fe7407f026dd5aea1d005.zip |
When compat32 binary asks for the value of hw.machine_arch, report the
name of 32bit sibling architecture instead of the host one. Do the
same for hw.machine on amd64.
Add a safety belt debug.adaptive_machine_arch sysctl, to turn the
substitution off.
Reviewed by: jhb, nwhitehorn
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=210369
Diffstat (limited to 'sys/kern/kern_mib.c')
-rw-r--r-- | sys/kern/kern_mib.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c index 7ef580f5ac27..e31daf7342d4 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"); -static char machine_arch[] = MACHINE_ARCH; -SYSCTL_STRING(_hw, HW_MACHINE_ARCH, machine_arch, CTLFLAG_RD, - machine_arch, 0, "System architecture"); +#ifdef SCTL_MASK32 +int adaptive_machine_arch = 1; +SYSCTL_INT(_debug, OID_AUTO, adaptive_machine_arch, CTLFLAG_RW, + &adaptive_machine_arch, 1, + "Adapt reported machine architecture to the ABI of the binary"); +#endif + +static int +sysctl_hw_machine_arch(SYSCTL_HANDLER_ARGS) +{ + int error; + static const char machine_arch[] = MACHINE_ARCH; +#ifdef SCTL_MASK32 + static const char machine_arch32[] = MACHINE_ARCH32; + + if ((req->flags & SCTL_MASK32) != 0 && adaptive_machine_arch) + error = SYSCTL_OUT(req, machine_arch32, sizeof(machine_arch32)); + else +#endif + error = 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"); static int sysctl_hostname(SYSCTL_HANDLER_ARGS) |