patches for 1.3.71 w/iBCS

Tom Grigg (st588@bayou.uh.edu)
Wed, 6 Mar 1996 15:17:16 -0600 (CST)


As many of you have noticed, the 1.3.71 kernel breaks iBCS. Below are
some patches to correct this problem, both for the kernel and iBCS itself.
The diffs for iBCS were taken against the February 1st release of version
1.3, which can be found at
ftp://tsx-11.mit.edu/pub/linux/BETA/ibcs2/ibcs-1.3-960201.tar.gz

The patches also fix the MAKEDEV.ibcs script, which was broken and caused
all the necessary /dev files to be deleted and not recreated, leaving the
iBCS system totally unusable. The iBCS makefile was adjusted to compile
with MODVERSIONS enabled; you can remove the line with -DMODVERSIONS if you
don't want this. Some of the warnings generated when compiling the iBCS code
were addressed as well.

PLEASE NOTE: once you have patched your iBCS sources, they will no longer
work with any kernel version prior to 1.3.71, so please save any old
compiled iBCS modules for previous kernels that you may want to use in the
future.

Below are the diffs, first for the kernel, and then for iBCS.

diff -u --recursive linux-1.3.71/fs/binfmt_aout.c linux/fs/binfmt_aout.c
--- linux-1.3.71/fs/binfmt_aout.c Sat Mar 2 12:29:23 1996
+++ linux/fs/binfmt_aout.c Tue Mar 5 17:41:36 1996
@@ -201,7 +201,7 @@
* memory and creates the pointer tables from them, and puts their
* addresses on the "stack", returning the new stack pointer value.
*/
-static unsigned long * create_aout_tables(char * p, struct linux_binprm * bprm, int ibcs)
+unsigned long * create_aout_tables(char * p, struct linux_binprm * bprm, int ibcs)
{
unsigned long *argv,*envp;
unsigned long * sp;
diff -u --recursive linux-1.3.71/include/linux/binfmts.h linux/include/linux/binfmts.h
--- linux-1.3.71/include/linux/binfmts.h Sat Mar 2 12:29:23 1996
+++ linux/include/linux/binfmts.h Tue Mar 5 20:46:58 1996
@@ -32,7 +32,7 @@
*/
struct linux_binfmt {
struct linux_binfmt * next;
- int *use_count;
+ long *use_count;
int (*load_binary)(struct linux_binprm *, struct pt_regs * regs);
int (*load_shlib)(int fd);
int (*core_dump)(long signr, struct pt_regs * regs);
@@ -54,6 +54,7 @@
extern int prepare_binprm(struct linux_binprm *);
extern int search_binary_handler(struct linux_binprm *,struct pt_regs *);
extern void flush_old_exec(struct linux_binprm * bprm);
+extern unsigned long * create_aout_tables(char *p, struct linux_binprm *bprm, int ibcs);
extern unsigned long setup_arg_pages(unsigned long p, struct linux_binprm * bprm);
extern unsigned long copy_strings(int argc,char ** argv,unsigned long *page,
unsigned long p, int from_kmem);
diff -u --recursive linux-1.3.71/include/linux/personality.h linux/include/linux/personality.h
--- linux-1.3.71/include/linux/personality.h Wed Sep 13 02:31:15 1995
+++ linux/include/linux/personality.h Tue Mar 5 18:08:25 1996
@@ -37,7 +37,7 @@
unsigned char pers_low, pers_high;
unsigned long * signal_map;
unsigned long * signal_invmap;
- int *use_count;
+ long *use_count;
struct exec_domain *next;
};

diff -u --recursive linux-1.3.71/kernel/ksyms.c linux/kernel/ksyms.c
--- linux-1.3.71/kernel/ksyms.c Sat Mar 2 12:29:24 1996
+++ linux/kernel/ksyms.c Tue Mar 5 17:42:53 1996
@@ -329,6 +329,7 @@
/* Program loader interfaces */
X(setup_arg_pages),
X(copy_strings),
+ X(create_aout_tables),
X(do_execve),
X(flush_old_exec),
X(open_inode),
-----------------------------[ cut here ]-------------------------
diff -u --recursive ibcs-960201/MAKEDEV.ibcs ibcs/MAKEDEV.ibcs
--- ibcs-960201/MAKEDEV.ibcs Thu Feb 1 06:54:59 1996
+++ ibcs/MAKEDEV.ibcs Tue Mar 5 14:52:54 1996
@@ -13,26 +13,26 @@
fi

rm -f socksys nfsd
-mknod -m 0666 socksys c $(SOCKSYS_MAJOR) 0
+mknod -m 0666 socksys c ${SOCKSYS_MAJOR} 0
ln socksys nfsd
rm -f spx X0R
-mknod -m 0666 spx c $(SOCKSYS_MAJOR) 1
+mknod -m 0666 spx c ${SOCKSYS_MAJOR} 1
ln spx X0R

rm -fr inet
rm -f ip icmp ggp ipip tcp egp pup udp idp rawip arp rip
mkdir -m 0755 inet

-mknod -m 0666 inet/ip c $(SOCKSYS_MAJOR) 32
-mknod -m 0666 inet/icmp c $(SOCKSYS_MAJOR) 33
-mknod -m 0666 inet/ggp c $(SOCKSYS_MAJOR) 34
-mknod -m 0666 inet/ipip c $(SOCKSYS_MAJOR) 35
-mknod -m 0666 inet/tcp c $(SOCKSYS_MAJOR) 36
-mknod -m 0666 inet/egp c $(SOCKSYS_MAJOR) 37
-mknod -m 0666 inet/pup c $(SOCKSYS_MAJOR) 38
-mknod -m 0666 inet/udp c $(SOCKSYS_MAJOR) 39
-mknod -m 0666 inet/idp c $(SOCKSYS_MAJOR) 40
-mknod -m 0666 inet/rawip c $(SOCKSYS_MAJOR) 41
+mknod -m 0666 inet/ip c ${SOCKSYS_MAJOR} 32
+mknod -m 0666 inet/icmp c ${SOCKSYS_MAJOR} 33
+mknod -m 0666 inet/ggp c ${SOCKSYS_MAJOR} 34
+mknod -m 0666 inet/ipip c ${SOCKSYS_MAJOR} 35
+mknod -m 0666 inet/tcp c ${SOCKSYS_MAJOR} 36
+mknod -m 0666 inet/egp c ${SOCKSYS_MAJOR} 37
+mknod -m 0666 inet/pup c ${SOCKSYS_MAJOR} 38
+mknod -m 0666 inet/udp c ${SOCKSYS_MAJOR} 39
+mknod -m 0666 inet/idp c ${SOCKSYS_MAJOR} 40
+mknod -m 0666 inet/rawip c ${SOCKSYS_MAJOR} 41
ln inet/udp inet/arp
ln inet/udp inet/rip
for i in ip icmp ggp ipip tcp egp pup udp idp rawip arp rip
diff -u --recursive ibcs-960201/iBCSemul/Makefile ibcs/iBCSemul/Makefile
--- ibcs-960201/iBCSemul/Makefile Thu Jan 18 10:10:25 1996
+++ ibcs/iBCSemul/Makefile Tue Mar 5 20:34:20 1996
@@ -100,6 +100,7 @@


CFLAGS = -D__KERNEL__=1 -DMODULE -D__NO_VERSION__ \
+ -DMODVERSIONS -include /usr/include/linux/modversions.h \
-I../include -Wall -Wstrict-prototypes \
-O3 -fomit-frame-pointer -m486 \
-DSOCKSYS_MAJOR=$(SOCKSYS_MAJOR) $(EMUOPTS)
diff -u --recursive ibcs-960201/iBCSemul/binfmt_aout.c ibcs/iBCSemul/binfmt_aout.c
--- ibcs-960201/iBCSemul/binfmt_aout.c Fri Jan 12 11:27:15 1996
+++ ibcs/iBCSemul/binfmt_aout.c Tue Mar 5 21:09:30 1996
@@ -9,6 +9,14 @@
* linux/fs/exec.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
+ *
+ * 5 March 1996
+ * Tom Grigg (st588@jetson.uh.edu)
+ * Modified code to work with Linux 1.3.71.
+ *
+ * ****************** !! NOTE !! ********************
+ * This code will not work on prior verions of Linux!
+ * **************************************************
*/
#include <linux/config.h>

@@ -272,10 +280,9 @@
if (current->binfmt && current->binfmt->use_count)
(*current->binfmt->use_count)++;

- p += setup_arg_pages(ex.a_text,bprm->page);
- p -= MAX_ARG_PAGES*PAGE_SIZE;
+ p = setup_arg_pages(p, bprm);
#ifdef __NR_getsid
- p = (unsigned long)create_tables((char *)p, bprm,
+ p = (unsigned long)create_aout_tables((char *)p, bprm,
current->personality != PER_LINUX);
#else
p = (unsigned long)create_tables((char *)p,
diff -u --recursive ibcs-960201/iBCSemul/binfmt_coff.c ibcs/iBCSemul/binfmt_coff.c
--- ibcs-960201/iBCSemul/binfmt_coff.c Fri Jan 12 11:27:17 1996
+++ ibcs/iBCSemul/binfmt_coff.c Tue Mar 5 21:09:02 1996
@@ -25,6 +25,14 @@
* If compile the module version of iBCS rather than the in-kernel
* version we must take care to signal when module code is in use
* or it may be freed from under us - Bad News :-).
+ *
+ * 5 March 1996
+ * Tom Grigg (st588@jetson.uh.edu)
+ * Modified code to work with Linux 1.3.71.
+ *
+ * ****************** !! NOTE !! ********************
+ * This code will not work on prior verions of Linux!
+ * **************************************************
*/

#include <linux/config.h>
@@ -563,9 +571,8 @@
* Construct the parameter and environment string table entries.
*/
#ifdef STACK_TOP
- bprm->p += setup_arg_pages (0, bprm->page);
- bprm->p -= MAX_ARG_PAGES*PAGE_SIZE;
- bprm->p = (unsigned long) create_tables ((char *) bprm->p,
+ bprm->p = setup_arg_pages (bprm->p, bprm);
+ bprm->p = (unsigned long) create_aout_tables ((char *) bprm->p,
bprm, 1);
#else
bprm->p += change_ldt (0, bprm->page);
@@ -957,7 +964,9 @@
{
unsigned long offset, nbytes;
char *buffer;
+#ifndef STACK_TOP
int old_fs;
+#endif
int status;

/*
@@ -1098,8 +1107,9 @@
else {
struct file *file; /* Pointer to the file table */
struct pt_regs regs; /* Register work area */
+#ifndef STACK_TOP
int old_fs = get_fs (); /* Previous FS register value */
-
+#endif
memset (bprm, '\0', sizeof (struct linux_binprm));

file = current->FD[fd];
diff -u --recursive ibcs-960201/iBCSemul/binfmt_xout.c ibcs/iBCSemul/binfmt_xout.c
--- ibcs-960201/iBCSemul/binfmt_xout.c Thu Jun 22 07:11:23 1995
+++ ibcs/iBCSemul/binfmt_xout.c Tue Mar 5 21:09:40 1996
@@ -9,6 +9,14 @@
* This file is based upon code written by Al Longyear for the COFF file
* format which is in turn based upon code written by Eric Youngdale for
* the ELF object file format. Any errors are most likely my own however.
+ *
+ * 5 March 1996
+ * Tom Grigg (st588@jetson.uh.edu)
+ * Modified code to work with Linux 1.3.71.
+ *
+ * ****************** !! NOTE !! ********************
+ * This code will not work on prior verions of Linux!
+ * **************************************************
*/
#include <linux/config.h>

@@ -388,10 +396,9 @@
/*
* Construct the parameter and environment string table entries.
*/
- bprm->p += change_ldt(0, bprm->page);
- bprm->p -= MAX_ARG_PAGES*PAGE_SIZE;
+ bprm->p = change_ldt(bprm->p, bprm);
#ifdef __NR_getdents
- bprm->p = (unsigned long)create_tables((char *) bprm->p,
+ bprm->p = (unsigned long)create_aout_tables((char *) bprm->p,
bprm,
#else
bprm->p = (unsigned long)create_tables((char *) bprm->p,
diff -u --recursive ibcs-960201/iBCSemul/ioctl.c ibcs/iBCSemul/ioctl.c
--- ibcs-960201/iBCSemul/ioctl.c Wed Jan 24 04:22:29 1996
+++ ibcs/iBCSemul/ioctl.c Tue Mar 5 19:04:41 1996
@@ -774,7 +774,7 @@
}

memcpy_fromfs(&tx, arg, sizeof(struct termiox));
- if ((tx.x_hflag != 0 && tx.x_hflag != RTSXOFF|CTSXON)
+ if ((tx.x_hflag != 0 && tx.x_hflag != (RTSXOFF|CTSXON))
|| tx.x_cflag || tx.x_rflag[0] || tx.x_rflag[1]
|| tx.x_rflag[2] || tx.x_rflag[3] || tx.x_rflag[4]
|| tx.x_sflag)
diff -u --recursive ibcs-960201/iBCSemul/open.c ibcs/iBCSemul/open.c
--- ibcs-960201/iBCSemul/open.c Tue Dec 12 04:31:05 1995
+++ ibcs/iBCSemul/open.c Tue Mar 5 20:09:15 1996
@@ -35,6 +35,7 @@
#include <linux/malloc.h>

#include <ibcs/ibcs.h>
+#include <ibcs/xnx.h>

#ifdef __NR_getdents
#include <linux/dirent.h>
diff -u --recursive ibcs-960201/iBCSemul/socksys.c ibcs/iBCSemul/socksys.c
--- ibcs-960201/iBCSemul/socksys.c Wed Jan 24 04:22:32 1996
+++ ibcs/iBCSemul/socksys.c Tue Mar 5 18:56:20 1996
@@ -54,7 +54,7 @@
int sel_type, select_table *wait);

static int spx_write(struct inode *ino, struct file *filep,
- char *buf, int count);
+ const char *buf, int count);

/* spx_fops defines the file operations that can be applied to the
* /dev/spx server devices.
@@ -647,7 +647,7 @@


static int
-spx_write(struct inode *ino, struct file *filep, char *buf, int count)
+spx_write(struct inode *ino, struct file *filep, const char *buf, int count)
{
int newfd, err, args[3];
struct sockaddr_un addr = {

--
Tom Grigg
st588@jetson.uh.edu
http://www.egr.uh.edu/~eac64750/tom/