1
0
mirror of https://github.com/livingcomputermuseum/pdp7-unix.git synced 2026-04-26 12:17:26 +00:00

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"
This commit is contained in:
phil
2019-10-22 21:22:21 -04:00
parent 723b2d3ee9
commit 96af8f1c17
2 changed files with 9 additions and 2 deletions

View File

@@ -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

View File

@@ -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 );
}