Subject: sysctl,make,cpp have inconsistent machine type (#407) Index: pdp/machparam.h,bin/make/main.c,sys/kern_sysctl.c 2.11BSD Description: Some programs need to determine the machine type being used. There were 3 methods available. Unfortunately none of them returned or depended on the same value! Repeat-By: Observation. Or by using the 'MACHINE' variable of make(1) and finding out it uses 'PDP' rather than the expected 'pdp11. The 3 methods of a program determining the machine type are: 1) 'cpp'. This is a compile time option. The C preprocessor predefines the symbol "pdp11". Thus it is possible to do something like this: #ifdef pdp11 code code #endif 2) use the C library routine uname(3) or the underlying sysctl(2) call. The kernel returns the value "PDP11" for the machine type. This is the runtime method. 3) Use the sys/machparam.h 'MACHINE' define. This is defined as "PDP. This is another compile time option. However it does not agree with the first method above! make(1) used method #3. Other programs use #1. Confusing isn't it? Fix: Apply the patch below, recompile and install make(1) and the kernel. Optionally the GENERIC kernel may be recompiled and installed in /genunix. The patch changes the sysctl(2) handling of the kernel so that vm.machine is "pdp11". make(1) is modified to use uname(3) rather than the MACHINE definition in machparam.h machparam.h has the MACHINE definition removed because make(1) was the only program in the system using the define. The machine type is now always "pdp11". Cut where indicated and save to temp file (/tmp/407). Then: patch -p0 < /tmp/407 cd /usr/src/bin/make make make install make clean Then: cd /sys/YOUR_KERNEL make mv /unix /ounix mv /netnix /onetnix # Above is only necessary if you run a networking kernel mv unix netnix / chmod 744 /unix /netnix reboot Optionally you may compile and install an emergency GENERIC kernel cd /sys/GENERIC make mv unix /genunix As always this and previous updates to 2.11BSD are available via anonymous FTP to either FTP.IIPO.GTEGSC.COM or MOE.2BSD.COM in the directory /pub/2.11BSD. =============================cut here=========================== *** /usr/src/sys/sys/kern_sysctl.c.old Thu Jan 29 20:07:58 1998 --- /usr/src/sys/sys/kern_sysctl.c Tue Sep 15 19:57:05 1998 *************** *** 33,39 **** * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)kern_sysctl.c 8.4.8 (2.11BSD GTE) 1998/1/28 */ /* --- 33,39 ---- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)kern_sysctl.c 8.4.9 (2.11BSD GTE) 1998/9/15 */ /* *************** *** 275,283 **** void *newp; size_t newlen; { ! char m[10], c[10]; char *cpu2str(); ! extern size_t physmem; /* all sysctl names at this level are terminal */ if (namelen != 1) --- 275,283 ---- void *newp; size_t newlen; { ! char c[10]; char *cpu2str(); ! extern size_t physmem; /* machdep2.c */ /* all sysctl names at this level are terminal */ if (namelen != 1) *************** *** 285,292 **** switch (name[0]) { case HW_MACHINE: ! m[0]='P';m[1]='D';m[2]='P';m[3]='1';m[4]='1';m[5]='\0'; ! return (sysctl_rdstring(oldp, oldlenp, newp, m)); case HW_MODEL: return (sysctl_rdstring(oldp, oldlenp, newp, cpu2str(c,sizeof (c)))); --- 285,291 ---- switch (name[0]) { case HW_MACHINE: ! return (sysctl_rdstring(oldp, oldlenp, newp, "pdp11")); case HW_MODEL: return (sysctl_rdstring(oldp, oldlenp, newp, cpu2str(c,sizeof (c)))); *** /usr/src/sys/pdp/machparam.h.old Wed Jun 19 21:41:20 1996 --- /usr/src/sys/pdp/machparam.h Tue Sep 15 19:53:58 1998 *************** *** 3,17 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)machparam.h 1.3 (2.11BSD GTE) 1996/6/19 */ /* * Machine dependent constants for PDP. */ - - #define MACHINE "pdp" - #ifndef ENDIAN /* * Definitions for byte order, --- 3,14 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)machparam.h 1.4 (2.11BSD GTE) 1998/9/15 */ /* * Machine dependent constants for PDP. */ #ifndef ENDIAN /* * Definitions for byte order, *** /usr/src/bin/make/main.c.old Sat Aug 10 16:05:36 1991 --- /usr/src/bin/make/main.c Tue Sep 15 21:22:47 1998 *************** *** 1,5 **** ! /* static char *sccsid = "@(#)main.c 4.9 (Berkeley) 87/05/21"; */ ! # include "defs" /* command make to update programs. Flags: 'd' print out debugging comments --- 1,7 ---- ! /* static char *sccsid = "@(#)main.c 4.10 (2.11BSD) 98/9/15"; */ ! ! #include "defs" ! /* command make to update programs. Flags: 'd' print out debugging comments *************** *** 161,167 **** *options = '\0'; setvar("MFLAGS", options); /* MFLAGS=options to make */ ! setvar("MACHINE", MACHINE); if( !descset ) #ifdef unix --- 163,169 ---- *options = '\0'; setvar("MFLAGS", options); /* MFLAGS=options to make */ ! setmachine(); if( !descset ) #ifdef unix *************** *** 410,412 **** --- 412,429 ---- } } } + + #include + + /* + * This is done in a function by itself because 'uname()' uses a 640 + * structure which we do not want permanently allocated on main()'s stack. + */ + setmachine() + { + struct utsname foo; + + if (uname(&foo) < 0) + strcpy(foo.machine, "?"); + setvar("MACHINE", foo.machine); + } *** /VERSION.old Tue May 12 21:03:49 1998 --- /VERSION Tue Sep 15 21:04:06 1998 *************** *** 1,5 **** ! Current Patch Level: 406 ! Date: May 12, 1998 2.11 BSD ============ --- 1,5 ---- ! Current Patch Level: 407 ! Date: September 15, 1998 2.11 BSD ============