BSD 4_4 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Tue, 8 Jun 1982 12:35:30 +0000 (04:35 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Tue, 8 Jun 1982 12:35:30 +0000 (04:35 -0800)
Work on file usr/src/old/games.vax/compat/modshell/Makefile
Work on file usr/src/old/games.vax/compat/modshell/compat.c
Work on file usr/src/old/games.vax/compat/modshell/defs.h.ediff
Work on file usr/src/old/games.vax/compat/modshell/msg.c.ediff
Work on file usr/src/old/games.vax/compat/modshell/name.c.ediff
Work on file usr/src/old/games.vax/compat/modshell/service.c.edif
Work on file usr/src/old/games.vax/compat/modshell/v6flag.c

Synthesized-from: CSRG/cd3/4.4

usr/src/old/games.vax/compat/modshell/Makefile [new file with mode: 0644]
usr/src/old/games.vax/compat/modshell/compat.c [new file with mode: 0644]
usr/src/old/games.vax/compat/modshell/defs.h.ediff [new file with mode: 0644]
usr/src/old/games.vax/compat/modshell/msg.c.ediff [new file with mode: 0644]
usr/src/old/games.vax/compat/modshell/name.c.ediff [new file with mode: 0644]
usr/src/old/games.vax/compat/modshell/service.c.edif [new file with mode: 0644]
usr/src/old/games.vax/compat/modshell/v6flag.c [new file with mode: 0644]

diff --git a/usr/src/old/games.vax/compat/modshell/Makefile b/usr/src/old/games.vax/compat/modshell/Makefile
new file mode 100644 (file)
index 0000000..b4404d2
--- /dev/null
@@ -0,0 +1,34 @@
+CFLAGS = -n -s -O
+
+all:   sh
+
+cp:    sh
+       cp sh /bin/sh
+       rm sh *.o
+
+cmp:   sh
+       cmp sh /bin/sh
+       rm sh *.o
+
+sh:    setbrk.o
+sh:    builtin.o blok.o stak.o
+sh:    cmd.o fault.o main.o
+sh:    word.o string.o name.o args.o
+sh:    xec.o service.o error.o io.o
+sh:    print.o macro.o expand.o
+sh:    ctype.o msg.o
+sh:    compat.o
+blok.o:                brkincr.h
+fault.o:       brkincr.h
+main.o:                brkincr.h
+stak.o:                brkincr.h
+
+sh:;           cc -o sh -n *.o
+
+newsys:;       :newsys file=msg; make sh
+install:;      install -s sh $(DESTDIR)/bin
+clean:; rm -f sh *.o
+diff:;         :diff
+list:;         list Makefile *.h *.s *.c
+
+.c.o:; cc -O  -c $<
diff --git a/usr/src/old/games.vax/compat/modshell/compat.c b/usr/src/old/games.vax/compat/modshell/compat.c
new file mode 100644 (file)
index 0000000..4dae3da
--- /dev/null
@@ -0,0 +1,58 @@
+#include "defs.h"
+#define BS 8
+#define        MAXARGS 300
+short buf[BS];
+/*
+ *     Check for possible program to run under alternate runtime system
+ *     If it checks out, start the rts and pass file and args
+ *     Art Wetzel 3/13/80
+ */
+compat(file, argv, envp) char *file, *argv[], *envp[]; {
+       register int fd;
+       register char *rts;
+       register char **nargv;
+       char    *nargs[MAXARGS];
+       /* alternate rts images must be readable */
+       /* if not just go back and let rest of shell worry about it */
+       if((fd = open(file,0))<0)
+               return(0);
+       /* read first BS pdp-11 words */
+       if(read(fd,buf,sizeof buf) != sizeof buf) {
+               close(fd);
+               /* if can't, go back as it may be a short shell file */
+               return(0);
+       }
+       close(fd);
+       /* check type of image and set up run time system name */
+       if(buf[0]==0407 || buf[0]==0410 || buf[0]==0411 || buf[0]==0405) {
+               /* looks like UNIX a.out file */
+               /* RTS or default rts */
+               if((rts = rtsnod.namval) == 0)
+                       rts = defrts;
+               /* if header unused is set to 1 force version 6 */
+               /* this is not a real difference between v6 and v7 a.outs */
+               /* rather, version 6 a.outs were patched to be identifiable */
+               if(buf[6] == 1)
+                       rts = "/usr/bin/v6run";
+       } else if(buf[6] == 0) {
+               /* it looks like almost all RT-11 save images have 0 here */
+               rts = "/usr/bin/rtrun";
+       } else {
+               /* was not a recognizable file type */
+               return(0);
+       }
+       /* must make a new argv list with runtime system prefix */
+       nargv = &nargs[0];
+       *nargv++ = rts;
+       /* have to pass full file name to rts */
+       *nargv++ = file;
+       argv++;
+       while(*argv && nargv < &nargs[MAXARGS-1])
+               *nargv++ = *argv++;
+       /* force in final null */
+       *nargv++ = (char *)0;
+       /* try to start rts */
+       execve(nargs[0], nargs, envp);
+       /* if that failed, report no runtime system */
+       failed(nargs[0], norts);
+}
diff --git a/usr/src/old/games.vax/compat/modshell/defs.h.ediff b/usr/src/old/games.vax/compat/modshell/defs.h.ediff
new file mode 100644 (file)
index 0000000..01f619b
--- /dev/null
@@ -0,0 +1,12 @@
+282a
+MSG            norts;
+.
+188a
+MSG            rtsname;
+.
+179a
+MSG            defrts;
+.
+169a
+NAMNOD         rtsnod;
+.
diff --git a/usr/src/old/games.vax/compat/modshell/msg.c.ediff b/usr/src/old/games.vax/compat/modshell/msg.c.ediff
new file mode 100644 (file)
index 0000000..5c88e88
--- /dev/null
@@ -0,0 +1,9 @@
+66a
+MSG    defrts          = "/usr/bin/v7run";
+.
+50a
+MSG    rtsname         = "RTS";
+.
+41a
+MSG    norts   = "alternate RTS not found";
+.
diff --git a/usr/src/old/games.vax/compat/modshell/name.c.ediff b/usr/src/old/games.vax/compat/modshell/name.c.ediff
new file mode 100644 (file)
index 0000000..2cb43e5
--- /dev/null
@@ -0,0 +1,14 @@
+23c
+NAMPTR         namep = &pathnod;
+.
+19,21c
+       homenod = {     &fngnod,        NIL,            homename},
+       ps2nod  = {     &ps1nod,        &rtsnod,        ps2name},
+       mailnod = {     &homenod,       &ifsnod,        mailname},
+       pathnod = {     &mailnod,       &ps2nod,        pathname};
+.
+15,17c
+NAMNOD fngnod  = {     NIL,            NIL,            fngname},
+       rtsnod  = {     NIL,            NIL,            rtsname},
+       ps1nod  = {     NIL,            NIL,            ps1name},
+.
diff --git a/usr/src/old/games.vax/compat/modshell/service.c.edif b/usr/src/old/games.vax/compat/modshell/service.c.edif
new file mode 100644 (file)
index 0000000..45f7a15
--- /dev/null
@@ -0,0 +1,5 @@
+140a
+               /* file was found - try compatability mode here */
+               compat(p, &t[0], xecenv);
+               /* otherwise assume a shell file */
+.
diff --git a/usr/src/old/games.vax/compat/modshell/v6flag.c b/usr/src/old/games.vax/compat/modshell/v6flag.c
new file mode 100644 (file)
index 0000000..87ccbb1
--- /dev/null
@@ -0,0 +1,25 @@
+#
+/* flag version 6 a.outs by putting a 1 in word 6 */
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+struct stat stbuf;
+int    fd;
+short  hbuf[8];
+time_t timep[2];
+main(argc, argv) char *argv[]; {
+       if(stat(argv[1], &stbuf) < 0) exit(0);
+       if(!(stbuf.st_mode & S_IEXEC)) exit(0);
+       if((fd = open(argv[1], 2)) < 0) exit(0);
+       if(read(fd, hbuf, sizeof hbuf) != sizeof hbuf) exit(0);
+       lseek(fd, 0L, 0);
+       if(hbuf[0]!=0407&&hbuf[0]!=0410&&hbuf[0]!=0411&&hbuf[0]!=0405) exit(0);
+       if(hbuf[6] != 0) exit(0);
+       hbuf[6] = 01;
+       if(write(fd, hbuf, sizeof hbuf) != sizeof hbuf) exit(0);
+       close(fd);
+       timep[0] = stbuf.st_atime;
+       timep[1] = stbuf.st_mtime;
+       utime(argv[1], timep);
+       printf("%s fixed\n",argv[1]);
+}