diff --git a/build/proto b/build/proto index 2836373..459b164 100644 --- a/build/proto +++ b/build/proto @@ -11,19 +11,18 @@ # Contents of each directory ends with a $ on a line by itself # Format was inspired by 6th Edition mkfs # -dd drw-- -1 2 +dd drw-- -1 4 system drw-- -1 3 - init frwr- -1 ../bin/init - password frw-- -1 password ttyin irwr- -1 6 keyboard irwr- -1 7 pptin irwr- -1 8 ttyout irwr- -1 11 display irwr- -1 12 pptout irwr- -1 13 + init frwr- -1 ../bin/init + password frw-- -1 password sh frwr- -1 ../bin/sh $ - as frwr- -1 ../bin/as cat frwr- -1 ../bin/cat chmod frwr- -1 ../bin/chmod diff --git a/tools/mkfs7 b/tools/mkfs7 index 4a80b45..f6b12f0 100755 --- a/tools/mkfs7 +++ b/tools/mkfs7 @@ -139,8 +139,11 @@ sub allocate_blocks { sub allocate_inode { my $inum = shift; return ( $nextinum++ ) if ( !defined($inum) ); - die("i-num $inum already allocated\n") if ( $inum < $nextinum ); - $nextinum = $inum + 1; + if ( $inum < $nextinum ) { + print("i-num $inum already allocated, ignoring this\n") + } else { + $nextinum = $inum + 1; + } return ($inum); } @@ -197,10 +200,10 @@ sub fill_inode { $inum = allocate_inode() if ( !defined($inum) ); my ( $blocknum, $offset ) = get_inode_block_offset($inum); - # Fill in the easy fields + # Fill in the easy fields. Link count is negative $Block[$blocknum][ $offset + I_UID ] = $uid; $Block[$blocknum][ $offset + I_SIZE ] = $size; - $Block[$blocknum][ $offset + I_NLKS ] = 1; + $Block[$blocknum][ $offset + I_NLKS ] = -1 & MAXINT; my $i = $offset; foreach my $datablocknum (@blklist) { @@ -289,7 +292,8 @@ sub add_direntry { # Move up to the next position in the directory. $dirref->[1] += D_NUMWORDS; - increment_file_length( $dirref->[2], D_NUMWORDS ); # update directory inode i.size + # Update the directory inode's i.size, another 8 words + increment_file_length( $dirref->[2], D_NUMWORDS ); # If we have filled the directory up, allocate another block to it if ( $dirref->[1] == WORDSPERBLK ) { @@ -324,8 +328,10 @@ sub make_dir { dprint("Pushing dir block $dirblock inum $inum to dirstack\n"); push( @Dirstack, [ $dirblock, 0, $inum ] ); - # Add a "dd" entry to this directory - add_direntry( "dd", DD_INUM ); + # 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] ); dprintf( "Made directory %s perms %06o uid %d in inum %d\n\n", $dirname, $perms, $uid, $inum ); }