IMD 1.17: 17/11/2010 7:13:05 /usr/sys (*.h files) /usr/sys/qxsrc (bootstrap, etc.) /usr/sys/source  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  !xwvuts}|{zy~CBA@DEb`_^QPONYa~rqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFECBA@?>=<D*)('/ Q`4Q`4Q^4Q4Q[4Q4QW4Q4 !"#$%&'(,+*;:97>323456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYrQU4QU4qQS4QS4mpQS4QS4nollZ[\]^_`abcdelCQ2kQO4QO4 aYZ[\]l7l7RSTUVWXGllNOPQl9l9p lEQ3MQB4QB4HIJKLQ?4Q?4Q>4Q4kFQ<4Q<4Q:4Q4Q94Q4Q84Q4=>?Q64Q64;<Q44Q44Q24Q49Q14Q1478Q04Q046Q.4Q.4<5Q-4Q-4x3Q)4Q)4&'()*Q&4Q&4b$%Q$4Q$4.Q"4Q"4   Q4Q4\Q4Q4 Y>Q4Q4Q4Q4Q 4Q 4Q 4Q 4Q4Q4"Q4Q4Q4Q4 Q3Q3lnEQ'4ll3QV3QV3QU3QU3 lLEl;ETCl6El6Eo 6789:;QJ3QJ3 12345QH3QH3m./0QG3QG3-QF3QF3@*+,QE3QE31'()QD3QD37 "#$%&:lJlJ( !QA3QA3Q@3Q@3Q?3Q?3Q>3Q>3Q=3Q=3Q<3Q<3Q;3Q;3 Q:3Q:3  through the other. * A buffer is on the available list, and is liable * to be reassigned to another disk block, if and only dev */ struct buf *b_back; /* last buffer for this dev */ struct buf *d_actf; /* head of I/O queue */ struct buf *d_actl; * if it is not marked BUSY. When a buffer is busy, the * available-list pointers can be used for other purposes. * Most drive /* tail of I/O queue */ }; /* * This is the head of the queue of available * buffers-- all unused except for the 2 list headrs use the forward ptr as a link in their I/O * active queue. * A buffer header contains all the information required * to pes. */ struct buf bfreelist; /* * These flags are kept in b_flags. */ #define B_WRITE 0 /* non-read pseudo-flag */ #define B_rform I/O. * Most of the routines which manipulate these things * are in bio.c. */ struct buf { int b_flags; /* see definesREAD 01 /* read when I/O occurs */ #define B_DONE 02 /* transaction finished */ #define B_ERROR 04 /* transaction aborted */ #de below */ struct buf *b_forw; /* headed by devtab of b_dev */ struct buf *b_back; /* " */ struct buf *av_forw; /* positifine B_BUSY 010 /* not on av_forw/back list */ #define B_WANTED 0100 /* issue wakeup when BUSY goes off */ #define B_RELOC 0200 on on free list, */ struct buf *av_back; /* if not BUSY*/ int b_dev; /* major+minor device name */ int b_wcount; /* t/* no longer used */ #define B_ASYNC 0400 /* don't wait for I/O completion */ #define B_DELWRI 01000 /* don't write till block l...ebuf.hdconf.hcconf.obfile.hafilsys.h`ino.hransfer count (usu. words) */ char *b_addr; /* low order core address */ char *b_blkno; /* block # on device */ char b_erro_inode.h^low.o]param.h\proc.h[qxeml.oZreg.hYsystm.hXtty.hr; /* returned after I/O */ char *b_resid; /* words not transferred after error */ } buf[NBUF]; /* * Each block device has Wuser.hVlib1Ulib2TrunSshldRqxsrcQsourcea devtab, which contains private state stuff * and 2 list heads: the b_forw/b_back list, which is doubly linked * and has all the buffers currently associated with that major * device; and the d_actf/d_actl list, which is private to the * device but in/* * Each buffer in the pool is usually doubly linked into 2 lists: * the device with which it is currently associated (always fact is always used for the head and tail * of the I/O queue for the device. * Various routines in bio.c look at b_forw/b_bac) * and also on a list of blocks available for allocation * for other use (usually). * The latter list is kept in last-used ok * (notice they are the same as in the buf structure) * but the rest is private to each device driver. */ struct devtab { crder, and the two * lists are doubly linked to make it easy to remove * a buffer from one list when it was found by * lookinghar d_active; /* busy flag */ char d_errcnt; /* error count (for recovery) */ struct buf *b_forw; /* first buffer for this   * main unix code and the driver. * The initialization of the * device switches is in the * file conf.c. */ struct bdevsw {TE 02 #define FPIPE 04  int (*d_open)(); int (*d_close)(); int (*d_strategy)(); int *d_tab; } bdevsw[]; /* * Nblkdev is the number of entries * /* * Definition of the unix super block. * The root super block is allocated and * read in iinit/alloc.c. Subsequently * a s(rows) in the block switch. It is * set in binit/bio.c by making * a pass over the switch. * Used in bounds checking on majoruper block is allocated and read * with each mount (smount/sys3.c) and * released with unmount (sumount/sys3.c). * A disk blo * device numbers. */ int nblkdev; /* * Character device switch. */ struct cdevsw { int (*d_open)(); int (*d_close)(); ick is ripped off for storage. * See alloc.c for general alloc/free * routines for free list and I list. */ struct filsys { int (*d_read)(); int (*d_write)(); int (*d_sgtty)(); } cdevsw[]; /* * Number of character switch entries. * Set by cinit/ttynt s_isize; /* size in blocks of I list */ int s_fsize; /* size in blocks of entire volume */ int s_nfree; /* number of in cor.c */ int nchrdev; e free blocks (0-100) */ int s_free[100]; /* in core free blocks */ int s_ninode; /* number of in core I nodes (0-100) */ int (8Xhx_bdevsw#_nulldev _qxstrat _qxtab  s_inode[100]; /* in core free I nodes */ char s_flock; /* lock during free list manipulation */ char s_ilock; /* lock during _cdevsw# _klopen _klclose _klread _klwrite _klsgtty _mmread _mmwrite _nodev I list manipulation */ char s_fmod; /* super block modified flag */ char s_ronly; /* mounted read-only flag */ int s_time[2]; /* current date of last update */ int pad[50]; }; eaves available list */ /* * One file structure is allocated * for each open/creat/pipe call. * Main use is to hold the read/write * pointer associa/* * Used to dissect integer device code * into major (driver designation) and * minor (driver parameter) parts. */ struct {ted with each open * file. */ struct file { char f_flag; char f_count; /* reference count */ int f_inode; /* pointer to ino char d_minor; char d_major; }; /* * Declaration of block device * switch. Each entry (row) is * the only link between thede structure */ char *f_offset[2]; /* read/write character pointer */ } file[NFILE]; /* flags */ #define FREAD 01 #define FWRI ode { int i_mode; char i_nlink; char i_uid; char i_gid; char i_size0; char *i_size1; int i_addr[8]; int i_atime[2]; int /* flags */ #define ILOCK 01 /* inode is locked */ #define IUPD 02 /* inode has been modified */ #define IMOUNT 010 /* inod i_mtime[2]; }; /* modes */ #define IALLOC 0100000 #define IFMT 060000 #define IFDIR 040000 #define IFCHR 020000 #define IFBe is mounted on */ #define IWANT 020 /* some process waiting on lock */ /* modes */ #define IALLOC 0100000 /* file is used */LK 060000 #define ILARG 010000 #define ISUID 04000 #define ISGID 02000 #define ISVTX 01000 #define IREAD 0400 #define IWRITE 020 #define IFMT 060000 /* type of file */ #define IFDIR 040000 /* directory */ #define IFCHR 020000 /* character special */ #de0 #define IEXEC 0100 fine IFBLK 060000 /* block special, 0 is regular */ #define ILARG 010000 /* large addressing algorithm */ #define ISUID 04000  /* set user id on execution */ #define IREAD 0400 /* read, write, execute permissions */ #define IWRITE 0200 #define IEXEC 0100 |ww/* * The I node is the focus of all * file activity in unix. There is a unique * inode allocated for each active file, * eac7P7J7D7>788888888h current directory, each mounted-on * file, text file, and the root. An inode is 'named' * by its dev/inumber pair. (iget/igeYt.c) * Data, from mode on, is read in * from permanent inode on volume. */ struct inode { char i_flag; char i_count; /* refIXIhIIIeisdumprkrpqxqxemlsaerence count */ int i_dev; /* device where inode resides */ int i_number; /* i number, 1-to-1 with device address */ int i_mhptctmlpfltvectdlhaltresetbr4br5br6ode; char i_nlink; /* directory entries */ char i_uid; /* owner */ char i_gid; /* group of owner */ char i_size0; /* most br7trap trapemstart _dump"_panic"klinkloukwlpemloulpou/* * Inode structure as it appears on * the disk. Not used by the system, * but by things like check, df, dump. */ struct insignificant of size */ char *i_size1; /* least sig */ int i_addr[8]; /* device addresses constituting file */ } inode[NINODE];  NMOUNT 3 /* number of mountable file systems */ #define SSIZE 20 /* initial stack size (*64 bytes) */ #define NOFILE 15 /* m structure to access an integer */ struct { int integ; }; /* * Certain processor registers */ /* * configuration dependenax open files per process */ #define CANBSIZ 256 /* max size of typewriter line */ #define NCALL 4 /* max simultaneous time cat variables */ #define UCORE (16*32) #define TOPSYS 12*2048 #define TOPUSR 28*2048 #define ROOTDEV 0 #define SWAPDEV 0 #definetciorkiotmioqxiorpiohpiosaiocall _clock _emlint llouts */ #define NPROC 6 /* max number of processes */ #ifdef VSWAP #define SMAPSIZ (2*NPROC) /* size of swap allocation area _lpint_rkintr_rpintr_qxintr _saintr_hpintr_tcintr_tmintr_klrint _klxint rkda*/ #endif #ifdef QX # define NCLIST 60 /* max total clist size */ #endif #ifndef QX # define NCLIST 100 /* max total clist sizrkcs_rkaddrdvtabe */ #endif #define HZ 60 /* Ticks/second of the clock */ /* * priorities * probably should not be * altered too much */ #define PSWP -100 #define PINOD -90 #define PRIBIO -50 #define PPIPE 1 #define PWAIT 40 #define PSLEP 90 #define PUSER 100 /* * signals * dont change */ #define NSIG 20 #define SIGHUP 1 /* hangup */ #define SIGINT 2 /* interrupt (rubout) */ #define  SIGQIT 3 /* quit (FS) */ #define SIGINS 4 /* illegal instruction */ #define SIGTRC 5 /* trace or breakpoint */ #define SIGIO/* * Terak Mini-Unix system parameter flags: * * define QX for Terak Mini-Unix * define VSWAP to enable code for variable siT 6 /* iot */ #define SIGEMT 7 /* emt */ #define SIGFPT 8 /* floating exception */ #define SIGKIL 9 /* kill */ #define SIGBUze (not fixed) swap areas * define SA for Shugart SA4600 driver stuff * define DEBUG for debugging printf's */ #define VSWAP 1S 10 /* bus error */ #define SIGSEG 11 /* segmentation violation */ #define SIGSYS 12 /* sys */ #define SIGPIPE 13 /* end of  #define QX 1 /* * tunable variables */ #define NBUF 6 /* size of buffer cache */ #ifdef QX # define NINODE 40 /* number opipe */ #define SIGCLK 14 /* alarm clock */ /* * fundamental constants * cannot be changed */ #define USIZE 16 /* size off in-core inodes */ #endif #ifndef QX # define NINODE 50 /* number of in-core inodes */ #endif #ifdef QX # define NFILE 40 /*  user block (*64) */ #define NULL 0 #define NODEV (-1) #define ROOTINO 1 /* i number of all roots */ #define DIRSIZ 14 /* max number of in-core file structures */ #endif #ifndef QX # define NFILE 50 /* number of in-core file structures */ #endif #definecharacters per directory */ /* * structure to access an * integer in bytes */ struct { char lobyte; char hibyte; }; /* * * intermediate state in process creation */ #define SZOMB 5 /* intermediate state in process termination */ /* flag codes */ #chrtst4put"emlbuf}belflgctlputXbufhdrdonecursoroldcrsxlf4xffdefine SLOAD 01 /* in core */ #define SSYS 02 /* scheduling process */ #define SLOCK 04 /* process cannot be swapped */ #defixxfrxfrxcntrlxcrxcskipne SSWAP 010 /* process is being swapped out */ /* * Location of the users' stored * registers relative to R0. * Usage is u.u_ar0[XX]. */ #define R0 (0) #define R1 (-2) #de- \&fvŀ  | !w P   @ fine R2 (-9) #define R3 (-8) #define R4 (-7) #define R5 (-6) #define R6 (-3) #define R7 (1) #define RPS (2) #define TBIT 020 //* * One structure allocated per active * process. It contains all data needed * about the process while the * process may b&fE U}_5t_fE Eɕ 6PBE %P e swapped out. * Other per process data (user.h) * is swapped with the process. */ struct proc { char p_stat; char p_flag; H~ЕE& e0~5 &&e   EPe@  UfE char p_pri; /* priority, negative is high */ char p_sig; /* signal number sent to this process */ char p_uid; /* user id,  ~ w8ɕw("ߋtvused to direct tty signals */ char p_time; /* resident time for scheduling */ char p_cpu; /* cpu usage for scheduling */ char p_nice; /* nice for cpu usage */ int p_pgrp; /* name of process group leader */ int p_pid; /* unique process id */ int p_ppid; /* process id of parent */ int p_wchan; /* event process is awaiting */ int p_addr; /* address of swappable image */vtbase int p_clktim; /* time to alarm clock signal */ int p_size; /* process size (for swap) */ } proc[NPROC]; /* stat codes */ #desrtedbvvirvcrgbenblbelbitsyncbitbelbslf ffefine SSLEEP 1 /* awaiting an event */ #define SWAIT 2 /* (abandoned state) */ #define SRUN 3 /* running */ #define SIDL 4 / cr space crs_emlint"_lkint"~putptr$endptrbufend\emlsus2emldun. f next sleep */ /* * The callout structure is for * a routine arranging * to be called by the clock interrupt * (clock.c) windle the * common code associated with * these structures. * The definition and device dependent * code is in each driver. (th a specified argument, * in a specified amount of time. * Used, for example, to time tab * delays on teletypes. */ struct kl.c dc.c dh.c) */ struct tty { struct clist t_rawq; /* input chars right off device */ struct clist t_canq; /* input chars acallo { int c_time; /* incremental time */ int c_arg; /* argument to routine */ int (*c_func)(); /* routine */ } callout[NCfter erase and kill */ struct clist t_outq; /* output list to device */ int t_flags; /* mode, settable by stty call */ int *tALL]; /* * Mount structure. * One allocated on every mount. * Used to find the super block. */ struct mount { int m_dev; /_addr; /* device address (register or startup fcn) */ char t_delct; /* number of delimiters in raw q */ char t_col; /* printi* device mounted */ int *m_bufp; /* pointer to superblock */ int *m_inodp; /* pointer to mounted on inode */ } mount[NMOUNT]; ng column of device */ char t_erase; /* erase character */ char t_kill; /* kill character */ char t_state; /* internal stateint mpid; /* generic for unique process id's */ char runrun; /* scheduling flag */ char curpri; /* more scheduling */ #ifn, not visible externally */ char t_char; /* character temporary */ int t_speeds; /* output+input line speed */ int t_pgrp; def QX int *lks; /* pointer to clock device */ #endif int rootdev; /* dev of root see conf.c */ int swapdev; /* dev of swap /* process group name */ }; char partab[]; /* ASCII table: parity, character class */ #define TTIPRI 10 #define TTOPRI 20 #see conf.c */ int updlock; /* lock for sync */ char regloc[]; /* locs. of saved user registers (trap.c) */ define CERASE '#' /* default special characters */ #define CEOT 004 #define CKILL '@' #define CQUIT 034 /* FS, cntl shift L */* PS trace bit */ /* * A clist structure is the head * of a linked list queue of characters. * The characters are stored in 4-word * blocks co/* * Random set of variables * used by more than one * routine. */ char canonb[CANBSIZ]; /* buffer for erase and kill (#@) *ntaining a link and 6 characters. * The routines getc and putc (m45.s or m40.s) * manipulate these structures. */ struct clis/ #ifdef VSWAP int swapmap[SMAPSIZ]; /* space for swaps allocation */ #endif int *rootdir; /* pointer to inode of root directort { int c_cc; /* character count */ int c_cf; /* pointer to first block */ int c_cl; /* pointer to last block */ }; /* *y */ int lbolt; /* time of day in 60th not in time */ int time[2]; /* time in sec from 1970 */ int tout[2]; /* time of day o A tty structure is needed for * each UNIX character device that * is used for normal terminal IO. * The routines in tty.c ha  efine NLDELAY 001400 #define TBDELAY 006000 #define CRDELAY 030000 #define VTDELAY 040000 /* Hardware bits */ #define DONE 0200 for IO */ char *u_offset[2]; /* offset in file for IO */ int *u_cdir; /* pointer to inode of current directory */ char u_d #define IENABLE 0100 /* Internal state bits */ #define TIMEOUT 01 /* Delay timeout in progress */ #define WOPEN 02 /* Waitinbuf[DIRSIZ]; /* current pathname component */ char *u_dirp; /* current pointer to inode */ struct { /* current directory eg for open to complete */ #define ISOPEN 04 /* Device is open */ #define SSTART 010 /* Has special start routine at addr */ #dntry */ int u_ino; char u_name[DIRSIZ]; } u_dent; int *u_pdir; /* inode of parent directory of dirp */ int u_uisa[16]; efine CARR_ON 020 /* Software copy of carrier-present */ #define BUSY 040 /* Output in progress */ #define ASLEEP 0100 /* Wak/* prototype of segmentation addresses */ int u_uisd[16]; /* prototype of segmentation descriptors */ int u_ofile[NOFILE]; /*eup when output done */  pointers to file structures of open files */ int u_arg[5]; /* arguments to current system call */ int u_tsize; /* text size (*64) */ int u_dsize; /* data size (*64) */ int u_ssize; /* stack size (*64) */ int u_sep; /* flag for I and D separatio/* * The user structure. * One allocated per process. * Contains all per process data * that doesn't need to be referenced n */ int u_qsav[2]; /* label variable for quits and interrupts */ int u_ssav[2]; /* label variable for swapping */ int u_si* while the process is swapped. * The user block is USIZE*64 bytes * long; resides at virtual kernel * loc 140000; contains tgnal[NSIG]; /* disposition of signals */ int u_utime; /* this process user time */ int u_stime; /* this process system timehe system * stack per user; is cross referenced * with the proc structure for the * same process. */ struct user { int u_rs */ int u_cutime[2]; /* sum of childs' utimes */ int u_cstime[2]; /* sum of childs' stimes */ int *u_ar0; /* address of uav[2]; /* save r5,r6 when exchanging stacks */ int u_fsav[25]; /* save fp registers */ /* rsav and fsav must be first insers saved R0 */ int u_prof[4]; /* profile arguments */ char u_intflg; /* catch intr from sys */ int u_ttyp; /* controlli structure */ char u_segflg; /* flag for IO; user or kernel space */ char u_error; /* return error code */ char u_uid; /*ng tty pointer */ int u_ttyd; /* controlling tty dev */ /* kernel stack per user * extends from u + USIZE*64  #define CINTR 0177 /* DEL */ /* limits */ #define TTHIWAT 90 #define TTLOWAT 30 #define TTYHOG 256 /* modes */ #define HUPCL effective user id */ char u_gid; /* effective group id */ char u_ruid; /* real user id */ char u_rgid; /* real group i 01 #define XTABS 02 #define LCASE 04 #define ECHO 010 #define CRMOD 020 #define RAW 040 #define ODDP 0100 #define EVENP 0200 #dd */ int u_procp; /* pointer to proc structure */ char *u_base; /* base address for IO */ char *u_count; /* bytes remaining  w TDE & t  5  J5 V ww DU Jww DU ww D5E& n w w DEH87, yfWp % Zw ft w ` D * backward not to reach here */ } u; /* u_error codes */ #define EFAULT 106 #define EPERM 1 #define ENOENT 2 #define ESR@ 25@E@ 25   EH0  Lww |@-F @ %6:UCH 3 #define EINTR 4 #define EIO 5 #define ENXIO 6 #define E2BIG 7 #define ENOEXEC 8 #define EBADF 9 #define ECHILD 10 #define E@(  t @t  t-t-  f5U@& * w  AGAIN 11 #define ENOMEM 12 #define EACCES 13 #define ENOTBLK 15 #define EBUSY 16 #define EEXIST 17 #define EXDEV 18 #define ENOD5U 0003t tw D &  5  V wjw ZEV 19 #define ENOTDIR 20 #define EISDIR 21 #define EINVAL 22 #define ENFILE 23 #define EMFILE 24 #define ENOTTY 25 #define ETXTBD l 00U Lw6w &DU5 JE@ 2ww @ ~w w 77SY 26 #define EFBIG 27 #define ENOSPC 28 #define ESPIPE 29 #define EROFS 30 #define EMLINK 31 #define EPIPE 32 77 WpDe t e4xr07j J %  @ e (w^ w N D 6_TtE@`e` TeWtE@4%et  4   apwNw >DCe - w& w N &e  *  a5 * @U7eEt 77\jtt   l 5L %te\ Nf @  e e w  Z 5 5 KNef  5 @ ` _et& D%EHEw, w  %5- U   L 5% w %5 AWpq-AWpq- %( ap%de% J%d 5#4e  w D57RRw w 2 e  5# T  &  e  2 Xw N %d  apww  L-%d%d4 4 3ee3%` S S @ 74. Jw D  B4 & d   b 4  bww BʵA :e5& @ 7bK\K``8 %w:w *CK-smK ewe  w BD f    5f  tA@lee eʵN ww D5 e D-m tm@m-*4c &e44@m- tLm  LeEe50 *5N&  e  & 8 , JN& 8 = e@-ʆEw^ (740( Effe E- ``fffffff UE 8  D<=>?@ABEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|-`  F 捦UE@BE   5 e EB>1   Z~Df @ _"_w :^D ZD <%j)Dw&w B D_E% Wp  dB\ ww 5 %̋ 5-l e%D T=̕.   55CE5CN r E%`#CC &E e1 r N * 5" \%\V=D7@=C˕\ * &  ˕= ww @55; 6;Ew(w ;ww ww DCB~ww  _j]Aw\`\AB\  NA     w  ut-N& X e%# 5@ . _#5`5I :_#@5 5 $ %_#e;N <%_# @  `[ G & ` 6r 6r@@A6v@@& ADCBF6ww %D t̥ Xww @Ĝ  5\w w z@2 \(7i@%w  F <F ww F7 F7aFB\  w & FF V w dtF  0 \6Ae&e  A&   A0A x87@  e@tQ7~@ \ww %/& @  %/   )F!F Z _F _E%@@& . H\ 7? 9?  ?, & . 5`?? B7 ?7 ?\??  Zo? wj E %V\Ґ %/%V\ n%/E7 E7 E5 &  7E5 E$ N J% w T jX? ̕tt b   v z ̕\ Dw Z Lw C  Xe~& . 7E @e7LE5>E N J&E  & * &  5X\@&DEww D4 ̕Zww B:67 2X Re%ʥ70  ` (!%eD D D DH\Z\H\` %V\ N J% & . _wp5 ʥ  &-8>) & \ *\ D>> >    \ D  : m9 % :9`\ %6\ ZN Jww |9t7&9 ww 82 \% ]\  F ,Z w F*3  2& ** w4w $  2& **  Zww N @&e  @&e%\d8 Z     \ (!% 8̕,  2, 2 e  @&e  tle@e5 Nef  e % f  e % J% "e%4 w  7, P ʥL 8`   D% 2 2 22 2lwbw R62     \w:w * R5%11<1  5     " 0 Zw:8]   ]  l8]   ]  7 Je% (6   6w e% f  0 J2J 2& (!%221E2 Jw 6ˋ e% 6 ? 77 77 77 |77 z77 x77 n7  r7j71`ww v 7e?tE  7 bw L  p5C01 " e%!0  5-0e% Z3 6e`%M6`6wFw 6 &w6w & &w&w C6  .̰ 6(66667575% Jww  E%`/-v/ Zww n0ww ~L`0\0Dwvw f B0  b65&e  N65?6ww    06 *6& &%ww ~ w56E  *<07" 2wNw >ğ"07B/ 72/2/07(/w$w ////w w /? /ww ww /& &%wNw > CB%5 . 5 . E%@44'  B b %  J  .0ww  / b. @  E%@ .X\|.x.7 . E 5E 4 @ 0 \ Zww v5  j5 0 \ F w~w nN5  D̵ Z ZwPw @ E%@+. Z@& . . Z7. bww >Ez.E[4=4%4t 54t5%E 45    x95mfe  tt4P Zww B   L. G.  Zww ,.%% - ?\Z. .\r-!%U:_# : 55 \2:.:7 .:7 (: :_#%:m:::m:e?tE5ew E5` w  >33E%@ (43 q3 Zg3%_#`%9_#`99F:9wF: <:@@A @e5X:pNf  30- ZM3 $ Zw6w &  3 3 3 3 Zww  @Def  & V ҋ@ fe  5 9 99 \5 e% ]3fe  ff e  wlfd^ e NfHB e w0w f-0w\w L 5 *.L-    ,% -7- -& X e%܂ ,ww  ]%5 _6% 5  D5 _65:ҋ !\ D5 %a%ze% 5n-  eb-%]ww ,-?-ww Z\  w C  f H Bz,  & X D5 e &  Zev85 E B x:ʋ=ʊ;tE5%ʋt&e X % e% z,- X ̋   @0 e%,%7 "ww %`U@e 7,@ tE5% U@%  e &U  w5@tE5%%  x$:  + X   ,wNe %  L,7{+ENe E w JD 6wBw 2B &5"e x%v8EP4 E6 te9%9)N e E?%?Ete9 "e  1\  N  1\e " %ww D  3   e x ww D#  6@&e  p+* 1+*d**_x0U*5 _x0 _l0w |+\ * 7l+ww rdu*wtw dwlw \%Z  ~ D5  6w>w .DC 33w 2\  ` f*C  4 8+w4+3 w4w $Ce 2**&  e&  e&  ww  `  * `` `/etc/initr* 7h*e 7\*e 7P* 2ww *  E% ) fWp %wpw `D ,,,,,,<,,,coreL(6(\(L(6(1#T%%&&'r$&v(x-@!-, @&e   B3 `w8w (eEe%  e 7ww De x):.f.%*'.-++,-,1p/)/1N221L-F)@-.,11*1L/11 e x  2e 2   x 4 Lww C  w    611.1111111111111/1h0000d000|&  @5 '\ %  %2:2: 5\2: %  x%5#`{}@~ABCDEFGHIJKLMNOPQRSTUVWXYZ6666\666({)}!|^~'`eD-w BCE% 5 5 %%% $  B3>%5%AyyII%Ze   5 % %  2  5 D5   D5  6ww CDE IXHIIII8HxxXIII XXIH)ihihh9xxx9I89IIYIYIXIIIxXXhIIHH)H HHIIH  yyyyyyII)))  IIIIIIYYYYYYX xxxxXX IIIIX yy ) _canonb _swapmap _rootdir _lbolt _time _max"X_signal"$_setrun"X_core"R_exit"#_swapfla _newproc"`_nodev"!_nulldev" !_exec"@!_rexit_tout _callout _mount _mpid _runrun _curpri _rootdev _swapdev _updlock _regloc#:_bdevsw"#_wait"r$_fork"T%_sbreak"%_read"%_rdwr"&_write"&_open"&_open1"&_creat"&_close"'_see _nblkdev _cdevsw _nchrdev _buf _bfreeli _inode _u!\_iinit"csv"._bread"_getblk"_panic _bcopy"(!_brelse"Jcret":_alloc"j_getfs"_sleep"_badbloc"_wakeup"2_clrbuf",_free"8_bwrite"_ialloc"_iget"@ _iput"Z_ifree"d_update"_iupdat"_prele"b_bflush" _proc _buffers _swbuf _iowait"_geterro"V _bdwrite"_bawrite"4_getps"H_spl6"_putps"L_spl0"^_notavai"_iodone"_binit"D_swap"_malloc"_idle"_mfree"D_clock"v _lkint _spl5"v_spl1"h_psignal"X_issig"_psig"_timeout" _spl7"_file @_getf" _closef"F _closei"n _openi" _access". _owner" _namei"_suser" _ufalloc" _falloc" _ldiv"_lrem"_itrunc"B_maknode"_wdir"$_writei"_icode#`8_main"_cinit"3_copyout"trap"call"emtrap"_trap"40nofault$:_swtch"_getc"x_putc"_cfreeli _fubyte"<_subyte"V_fuibyte"<_suibyte"V_fuword"_suword"_fuiword"_suiword"_copyin"_savu"*_retu"D_spl4"v_dpadd"_dpcmp"start"_end _edata _lshift"_haltins"R_mmread"V_passc" _mmwrite"_cpass" _uchar"_bmap"*_partab#v8_readi"_min"r_iomove"   xw         U5 "5[@U]]w ] EWpCe Et7l@EA]Z5=K E'5|5@5IhIhIhIhhˊ% 7 d  5& U777 :w5@ 5 @IhIhxI_bdevsw _nblkdev _cdevsw 5 e@  %w nCD`]\U5  w4w 0*_nchrdev _u &_partab _kl11 _klopen"~klopenflagaddrtpdevcsvE%@2 w(Ik"'_link"v(_mknod")_sslep"F)_fstat")_stat1"**_stat"*_dup"*_smount"+_getmdev"\,_sumount"+ L2L1|L36L4BL5f_ttyopen cret _klclose"~klclosetpdev_getswit",_gtime",_stime",_setuid",_getuid"-_getpid".-_sync"@-_nice"L-_unlink"x-_chdir"-_chmod_wflusht _klread"~klreaddev_ttread _klwrite"~klwritedev_ttwrite _klxint"":._chown"f._ssig"._kill"._times"L/_alarm"p/_pause"/_halt"/_sysent#9_nullsys"1_stty"N2_gtt~klxinttpdev_ttstart L10000L9_wakeup _klrint"~klrintaddrtpy"2_nosys"1_dump _trap1"1_maptab#2:_cfree _ttyopen"1_sgtty"2_wflusht"2_flushtt"B3_canon"3cdevL12*_ttyinpu _klsgtty"8~klsgtty8tpvdev_ttystty qx.o_ttyinpu"l4_ttyoutp"D5_ttstart"6_ttrstrt"6_ttread"b7_ttwrite"7_ttystty"7k0t w D  tm%U 4  707  ww  EWpCe~ 3t33& wTw PDC r3 rB 9r & r eBWp` r@3 Et75(@ _e~@   +  5E7D3 @ %$7 L!% :]6\ U5 (*Due % e ww BteU53& ww DueN& wIh8_buf _bfreeli _bdevsw _nblkdev _cdevsw _nchrdev _u &_qx *_qxtab _qxunit L23_qxhead"L24L26L20004_qxintr"`L7_qxtimer"L27*L10005NL1_qxhd _qxstrat"~qxstratbpabpcsv L10000$L20_iodone L1^_spl50006V~qxintr`bpcpqpnwqxerrL30(L31,L32 L33 L3DL4LL5Z_qxstart"b_spl0 cret ~qxstartbbpqpL6_qL34L20007L40L36L20008L43L44L45nL48HL49hL20006xsecto"~qxsectobpcpqpabpnaqplowL17r_min `~qxtimermsecqptimeaqpL54L20013L56~qxheadqpL5L11<L12ZL20001TL10001jL10002nL18 L10003L10004L19L21L20003chdir mxsys sh shs chdir ../dev sh shs chdir .. sh shld mv a.out /rkmx chdir mxsys e low.s /rk =/s/1/0/p /rp =/s/0/1/p w e conf.~}c /rk/s/.*/\/* & *\//p /rp/s/\/\*// s/\*\///p w q as low.s;mv a.out ../low.o cc -c -O conf.c mv conf.o ../conf.o chdir .. sh shlxekl.oky.`Xw %4CteDuepeeH3 x#@UCU@f ww |Due 4wbw ^@te wHw D@te w.w   =/s/0/1/p w e conf.c /hp/s/.*/\/* & *\//p /rk/s/\/\*// s/\*\///p w q as low.s;mv a.out ../low.o cc -c -O conf.c mv conf.o ../coJfile.cIld.cHps.cGreloc.cFsh.cEshassemDshccCtypo.cnf.o chdir .. sh shld #define NARMAG 0177545 struct { char name[14]; long date; char uid; char gid; int mode; long size; } arbuf; struct { charld -a -x low.o qxeml.o conf.o lib1 lib2 size a.out  minor; char major; int inumber; int flags; char nlinks; char usrid; char grpid; char siz0; int siz1; int addr[8]; long adate; long mdate; } stbuf; #define SKIP 1 #define IODD 2 #define OODD 4 #define HEAD 8 char *man { "mrxtdp" }; char *opt { "uvnbai" }; long itol(); int done(); int rcmd(); int dcmd(); int xcmd(); int tcmd(); int pcmd(); int mcmd(); int (*comfun)(); char flg[26]; char **namv; int namc; char *arnam; char *ponam; char *tfnam; char *tf1nam; char *tf2nam; char *file; char name[16R...B_halt.oA_halt.s@halt?halt.c3qxinit.c=haltsys.c]; int af; int tf; int tf1; int tf2; int bastate; int buf[256]; main(argc, argv) char *argv[]; { register i; register char *c<qx.sqx3.sqxboot3qxboot30.s8qxbootshqxbt3sh6qxfsboot.s5qxfsboot0.sp; for(i=1; i<4; i++) if((signal(i, 1) & 1) == 0) signal(i, done); if(argc < 3) usage(); cp = argv[1]; for(cp = argv4qxinitqxinit.c2qxps1qxps.c0qxsh/qxtty.s.qxuboot-rrk.s[1]; *cp; cp++) switch(*cp) { case 'v': case 'u': case 'n': case 'a': case 'b': case 'i': flg[*cp - 'a']++; continue;d mv a.out /rpmx chdir mxsys e low.s /rp =/s/1/0/p /hp =/s/0/1/p w e conf.c /rp/s/.*/\/* & *\//p /hp/s/\/\*// s/\*\///p w q as lsainitsainit.csash)testow.s;mv a.out ../low.o cc -c -O conf.c mv conf.o ../conf.o chdir .. sh shld mv a.out /hpmx chdir mxsys e low.s /hp =/s/1/0/p /rkQ...Par.cOdate.cNdb1.sMdb2.sLdb3.sKdb4.s ter f; if(getaf()) noar(); while(!getdir()) { if(namc == 0 || match()) { f = creat(file, arbuf.mode & 0777); if(f < case 'r': setcom(rcmd); continue; case 'd': setcom(dcmd); continue; case 'x': setcom(xcmd); continue; case  0) { printf("%s cannot create\n", file); goto sk; } mesg('x'); copyfil(af, f, IODD); close(f); continue;'t': setcom(tcmd); continue; case 'p': setcom(pcmd); continue; case 'm': setcom(mcmd); continue; default: pr } sk: mesg('c'); copyfil(af, -1, IODD+SKIP); } } pcmd() { if(getaf()) noar(); while(!getdir()) { if(namc == 0 |intf("bad option `%c'\n", *cp); done(); } if(flg['i'-'a']) flg['b'-'a']++; if(flg['a'-'a'] || flg['b'-'a']) { bastate =| match()) { copyfil(af, 1, IODD); continue; } copyfil(af, -1, IODD+SKIP); } } mcmd() { init(); if(getaf()) noa 1; ponam = trim(argv[2]); argv++; argc--; if(argc < 3) usage(); } arnam = argv[2]; namv = argv+3; namc = argc-3;r(); tf2nam = mktemp("/tmp/v2XXXXX"); close(creat(tf2nam, 0600)); tf2 = open(tf2nam, 2); if(tf2 < 0) { printf("cannot crea if(comfun == 0) { if(flg['u'-'a'] == 0) { printf("one of [%s] must be specified\n", man); done(); } setcom(rcmd); te third temp\n"); done(); } while(!getdir()) { bamatch(); if(match()) { mesg('m'); copyfil(af, tf2, IODD+OODD+HEA } (*comfun)(); notfound(); done(); } setcom(fun) int (*fun)(); { if(comfun != 0) { printf("only one of [%s] allowed\n",D); continue; } mesg('c'); copyfil(af, tf, IODD+OODD+HEAD); } install(); } tcmd() { if(getaf()) noar(); while(! man); done(); } comfun = fun; } rcmd() { register f; init(); if(getaf()) { printf("creating %s\n", arnam); cleanupgetdir()) { if(namc == 0 || match()) { if(flg['v'-'a']) longt(); printf("%s\n", trim(file)); } copyfil(af, -1, I(); return; } while(!getdir()) { bamatch(); if(namc == 0 || match()) { f = stats(); if(f < 0) { if(namc) ODD+SKIP); } } init() { tfnam = mktemp("/tmp/vXXXXX"); close(creat(tfnam, 0600)); tf = open(tfnam, 2); if(tf < 0) { priprintf("cannot open %s\n", file); goto cp; } if(flg['u'-'a']) if(stbuf.mdate <= arbuf.date) { close(f); ntf("cannot create temp file\n"); done(); } buf[0] = NARMAG; write(tf, buf, 2); } getaf() { af = open(arnam, 0); if(af goto cp; } mesg('r'); copyfil(af, -1, IODD+SKIP); movefil(f); continue; } cp: mesg('c'); copyfil(af, tf, < 0) return(1); buf[0] = 0; read(af, buf, 2); if(buf[0] != NARMAG) { printf("%s not in archive format\n", arnam); done(IODD+OODD+HEAD); } cleanup(); } dcmd() { init(); if(getaf()) noar(); while(!getdir()) { if(match()) { mesg('d'); ); } return(0); } usage() { printf("usage: ar [%s][%s] archive files ...\n", opt, man); done(); } noar() { printf("%s do copyfil(af, -1, IODD+SKIP); continue; } mesg('c'); copyfil(af, tf, IODD+OODD+HEAD); } install(); } xcmd() { regis 12)) > 0) write(af, buf, i); } } /* * insert the file 'file' * into the temporary file */ movefil(f) { register char *c f = open(tf1nam, 2); if(f < 0) { printf("cannot create second temp\n"); return; } tf1 = tf; tf = f; } } equal(sp; register i; cp = trim(file); for(i=0; i<14; i++) if(arbuf.name[i] = *cp) cp++; arbuf.size = itol(stbuf.siz0&0377, s1, s2) char *s1, *s2; { register char *p1, *p2; p1 = s1; p2 = s2; while(*p1++ == *p2) if(*p2++ == 0) return(1); returtbuf.siz1); arbuf.date = stbuf.mdate; arbuf.uid = stbuf.usrid; arbuf.gid = stbuf.grpid; arbuf.mode = stbuf.flags; copyfil(fn(0); } phserr() { printf("phase error on %s\n", file); } mesg(c) { if(flg['v'-'a']) if(c != 'c' || flg['v'-'a'] > 1) , tf, OODD+HEAD); close(f); } stats() { register f; f = open(file, 0); if(f < 0) return(f); if(fstat(f, &stbuf) < 0) {  printf("%c - %s\n", c, file); } trim(s) char *s; { register char *p1, *p2; for(p1 = s; *p1; p1++) ; while(p1 > s) { if close(f); return(-1); } return(f); } /* * copy next file * size given in arbuf */ copyfil(fi, fo, flag) { register i, o; int pe; if(flag & HEAD) write(fo, &arbuf, sizeof arbuf); pe = 0; while(arbuf.size > 0) { i = o = 512; if(arbuf.sies not exist\n", arnam); done(); } done() { if(tfnam) unlink(tfnam); if(tf1nam) unlink(tf1nam); if(tf2nam) unlink(tfze < i) { i = o = arbuf.size; if(i&1) { if(flag & IODD) i++; if(flag & OODD) o++; } } if(read(fi,2nam); exit(); } notfound() { register i; for(i=0; i 0) write(af, buf, i); if(tf2nam) { seek(tf2, 0, 0)n(1); } } return(0); } bamatch() { register f; switch(bastate) { case 1: if(!equal(file, ponam)) return; bastat; while((i = read(tf2, buf, 512)) > 0) write(af, buf, i); } if(tf1nam) { seek(tf1, 0, 0); while((i = read(tf1, buf, 5e = 2; if(flg['a'-'a']) return; case 2: bastate = 0; tf1nam = mktemp("/tmp/v1XXXXX"); close(creat(tf1nam, 0600));   }; int m6[] { 2, SGID, 's', XGRP, 'x', '-' }; int m7[] { 1, ROTH, 'r', '-' }; int m8[] { 1, WOTH, 'w', '-' }; int m9[] { 2, STXailed==0) time(timbuf); cbp = cbuf; ctime(timbuf); write(1, cbuf, 20); tzn = tzname[localtime(timbuf)[8]]; if (tzn) wriT, 't', XOTH, 'x', '-' }; int *m[] { m1, m2, m3, m4, m5, m6, m7, m8, m9}; pmode() { register int **mp; for (mp = &m[0]; mp te(1, tzn, 3); write(1, cbuf+19, 6); exit(0); } gtime() { register int i; register int y, t; int d, h, m; extern int *loc< &m[9];) select(*mp++); } select(pairp) int *pairp; { register int n, *ap; ap = pairp; n = *ap++; while (--n>=0 && (arbaltime(); int nt[2]; t = gpair(); if(t<1 || t>12) goto bad; d = gpair(); if(d<1 || d>31) goto bad; h = gpair(); if(huf.mode&*ap++)==0) ap++; putchar(*ap); }  == 24) { h = 0; d++; } m = gpair(); if(m<0 || m>59) goto bad; y = gpair(); if (y<0) { time(nt); y = localtime(nt)[5]; } if (*cbp == 'p') h =+ 12; if (h<0 || h>23) goto bad; timbuf[0] = 0; timbuf[1] = 0; y =+ 1900; for(i=1970; i= 3) gdadd(1); while(--t) gdadd(dmsize[t-1]); gdadd(int timbuf[2]; char *cbp; char *tzname[2]; int dmsize[]; char cbuf[]; char *cbp; struct { char name[8]; char tty; char filld-1); gmdadd(24, h); gmdadd(60, m); gmdadd(60, 0); return(0); bad: return(1); } gdadd(n) { register char *t; t = timbu(*--p1 != '/') break; *p1 = 0; } p2 = s; for(p1 = s; *p1; p1++) if(*p1 == '/') p2 = p1+1; return(p2); } #define I1; int wtime[2]; int fill2; } wtmp[2]; main(argc, argv) int argc, **argv; { register char *tzn; extern int timezone, *localFMT 060000 #define ISARG 01000 #define LARGE 010000 #define SUID 04000 #define SGID 02000 #define ROWN 0400 #define WOWN 0200 #dtime(); int wf, tfailed; tfailed = 0; if(argc > 1) { cbp = argv[1]; if(gtime()) { write(1, "bad conversion\n", 15); efine XOWN 0100 #define RGRP 040 #define WGRP 020 #define XGRP 010 #define ROTH 04 #define WOTH 02 #define XOTH 01 #define STXT  exit(-1); } if (*cbp != 's') { /* convert to Greenwich time, on assumption of Standard time. */ dpadd(timbuf, timezone01000 longt() { register char *cp; register t; pmode(); printf("%3d/%1d", arbuf.uid&0377, arbuf.gid&0377); printf("%6s", ); /* Now fix up to local daylight time. */ if (localtime(timbuf)[8]) dpadd(timbuf, -1*60*60); } time(wtmp[0].wtime)locv(arbuf.size)); cp = ctime(&arbuf.date); printf(" %-6.6s %-4.4s ", cp+4, cp+20); } int m1[] { 1, ROWN, 'r', '-' }; int m2[; wtmp[0].tty = '|'; if(stime(timbuf) < 0) { tfailed++; write(1, "no permission\n", 14); } else if ((wf = open("/us] { 1, WOWN, 'w', '-' }; int m3[] { 2, SUID, 's', XOWN, 'x', '-' }; int m4[] { 1, RGRP, 'r', '-' }; int m5[] { 1, WGRP, 'w', '-'r/adm/wtmp", 1)) >= 0) { time(wtmp[1].wtime); wtmp[1].tty = '}'; seek(wf, 0, 2); write(wf, wtmp, 32); } } if (tf turn(-1); cbp = cp; return (c+d); } .,getoff mov dbfin,r0 sys seek; 0; 0 mov dbfin,r0 sys read; regbuf; 1024. mov txtsiz,r0 ash $6,r0 mov r0,txtsiz add $17777,r0 bic $17777,r0 mov r0,rtxtsiz mov datsiz,r0 ash $6,r0 mov r0,datsiz mov stksiz,r0 ash $6,r0 mov r0,stksiz mov *locfpsr,r0 bic $!200,r0 mov r0,fpsr br loop 9: loop: clr error jsr pc,readlin jsr pc,readexp tst error bne errexit mov $1,/ db1 -- debugger fpp = 0 eae = 0 mx = 1 uorg = 60000 totcore = 160000 ldfps = 170100^tst db: mov sp,r5 mov (r5)+,r4 tst (rcount cmpb r0,$', bne 2f movb (r4)+,r0 mov addres,-(sp) mov adrflg,-(sp) jsr pc,readexp mov addres,count mov (sp)+,adrfl5)+ ckarg: cmp r4,$2 blt 1f .if mx mov (r5),r0 cmpb (r0)+,$'- bne 2f cmpb (r0),$'a bne 2f dec r4 tst (r5)+ inc absflg g mov (sp)+,addres tst error bne errexit 2: movb (r4),r0 jsr pc,command tst error beq loop errexit: sys signal; 2; errexbr ckarg 2: .endif mov (r5),dbfile mov (r5),odbfil mov (r5)+,namfil cmp r4,$2 beq 1f mov (r5)+,namfil 1: sys open; dbfileit mov savsp,sp jsr r5,mesg; ; .even br loop fnfnd: jsr r5,mesg; ; .even ex: sys exit readlin: core; 0 bec 9f jmp fnfnd 9: mov r0,dbfin clr dbfout sys open; odbfil:core; 1 bes 1f mov r0,dbfout 1: sys open; namfil:: mov $inbuf,r4 1: mov ttyfin,r0 sys read; ch; 1 tst r0 beq ex cmpb ch,$'\n beq 1f movb ch,(r4)+ br 1b 1: clrb (r4) m a.out; 0 bes 1f mov r0,r1 mov r0,symfin sys read; nambuf; 20 cmp nambuf,nobjmagic beq 2f cmp nambuf,objmagic bne 1f 2: ov $inbuf,r4 rts pc switch: mov (r5)+,r1 2: cmp r0,(r1)+ bne 1f tst (sp)+ jmp *(r1) 1: tst (r1)+ bne 2b rts r5 readex mov nambuf+2,r0 / text add nambuf+4,r0 / data cmp nambuf+16,$1 / relocation? beq 6f asl r0 / sym origin 6: add $20,r0 mop: mov $'+,lastop clr addres clr starmod clr taddr clr adrflg nextxp: movb (r4)+,r0 cmp r0,$'0 blt 1f cmp r0,$'9 ble nv r0,0f mov r1,r0 sys seek; 0:..; 0 mov nambuf+10,r0 / symbol size cmp r0,$maxsym blos 3f mov $maxsym,r0 3: add r0,0f syumin cmp r0,$'a blt 1f cmp r0,$'z bgt 1f jmp letin 1: cmp r0,$'a-40 blt 1f cmp r0,$'z-40 ble letin 1: jsr r5,switch; ef[1]+n; if(t < timbuf[1]) timbuf[0]++; timbuf[1] = t; } gmdadd(m, n) { register int t1; timbuf[0] =* m; t1 = timbuf[1];s break; 0: nambuf mov r0,0f mov r1,r0 sys read; nambuf; 0:.. add $nambuf,r0 mov r0,namsiz 1: jsr r5,get; zero / test new  while(--m) gdadd(t1); gdadd(n); } gpair() { register int c, d; register char *cp; cp = cbp; if(*cp == 0) return(-1)object cmp r0,nobjmagic beq 2f cmp r0,objmagic bne 1f 2: mov $20,getoff 1: mov sp,savsp sys signal; 2; 1 ror r0 bcs 1f ; c = (*cp++ - '0') * 10; if (c<0 || c>90) return(-1); if(*cp == 0) return(-1); if ((d = *cp++ - '0') < 0 || d > 9) re sys signal; 2; errexit 1: cmp r4,$2 / arg count beq 9f / not core image cmp r4,$4 / no-core image flag beq 9f mov $1024 xpsw tstb -(r4) tst starmod beq 1f mov dot,taddr br operand 1: rts pc expsw: '+; opex '-; opex ' ; nextxp '.; letin '_; letin '^; circumf '*; star -1; 0 star: mov pc,starmod br nextxp operand: inc adrflg tst starmod beq 1f clr starmod bis bytemod,error jsr r5,get; taddr tst error bne 1f mov r0,taddr 1: cmp lastop,$'+ beq 1f sub taddr,addres br 2f 1:  add taddr,addres 2: mov $'+,lastop br nextxp circumf: mov dot,taddr dec taddr tst bytemod bne operand dec taddr br opev sigp,r1 bic $!17,r1 asl r1 mov traptab(r1),r1 jsr pc,string jsr pc,pnl mov $doltab,r5 1: mov (r5)+,r1 beq 1f jsr pc,*rand numin: clr r1 clr r3 1: sub $'0,r0 asl r1 asl r1 asl r1 mpy $10.,r3 bis r0,r1 add r0,r3 movb (r4)+,r0 cmp r0,$'(r5)+ br 1b .if fpp 1: mov (r5)+,r1 beq 1f ldfps fpsr jsr pc,*(r5)+ br 1b 1: mov (r5)+,r1 jsr pc,*(r5)+ .endif 1: rts0 blo 1f cmp r0,$'9 blos 1b 1: cmp r0,$'. bne 1f mov r3,r1 inc r4 1: mov r1,taddr dec r4 br operand letin: dec r4 m pc traptab: 1f; .data; 1:; .text 1f; .data; 1:; .text 1f; .data; 1:; .text 1f; .data; 1:; .text 1f; .data; 1:; .text 1f; .data; 1:; .text 1f; .data; 1:; .text 1f; .datstb (r4)+ cmpb (r4),$'. beq 2f cmpb (r4),$'0 blo 3f cmpb (r4),$'9 blos 2f cmpb (r4),$'A blo 3f cmpb (r4),$'Z blos 2f ta; 1:; .text 1f; .data; 1:; .text 1f; .data; 1:; .text 1f; .data; 1:; .text 1 cmpb (r4),$'_ beq 2f cmpb (r4),$'a blo 3f cmpb (r4),$'z bhi 3f 2: dec (sp) blt 1b movb (r4),(r1)+ br 1b 3: tst (sp)+ f; .data; 1:; .text 1f; .data; 1:; .text 1f; .data; 1:; .text 1f; .data;  jsr pc,lookupn tst error bne 1f cmpb (r4),$'; beq 2f 1: jmp operand 2: tstb (r4)+ mov r1,namstrt br letin1 opex: mov 1:; .text 1f; .data; 1:; .text locps: regbuf+1776 locpc: regbuf+1774 locr0: regbuf+1772 locr1: regbuf+1766 locr2r0,lastop jmp nextxp command: jsr r5,switch; comsw inc error rts pc comsw: '/; slash '\\; bslash '?; quest '\0; newln: regbuf+1750 locr3: regbuf+1752 locr4: regbuf+1754 locsp: regbuf+1764 locr5: regbuf+1756 locfpsr: regbuf+4 locfr0: regbuf+6 loc '^; circumf '=; equal ':; colon '!; excla ''; squote '"; dquote '$; dolr '&; amper '%; ex '`; grave -1; 0 dolr: mofr4: regbuf+16 locfr5: regbuf+26 locfr1: regbuf+36 locfr2: regbuf+46 locfr3: regbuf+56 doltab: 1f; prgreg; locsp; .data; 1:; .text 1f; proct; locps; .data; 1:; .text 1f; prgreg; locpc; .data; 1:; .text 1f; prgreg; locr0; .data; 1: ytemod mov $1,incdot br 1f slash: clr bytemod mov $2,incdot 1: jsr r5,cycle; octp rts pc grave: clr bytemod mov $2,inc jsr pc,putc 1: cmpf r3,r0 cfcc bgt 1f inc r4 divf r3,r0 br 1b 1: cmpf r2,r0 cfcc ble 2f dec r4 mulf r3,r0 br 1b 2:dot jsr r5,cycle; decp rts pc quest: clr bytemod jsr r5,cycle; psym rts pc decp: jsr pc,printd jsr r5,mesg; <.\n\0>; . modf r2,r0 movfi r1,r0 add $'0,r0 jsr pc,putc mov $'.,r0 jsr pc,putc mov $8.,r3 1: modf r3,r0 movfi r1,r0 add $'0,r0 even rts pc octp: jsr pc,printo jsr pc,pnl rts pc newln: tst adrflg bne 1f add incdot,dot 1: mov nlcom,r0 jmp command jsr pc,putc dec r3 bgt 1b mov $'E,r0 jsr pc,putc mov r4,r0 mov (sp)+,r3 mov (sp)+,r4 br printd .endif printd: mov r1; .text 1f; prgreg; locr1; .data; 1:; .text 1f; prgreg; locr2; .data; 1:; .text 1f; prgreg; locr3; .data excla: tst adrflg bne 1f 2: inc error rts pc 1: bit $1,dot beq 1f tst bytemod beq 2b 1: jsr r5,put; dot; addres rts ; 1:; .text 1f; prgreg; locr4; .data; 1:; .text 1f; prgreg; locr5; .data; 1:; .text 0 .if fpp 1f; prfrpc squote: inc bytemod mov $1,incdot br 2f dquote: clr bytemod mov $2,incdot 2: jsr r5,cycle; ascp rts pc ascp: mov r0eg; locfr0; .data; 1:; .text 1f; prfreg; locfr1; .data; 1:; .text 1f; prfreg; locfr2; .data; 1:; .text,-(sp) jsr pc,ascp1 mov (sp)+,r0 tst bytemod bne 1f swab r0 jsr pc,ascp1 1: cmp count,$1 bgt 1f jsr pc,pnl 1: rts pc  1f; prfreg; locfr3; .data; 1:; .text 1f; prfreg; locfr4; .data; 1:; .text 1f; prfreg; locfr5; .data; 1:; .text 0 1f; proct; locfpsr; .data; 1:; .text .endif .data .even .text .if fpp prfreg: mov *(r5)+,r4 movf (r 1: mov r0,r1 jsr r5,mesg; <\\\0> clr r0 alsc $10.,r0 add $'0,r0 jsr pc,putc clr r0 alsc $3,r0 add $'0,r0 jsr pc,putc 4),fr0 cfcc beq 1f jsr pc,string jsr pc,printf jsr pc,pnl 1: rts pc .endif prgreg: jsr pc,string mov *(r5)+,r4 mov (r clr r0 alsc $3,r0 add $'0,r0 jsr pc,putc rts pc colon: jsr r5,coleq; pname rts pc coleq: jsr pc,setadr mov addres,r0 4),r0 jsr pc,printo mov (r4),r0 jsr pc,lookupv tst r2 beq 1f jsr r5,mesg; < \0>; .even mov (r4),r0 jsr pc,pname 1: jsr  jsr pc,*(r5)+ jsr pc,pnl rts r5 cycle: mov r0,nlcom jsr pc,setadr mov addres,dot tst bytemod bne 1f bic $1,dot 1: jsrpc,pnl rts pc proct: jsr pc,string mov *(r5)+,r4 mov (r4),r0 jsr pc,printo jsr pc,pnl rts pc string: movb (r1)+,r0 be r5,get; dot tst error bne 1f tst bytemod beq 2f bic $!377,r0 2: jsr pc,*(r5) tst error bne 1f dec count ble 1f add iq 1f jsr pc,putc br string 1: rts pc putc: mov r0,och mov $1,r0 sys write; och; 1 rts pc equal: jsr r5,coleq; printo ncdot,dot br 1b 1: tst (r5)+ rts r5 setadr: tst adrflg bne 1f mov dot,addres 1: rts pc .if fpp printf: ldfps $200 / rts pc amper: clr bytemod mov $2,incdot jsr r5,cycle; asymp rts pc asymp: jsr pc,pname jsr pc,pnl rts pc bslash: inc bround+double mov r4,-(sp) mov r3,-(sp) movif $10.,r3 movif $1,r2 clr r4 tstf r0 cfcc beq 2f bge 1f negf r0 mov $'-,r0 if rts pc 2: tst (r1)+ 3: tst (r1)+ 4: tst (r1)+ 5: cmp (r1)+,(r1)+ cmp r1,r2 blo 1b inc error clr taddr rts pc looku r0,0f mov dbfout,r0 bne 1f 2: tst (r5)+ 3: inc error rts r5 1: tst error bne 3b sys seek; 0:0; 0 bes 2b mov (r5)+,0f pv: mov r5,-(sp) mov $nambuf,r5 clr r2 mov $177777,r3 1: cmp r5,namsiz bhis 4f mov 12(r5),r1 sub r0,r1 neg r1 blt 3f  mov dbfout,r0 tst bytemod beq 1f mov $1,0f+2 br 2f 1: mov $2,0f+2 2: sys write; 0:0; 2 bes 3b rts r5 decodadr: mov r0cmp r1,r3 bhi 3f cmp r1,$4000 bhis 3f cmp r2,r5 bhi 3f mov r1,r3 mov r5,r2 3: add $14,r5 br 1b 4: mov (sp)+,r5 rts pc,r3 mov r3,-(sp) bic $!10,(sp) bic $!7,r0 cmp r0,$7 beq pcadr 7: mov r3,r0 asr r0 asr r0 asr r0 bic $!6,r0 jmp *1f(r0 get: mov *(r5)+,r0 jsr r5,remap tst error bne 2f mov r0,0f mov curfin,r0 sys seek; 0:0; 0 bec 1f 2: inc error rts r5) 1: simp incr decr indx simp: tst (sp) beq 1f jsr pc,plp 1: jsr pc,preg tst (sp)+ beq 9f jsr pc,prp br 9f incr:  1: mov curfin,r0 sys read; temp; 2 bes 2b tst r0 beq 2b mov temp,r0 rts r5 remap: mov dbfin,curfin cmp getoff,$1024.  tst (sp)+ beq 1f jsr pc,pstar 1: jsr pc,plp jsr pc,preg jsr r5,mesg; <)+\0>; .even br 9f decr: tst (sp)+ beq 1f jsr p bne 1f cmp r0,txtsiz bhis 2f add $20,r0 mov symfin,curfin rts r5 2: cmp r0,rtxtsiz blo 3f sub rtxtsiz,r0 cmp r0,datsizc,pstar 1: jsr r5,mesg; <-(\0>; .even jsr pc,preg jsr pc,prp br 9f indx: tst (sp)+ beq 1f jsr pc,pstar 1: jsr pc,get1 ,-(sp) mov r0,r1 bpl 1f neg r1 mov $'-,r0 jsr pc,putc 1: jsr pc,1f mov (sp)+,r1 rts pc 1: clr r0 dvd $10.,r0 mov r1,- bhis 2f add $1024.,r0 rts r5 2: add rtxtsiz,r0 .if mx sub $totcore,r0 .endif neg r0 cmp r0,stksiz bhi 3f neg r0 .if mx(sp) mov r0,r1 beq 1f jsr pc,1b 1: mov (sp)+,r0 add $'0,r0 jsr pc,putc rts pc  add $totcore,r0 .endif .if mx-1 add datsiz,r0 add stksiz,r0 .endif add $1024.,r0 .if mx sub $uorg,r0 .endif rts r5 1: add getoff,r0 rts r5 3: inc error rts r5 printo: mov $obuf+6,r1 clr r2 1: inc r2 movb r0,-(r1) bicb $!7,(r1) bisb $'0,(r1) clc ror r0 asr r0 asr r0 bne 1b mov r2,0f+2 mov r1,0f mov $1,r0 sys write; 0:obuf; 6 rts pc mesg: movb (r5)+,r0 / db2 -- debugger lookupn: cmp symbol,$'. bne 1f mov dot,taddr rts pc 1: tst error beq 1f rts pc 1: mov r2,-(sp) mov nbeq 1f jsr pc,putc br mesg 1: inc r5 bic $1,r5 rts r5 pnl: jsr r5,mesg; <\n\0> rts pc psp: jsr r5,mesg; < \0> rts pc amstrt,r1 mov namsiz,r2 jsr pc,1f mov (sp)+,r2 rts pc 1: mov $symbol,r0 cmp (r0)+,(r1)+ bne 2f cmp (r0)+,(r1)+ bne 3f  pstar: jsr r5,mesg; <*\0> rts pc plp: jsr r5,mesg; <(\0> rts pc prp: jsr r5,mesg; <)\0> rts pc pb: jsr r5,mesg; cmp (r0)+,(r1)+ bne 4f cmp (r0)+,(r1)+ bne 5f tst (r1)+ mov (r1)+,taddr .if mx tst absflg bne 9f sub $uorg,taddr 9: .end rts pc pcom: jsr r5,mesg; <,\0> rts pc put: mov *(r5)+,r0 jsr r5,remap tst error bne 2f cmp curfin,dbfin bne 2f mov mov r1,-(sp) jsr pc,lookupv tst r2 beq 5f cmp (sp),$1 bne 1f tst r3 bne 5f 1: mov r2,r1 mov $8,-(sp) mov r0,r5 1: movasr\0\0\0> 100077; 006300; single; 000077; 000100; single; 000077; 000300; single; 000077b (r1)+,r0 beq 1f jsr pc,putc dec (sp) bne 1b 1: tst (sp)+ cmp 12(r2),r5 beq 1f blt 2f jsr r5,mesg; <-\0> br 3f 2: js; 170100; singlw; 000077; 170200; singlw; 000077; 170300; singlw; 000077; 170400; singlw; 3: mov r3,r0 5: jsr pc,printo 1: tst (sp)+ mov (sp)+,r3 mov (sp)+,r5 rts pc get1: mov *(r5)+,r1 add $2f\0\0> 000077; 170500; singlw; 000077; 170600; singlw; 000077; 170700; singlw; 000077; 0067,r1 mov r1,temp jsr r5,get; temp rts pc 00; singlw; 000077; 006600; singlw; 000077; 106600; singlw; 000077; 006500; singlw; 000077; 106500; singlw; 000777; 070000; muldiv; 000777; 071000; muldiv; 000777; 072000; muldiv; 000777; 073000; muldiv; 000377; 000400; branch; 000377; 001000; branch; 000377; 001400; branch; 000377; 002000; branch; 000377; 002400; branch; 000377; 0 bic (r1)+,r0 cmp (r1)+,r0 bne 2f mov (r1)+,-(sp) jsr pc,string jmp *(sp)+ 2: add $8.,r1 br 1b optab: 107777; 010000; 03000; branch; 000377; 003400; branch; 000377; 100000; branch; 000377; 100400; branch; 107777; 020000; double; 107777; 030000; double; 107777; 040000; double; 000377; 101000; branch; 000377; 101400; branch; 000377; 102000; branch; 000377;jsr pc,pname jsr pc,plp jsr pc,preg jsr pc,prp br 5f pcadr: mov r3,r0 bit $20,r3 beq 7b tst (sp)+ beq 1f jsr pc,pstar0> 107777; 050000; double; 007777; 060000; double; 007777; 160000; double; 100077; 005 1: bit $40,r3 bne 6f jsr r5,mesg; <$\0> jsr pc,get1 jsr pc,pname br 5f 6: jsr pc,get1 add $2,r0 add r1,r0 mov $3,r1 000; single; 100077; 005100; single; 100077; 005200; single; 100077; 005300; single; 100077; 005400; single; 100077; 005500; single; 100077; 005600; single; 100077; uf mov $1,r0 sys write; obuf; 2 rts pc regtab: "r0 "r1 "r2 "r3 "r4 "r5 "sp "pc pname: mov r5,-(sp) mov r3,-(sp) 005700; single; 100077; 006000; single; 100077; 006100; single; 100077; 006200; single; <  000000; 000001; noaddr; 000000; 000002; noaddr; 000000; 000004; noaddr; 000000 add r0,incdot rts pc single: tst (sp) bge singlw jsr pc,pb singlw: jsr pc,psp mov (sp)+,r0 jsr r5,decodadr; dot add r0; 000005; noaddr; 000377; 171000; fltrev; 000377; 171400; fltrev; 000377; 172000; fltrev; 000377; 172400; fltrev; 000377; 173000; fltrev; 000377; 173400; fltrev; 000377; 174000; fltnor; 000377; 174400; fltrev; 000377; 175000; fltnor; 000377; 175400; fltnor; 000377; 176000; fltnor; 000377; 176400; fltrev; 000377; 177000; fltrev; 000377; 177400; fltrev; 000000; 170000; noaddr; 000000; 170001; noaddr; 000000; 170002; noaddr; 000000; 170011; noaddr; 000000; 170012; noaddr; 000777; 004000; specl1; 000777; 074000; specl1 br 1f branch: jsr pc,psp mov (sp)+,r0 bic $!377,r0 bit $200,r0 beq 1f bis $177400,r0 1: inc r0 asl r0 add dot,r0 js; 000007; 000200; specl2; 000017; 000240; specl3; 000017; 000260; specl3; 0003r pc,pname rts pc noaddr: tst (sp)+ rts pc specl1: / jsr jsr pc,psp mov (sp),r3 als $-6,r3 jsr pc,preg jsr pc,pcom mo77; 104000; specl4; 000377; 104400; specl5; 000077; 006400; specl7; 000777; 077000; specl8v (sp)+,r0 jsr r5,decodadr; dot add r0,incdot rts pc specl2: / rts jsr pc,psp mov (sp)+,r3 jsr pc,preg rts pc specl3: /; 000007; 000230; specl9; 177777; 000000; specl6; fltrev: bic $!377,(sp) muldiv: jsr pc opr jsr pc,psp mov (sp)+,r2 mov $3f,r1 1: bit $17,r2 beq 1f bit $10,r2 beq 2f movb (r1),r0 jsr pc,putc 2: inc r1 asl,psp mov (sp)+,r0 asl r0 asl r0 swab r0 aslb r0 aslb r0 aslb r0 aslb r0 asr r0 asr r0 asr r0 asr r0 bic $!7707,r0  r2 br 1b 1: rts pc 3: specl7: / mark bic $!77,(sp) br specl4 specl9: / spl bic $!7,(sp) br specl4 specl4: / emmov r0,-(sp) br fltnor1 fltnor: bic $!377,(sp) br 1f double: tst (sp) bge 1f jsr pc,pb 1: jsr pc,psp mov (sp),r0 fltnot jsr pc,psp mov (sp)+,r0 bic $!377,r0 8: jsr pc,printo rts pc specl5: / sys jsr pc,psp mov (sp)+,r2 bic $!377,r2 mov  102400; branch; 000377; 103000; branch; 000377; 103400; branch; 000000; 000000; noaddr; r1: als $-6,r0 jsr r5,decodadr; dot add r0,incdot add dot,r0 mov r0,temp jsr pc,pcom mov (sp)+,r0 jsr r5,decodadr; temp  .text 1f; 0; .data; 1:; .text 1f; 0; .data; 1:; .text 1f; 0; .data; 1:; .text 1f; 0; .data; 1:; .text 1f; 0; .data; 1:; .text 1f; 0; .data; 1:; .text esystab: .data .even .text specl6: / unknown j while(argc > 1) { printf("%s: ", argv[1]); type(argv[1]); argc--; argv++; } } type(file) char *file; { int j,nl; r2,r0 asl r2 asl r2 cmp r2,$esystab-systab bhis 8b mov systab(r2),r1 jsr pc,string mov systab+2(r2),-(sp) mov dot,temp1 sr pc,psp mov (sp)+,r0 jsr pc,printo rts pc 1: dec (sp) bge 2f tst (sp)+ rts pc 2: jsr r5,mesg; <;\0> add $2,temp1 add $2,incdot jsr r5,get; temp1 jsr pc,pname br/ db4 -- debugger maxsym = 24000. core: a.out: .even zero: 0 .bss regbuf: .=.+1024. sigp = regbuf+310 1b systab: 1f; 0; .data; 1:; .text 1f; 0; .data; 1:; .text 1f; 0; .data; 1:; .text 1f; 2; .data; 1 txtsiz = regbuf+322 datsiz = regbuf+324 stksiz = regbuf+326 rtxtsiz: .=.+2 .data objmagic: 407 nobjmagic: 410 namsiz: nambuf in:; .text 1f; 2; .data; 1:; .text 1f; 2; .data; 1:; .text 1f; 0; .data; 1:; .text 1f; 0; .dcdot: 2 nlcom: '/ .bss .if mx absflg: .=.+2 .endif starmod:.=.+2 symbol: .=.+10. getoff: .=.+2 namstrt: .=.+2 bytemod: .=.+2 ata; 1:; .text 1f; 2; .data; 1:; .text 1f; 2; .data; 1:; .text 1f; 1; .data; 1:; .text 1fsavsp: .=.+2 error: .=.+2 ttyfin: .=.+2 dbfin: .=.+2 symfin: .=.+2 curfin: .=.+2 dbfout: .=.+2 ch: .=.+2 lastop: .=.+2 addres: .; 2; .data; 1:; .text 1f; 1; .data; 1:; .text 1f; 0; .data; 1:; .text 1f; 1; .data; 1:; .t=.+2 taddr: .=.+2 adrflg: .=.+2 fpsr: .=.+2 och: .=.+2 dot: .=.+2 count: .=.+2 syscnt: .=.+2 temp: .=.+2 temp1: .=.+2 obuf: .=.+ext 1f; 2; .data; 1:; .text 1f; 2; .data; 1:; .text 1f; 1; .data; 1:; .text 1f; 2; .data; 1:; .text 1f; 2; .data; 1:; .text 1f; 2; .data; 1:; .text 1f; 2; .data; 1:; .text 1f; 1; .data; 1:; .text 1f; 0; .data; 1:; .text 1f; 0; .data; 1:; .text 1f; 0; .data; 1:; .text 1f; 1; .data; 1:; .text 1f; 1; .data; 1:; .text 1f; 1; .data; 1:; .text 1f; 1; .data; 1:; .text 1int in; int i 0; char buf[512]; int *wd { &buf[0]}; char *fort[]{ "function","subroutine","common","dimension","block","integef; 1; .data; 1:; .text 1f; 1; .data; 1:; .text 1f; 1; .data; 1:; .text 1f; 1; .data; 1:; r", "real","data","double",0}; char *asc[]{ "sys","mov","tst","clr","jmp",0}; char *c[]{ "int","char","float","double","struc! m() == 0)goto notc; } check: if(lookup(c) == 1){ while((ch = buf[i++]) != ';' && ch != '{')if(i >= in)goto notc; printf("c) if(buf[i++] <= 0){ printf(" with garbage\n"); goto out; } while((in = read(ibuf[0],buf,512)) > 0) for(i = 0; i <  program"); goto outa; } nl = 0; while(buf[i] != '('){ if(buf[i] <= 0){ printf("data\n"); goto out; } if(buf[in; i++) if(buf[i] <= 0){ printf(" with garbage\n"); goto out; } printf("\n"); out: close(ibuf[0]); } lookup(tabi] == ';'){ i++; goto check; } if(buf[i++] == '\n') if(nl++ > 6)goto notc; if(i >= in)goto notc; } while(buf[) char *tab[]; { char r; int k,j,l; while(buf[i] == ' ' || buf[i] == '\t' || buf[i] == '\n')i++; for(j=0; tab[j] != 0; j++){i] != ')'){ if(buf[i++] == '\n') if(nl++ > 6)goto notc; if(i >= in)goto notc; } while(buf[i] != '{'){ if(buf[i++] ==  l=0; for(k=i; ((r=tab[j][l++]) == buf[k] && r != '\0');k++); if(r == '\0') if(buf[k] == ' ' || buf[k] == '\n' || buf[k'\n') if(nl++ > 6)goto notc; if(i >= in)goto notc; } printf("c program"); goto outa; notc: i = 0; while(buf[i] == 'c' ] == '\t' || buf[k] == '{' || buf[k] == '/'){ i=k; return(1); } } return(0); } ccom(){ char cc; while((cc char ch; int mbuf[20]; if(stat(file, mbuf) < 0) { printf("cannot stat\n"); return; } switch(mbuf[2]&060000) { case 02|| buf[i] == '#'){ while(buf[i++] != '\n')if(i >= in)goto notfort; } if(lookup(fort) == 1){ printf("fortran"); goto outa0000: printf("character"); goto spcl; case 040000: printf("directory\n"); return; case 060000: printf("block"); s; } notfort: i=0; if(ascom() == 0)goto notas; j = i-1; if(buf[i] == '.'){ i++; if(lookup(as) == 1){ printf("assemblepcl: printf(" special (%d/%d)\n", (mbuf[6]>>8)&0377, mbuf[6]&0377); return; } ibuf[0] = open(file, 0); if(ibuf[0] < r program"); goto outa; } else if(buf[j] == '\n'){ printf("roff, nroff, or eqn input"); goto outa; } } while(l0) { printf("cannot open\n"); return; } in = read(ibuf[0], buf, 512); if(in == 0){ printf("empty\n"); return; } swiookup(asc) == 0){ if(ascom() == 0)goto notas; while(buf[i] != '\n' && buf[i++] != ':') if(i >= in)goto notas; while(buftch(*wd) { case 0410: printf("pure "); goto exec; case 0411: printf("separate "); case 0407: exec: printf("execut[i] == '\n' || buf[i] == ' ' || buf[i] == '\t')if(i++ >= in)goto notas; j = i-1; if(buf[i] == '.'){ i++; if(lookup(as)able"); if(wd[4] != 0) printf(" not stripped"); printf("\n"); goto out; case 0177555: printf("old archive\n"); go == 1){ printf("assembler program"); goto outa; } else if(buf[j] == '\n'){ printf("roff, nroff, or eqn inputto out; case 0177545: printf("archive\n"); goto out; } i = 0; if(ccom() == 0)goto notc; while(buf[i] == '#'){ j = i"); goto outa; } } } printf("assembler program"); goto outa; notas: for(i=0; i < in; i++)if(buf[i] <= 0){ printf(; while(buf[i++] != '\n'){ if(i - j > 255){ printf("data\n"); goto out; } if(i >= in)goto notc; } if(cco"data\n"); goto out; } if((mbuf[2] & 00111) != 0) printf("commands"); else printf("probably text"); outa: while(i < in" liblist liblist[NROUT]; struct liblist *libp { &liblist[0] }; struct symbol { char sname[8]; char stype; char spad; int svarn(0); } if(buf[i] == '\n')if(ccom() == 0)return(0); return(1); } ascom(){ while(buf[i] == '/'){ i++; while(buf[i++] != lue; }; struct symbol cursym; struct symbol symtab[NSYM]; struct symbol *hshtab[NSYM+2]; struct symbol *symp { symtab }; struct'\n')if(i >= in)return(0); while(buf[i] == '\n')if(i++ >= in)return(0); } return(1); }  symbol **local[NSYMPR]; struct symbol *p_etext; struct symbol *p_edata; struct symbol *p_end; int aflag; /* relocate to absolute 0, otherwise to TOPSYS */ int xflag; /* discard local symbols */ int Xflag; /* discard locals starting with 'L' */ int rflag; /* preserve relocation bits, don't define common */ int arflag; /* original copy of rflag */ int sflag; /* discard all sy# /* * link editor */ #define TOPSYS 060000 #define SIGINT 2 #define ARCMAGIC 0177545 #define FMAGIC 0407 #define NMAGIC 04mbols */ int nflag; /* pure procedure */ int dflag; /* define common even with rflag */ int iflag; /* I/D space separated */ 10 #define IMAGIC 0411 #define EXTERN 040 #define UNDEF 00 #define ABS 01 #define TEXT 02 #define DATA 03 #define BSS 04 #defin int infil; char *filname; int tsize; int dsize; int bsize; int ssize; int nsym; int torigin; int dorigin; int borigin; int ce COMM 05 /* internal use only */ #define RABS 00 #define RTEXT 02 #define RDATA 04 #define RBSS 06 #define REXT 010 #define Rtrel; int cdrel; int cbrel; int errlev; int delarg 4; char tfname[] "/tmp/lxyyyyy"; int toutb[259]; int doutb[259]; int troutb[= buf[i]) == ' ' || cc == '\t' || cc == '\n')if(i++ >= in)return(0); if(buf[i] == '/' && buf[i+1] == '*'){ i =+ 2; while(buELFLG 01 #define NROUT 256 #define NSYM 501 #define NSYMPR 500 #define RONLY 0400 char premeof[] "Premature EOF on %s"; strucf[i] != '*' || buf[i+1] != '/'){ if(buf[i] == '\\')i =+ 2; else i++; if(i >= in)return(0); } if((i =+ 2) >= in)retut page { int nuser; int bno; int nibuf; int buff[256]; } page[2]; struct { int nuser; int bno; } fpage; struct stream {  int *ptr; int bno; int nibuf; int size; struct page *pno; }; struct stream text; struct stream reloc; struct archdr { char aname[14]; int atime[2]; char auid, agid; int amode; int asize[2]; } archdr; struct filhdr { int fmagic; int tsize; int dsize; int bsize; int ssize; int entry; int pad; int relflg; } filhdr; struct liblist { int off; int bno; }; struct # GINT, delexit); if (argc == 1) exit(4); p = argv + 1; for (c = 1; c= argc) error(1, "Bad 'use'"); if (*(hp = slookup(*p++)) == 0) { *hp = symp; enter(); } continue; case 'l': break; case 'x': xflag++; continue; case 'X': Xflag++; continue; case 'r': rflag++; arflag++; continue; case 's': sflag++; xflag++; continue; case 'n': nflag++; continue; case 'd': dflag++; continue; case 'i': iflag++; continue; case 'a': aflag++; continue; } load1arg(ap); close(infil); } middle(); setupout(); p = argv+1; libp = liblist; for (c=1; c 0) { mget(&cursym, sizeof cursym); if ((cursym.stype&EXTERN)=ad2arg(ap); close(infil); } finishout(); } load1arg(acp) char *acp; { register char *cp; register noff, nbno; cp = acp;=0) { if (Xflag==0 || cursym.sname[0]!='L') nloc =+ sizeof cursym; continue; } symreloc(); hp = lookup(); if ( if (getfile(cp)==0) { load1(0, 0, 0); return; } nbno = 0; noff = 1; for (;;) { dseek(&text, nbno, noff, sizeof archd(sp = *hp) == 0) { *hp = enter(); *cp++ = hp; continue; } if (sp->stype != EXTERN+UNDEF) continue; if (cursym.r); if (text.size <= 0) { libp->bno = -1; libp++; return; } mget(&archdr, sizeof archdr); if (load1(1, nbno, nostype == EXTERN+UNDEF) { if (cursym.svalue > sp->svalue) sp->svalue = cursym.svalue; continue; } if (sp->svalue !=ff + (sizeof archdr) / 2)) { libp->bno = nbno; libp->off = noff; libp++; } noff =+ ((archdr.asize[1]&0777)+sizeof(a 0 && cursym.stype == EXTERN+TEXT) continue; ndef++; sp->stype = cursym.stype; sp->svalue = cursym.svalue; } if (libf259]; int droutb[259]; int soutb[259]; struct symbol **lookup(); struct symbol **slookup(); main(argc, argv) char **argv; { erchdr)+1) >> 1; nbno =+ (archdr.asize[1] >> 9) & 0177; nbno =+ (archdr.asize[0]) << 7; nbno =+ noff >> 8; noff =& 0377; xtern int delexit(); register c; register char *ap, **p; struct symbol **hp; if ((signal(SIGINT, 1) & 01) == 0) signal(SI } } load1(libflg, bno, off) { register struct symbol *sp, **hp, ***cp; struct symbol *ssymp; int ndef, nloc; readhdr(bno,$ flag) dorigin = 0; corigin = dorigin + dsize; borigin = corigin + csize; if(!aflag) { torigin =+ TOPSYS; dorigin =+ TOPcp; { register char *cp; register struct liblist *lp; cp = acp; if (getfile(cp) == 0) { while (*cp) cp++; while (cp lg==0 || ndef) { tsize =+ filhdr.tsize; dsize =+ filhdr.dsize; bsize =+ filhdr.bsize; ssize =+ nloc; return(1); } /* SYS; corigin =+ TOPSYS; borigin =+ TOPSYS; } nund = 0; for (sp=symtab; spstype) { case EXTERN+U * No symbols defined by this library member. * Rip out the hash table entries and reset the symbol table. */ symp = ssymp; NDEF: errlev =| 01; if (arflag==0 && sp->svalue==0) { if (nund==0) printf("Undefined:\n"); nund++; printf("%.8swhile (cp > local) **--cp = 0; return(0); } middle() { register struct symbol *sp; register t, csize; int nund, corigin; \n", sp->sname); } continue; case EXTERN+ABS: default: continue; case EXTERN+TEXT: sp->svalue =+ torigin; continu p_etext = *slookup("_etext"); p_edata = *slookup("_edata"); p_end = *slookup("_end"); /* * If there are any undefined symboe; case EXTERN+DATA: sp->svalue =+ dorigin; continue; case EXTERN+BSS: sp->svalue =+ borigin; continue; case EXTERls, save the relocation bits. */ if (rflag==0) for (sp=symtab; spstype==EXTERN+UNDEF && sp->svalue==0 N+COMM: sp->stype = EXTERN+BSS; sp->svalue =+ corigin; continue; } if (sflag || xflag) ssize = 0; bsize =+ csize; ns && sp!=p_end && sp!=p_edata && sp!=p_etext) { rflag++; dflag = 0; nflag = 0; iflag = 0; sflag = 0; break; ym = ssize / (sizeof cursym); } setupout() { register char *p; register pid; if ((toutb[0] = creat("l.out", 0666)) < 0) e} /* * Assign common locations. */ csize = 0; if (dflag || rflag==0) { for (sp=symtab; spstype==EXrror(1, "Can't create l.out"); pid = getpid(); for (p = &tfname[12]; p > &tfname[7];) { *--p = (pid&07) + '0'; pid =>> 3; TERN+UNDEF && (t=sp->svalue)!=0) { t = (t+1) & ~01; sp->svalue = csize; sp->stype = EXTERN+COMM; csize =+ t;  } tcreat(doutb, 'a'); if (sflag==0 || xflag==0) tcreat(soutb, 'b'); if (rflag) { tcreat(troutb, 'c'); tcreat(droutb, '} if (p_etext && p_etext->stype==EXTERN+UNDEF) { p_etext->stype = EXTERN+TEXT; p_etext->svalue = tsize; } if (p_edatd'); } filhdr.fmagic = FMAGIC; if (nflag) filhdr.fmagic = NMAGIC; if (iflag) filhdr.fmagic = IMAGIC; filhdr.tsize = tsia && p_edata->stype==EXTERN+UNDEF) { p_edata->stype = EXTERN+DATA; p_edata->svalue = dsize; } if (p_end && p_end->stypze; filhdr.dsize = dsize; filhdr.bsize = bsize; filhdr.ssize = sflag? 0: (ssize + (sizeof cursym)*(symp-symtab)); filhdr.ente==EXTERN+UNDEF) { p_end->stype = EXTERN+BSS; p_end->svalue = bsize; } } /* * Now set symbols to their final value */ry = 0; filhdr.pad = 0; filhdr.relflg = (rflag==0); mput(toutb, &filhdr, sizeof filhdr); return; } tcreat(buf, letter) int  if (nflag || iflag) tsize = (tsize + 077) & ~077; dorigin = tsize; if (nflag) dorigin = (tsize+017777) & ~017777; if (i*buf; { tfname[6] = letter; if ((buf[0] = creat(tfname, RONLY)) < 0) error(1, "Can't create temp"); } load2arg(acp) char *a% | cursym.svalue!=sp->svalue) { printf("%.8s: ", cursym.sname); error(0, "Multiply defined"); } } dseek(&text, bno, off putw(0, troutb); } } copy(doutb, 'a'); if (rflag) { copy(troutb, 'c'); copy(droutb, 'd'); } if (sflag==0) { if , filhdr.tsize); dseek(&reloc, bno, off+(filhdr.tsize+filhdr.dsize)/2, filhdr.tsize); load2td(lp, ctrel, toutb, troutb); dsee(xflag==0) copy(soutb, 'b'); for (p=symtab; p < symp;) putw(*p++, toutb); } fflush(toutb); close(toutb[0]); unlink("k(&text, bno, off+(filhdr.tsize/2), filhdr.dsize); dseek(&reloc, bno, off+filhdr.tsize+(filhdr.dsize/2), filhdr.dsize); load2ta.out"); link("l.out", "a.out"); delarg = errlev; delexit(); } delexit() { register c; unlink("l.out"); for (c = 'a'; c d(lp, cdrel, doutb, droutb); torigin =+ filhdr.tsize; dorigin =+ filhdr.dsize; borigin =+ filhdr.bsize; } load2td(lp, creloc<= 'd'; c++) { tfname[6] = c; unlink(tfname); } if (delarg==0) chmod("a.out", 0777); exit(delarg); } copy(buf, c) int >= acp && *--cp != '/'); mkfsym(++cp); load2(0, 0); return; } for (lp = libp; lp->bno != -1; lp++) { dseek(&text, lp->, b1, b2) int *lp; { register r, t; register struct symbol *sp; for (;;) { /* * The pickup code is copied from "get" for bno, lp->off, sizeof archdr); mget(&archdr, sizeof archdr); mkfsym(archdr.aname); load2(lp->bno, lp->off + (sizeof archdr)speed. */ if (--text.size <= 0) { if (text.size < 0) break; text.size++; t = get(&text); } else if (--text.ni / 2); } libp = ++lp; } load2(bno, off) { register struct symbol *sp; register int *lp, symno; readhdr(bno, off); ctrel buf < 0) { text.nibuf++; text.size++; t = get(&text); } else t = *text.ptr++; if (--reloc.size <= 0) { if (re= torigin; cdrel =+ dorigin; cbrel =+ borigin; /* * Reread the symbol table, recording the numbering * of symbols for fixingloc.size < 0) error(1, "Relocation error"); reloc.size++; r = get(&reloc); } else if (--reloc.nibuf < 0) { reloc. external references. */ lp = local; symno = -1; off =+ (sizeof filhdr)/2; dseek(&text, bno, off+filhdr.tsize+filhdr.dsize,nibuf++; reloc.size++; r = get(&reloc); } else r = *reloc.ptr++; switch (r&016) { case RTEXT: t =+ ctrel;  filhdr.ssize); while (text.size > 0) { symno++; mget(&cursym, sizeof cursym); symreloc(); if ((cursym.stype&EXTERN) ==break; case RDATA: t =+ cdrel; break; case RBSS: t =+ cbrel; break; case REXT: sp = lookloc(lp, r); i 0) { if (!sflag&&!xflag&&(!Xflag||cursym.sname[0]!='L')) mput(soutb, &cursym, sizeof cursym); continue; } if ((spf (sp->stype==EXTERN+UNDEF) { r = (r&01) + ((nsym+(sp-symtab))<<4) + REXT; break; } t =+ sp->svalue; r = (r&01) = *lookup()) == 0) error(1, "internal error: symbol not found"); if (cursym.stype == EXTERN+UNDEF) { if (lp >= &local[N + ((sp->stype-(EXTERN+ABS))<<1); break; } if (r&01) t =- creloc; putw(t, b1); if (rflag) putw(r, b2); } } fiSYMPR]) error(1, "Local symbol overflow"); *lp++ = symno; *lp++ = sp; continue; } if (cursym.stype!=sp->stype |nishout() { register n, *p; if (nflag||iflag) { n = torigin; while (n&077) { n =+ 2; putw(0, toutb); if (rflag) & loc; register n; loc = aloc; n = an>>1; do { putw(*loc++, buf); } while (--n); } dseek(asp, ab, o, s) { register struc(get(&text) == ARCMAGIC); } struct symbol **lookup() { int i; register struct symbol **hp; register char *cp, *cp1; i = 0;t stream *sp; register struct page *p; register b; int n; sp = asp; b = ab + ((o>>8) & 0377); o =& 0377; --sp->pno->nuse for (cp=cursym.sname; cp < &cursym.sname[8];) i = (i<<1) + *cp++; for (hp = &hshtab[(i&077777)%NSYM+2]; *hp!=0;) { cp1 = r; if ((p = &page[0])->bno!=b && (p = &page[1])->bno!=b) if (p->nuser==0 || (p = &page[0])->nuser==0) { if (page[0].nuser=(*hp)->sname; for (cp=cursym.sname; cp < &cursym.sname[8];) if (*cp++ != *cp1++) goto no; break; no: if (++hp =0 && page[1].nuser==0) if (page[0].bno < page[1].bno) p = &page[0]; p->bno = b; seek(infil, b, 3); if ((n = r>= &hshtab[NSYM+2]) hp = hshtab; } return(hp); } struct symbol **slookup(s) char *s; { cp8c(s, cursym.sname); cursym.styead(infil, p->buff, 512)>>1) < 0) n = 0; p->nibuf = n; } else error(1, "No pages"); ++p->nuser; sp->bno = b; sp->pe = EXTERN+UNDEF; cursym.svalue = 0; return(lookup()); } enter() { register struct symbol *sp; if ((sp=symp) >= &symtab[pno = p; sp->ptr = p->buff + o; if (s != -1) sp->size = (s>>1) & 077777; if ((sp->nibuf = p->nibuf-o) <= 0) sp->size = 0;NSYM]) error(1, "Symbol table overflow"); cp8c(cursym.sname, sp->sname); sp->stype = cursym.stype; sp->svalue = cursym.sval } get(asp) struct stream *asp; { register struct stream *sp; sp = asp; if (--sp->nibuf < 0) { dseek(sp, sp->bno+1, 0, -1ue; symp++; return(sp); } symreloc() { switch (cursym.stype) { case TEXT: case EXTERN+TEXT: cursym.svalue =+ ctrel; r*buf; { register f, *p, n; fflush(buf); close(buf[0]); tfname[6] = c; f = open(tfname, 0); while ((n = read(f, doutb, 512); --sp->nibuf; } if (--sp->size <= 0) { if (sp->size < 0) error(1, premeof); ++fpage.nuser; --sp->pno->nuser; sp)) > 1) { n =>> 1; p = doutb; do putw(*p++, toutb); while (--n); } close(f); } mkfsym(s) char *s; { if (sflag ||->pno = &fpage; } return(*sp->ptr++); } getfile(acp) char *acp; { register char *cp; register c; cp = acp; archdr.aname[ xflag) return; cp8c(s, cursym.sname); cursym.stype = 037; cursym.svalue = torigin; mput(soutb, &cursym, sizeof cursym); }0] = '\0'; filname = cp; if (cp[0]=='-' && cp[1]=='l') { if(cp[2] == '\0') cp = "-la"; filname = "/lib/libxxxxxxxxxxxxx mget(aloc, an) int *aloc; { register *loc, n; register *p; n = an; n =>> 1; loc = aloc; if ((text.nibuf =- n) >= 0) { xx"; for(c=0; cp[c+2]; c++) filname[c+8] = cp[c+2]; filname[c+8] = '.'; filname[c+9] = 'a'; filname[c+10] = '\0'; }  if ((text.size =- n) > 0) { p = text.ptr; do *loc++ = *p++; while (--n); text.ptr = p; return; } else t if ((infil = open(filname, 0)) < 0) error(1, "cannot open"); page[0].bno = page[1].bno = -1; page[0].nuser = page[1].nuser ext.size =+ n; } text.nibuf =+ n; do { *loc++ = get(&text); } while (--n); } mput(buf, aloc, an) int *aloc; { register *= 0; text.pno = reloc.pno = &fpage; fpage.nuser = 2; dseek(&text, 0, 0, 2); if (text.size <= 0) error(1, premeof); return' %s\n", s); if (n) delexit(); errlev = 2; } lookloc(alp, r) { register int *clp, *lp; register sn; lp = alp; sn = (r>>4ar iuid; char igid; char isize0; int isize; int iaddr[8]; char *ictime[2]; char *imtime[2]; int fill; }; main(argc, arg) & 07777; for (clp=local; clp1) { ap = argv[1](bno, off) { register st, sd; dseek(&text, bno, off, sizeof filhdr); mget(&filhdr, sizeof filhdr); if (filhdr.fmagic != FMA; while (*ap) switch (*ap++) { case 'a': aflg++; break; case 't': tflg++; break; case 'x': xflg++; bGIC) error(1, "Bad format"); st = (filhdr.tsize+01) & ~01; filhdr.tsize = st; cdrel = -st; sd = (filhdr.dsize+01) & ~01; reak; case 'l': lflg++; break; case 'k': kflg++; break; } } if(chdir("/dev") < 0) { printf("cannot chacbrel = - (st+sd); filhdr.bsize = (filhdr.bsize+01) & ~01; } cp8c(from, to) char *from, *to; { register char *f, *t, *te; fnge to /dev\n"); done(); } setup(&nl[0], "_proc"); nlist(argc>2? argv[2]:"/mx", nl); if (nl[0].type==0) { printf("No nam = from; t = to; te = t+8; while ((*t++ = *f++) && t>3; laddr = (laddr&07)<<6; seek(mf, baddr, 3); seek(mf, ladtat], puid); } printf("%6l", proc[0].p_pid); if (lflg) { printf("%4d%4d%6o%4d", proc[0].p_cpu&0377, proc[0].p_pri, dr, 1); if (read(mf, &ua[0], 512) != 512) return(0); printf(" %c", gettty()); if (stat==5) { printf(" "); ret proc[0].p_pid*SWPSIZ + SWPLO, proc[0].p_size); if (proc[0].p_wchan) printf("%7o", proc[0].p_wchan); else prinurn; } c = ((ua[0].u_utime>>1)&077777); c =+ ((ua[0].u_stime>>1)&077777); c = ldiv(0, c, 30); printf(" %2d:", c/60); c =% tf(" "); } prcom(proc[0].p_stat); printf("\n"); flush(); } done(); } getdev() { register struct { int dir_ino;60; printf(c<10?"0%d":"%d", c); if (proc[0].p_flag&SLOAD) c = (SWPSIZ<<3) - 8; else c = proc[0].p_size - 8; laddr =+ (c& char dir_n[14]; } *p; register i, c; int f; char dbuf[512]; int sbuf[20]; f = open("/dev", 0); if(f < 0) { printf("can07)<<6; baddr =+ c>>3; seek(mf, baddr, 3); seek(mf, laddr, 1); if (read(mf, ua, 512) != 512) return(0); for (ip = &ua[256not open /dev\n"); done(); } swap = -1; c = 0; loop: i = read(f, dbuf, 512); if(i <= 0) { close(f); if(swap < 0) {  printf("no swap device\n"); done(); } ndev = c; return; } while(i < 512) dbuf[i++] = 0; for(p = dbuf; p < dbuf+512; p++) { if(p->dir_ino == 0) continue; if(p->dir_n[0] == 't' && p->dir_n[1] == 't' && p->dir_n[2] == 'y' &&  p->dir_n[4] == 0 && p->dir_n[3] != 0) { if(stat(p->dir_n, sbuf) < 0) continue; devc[c] = p->dir_n[3]; devl[c] = sbuf->iaddr[0]; c++; continue; } if(swap >= 0) continue; if(stat(p->dir_n, sbuf) < 0) continue; if((sb]; ip > &ua[0];) { if (*--ip == -1) { cp = ip+1; if (*cp==0) cp++; nbad = 0; for (cp1 = cp; cp1 < &ua[256]; cpuf->iflags & 060000) != 060000) continue; if(sbuf->iaddr[0] == swapdev) swap = open(p->dir_n, 0); } goto loop; } setu1++) { c = *cp1; if (c==0) *cp1 = ' '; else if (c < ' ' || c > 0176) { if (++nbad >= 5) { *cp1++ = 'p(p, s) char *p, *s; { while (*p++ = *s++); } prcom(stat) { int baddr, laddr, mf; register int *ip; register char *cp, *cp1 '; break; } *cp1 = '?'; } } while (*--cp1==' ') *cp1 = 0; printf(lflg?" %.16s":" %.64s", cp); ; int c, nbad; baddr = 0; laddr = 0; if (proc[0].p_flag&SLOAD) { laddr = (TOPSYS>>6) - 16; mf = swmem; } else { badd return(1); } } return(0); } gettty() { register i; if (ua[0].u_ttyp==0) return('?'); for (i=0; i= &tbuf[256]) { write(fout, &tbuf[0], txtw); seek(fitw = read(fin, tbuf, 512); if (tbuf[0]!=0411 && tbuf[0]!=0410 && tbuf[0]!=0407) { /* magic */ write(1, "Bad format\n", 11); n, txtloc, 0); txtw = read(fin, &tbuf[0], 512); txtp = &tbuf[0]; } } adv6() { txtp =+ 6; if(txtp >= &tbuf[256]) { write return; } if (tbuf[7] != 0) { /* relocation? */ write (1, "No relocation bits\n", 19); return; } t1 = tbuf[1]; t2 = t(fout, tbuf, txtw); txtw = read(fin, tbuf, 512); txtp =- 256; } } devl[i] == ua[0].u_ttyd) return(devc[i]); return('?'); } done() { flush(); exit(); } buf[2]; t4 = tbuf[4]; txtloc = 020; if (argc>3 && argv[3][1]=='o') { dotdot =+ 020; tbuf[0] = 0405; /* old magic */ tbuf[1] =+ tbuf[2]; tbuf[2] = 0; tbuf[4] = tbuf[3]; tbuf[3] = 0; tbuf[6] = 0240; tbuf[7] = t7 = 0240; } txtsiz = tbuf[1]+tbuf[2]; relloc = txtloc+txtsiz; txtsiz = (txtsiz>>1) & 077777; seek(fin, relloc&~0777, 0); read(fin, rbuf, 512); txtp = &tbuf[8]; relp = &rbuf[(relloc&0777) >> 1]; if (argc>3) /* nop out "setd" at start */ if (tbuf[8] == 0170011) tbuf[8] = /* * relocate command-- * reloc file [-]octal [ - ] * * relocate object or a.out file up in core * by the possibly negated 0240; while(txtsiz--) { switch (*relp & 017) { case 01: /* pc ref to abs */ *txtp =- dotdot; break; case 02: /* roctal number. * * if optional 3rd arg is given, * replace "setd" at start by "nop" */ int tbuf[256]; int rbuf[256]; int finef to text */ case 04: /* ref to data */ case 06: /* ref to bss */ *txtp =+ dotdot; } advance(); } if (txtp != &; int fout; int *txtp; int *relp; int relloc; int txtloc; int dotdot; int txtsiz; int t1; int t2; int t4; int t7; int txtw; maitbuf[0]) write(fout, &tbuf[0], txtw); txtsiz = (t4 >> 1) & 077777; relloc = 020 + 2*(t1 + t2); seek(fin, relloc&~0777, 0n(argc, argv) char *argv[]; { int sign, c; if (argc<3) { usage: write(1, "reloc file [-]octal\n", 20); return; } dotdo); seek(fout, relloc&~0777, 0); txtw = read(fin, tbuf, 512); txtp = &tbuf[(relloc&0777) >> 1] + 4; while((txtsiz =- 6) > 0) t = 0; if (*argv[2] == '-') { sign = -1; argv[2]++; } else sign = 1; while (*argv[2]) { c = *argv[2]++ - '0'; if (c{ switch(*txtp & 77) { case 2: case 3: case 4: *(txtp + 1) =+ dotdot; } adv6(); } if(txtp != &tbuf[0]) write<0 || c>7) goto usage; dotdot = (dotdot<<3) + c; } dotdot =* sign; if ((fin = open(argv[1], 0)) < 0) { write(1, "File (fout, &tbuf[0], txtw); } advance() { relp++; relloc =+ 2; if (relp == &rbuf[256]) { seek(fin, relloc, 0); read(fin, * r acctf; char uid; char setintr; char *arginp; int onelflg; char *pipe ".__pf0"; char *mesg[] { 0, "Hangup", 0, "Quit", "I(error) return; t = syntax(args, argp); } if(error != 0) err("syntax error"); else execute(t); } } word() { llegal instruction", "Trace/BPT trap", "IOT trap", "EMT trap", "Floating exception", "Killed", "Bus error", "Memory faultregister char c, c1; *argp++ = linep; loop: switch(c = getc()) { case ' ': case '\t': goto loop; case '\'': case '"'", "Bad system call", 0, "Sig 14", "Sig 15", "Sig 16", "Sig 17", "Sig 18", "Sig 19", }; struct stime { int proct[2]; : c1 = c; while((c=readc()) != c1) { if(c == '\n') { error++; peekc = c; return; } *linep++ = c|QUOTE; int cputim[2]; int systim[2]; } timeb; char line[LINSIZ]; char *args[ARGSIZ]; int trebuf[TRESIZ]; main(c, av) int c; char **a } goto pack; case '&': case ';': case '<': case '>': case '(': case ')': case '|': case '^': case '\n': *linep++v; { register f; register char *acname, **v; for(f=2; f<15; f++) close(f); if((f = dup(1)) != 2) close(f); dolc = getp = c; *linep++ = '\0'; return; } peekc = c; pack: for(;;) { c = getc(); if(any(c, " '\"\t;&<>()|^\n")) { peekc =id(); for(f=4; f>=0; f--) { dolc = ldiv(0, dolc, 10); pidp[f] = ldivr+'0'; } v = av; acname = "/usr/adm/sha"; promp = " c; if(any(c, "\"'")) goto loop; *linep++ = '\0'; return; } *linep++ = c; } } tree(n) int n; { register *t; % "; if(((uid = getuid())&0377) == 0) { promp = "# "; acname = "/usr/adm/shb"; } /* acctf = open(acname, 1); */ acctf = -1; /* no accounting */ if(c > 1) { promp = 0; if (*v[1]=='-') { **v = '-'; if (v[1][1]=='c' && c>2) arginp = v[2# /* * Modified for fake on-disk 'pipes' */ #define INTR 2 #define QUIT 3 #define LINSIZ 1000 #define ARGSIZ 50 #define TRESI]; else if (v[1][1]=='t') onelflg = 2; } else { close(0); f = open(v[1], 0); if(f < 0) { prs(v[1]); erZ 100 #define QUOTE 0200 #define FAND 1 #define FCAT 2 #define FPIN 4 #define FPOU 8 #define FPAR 16 #define FINT 32 #define FPr(": cannot open"); } } } if(**v == '-') { setintr++; signal(QUIT, 1); signal(INTR, 1); } dolv = v+1; dolc = c-1RS 64 #define TCOM 1 #define TPAR 2 #define TFIL 3 #define TLST 4 #define DTYP 0 #define DLEF 1 #define DRIT 2 #define DFLG 3 #d; loop: if(promp != 0) prs(promp); peekc = getc(); main1(); goto loop; } main1() { register char c, *cp; register *t; efine DSPR 4 #define DCOM 5 #define ENOMEM 12 #define ENOEXEC 8 char *dolp; char pidp[6]; int ldivr; char **dolv; int dolc; cha argp = args; eargp = args+ARGSIZ-5; linep = line; elinep = line+LINSIZ-5; error = 0; gflg = 0; do { cp = linep; wordr *promp; char *linep; char *elinep; char **argp; char **eargp; int *treep; int *treeend; char peekc; char gflg; char error; cha(); } while(*cp != '\n'); treep = trebuf; treeend = &trebuf[TRESIZ]; if(gflg == 0) { if(error == 0) { setexit(); if + '\0') return(c); dolp = 0; } c = readc(); if(c == '\\') { c = readc(); if(c == '\n') return(' '); return(c|QUOTEF] = syn2(p1, p); t[DFLG] = 0; if(l == '&') { t1 = t[DLEF]; t1[DFLG] =| FAND|FPRS|FINT; } t[DRIT] = syntax(E); } if(c == '$') { c = readc(); if(c>='0' && c<='9') { if(c-'0' < dolc) dolp = dolv[c-'0']; goto getd; } ip+1, p2); return(t); } } if(l == 0) return(syn2(p1, p2)); error++; } /* * syn2 * syn3 * syn3 | syn2 */ syn2(p1, f(c == '$') { dolp = pidp; goto getd; } } return(c&0177); } readc() { char cc; register c; if (arginp) { if (arp2) char **p1, **p2; { register char **p; register int l, *t; l = 0; for(p=p1; p!=p2; p++) switch(**p) { case '(': l++ginp == 1) exit(); if ((c = *arginp++) == 0) { arginp = 1; c = '\n'; } return(c); } if (onelflg==1) exit(); ; continue; case ')': l--; continue; case '|': case '^': if(l == 0) { t = tree(4); t[DTYP] = TFIL; t[DLEF]    !"# = syn3(p1, p); t[DRIT] = syn2(p+1, p2); t[DFLG] = 0; return(t); } } return(syn3(p1, p2)); } /* * syn3 * ( syn1 ) [ < in ] [ > out ] * word word* [ < in ] [ > out ] */ syn3(p1, p2) char **p1, **p2; { register char **p; char **lp, **rp; register *t; int n, l, i, o, c, flg; flg = 0; if(**p2 == ')') flg =| FPAR; lp = 0; rp = 0; i = 0; o = 0; n = 0; l = 0; for(p=p1; p!=p2; p++) switch(c = **p) { case '(': if(l == 0) { if(lp != 0) error++; lp = p+1; } l++; if(read(0, &cc, 1) != 1) { exit(0); } if (cc=='\n' && onelflg) onelflg--; return(cc); } /* * syntax * empty * syn1 * continue; case ')': l--; if(l == 0) rp = p; continue; case '>': p++; if(p!=p2 && **p=='>') flg =| FCAT; els t = treep; treep =+ n; if (treep>treeend) { prs("Command line overflow\n"); error++; reset(); } return(t); } getc()/ syntax(p1, p2) char **p1, **p2; { while(p1 != p2) { if(any(**p1, ";&\n")) p1++; else return(syn1(p1, p2)); } retu { register char c; if(peekc) { c = peekc; peekc = 0; return(c); } if(argp > eargp) { argp =- 10; while((c=getc()rn(0); } /* * syn1 * syn2 * syn2 & syntax * syn2 ; syntax */ syn1(p1, p2) char **p1, **p2; { register char **p; registe) != '\n'); argp =+ 10; err("Too many args"); gflg++; return(c); } if(linep > elinep) { linep =- 10; while((c=getcr *t, *t1; int l; l = 0; for(p=p1; p!=p2; p++) switch(**p) { case '(': l++; continue; case ')': l--; if(l < 0) ()) != '\n'); linep =+ 10; err("Too many characters"); gflg++; return(c); } getd: if(dolp) { c = *dolp++; if(c !=  error++; continue; case '&': case ';': case '\n': if(l == 0) { l = **p; t = tree(4); t[DTYP] = TLST; t[DL, if(c == '<') { if(i != 0) error++; i = *p; continue; } if(o != 0) error++; o = *p; } continue;(-1, 0); return; } if(equal(cp1, ":")) return; case TPAR: f = t[DFLG]; i = 0; if((f&FPAR) == 0) i = fork(); default: if(l == 0) p1[n++] = *p; } if(lp != 0) { if(n != 0) error++; t = tree(5); t[DTYP] = TPAR; t[DSPR]  if(i == -1) { err("try again"); return; } if(i != 0) { if((f&FPIN) != 0) { close(pf1[0]); close(pf1[1]);= syn1(lp, rp); goto out; } if(n == 0) error++; p1[n++] = 0; t = tree(n+5); t[DTYP] = TCOM; for(l=0; l= 0) { seek(i, 0, 2); goto f1; gflg = 1; return(c); } trim(c) int c; { return(c&0177); } execute(t, pf1, pf2) int *t, *pf1, *pf2; { int i, f, pv[2];  } } i = creat(t[DRIT], 0666); if(i < 0) { prs(t[DRIT]); err(": cannot create"); exit(); } f1: register *t1; register char *cp1, *cp2; extern errno; if(t != 0) switch(t[DTYP]) { case TCOM: cp1 = t[DCOM]; if(equalclose(1); dup(i); close(i); } if((f&FPIN) != 0) { close(0); dup(pf1[0]); close(pf1[0]); close(pf1[1]); }(cp1, "chdir") || equal(cp1, "cd")) { if(t[DCOM+1] != 0) { if(chdir(t[DCOM+1]) < 0) err("chdir: bad directory");  if((f&FPOU) != 0) { close(1); dup(pf2[1]); close(pf2[0]); close(pf2[1]); } if((f&FINT)!=0 && t[DLEF]==0 && (f} else if(chdir("/usr") < 0) err("chdir: \"/usr\" bad directory"); return; } if(equal(cp1, "shift")) { if(dol&FPIN)==0) { close(0); open("/dev/null", 0); } if((f&FINT) == 0 && setintr) { signal(INTR, 0); signal(QUIT, 0); c < 1) { prs("shift: no args\n"); return; } dolv[1] = dolv[0]; dolv++; dolc--; return; } if(equal(cp1 } if(t[DTYP] == TPAR) { if(t1 = t[DSPR]) t1[DFLG] =| f&FINT; execute(t1); exit(); } close(acctf); gflg = ,"sync")) { sync(); return; } if(equal(cp1, "login")) { if(promp != 0) { close(acctf); execv("/bin/login", 0; scan(t, &tglob); if(gflg) { t[DSPR] = "/etc/glob"; execv(t[DSPR], t+DSPR); prs("glob: cannot execute\n"); exit+DCOM); } prs("login: cannot execute\n"); return; } if(equal(cp1, "newgrp")) { if(promp != 0) { close(acctft(); } scan(t, &trim); *linep = 0; texec(t[DCOM], t); cp1 = linep; cp2 = "/usr/bin/"; while(*cp1 = *cp2++) cp1+e p--; case '<': if(l == 0) { p++; if(p == p2) { error++; p--; } if(any(**p, "<>(")) error++; ); execv("/bin/newgrp", t+DCOM); } prs("newgrp: cannot execute\n"); return; } if(equal(cp1, "wait")) { pwait- char *s1, *s2; s1 = as1; s2 = as2; while(*s1++ == *s2) if(*s2++ == '\0') return(1); return(0); } pwait(i, t) int i, *as as1?.s;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/as as as2?.s;reloc a.out 60000;strip a.out;mv a.out ../rfs/lib/as2 at; { register p, e; int s; if(i != 0) for(;;) { times(&timeb); time(timeb.proct); p = wait(&s); if(p == -1) breas chown.s;ld -r -d a.out -la;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/chown as db?.s;reloc a.out 60000;strip a.out;mv a+; cp2 = t[DCOM]; while(*cp1++ = *cp2++); texec(linep+4, t); texec(linep, t); prs(t[DCOM]); err(": not found"); exk; e = s&0177; if(mesg[e] != 0) { if(p != i) { prn(p); prs(": "); } prs(mesg[e]); if(s&0200) prs(" -it(); case TFIL: f = t[DFLG]; /* * fake pipe mods follow */ close(creat(pipe,0666)); pv[0] = open(pipe,0); pv[1] = o- Core dumped"); } if(e != 0) err(""); if(i == p) { acct(t); break; } else acct(0); } } acct(t) int *t; { pen(pipe,1); unlink(pipe); /* * original was just pipe(pv) */ t1 = t[DLEF]; t1[DFLG] =| FPOU | (f&(FPIN|FINT|FPRS)); e/****** if(t == 0) enacct("**gok"); else if(*t == TPAR) enacct("()"); else enacct(t[DCOM]); ******/ } enacct(as) char *axecute(t1, pf1, pv); t1 = t[DRIT]; t1[DFLG] =| FPIN | (f&(FPOU|FINT|FAND|FPRS)); execute(t1, pv, pf2); return; case TLs; { /****** struct stime timbuf; struct { char cname[14]; char shf; char uid; int datet[2]; int realt[2]; int bcpST: f = t[DFLG]&FINT; if(t1 = t[DLEF]) t1[DFLG] =| f; execute(t1); if(t1 = t[DRIT]) t1[DFLG] =| f; execute(t1); ut[2]; int bsyst[2]; } tbuf; register i; register char *np, *s; s = as; times(&timbuf); time(timbuf.proct); lsub(tbuf. return; } } texec(f, at) int *at; { extern errno; register int *t; t = at; execv(f, t+DCOM); if (errno==ENOEXEC) { realt, timbuf.proct, timeb.proct); lsub(tbuf.bcput, timbuf.cputim, timeb.cputim); lsub(tbuf.bsyst, timbuf.systim, timeb.systimif (*linep) t[DCOM] = linep; t[DSPR] = "/bin/sh"; execv(t[DSPR], t+DSPR); prs("No shell!\n"); exit(); } if (errno==); do { np = s; while (*s != '\0' && *s != '/') s++; } while (*s++ != '\0'); for (i=0; i<14; i++) { tbuf.cname[i] = ENOMEM) { prs(t[DCOM]); err(": too large"); exit(); } } err(s) char *s; { prs(s); prs("\n"); if(promp == 0) { seek*np; if (*np) np++; } tbuf.datet[0] = timbuf.proct[0]; tbuf.datet[1] = timbuf.proct[1]; tbuf.uid = uid; tbuf.shf = 0; (0, 0, 2); exit(); } } prs(as) char *as; { register char *s; s = as; while(*s) putc(*s++); } putc(c) { write(2, &c, if (promp==0) tbuf.shf = 1; seek(acctf, 0, 2); write(acctf, &tbuf, sizeof(tbuf)); ******/ }  1); } prn(n) int n; { register a; if(a=ldiv(0,n,10)) prn(a); putc(lrem(0,n,10)+'0'); } any(c, as) int c; char *as; { register char *s; s = as; while(*s) if(*s++ == c) return(1); return(0); } equal(as1, as2) char *as1, *as2; { register . a.out;mv a.out ../rfs/bin/check cc -O -r -d chmod.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/chmod cc -O -r -d cp.c;rel0000;strip a.out;mv a.out ../rfs/bin/stty cc -O -r -d sync.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/sync cc -O -r -d oc a.out 60000;strip a.out;mv a.out ../rfs/bin/cp cc -O -r -d date.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/date cc -time.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/time cc -O -r -d umount.c;reloc a.out 60000;strip a.out;mv a.out ../rfsO -r -d ed.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/ed cc -O -r -d getty.c;reloc a.out 60000;strip a.out;mv a.out ..//etc/umount cc -O -r -d who.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/who rfs/etc/getty cc -O -r -d glob.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/etc/glob cc -O -r -d init.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/etc/init cc -O -r -d ld.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/ld cc -O -r -d login.c;relo.out ../rfs/bin/db as kill.s;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/kill as mkdir.s;reloc a.out 60000;strip a.out;mv c a.out 60000;strip a.out;mv a.out ../rfs/bin/login cc -O -r -d ls.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/ls cc -O a.out ../rfs/bin/mkdir as rmdir.s;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/rmdir as strip.s;reloc a.out 60000;strip a.o-r -d mkfs.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/etc/mkfs cc -O -r -d mknod.c;reloc a.out 60000;strip a.out;mv a.out .ut;mv a.out ../rfs/bin/strip as update.s;reloc a.out 60000;strip a.out;mv a.out ../rfs/etc/update ./rfs/etc/mknod cc -O -r -d mkpt.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/etc/mkpt cc -O -r -d mount.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/etc/mount cc -O -r -d mv.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/mv cc -O -r -d od.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/od cc -O -r -d pr.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/pr cc -O -r -d ps.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/ps cc -O -r -d reloc.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/cc -O -r -d ar.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/ar cc -O -r -d cat.c;reloc a.out 60000;strip a.out;mv a.out .bin/reloc cc -O -r -d rm.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/rm cc -O -r -d sh.c;reloc a.out 60000;strip a.out;m./rfs/bin/cat cc -O -r -d cc.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/cc cc -O -r -d check.c;reloc a.out 60000;strip v a.out ../rfs/bin/sh cc -O -r -d size.c;reloc a.out 60000;strip a.out;mv a.out ../rfs/bin/size cc -O -r -d stty.c;reloc a.out 6/ nal(2,unl); name[0] = "/usr/tmp/ttmpa1"; name[1] = "/usr/tmp/ttmpa2"; name[2] = "/usr/tmp/ttmpa3"; while((file[0] = open(namelse { i = 0 ; while((c = "Possible typo's in "[i++])!=0) *ffptr++ = c; i = 0; while((c = fptr[i++]) != 0) e[0],1)) > 0){ close(file[0]); for(j=0; j < 3; j++)name[j][13]++; if(name[0][13] == 'z')err("creat tmp file"); } file[0] *ffptr++ = c; *ffptr = 0; execl("/bin/pr","pr","-3", "-h", ffbuf,name[0],0); err("pr"); } } if(sw == - = creat(name[0],0666); fptr = argv[arg]; if(argc == 1) {argc = 2; arg = 0;} while(--argc){ if(arg == 0){ file[2] = 0; 1)err("fork"); er = wait(&status); if(er != sw)err("prob"); unl(); } unl() { register j; j = 2; exit(); } err(c) char  }else{ file[2] = open(argv[arg++],0); if(file[2] < 0)err("open input file"); } eflg = 1; while((j = wdval(2)) != 0)c[];{ register j; printf("cannot %s\n",c); unl(); } get(ifile) int ifile;{ static char *ibuf[10]; if(--ptr[ifile]){ retu{ put(0,nwd,ct); } if(file[2]) close(file[2]); } flsh(0,0); close(file[0]); sw = fork(); if(sw == 0){execl("/usr/birn(*ibuf[ifile]++ & 0377);} if(ptr[ifile] = read(file[ifile],buf[ifile],512)){ if(ptr[ifile] < 0)goto prob; ibuf[ifile] = bn/usort","usort","-o",name[2],name[0],0); err("sort"); } if(sw == -1)err("fork"); er = wait(&status); if(er != sw)err("puf[ifile]; return(*ibuf[ifile]++ & 0377); } ptr[ifile] = 1; return(-1); prob: ptr[ifile] = 1; printf("read error\n"); rrobs"); file[0] = creat(name[0],0666); if(file[0] < 0)err("creat tmp"); file[1] = open("/usr/lib/w2006",0); if(file[1] < 0eturn(-1); } put(ofile,s,optr) char s[]; { register i; while(optr-- >= 0) buf[ofile][(ptr[ofile] < 512)?ptr[ofile]++:flsh)err("open w2006"); ptr[1] = 1; for(j=0; (w2006[j] = get(1)) != '\n';j++); file[2] = open(name[2],0); if(file[2] < 0)err("o(ofile,1)] = *s++; return; } flsh(ofile,i){ register error; error = write(file[ofile],buf[ofile],ptr[ofile]); if(error < 0)int status; int eflg; char w2006[100]; flg 0; char *fptr; char *ffptr &ffbuf; char ffbuf[36]; int npr; char nwd[100]; char *buf[pen tmp"); ptr[2] = 1; while(ptr[2]){ l=0; for(k=0;((c = nwd[k] = get(2)) != '\n');k++) if(c == -1)goto done; for(i=3]; file[3]; ptr[3]; char *name[3]; bsp[768]; int ct; main(argc,argv) int argc; char *argv[]; { char let,lt; auto arg,t,sw,i,0; i<=k;i++){ if(nwd[i] < w2006[l]){ put(0,nwd,k); break; } if(nwd[i] > w2006[l]){ for(l=0; (w2006[l] = getj,er,c; register k,l,m; int unl(); nice(-20); buf[0] = bsp; buf[1] = bsp + 0400; buf[2] = bsp + 01000; ptr[0] = 0; ptr[1(1)) != '\n';l++); if(l == -1){ put(0,nwd,k); for(k=0;((c = nwd[k] =get(2))!= -1);k++){ put(0,nwd,k); ] = 0; ptr[2] = 1; arg = 1; while(argc>1 && argv[arg][0] == '-') { switch(argv[arg][1]) { default: printf("Unrecogniza k = -1; } goto done; } i = -1; l=0; continue; } l++; } } done: close(file[2]); flshble argument: %c\n",argv[arg][1]); exit(); case '1': npr++; } arg++; --argc; } if((signal(2,1) & 1) != 1) sig(0,0); close(file[1]); close(file[0]); sw = fork(); if(sw == 0){ if(npr) { execl("/bin/cat","cat",name[0],0); } 0 witch(let){ case -1: return(0); case '%': if(k != -1)break; goto ret; case '-': if((let = get(wfile)) == '\n'){  while((let = get(wfile)) == '\n')if(let == -1)return(0); goto st; } else {wflg = 1; goto ret; } case '\'':  if(eflg != 1){ if(k < 0)goto beg; if(((let=get(wfile)) >= 'A' && let <= 'Z')|| (let >= 'a' && let <= 'z')){  nwd[++k] = '\''; goto st; } else { wflg = 0; goto ret; } } case '.': if(eflg =/ C library - halt / / mgs 1/80 / system table entry for call = 62 (076) halt = 76 .globl _halt _halt: mov r5,-(sp) mov sp,+,-./0124r5 sys halt mov (sp)+,r5 rts pc > & 6  aw  b :` wf>w ~w|Der  l % bw7 X7 = 1){ while((let = get(wfile)) != '\n')if(let == -1)return(0); goto beg; } else goto ret; default: eflg = 0;XׯN- F D(w87 : .w.ebB J ӕ- R r f e0 @ > if(let < 'A')goto ret; if(let <= 'Z'){ nwd[++k] = let + ' '; break; } if(let < 'a' || let > 'z')goto ret; ҋ D~8bb ӕ0 $f v Le0 9e~ vp 7`we nwd[++k] = let; } eflg = 0; } eflg = 1; ret: if(k < 1)goto beg; nwd[++k] = '\n'; ct = k; return(k); } &  mD B b~  b  b~ w7   0   Wp `e0@& Hgoto prob; ptr[ofile] = i; return(0); prob: printf("write error on t.%d\n",file[ofile]); unl(); } wdval(wfile) int wfile; { static let,wflg; register k; beg: k = -1; if(wflg == 1){wflg = 0; goto st; } while((let = get(wfile)) != '\n'){ st: s f>halt>_halt"1 /* * Implement the halt system call; bring down the system gracefully. * mgs 1/80 */ halt() { register struct proc *p, *proub r0,r5 tstb r5 beq cksctr blt seekin seekot: mov $xseeko,skipx seekwt: mov skipx,(r4) jsr pc,qwait mov r0,-(sp) mov $300ADCBFf@eӕ?f ,P  @f  b7dn bbdcs; register done; extern wakeup(); if (!suser()) return; /* caller must be super user */ spl7(); /* wait for update c\-VN No!! `daoaxBafPae`c`s`l^arbompletion */ for (;;) { if (updlock==0) break; idle(); } updlock++; procs = u.u_procp; for (p= &proc[0]; p<&proc[NPROC]; p++) if (p!=procs) psignal(p,SIGKIL); spl0(); u.u_ar0[R0] = 2; do { /* wait for everything done */ sslep();  done = 0; for (p= &proc[0]; p<&proc[NPROC]; p++) if (p->p_stat!=NULL && p->p_stat&SZOMB==0) done++; u.u_ar0[R0] = 1; }/* * Terak-Unix "halt" system command. * Causes file system to be updated, and system to halt gracefully. */ main() { /*  while(done > 1); updlock = 0; update(); printf("\7UNIX halted.\7\n"); haltins(); }  * call system routine */ halt(); write(2,"no!\n",4); /* this executes if "halt()" fails */ exit(1); } / qx disk driver qxcs = 177000 qxdb = 177002 xrts = 31 xread = 33 xseekn = 25 xseeko = 27 xhead = 20 xclk = 23 mov r2,-(sp SWPLO 340 #define NSWAP (494-SWPLO) #define SWPSIZ 66 ) mov r5,-(sp) mov wc,r1 mov ba,r2 asl r0 asl r0 1: mov r0,-(sp) mov r0,r3 mov r0,r4 clr r0 br 3f 2: sub $23.,r3 3: inc r0 sub $26.,r4 bpl 2b cmp $-14.,r4 rol r3 4: sub $26.,r3 bpl 4b add $27.,r3 jsr pc,qreads mov (sp)+,r0 inc r0 tst r1  bgt 1b mov (sp)+,r5 mov (sp)+,r2 rts pc qreads: mov $qxcs,r4 swab r3 bit $xhead,(r4) bne readz mov $xhead,(r4) mov $25000.,r5 time1: sob r5,time1 readz: mov r4,r5 mov $xrts,(r5)+ jsr pc,qwait cktrk: mov (r5),r5 bpl 1f clr r5 br seekwt 1: s2  number in r0 clr r0 br 3f 2: add $6,r3 / add skew for each track 3: inc r0 sub $26.,r4 bpl 2b / compute sector number in rŗ H  !W N  e7 J  j De Ԥ!@eW  8F3 / i = sctr*3 mod 26 ;(3:1 interleave) mov (sp),r4 asl r4 / 3*logical-sector in r4 add (sp),r4 4: sub $26.,r4 / mod 26  RW et ZEWue T!ef b5: &      unix bpl 4b add $26.,r4 / adjust / i = (i + tracks*6) mod 26 ;(add track sector skew) add r4,r3 / add sector skew 5: sub $26.,r "  f &  e  ceae  53 / mod 26 bpl 5b add $27.,r3 / add 26. to adjust for modulo, then inc r3 / input to qreads: / r0 = track number / r3 = sectaA ZE ŋ" <&~ŊAC!  @ D~̋ w0,r0 time2: sob r0,time2 mov (sp)+,r0 decb r5 bgt seekwt mov $12000,r5 time3: sob r5,time3 br readz seekin: mov $xseekn,(pcor number jsr pc,qreads mov (sp)+,r0 inc r0 tst r1 bgt 1b mov (sp)+,r5 mov (sp)+,r2 rts pc qreads: mov $qxcs,r4 swab)+ skipx: xseekn negb r5 br seekwt cksctr: cmp r5,r3 bne readz movbuf: mov $xread,(r4) jsr pc,qwait tst (r4)+ mov $100,r5  r3 bit $xhead,(r4) bne readz mov $xhead,(r4) mov $25000.,r5 time1: sob r5,time1 readz: mov r4,r5 mov $xrts,(r5)+ jsr pc,qmovwrd: dec r5 blt ex mov (r4),(r2)+ sob r1,movwrd ex: rts pc qwait: tstb (r4) bpl qwait tst (r4) bmi bioerr rts pc wait cktrk: mov (r5),r5 bpl 1f clr r5 br seekwt 1: sub r0,r5 tstb r5 beq cksctr blt seekin seekot: mov $xseeko,skipx seekw bioerr: jmp . t: mov skipx,(r4) jsr pc,qwait mov r0,-(sp) mov $3000,r0 time2: sob r0,time2 mov (sp)+,r0 decb r5 bgt seekwt mov $12000,r5 time3: sob r5,time3 br readz seekin: mov $xseekn,(pc)+ skipx: xseekn negb r5 br seekwt cksctr: cmp r5,r3 bne readz movbuf: mov $xread,(r4) jsr pc,qwait tst (r4)+ mov $100,r5 movwrd: dec r5 blt ex mov (r4),(r2)+ sob r1,movwrd ex: rts pc qwait/ qx disk driver / modified 2/80 for 3:1 interleave qxcs = 177000 qxdb = 177002 xrts = 31 xread = 33 xseekn = 25 xseeko = 27: tstb (r4) bpl qwait tst (r4) bmi bioerr rts pc bioerr: jmp .  xhead = 20 xclk = 23 mov r2,-(sp) mov r5,-(sp) mov wc,r1 mov ba,r2 / r0 = block no. / compute logical sector number (= 4*blkno) asl r0 asl r0 / save sector number on stack 1: mov r0,-(sp) / r3 = track skew offset clr r3 mov r0,r4 / compute track3 16.(r1),r0 add $14.,r2 br 1b 5: cmp r1,$buf+512. blo 3b br 2b / last entry was found / read into 0. 1: clr r2 1: jsr pc,rmblk br callout mov $buf,r1 2: mov (r1)+,(r2)+ cmp r1,$buf+512. blo 2b br 1b / subroutine will read in inode / number SCREEN; } } specified in r0 iget: add $31.,r0 mov r0,r5 ash $-4.,r0 jsr pc,rblka bic $!17,r5 ash $5.,r5 add $buf,r5 mov $inod,r4 1:  mov (r5)+,(r4)+ cmp r4,$addr+16. blo 1b rts pc / routine to read in block / number specified by bno / after applying file system / mapping algorithm in inode. / bno is incremented, success / return is a skip, error (eof) / is direct return. rmblk: add $2,(sp) mov bno,r0 inc bno bit $LRG,mode bne 1f asl r0 mov addr(r0),r0 bne rblka 2: sub $2,(sp) rts pc / large algori/ disk boot program to load and transfer / to a unix file system entry / must be assembled with tty.s and / appropriate disk drithm / huge algorithm is not implemented 1: clr -(sp) movb r0,(sp) clrb r0 swab r0 asl r0 mov addr(r0),r0 beq 2b jsr pc,rboot7g = 10110 mov r0,r1 / validation code: 010001 boot1: movb *(pc)+,r5 1: seclst beq start dec 1b mov $boot7g,pc .byte ver / entry is made by jsr pc,*$0 / so return can be rts pc core = 24. / first core loc (in KW) not used .. = [core*2048.]-5120 .byte 10. .byte 7 seclst: .byte 4 .even .-512. start: / copy self to 'core' - 512. - 512. bytes / strip of UNIX execute header if present mov $..,sp mov sp,r1 clr r0 cmp pc,r1 bhis 2f 1: mov (r0)+,(r1)+ cmp r1,$core*2048. blo 1b jmp (sp) / clear all of core 2: clr (r0)+ cmp r0,sp  blo 2b / start of path name decoding / start with first name and root ino mov pc,r2 here: add $nam-here,r2 mov $1,r0 / gas qxfsboot0.s qxfsboot.s qxtty.s rrk.s qx.s strip a.out dd if=a.out of=qxuboot bs=16 skip=1 ls -l qxuboot et next inode 1: clr bno jsr pc,iget tst (r2) beq 1f / read next directory looking for next name 2: jsr pc,rmblk br start mov $buf,r1 3: mov r2,r3 mov r1,r4 add $16.,r1 tst (r4)+ beq 5f 4: cmpb (r3)+,(r4)+ bne 5f cmp r4,r1 blo 4b mov -4  @ >  ҋ D~8gg ӕ0 $f v Le0 9eP J Z B < L7, we&  m    Jf~  Jf  Jf~ w7  0   Wp `e0w w w w  wfAW @wx fo1o7l 5 ehdwXg 5& wt&< Lboot7g = 10110 mov r0,r1 boot1: movb *(pc)+,r5 1: seclst beq start dec 1b mov $boot7g,pc .byte 0 .byte 7 .byte 5 seclst:&6 H&0 D&* @&$ <& 8& 4& 0& ,& (& $& & & & & &  .byte 3 .even & & & f& f@wxgw f |& w }f@wp fw,w(gwP@& HADCBFf@eӕ?fA w,w"e"w"ew"@lw"Alew &@t`e fwwgwf  ,z P p j    & 6  ew t d  d f ,f  bg Hb \e \e'g @f N o76<  go2 * -$  f@wwgw7F/etc/ire  \e pd d   \e % 6f ,f  b  @Eg& e 1g nit/bin/sh-/dev/tty8/bin/halt RESTRICTED RIGHTS /etc/mtab Welcome to Terak-UNIX No Shell!! /etc/charset bdHb ff b%Kg Hb e &! fg b% wlw Z Xg ,f 5Xgf f%% cocxPcf^cebcbsbllcr0 %ewDoblka mov (sp)+,r0 asl r0 mov buf(r0),r0 beq 2b rblka: br rblk ba: buf wc: 256. nam: .byte 'u,'n,'i,'x,0,0,0,0,0,0,0,0,0,0,e5 DAWp Ceg Ԕ e %`5 DAWp Cek Ԕ e %`N0,0 .even .bss end: inod = ..-1024.-512. mode = inod addr = inod+8. buf = inod+32. bno = buf+514. dska = bno+2 names = dska+2 L \ewf@)wfwJ@e7Bfgwfw7X w D~wH De>  8  % RG = 10000 .text Jfw&7 $ 7 $ ׯ -   (w 7   .w elgB J ӕ- R r f e05 # /* * "init" process for Terak-Unix * MGS, Sept. 1979 * * This is a stripped down version of the original "/etc/init" pen this is the child */ /* open terminal */ open(console,2); /* fd == 0 */ dup(0); /* fd == 1 */ /* set terminal moderocess * under Mini-Unix. This process is the first executed upon boot-up, * and takes care of setting up the console mode (a */ ttyb.ispeed = B1200; ttyb.ospeed = B1200; ttyb.erase = BKSP; ttyb.kill = ATSIGN; ttyb.tflags = (XTABS | ECHO | CRll references to * terminals other than the console were deleted), * and initializing the Terak character set in memory. LoMOD | CR1 | ANYP); ttyb.tflags =& ~LCASE; stty(0,&ttyb); printf("\n\7Welcome to Terak-UNIX\n\n"); /* execute shell */ gging in was * was done away with, and the system comes up in a "single user" mode. */ char init[] "/etc/init"; char shell[]  execl(shell,minus,0); printf("\7No Shell!!\n"); exit(-1); /* if can't execute shell */ } /* * wait for child to fin"/bin/sh"; char minus[] "-"; char console[] "/dev/tty8"; char halt[] "/bin/halt"; struct { char ispeed, ospeed; char erase, kish * (i.e. when shell "dies", by EOF ) * then sync, halt */ while(wait() != id); execl(halt,minus,0); /* iill; int tflags; } ttyb; #define SIGHUP 1 #define SIGINT 2 #define SIGQIT 3 #define BKSP '\010' #define ATSIGN '@' #define B1f can't execute halt, jump back to last setexit */ reset(); } #define SETADDR 0160000 /* starting address for std. char200 9 #define XTABS 02 #define LCASE 04 #define ECHO 010 #define CRMOD 020 #define ANYP 0300 #define CR1 010000 main() { int. set */ #define SETSIZE (0177-040+1) /* char set ranges from ASCII 040->0177 */ #define SETLEN (SETSIZE*10) /* 10 lines per cha reset(); register int id; signal(SIGINT,1); signal(SIGQIT,1); /* initialize character set */ initcharset(); /* print r */ struct CHARBUF { char set1[SETSIZE][10]; char filler[64]; char set2[SETSIZE][10]; } charbuf; struct {int integ; }; out proprietary message */ open(console,1); /* fd == 0 */ dup(0); /* fd == 1 */ printf("\nRESTRICTED RIGHTS\n\n"); /* pr #define VCR 0177744 #define GENSELECT 0200 #define ALLSCREEN 07 initcharset() { int fd; register char *p, *s; register intf("Use, duplication or disclosure is subject to\n"); printf("restrictions stated in your Contract with\n"); printf("Westernint j; int i; char *charloc; /* location of each character image in generator buf. */ fd = open("/etc/charset",0); if(!(f Electric Company, Inc.\n\n"); */ close(1); close(0); /* * clear mount-table, "/etc/mtab" */ id = creat("/etc/mtab",066d < 0)) { /* initialize char. generator controller */ VCR->integ = GENSELECT; /* read in two charsets, filler */ if(re6); close(id); /* * Main loop for hangup signal (starting at setexit) * close all files */ setexit(); signal(SIGHUP,ad(fd,&charbuf,2*SETLEN+64) != 2*SETLEN+64) exit(-1); /* fill in standard char. set */ charloc = SETADDR | (040 << 4); foreset); for(id = 0; id < 14; id++) close(id); /* * fork off and set up user shell */ id = fork(); if(id==0) { /* thr(i=0; i %2d:0%d%d %.16s %.64s `gdgogxgfhegcgslglhr~wDe   % hw7 7 ׯ-  (w7  .weLkB J ӕ- ocrt0.o`start`xps.o`~main`apargcargvpu 020; } /* fill in alternate char. set */ charloc = SETADDR | (0240 << 4); for(i=0; iT ҋ D~8tkxk 2ӕ0 $f v Le0 9e s = &charbuf.set2[i]; j = 10; while(j--) { *p++ = *s++; } charloc =+ 020; } close(fd); VCR->integ = ALL  7we&  m  h~  h  h~ w7   0 j f j f  rcj f  % ww t* j h 5j f p  fef fi   nWp `e0f@w* @& HADCBFf@eӕ?fww|kw%N h k f 6z w%@a0 De@e!҆ It#tyNe&e f ,P   @f  o7H ko-f@wi ,2o pRo " Ne&e i @E%` -  &e h 7 ew N@ A HwwkwHf@wwkw& fwwkw 7F6rwDw 2 5 5 pt h @t5`@Et5ff i%ff i%lf6r@akltxL`d`^`R`X`h`/devcannot change to /dev _proc/unixNo namelist /dev/mem/usr/sys/koreNo mem F S UID fi%% k fw k f % E5 E5`f& i%5 r<!k f A r PID CPU PRI ADDR SZ WCHAN TTY TIME COMMAND PID TTY TIME COMMAND %2o %c%4d0SWRIZT%6l%4d%4d%6o%4d%7o /devc<uN% 'k+k f  e5@Et5`@t5`ff i%ff i%annot open /dev no swap device %c %2d:0%d%d %.16s %.64s `gdgogxgfhegcgslglhrlf fi%%_cn%l_c%eˋ 5 %n5ʕ % %~ %ҕ  ʕ?o  .k5k f _dw  ?ow   -hRo -L w  V wfw^1) { ap = argv[1]j e j f @0jl Vc l%@&6j f ( 2? argv[2]:"/unix", nl); if (nl[0].type==0) { printf("No n$o_swap$ o_swapdev$ o_ndev$o_devc$o_devl$Ro_coref$ocsv"h_chdir"e_printf"f_done"e_samelist\n"); done(); } coref = "/dev/mem"; if(kflg) coref = "/usr/sys/kore"; if ((mem = open(coref, 0)) < 0) { printf(idbcinpuid~getdev0bdbufsbufcetup"Vc_nlist"f_open"h_seek"i_getdev"0b_getuid"f_dup"e_fout$o_read"fi_prcom"rc_flush"fip~setupVcps~prcomrcnbadmfcpstat$icret"h_close"h_stat"i_gettty"e_ldiv"icerror"ipfloat"hpscien"h_putchar"h_errno$o_ldivripcp1cbaddrladdr~getttyei~doneechdir.oedup.oedu$q_lrem"ip)getuid.ofnlist.ofdonefbufocdonefcountoprintf.offormpoloopfrjust# /* * ps - process status * examine and print certain things about processes */ #include "/usr/sys/param.h" #include "/usrondigitognum^hwidthondfndoswtabLkdecimal`goctalghexgfloatgscienhcharac/sys/proc.h" #include "/usr/sys/tty.h" #include "/usr/sys/user.h" struct { char name[8]; int type; char *value; } nl[3]; gstringglogicallgremotehprbufhprstr hclose.ohcsv.ohexit.ohffltpr.ohopen.ohpustruct proc proc[1]; int ua[256]; int lflg; int kflg; int xflg; int tflg; int aflg; int mem; int swmem; int swap; int swapdev; tchr.ohfl0iread.ofiseek.oistat.oicerror.oildiv.oisavr5$o_exit"h_main"`_proc$int ndev; char devc[65]; int devl[65]; char *coref; struct ibuf { char idevmin, idevmaj; int inum; int iflags; char inl; ch8  & 0377; if (uid != puid && aflg==0) continue; if (lflg) { printf("%2o %c%4d", proc[0].p_flag, "0SWRIZT"[proc[0].p6; mf = swmem; } else { /* baddr = proc[0].p_pid*SWPSIZ + SWPLO; */ baddr = proc[0].p_addr; mf = swap; } baddr =+ _stat], puid); } printf("%6l", proc[0].p_pid); if (lflg) { printf("%4d%4d%6o%4d", proc[0].p_cpu&0377, proc[0].p_pri, laddr>>3; laddr = (laddr&07)<<6; seek(mf, baddr, 3); seek(mf, laddr, 1); if (read(mf, &ua[0], 512) != 512) return(0); pri/* proc[0].p_pid*SWPSIZ + SWPLO, */ proc[0].p_addr, proc[0].p_size); if (proc[0].p_wchan) printf("%7o"ntf(" %c", gettty()); if (stat==5) { printf(" "); return; } c = ((ua[0].u_utime>>1)&077777); c =+ ((ua[0].u_st, proc[0].p_wchan); else printf(" "); } prcom(proc[0].p_stat); printf("\n"); flush(); } done(); } getdev() ime>>1)&077777); c = ldiv(0, c, 30); printf(" %2d:", c/60); c =% 60; printf(c<10?"0%d":"%d", c); if (proc[0].p_flag&SLOAD) { register struct { int dir_ino; char dir_n[14]; } *p; register i, c; int f; char dbuf[512]; int sbuf[20]; f = open("/dev c = (SWPSIZ<<3) - 8; else c = proc[0].p_size - 8; laddr =+ (c&07)<<6; baddr =+ c>>3; seek(mf, baddr, 3); seek(mf, laddr", 0); if(f < 0) { printf("cannot open /dev\n"); done(); } swap = -1; c = 0; loop: i = read(f, dbuf, 512); if(i <= 0)cdefghijlm { close(f); if(swap < 0) { printf("no swap device\n"); done(); } ndev = c; return; } while(i < 512) dbuf[i++] = 0; for(p = dbuf; p < dbuf+512; p++) { if(p->dir_ino == 0) continue; if(p->dir_n[0] == 't' && p->dir_n[1] == 't' && p->dir_n[2] == 'y' && p->dir_n[4] == 0 && p->dir_n[3] != 0) { if(stat(p->dir_n, sbuf) < 0) continue; "No mem\n"); done(); } swmem = open(coref, 0); /* * read mem to find swap dev. */ swapdev = SWAPDEV; /* * Locate pr devc[c] = p->dir_n[3]; devl[c] = sbuf->iaddr[0]; c++; continue; } if(swap >= 0) continue; if(stat(p->dir_n,oc table */ seek(mem, nl[0].value, 0); getdev(); uid = getuid() & 0377; fout = dup(1); if(lflg) printf("F S UID PID C sbuf) < 0) continue; if((sbuf->iflags & 060000) != 060000) continue; if(sbuf->iaddr[0] == swapdev) swap = open(p->PU PRI ADDR SZ WCHAN TTY TIME COMMAND\n"); else printf(" PID TTY TIME COMMAND\n"); for (i=0; i>6) - 19 (*cp==0) cp++; nbad = 0; for (cp1 = cp; cp1 < &ua[256]; cp1++) { c = *cp1; if (c==0) *cp1 = ' '; elseinit cp /mnt/usr/sys/qxsrc/qxps /fp$1/bin/ps ln /fp$1/bin/mount /fp$1/etc/mount ln /fp$1/bin/umount /fp$1/etc/umount mkdir /fp$1 if (c < ' ' || c > 0176) { if (++nbad >= 5) { *cp1++ = ' '; break; } *cp1 = '?'; } } while/tmp mkdir /fp$1/lib mkdir /fp$1/usr mkdir /fp$1/usr/bin mkdir /fp$1/usr/lib mkdir /fp$1/mnt cd / umount /dev/rx$1t  (*--cp1==' ') *cp1 = 0; printf(lflg?" %.16s":" %.64s", cp); return(1); } } return(0); } gettty() { register i; callout: clr r0 cmp (r0),$407 bne 2f 1: mov 20(r0),(r0)+ cmp r0,sp blo 1b 2: mov $start,-(sp) clr pc  if (ua[0].u_ttyp==0) return('?'); for (i=0; i &ua[0];) { if (*--ip == -1) { cp = ip+1; if ir /fp$1/etc cd /mnt/etc cpall charset mtab mknod glob mkfs /fp$1/etc cp clri /fp$1/bin cp /mnt/usr/sys/qxsrc/qxinit /fp$1/etc/: f@w0 @& HADCBFf@eӕ?fA w,w"e"w"ew"@lw"|Alewo &@t`e fwLwHzfwtf ,vP l f @f J f78 ff.&- 7F/etc/init/bin/sh-/dev/tty8/bin/date RESTRICTED RIGHTS U of M SICL Terak-Unix No Shell!! ad,bo&bxhbfvbebcbsalbr0 %H & 6  dw n (c  (c e &e  ae `a td td c ewfcrt0.o`start`jinit.o`~main`iddup.oadup)execl.o,afork.o(c   td % 6e &e  a  @Ef& 6d e `a ee ,a%f `aHaprintf.o`aformpflooptarjustfndigitfgnumbwidthfndfndfswtab.fdecimalaoctal d X! ee ,a% wf@)wfw@e7(fwlfw^76 w &~w&D,bhex&bfloathbscienvbcharacbstringblogicalaremotebprbufbprstrbreset.ocsre   % Dew7 7 ׯ-  (w7  .we.fB J ӕ- R r 5fspcfsignal.o(crttNSIGdvectftvectcstty.o6dwait.oTdclose.otdcsv.of e0 @ > ҋ D~8VfZf bӕ0 $f v Le0 9e.(dexit.odffltpr.odnargs.odjsrsdhftstilfcmpinfaddipfjmpitfbrixfopen.o&eputchr <   .7 we&  m  De~  De  De~ w7   0 .oDefl~ecerror.oesavr5$f_exit"d_main"`_init#e_shell#e_minus#e_console#e_dt#e_t  Wp `e0w ~www~~|wpfAW @w" ff1f7 5 ecw^f 5tyb$fcsv"d_signal"(c_open"&e_dup"a_printf"`a_close"td_setexit"c_reset"c_fork"Ha_stty"& w4&L&H&D&@&<&8&4&0&,&(&$& &&6d_execl",a_wait"Tdcret"dcerror"e_par_uid$fpfloat"dpscien"d_putchar"De_nargs"d_flush"re_fout&&& &&&f& f@w"dfwf f ^& wL }$f_errno$f;  message */ open(console,1); /* fd == 0 */ dup(0); /* fd == 1 */ printf("\nRESTRICTED RIGHTS\n\n"); /* printf("Use, duplnt=1 sync /etc/mount /dev/rx$1t /fp$1 cp /mnt/usr/sys/samx /fp$1/unix mkdir /fp$1/bin cd /mnt/bin cpall cat chmod cp date df du ication or disclosure is subject to\n"); printf("restrictions stated in your Contract with\n"); printf("Western Electric Compaecho ed halt ls mkdir mv passwd pr pwd rm rmdir sh size su /fp$1/bin cpall icheck ncheck mount umount dcheck /fp$1/bin cd / mkdiny, Inc.\n\n"); */ close(1); close(0); /* set the date */ /* * Main loop for hangup signal (starting at setexit) * closr /fp$1/dev /etc/mknod /fp$1/dev/tty8 c 0 0 /etc/mknod /fp$1/dev/mem c 1 0 /etc/mknod /fp$1/dev/kmem c 1 1 /etc/mknod /fp$1/dev/e all files */ setexit(); signal(SIGHUP,reset); for(id = 0; id < 14; id++) close(id); /* * fork off and set up usernull c 1 2 /etc/mknod /fp$1/dev/qx0 b 0 0 /etc/mknod /fp$1/dev/qx1 b 0 1 /etc/mknod /fp$1/dev/sa0 b 1 0 mkdir /fp$1/etc cd /mnt/ shell */ id = fork(); if(id==0) { /* then this is the child */ /* open terminal */ open(console,2); /* fd == 0 */ duetc cpall charset mtab mknod glob mkfs /fp$1/etc cp /mnt/usr/sys/qxsrc/sainit /fp$1/etc/init cp /mnt/usr/sys/qxsrc/qxps /fp$1/b# /* * "init" process for SICL Terak-Unix * Marc Smith, SICL, Sept. 1979 * * This is a stripped down version of the origp(0); /* fd == 1 */ /* set terminal mode */ ttyb.ispeed = B1200; ttyb.ospeed = B1200; ttyb.erase = BKSP; ttyb.kill inal "/etc/init" process * under Mini-Unix. This process is the first executed upon boot-up, * and takes care of setting up t = ATSIGN; ttyb.tflags = (XTABS | ECHO | CRMOD | CR1 | ANYP); ttyb.tflags =& ~LCASE; stty(0,&ttyb); printf("\n\7U of M he console mode (all references to * terminals other than the console were deleted), setting the date, * and initializing theSICL Terak-Unix\n\n"); /* execute shell */ execl(shell,minus,0); printf("\7No Shell!!\n"); exit(-1); /* if can't exec Terak character set in memory. Logging in was * was done away with, and the system comes up in a "single user" mode. */ chaute shell */ } /* * wait for child to finish * then sync, halt */ while(wait() != id); execl(init,minus,0); /* if r init[] "/etc/init"; char shell[] "/bin/sh"; char minus[] "-"; char console[] "/dev/tty8"; char dt[] "/bin/date"; struct { chcan't execute halt, jump back to last setexit */ reset(); } ar ispeed, ospeed; char erase, kill; int tflags; } ttyb; #define SIGHUP 1 #define SIGINT 2 #define SIGQIT 3 #define BKSP '\010' #define ATSIGN '@' #define B1200 9 #define XTABS 02 #define LCASE 04 #define ECHO 010 #define CRMOD 020 #define ANYP 0300 #define CR1 010000 main() { int reset(); register int id; signal(SIGINT,1); signal(SIGQIT,1); /* print out proprietaryif $1x = x exit if $2x = x exit set E = 1 /etc/mkfs /dev/rx$1t $2 sync dd if=/mnt/usr/sys/qxsrc/qxuboot of=/dev/rx$1t bs=512 cou<  ZE ŋ" <&~ŊAC!  @ D~̋ wwin/ps cd / umount /dev/rx$1t ŗ H !W N  e7 J  j De Ԥ!@eW  8F RW et ZEWue T!ef b5: &      unix "  f &  %C e  5aA= d> ? @ A B C D E F G H I J K L