From 96af8f1c17000e5c0b143799b0f65aed59ec3164 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 22 Oct 2019 21:22:21 -0400 Subject: [PATCH] two mkfs7 changes (.. and link to inum -1), make hard link for list program mkfs: if neither --dotdot or --dot options given, create .. link to current dir accept -1 for inum in add_direntry to mean "use previous i-num" for links proto: use inum -1 to make "list" a link to "nls" --- build/proto | 2 +- tools/mkfs7 | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/build/proto b/build/proto index 24e9c6a..915b33e 100644 --- a/build/proto +++ b/build/proto @@ -61,11 +61,11 @@ dd drwr- -1 4 nsh frwr- -1 bin/nsh nls frwr- -1 bin/nls + list l---- -1 # nbc frwr- -1 bin/nbc nstat frwr- -1 bin/nstat - $ ken drwr- 10 system l---- 3 diff --git a/tools/mkfs7 b/tools/mkfs7 index aef67a2..ac6775e 100755 --- a/tools/mkfs7 +++ b/tools/mkfs7 @@ -62,6 +62,7 @@ my $nextinum = 1; # i-num 0 is never used my @Dirstack; # Stack of directories. Each value is a ref # to a [ blocknum, offset, inum ] array which # is the next free position in the directory +my $lastinum = -1; # last inum assigned, for link to i-num -1 # Debug printing sub dprint { @@ -277,6 +278,8 @@ sub add_block_to_inode { sub add_direntry { my ( $name, $inum ) = @_; + $inum = $lastinum if ($inum == -1); + # Get the block and offset to the next empty slot in the directory my $dirref = $Dirstack[-1]; @@ -320,6 +323,7 @@ sub add_direntry { # Finally, increment the link count increment_link_count($inum); + $lastinum = $inum; } # Given a name, perms, a user-id and an optional i-node number, make a @@ -360,8 +364,11 @@ sub make_dir { if (!$no_dd) { add_direntry( "dd", $Dirstack[0]->[2] ); dprintf("Added a dd entry to i-num %d\n", $Dirstack[0]->[2] ); + if (!$wantdotdot && !$wantdot) { # PLB 2019 + 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 ); }