1
0
mirror of https://github.com/DoctorWkt/pdp7-unix.git synced 2026-01-13 23:36:52 +00:00

I've got init past the link, but it then dies on the open("sh") immediately

after that. Yes, dd has to be i-num 4. I've modified mkfs7 and the proto
file to allow this to occur. I've also make link counts negative.
This commit is contained in:
Warren Toomey 2016-03-14 19:49:37 +10:00
parent cd7befb2de
commit 9da0484a39
2 changed files with 16 additions and 11 deletions

View File

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

View File

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