From 00c2de0292a1352ed540d3112b4bc1cfc91e8d19 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Wed, 16 Mar 2016 05:36:22 +1000 Subject: [PATCH] I bit the bullet and implemented "." in the filesystem. I've changed the proto file to put the binaries in system. I added a few more checks to fsck, and I fixed a few bugs in src/other/wktls.s. --- build/proto | 24 ++++++++++++------------ src/other/wktls.s | 9 +++++---- tools/fsck7 | 7 ++++++- tools/mkfs7 | 5 +++++ 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/build/proto b/build/proto index 459b164..95ce9c0 100644 --- a/build/proto +++ b/build/proto @@ -19,22 +19,22 @@ dd drw-- -1 4 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/chrm + cp frwr- -1 ../bin/cp + date frwr- -1 ../bin/date + ds frwr- -1 ../bin/ds init frwr- -1 ../bin/init + ln frwr- -1 ../bin/ln + ls frwr- -1 ../bin/ls + mv frwr- -1 ../bin/mv password frw-- -1 password sh frwr- -1 ../bin/sh + stat frwr- -1 ../bin/stat $ - as frwr- -1 ../bin/as - cat frwr- -1 ../bin/cat - chmod frwr- -1 ../bin/chmod - chown frwr- -1 ../bin/chown - chrm frwr- -1 ../bin/chrm - cp frwr- -1 ../bin/cp - date frwr- -1 ../bin/date - ds frwr- -1 ../bin/ds - ln frwr- -1 ../bin/ln - ls frwr- -1 ../bin/ls - mv frwr- -1 ../bin/mv - stat frwr- -1 ../bin/stat ken drwr- 10 system l---- 3 $ diff --git a/src/other/wktls.s b/src/other/wktls.s index d2b36e1..419002a 100644 --- a/src/other/wktls.s +++ b/src/other/wktls.s @@ -39,7 +39,7 @@ entryloop: sna jmp 1f " No, don't print out the inode number - lac bufptr " Print out the inode number as 5 digits + lac bufptr i " Print out the inode number as 5 digits jms octal; -5 1: isz bufptr " Move up to the filename @@ -50,7 +50,7 @@ entryloop: lac bufptr dac statfile " Copy the pointer to the status call lac statbufptr " Get the file's details into the statbuf - sys status; statfile:0; 0 + sys status; curdir; statfile:0 spa jms fileend @@ -70,15 +70,16 @@ entryloop: sys write; l; 1 " Yes, print an l jmp 2f 1: lac fd1 - sys write; minus; 1 " Not a dir, not large, print an s + sys write; s; 1 " Not a dir, not large, print an s 2: lac s.perm " Readable by owner? and ureadmask sna jmp 1f lac fd1 -1: sys write; r; 1 " Yes, print an r + sys write; r; 1 " Yes, print an r jmp 2f +1: lac fd1 sys write; minus; 1 " No, print a - sign 2: lac s.perm " Writable by owner? diff --git a/tools/fsck7 b/tools/fsck7 index b99498d..0217bea 100755 --- a/tools/fsck7 +++ b/tools/fsck7 @@ -97,6 +97,8 @@ sub get_inode_block_offset { # Mark a block as being in-use sub mark_block_inuse { my $usedblk = shift; + die("bad usedblk $usedblk\n") if ($usedblk >= NUMBLOCKS); + dprint("Block $usedblk is in-use\n"); print("Free block $usedblk is being used\n") if ( $Freelist[$usedblk] ); @@ -143,8 +145,11 @@ sub get_inode { { my $usedptr = $Block[$blocknum][$o]; next if ( $usedptr == 0 ); + die("bad usedptr $usedptr in i-node $inode\n") if ($usedptr >= NUMBLOCKS); + mark_block_inuse($usedptr); foreach my $indo ( 0 .. WORDSPERBLK - 1 ) { + my $usedblk = $Block[$usedptr][$indo]; next if ( $usedblk == 0 ); push( @used, $usedblk ); @@ -187,7 +192,7 @@ sub print_direntry { my ( $inum, $name ) = @_; my ( $flags, $uid, $links, $size, $uniq ) = get_inode( $inum, 0 ); if ( !defined($flags) ) { - printf( "%4d unallocated i-node\n", $inum ); + printf( "%4d unallocated i-node in this dir named %s\n", $inum, $name ); return; } diff --git a/tools/mkfs7 b/tools/mkfs7 index 1d76b3a..52a4806 100755 --- a/tools/mkfs7 +++ b/tools/mkfs7 @@ -332,6 +332,11 @@ sub make_dir { # 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] ); + + # Also add a "." entry to this directory + add_direntry( ".", $inum ); + dprint("Added a . entry to ourselves\n"); + dprintf( "Made directory %s perms %06o uid %d in inum %d\n\n", $dirname, $perms, $uid, $inum ); }