diff --git a/build/Makefile b/build/Makefile index f39a5d5..9be34e9 100644 --- a/build/Makefile +++ b/build/Makefile @@ -22,16 +22,29 @@ BINARIES=../binaries/ all: cmd others a.rim image.fs copybinaries +# Make alternative everything: no dd but . and .. +alt: altcmd altothers alta.rim altimage.fs + # The run rule has no dependencies so that the system can be booted easily # and frequently with make run. However, you have to manually make all first! run: $(PDP7) unixv0.simh +# Alternative run, use the altimage.fs +altrun: + $(PDP7) altunixv0.simh + # Warm boot Unix kernel: boots into init and a login prompt a.rim: $(AS) -f rim -o a.rim $(SYSSRC)/sop.s $(SYSSRC)/s[1-8].s $(AS) -n -f list -o a.lst $(SYSSRC)/sop.s $(SYSSRC)/s[1-8].s +# Alternative kernel: no dd, but . and .. +alta.rim: + $(AS) -f rim -o alta.rim -DNO_DD $(SYSSRC)/sop.s $(SYSSRC)/s[1-8].s + $(AS) -n -f list -o alta.lst -DNO_DD $(SYSSRC)/sop.s $(SYSSRC)/s[1-8].s + + # Cold boot Unix kernel: attempts to build a minimal filesystem. # Don't use this one! coldboot: @@ -40,16 +53,22 @@ coldboot: # Filesystem image image.fs: cmd others - $(MKFS) --format simh proto + $(MKFS) proto $(FSCK) image.fs +# Alternate filesystem image: . and .. but no dd +altimage.fs: altcmd altothers + $(MKFS) -1 -2 -3 -o altimage.fs altproto + $(FSCK) -3 altimage.fs + + copybinaries: mkdir -p $(BINARIES) cp image.fs $(BINARIES) cp a.rim $(BINARIES) clean: - rm -f a.rim image.fs a.lst n.out + rm -f a.rim image.fs a.lst n.out altimage.fs alta.rim alta.lst rm -rf $(BINDIR) rm -rf $(TESTDIR) rm -rf $(BINARIES) @@ -62,6 +81,11 @@ cmd: dirs $(BINDIR)/as $(BINDIR)/cat $(BINDIR)/check $(BINDIR)/chmod \ $(BINDIR)/chown $(BINDIR)/chrm $(BINDIR)/cp $(BINDIR)/ds $(BINDIR)/ed \ $(BINDIR)/init +# Alternate commands: no dd, but . and .. +altcmd: dirs $(BINDIR)/as $(BINDIR)/cat $(BINDIR)/check $(BINDIR)/chmod \ + $(BINDIR)/chown $(BINDIR)/altchrm $(BINDIR)/cp $(BINDIR)/ds $(BINDIR)/ed \ + $(BINDIR)/altinit + $(BINDIR)/as: $(CMDSRC)/as.s $(AS) $(ASARGS) -o $(BINDIR)/as $(CMDSRC)/as.s @@ -80,6 +104,9 @@ $(BINDIR)/chown: $(CMDSRC)/chown.s $(BINDIR)/chrm: $(CMDSRC)/chrm.s $(AS) $(ASARGS) -o $(BINDIR)/chrm $(CMDSRC)/chrm.s +$(BINDIR)/altchrm: $(OTHERSRC)/wktchrm.s + $(AS) $(ASARGS) -o $(BINDIR)/altchrm -DNO_DD $(OTHERSRC)/wktchrm.s + $(BINDIR)/cp: $(CMDSRC)/cp.s $(AS) $(ASARGS) -o $(BINDIR)/cp $(CMDSRC)/cp.s @@ -92,10 +119,19 @@ $(BINDIR)/ed: $(CMDSRC)/ed1.s $(CMDSRC)/ed2.s $(BINDIR)/init: $(CMDSRC)/init.s $(AS) $(ASARGS) -o $(BINDIR)/init $(CMDSRC)/init.s +# Alternative init: no dd directory +$(BINDIR)/altinit: $(CMDSRC)/init.s + $(AS) $(ASARGS) -DNO_DD -o $(BINDIR)/altinit $(CMDSRC)/init.s + # The commands that did not come from the scans others: dirs $(BINDIR)/sh $(BINDIR)/wktcat $(BINDIR)/wktcp $(BINDIR)/date \ $(BINDIR)/ln $(BINDIR)/ls $(BINDIR)/mv $(BINDIR)/stat +# Alternative other commands: no dd, but . and .. +altothers: dirs $(BINDIR)/sh $(BINDIR)/wktcat $(BINDIR)/wktcp $(BINDIR)/date \ + $(BINDIR)/ln $(BINDIR)/altls $(BINDIR)/mv $(BINDIR)/stat + + $(BINDIR)/sh: $(OTHERSRC)/pbsh.s $(AS) $(ASARGS) -o $(BINDIR)/sh $(OTHERSRC)/pbsh.s @@ -114,6 +150,9 @@ $(BINDIR)/ln: $(OTHERSRC)/wktln.s $(BINDIR)/ls: $(OTHERSRC)/wktls.s $(AS) $(ASARGS) -o $(BINDIR)/ls $(OTHERSRC)/wktls.s +$(BINDIR)/altls: $(OTHERSRC)/wktls.s + $(AS) $(ASARGS) -o $(BINDIR)/altls -DNO_DD $(OTHERSRC)/wktls.s + $(BINDIR)/mv: $(OTHERSRC)/wktmv.s $(AS) $(ASARGS) -o $(BINDIR)/mv $(OTHERSRC)/wktmv.s diff --git a/build/altproto b/build/altproto new file mode 100644 index 0000000..38e8733 --- /dev/null +++ b/build/altproto @@ -0,0 +1,47 @@ +# Alternative prototype file for PDP-7 Unix filesystem layout +# +# This one has . and .. but no dd directory entries +# +# Entries are one of: +# filename f[r-][w-][r-][w-] uid local_file_to_insert +# dirname d[r-][w-][r-][w-] uid [inumber] +# device i[r-][w-][r-][w-] uid inumber +# link l---- inumber +# +# The top directory's name is ignored +# Numeric values are in decimal +# Contents of each directory ends with a $ on a line by itself +# Format was inspired by 6th Edition mkfs +# +/ drwr- -1 2 + system drwr- -1 3 + ttyin irwr- -1 6 + keyboard irwr- -1 7 + pptin irwr- -1 8 + ttyout irwr- -1 11 + display irwr- -1 12 + pptout irwr- -1 13 + as frwr- -1 bin/as + cat frwr- -1 bin/cat + chmod frwr- -1 bin/chmod + chown frwr- -1 bin/chown + chrm frwr- -1 bin/altchrm + cp frwr- -1 bin/cp + date frwr- -1 bin/date + ds frwr- -1 bin/ds + ed frwr- -1 bin/ed + init frwr- -1 bin/altinit + ln frwr- -1 bin/ln + ls frwr- -1 bin/altls + mv frwr- -1 bin/mv + password frw-- -1 fs/password + sh frwr- -1 bin/sh + stat frwr- -1 bin/stat + $ + ken drwr- 10 + system l---- 3 + hello frwr- 10 fs/hello + $ + dmr drwr- 12 + system l---- 3 + $ diff --git a/build/altunixv0.simh b/build/altunixv0.simh new file mode 100644 index 0000000..1fc7457 --- /dev/null +++ b/build/altunixv0.simh @@ -0,0 +1,12 @@ +set cpu 8k +set cpu eae +set cpu history=100 +show cpu + +set tti unix +set rb ena +att rb altimage.fs +show dev + +load -S alta.rim +dep pc 0100 diff --git a/src/cmd/init.s b/src/cmd/init.s index ec92b3c..e5f3265 100644 --- a/src/cmd/init.s +++ b/src/cmd/init.s @@ -124,8 +124,12 @@ login: 2: lac nchar sys setuid " Set the user's user-id - sys chdir; dd " and change into the "dd" directory - sys chdir; dir +#ifdef NO_DD + sys chdir; dotdot " Change into the root directory (out of system) +#else + sys chdir; dd " Change into the "dd" directory +#endif + sys chdir; dir " and then the user's home directory lac d2 " Close file descriptor 2 sys close @@ -249,6 +253,8 @@ m3: m3s = .-m3 dd:
;040040;040040;040040 +dotdot: + <..>;040040;040040;040040 dir: 040040;040040;040040;040040 diff --git a/src/other/wktchrm.s b/src/other/wktchrm.s new file mode 100644 index 0000000..acbf8e0 --- /dev/null +++ b/src/other/wktchrm.s @@ -0,0 +1,41 @@ +" Alternative chrm: chrm file [file file ...] +" +" Unlink the named files + + lac 017777 " Go to the argc + tad d1 " Skip past the argc + dac 2f " Save pointing at cmd name, we will skip later + lac 017777 i " How many arguments do we have? + sad d4 + sys exit " None, so exit + tad dm4 " Subtract 1 + dac 017777 i " and save in the argc + +1: + lac 017777 i " Any arguments left? + sna + sys exit " No, exit the program + tad dm4 " Subtract 4 from the argc and update it + dac 017777 i + lac 2f " Move up to the next filename + tad d4 + dac 2f " and save it in the unlink arg + sys unlink; 2:0 " Unlink the file + sma + jmp 1b " Loop back if the unlink was OK, or issue err + lac 2b " Copy the filename pointer below + dac 2f + lac d1 " Write the filename on stdout + sys write; 2:0; 4 + lac d1 + sys write; 1f; 2 " Write " ?\n" on stdout + jmp 1b " and loop back + +1: + 040077;012000 " String literal " ?\n" +dd: +
;040040;040040;040040 " Filename dd +d1: 1 +d4: 4 +d5: 5 +dm4: -4 diff --git a/src/other/wktls.s b/src/other/wktls.s index 8d3ea23..051af8d 100644 --- a/src/other/wktls.s +++ b/src/other/wktls.s @@ -23,7 +23,9 @@ argloop: jmp setlong lac argptr " It wasn't -l, so save it as the dir to open +#ifndef NO_DD dac 8f +#endif dac 9f skp @@ -79,7 +81,11 @@ entryloop: lac bufptr dac statfile " Copy the pointer to the status call lac statbufptr " Get the file's details into the statbuf +#ifdef NO_DD + sys status; statfile:0 +#else sys status; 8:curdir; statfile:0 +#endif spa jms fileend diff --git a/src/sys/s2.s b/src/sys/s2.s index 061d820..8fc2c98 100644 --- a/src/sys/s2.s +++ b/src/sys/s2.s @@ -4,7 +4,13 @@ " file status (stat) system call " AC/ pointer to status (inode) buffer + i-num (13 words) " sys status; dir_name_ptr; file_name_ptr + " NO_DD version: sys status; file_name_ptr .status: +#ifdef NO_DD + jms arg " fetch file name pointer + dac .+3 + lac u.cdir " get current working directory +#else jms arg " fetch directory name pointer dac .+5 jms arg " fetch file name pointer @@ -12,6 +18,7 @@ lac u.cdir " get current working directory jms namei; .. " look up source directory jms error " not found: return error to user +#endif jms namei; .. " look up file jms error " not found: return error jms iget " read file inode @@ -103,7 +110,11 @@ dac 1f jms arg dac 2f +#ifdef NO_DD + lac u.cdir " Search the current directory +#else lac d4 " Search the directory at i-num 4 +#endif jms namei; 0:0 " for the first argument jms error " Didn't find it jms namei; 1:0 " In the i-num found by 1st namei, diff --git a/tools/fsck7 b/tools/fsck7 index 05c080c..00f274d 100755 --- a/tools/fsck7 +++ b/tools/fsck7 @@ -57,7 +57,7 @@ use constant D_UNIQ => 5; use constant D_NUMWORDS => 8; # Eight words in a direntry # Globals -my $debug = 0; +my ($debug, $no_dd) = (0,0); my @Block; # Array of blocks and words in each block my @Freelist; # List of free block numbers my @Usedlist; # List of in-use block numbers @@ -271,7 +271,10 @@ sub usage { ### MAIN PROGRAM -GetOptions( 'debug|d' => \$debug, ) +GetOptions( + 'debug|d' => \$debug, + 'no_dd|3' => \$no_dd, +) or usage(); usage() if ( @ARGV < 1 ); @@ -327,6 +330,10 @@ foreach my $inode ( 0 .. NUMINODEBLKS * INODESPERBLK - 1 ) { } # Now check the directories. We start with dd at i-num 4. -check_directory( 4, "dd" ); +if ($no_dd) { + check_directory( 2, "" ); +} else { + check_directory( 4, "dd" ); +} exit(0); diff --git a/tools/mkfs7 b/tools/mkfs7 index aaf2e6a..90242b1 100755 --- a/tools/mkfs7 +++ b/tools/mkfs7 @@ -55,7 +55,7 @@ use constant D_UNIQ => 5; use constant D_NUMWORDS => 8; # Eight words in a direntry # Globals -my ($debug,$wantdot,$wantdotdot)=(0,0,0); +my ($debug,$wantdot,$wantdotdot, $no_dd)=(0,0,0,0); my @Block; # Array of blocks and words in each block my @Freelist; # List of free block numbers my $nextinum = 1; # i-num 0 is never used @@ -353,9 +353,11 @@ sub make_dir { } # Finally, add a "dd" entry to this directory. We get the - # i-num from the first entry in the Dirstack - add_direntry( "dd", $Dirstack[0]->[2] ); - dprintf("Added a dd entry to i-num %d\n", $Dirstack[0]->[2] ); + # i-num from the first entry in the Dirstack. Sorry for the dbl negative. + if (!$no_dd) { + add_direntry( "dd", $Dirstack[0]->[2] ); + dprintf("Added a dd entry to i-num %d\n", $Dirstack[0]->[2] ); + } dprintf( "Made directory %s perms %06o uid %d in inum %d\n\n", $dirname, $perms, $uid, $inum ); @@ -643,6 +645,7 @@ GetOptions( 'debug|d' => \$debug, 'dot|1' => \$wantdot, 'dotdot|2' => \$wantdotdot, + 'no_dd|3' => \$no_dd, 'format|f=s' => \$format, 'output|o=s' => \$output, ) or usage();