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:
+3
-4
@@ -11,19 +11,18 @@
|
|||||||
# Contents of each directory ends with a $ on a line by itself
|
# Contents of each directory ends with a $ on a line by itself
|
||||||
# Format was inspired by 6th Edition mkfs
|
# Format was inspired by 6th Edition mkfs
|
||||||
#
|
#
|
||||||
dd drw-- -1 2
|
dd drw-- -1 4
|
||||||
system drw-- -1 3
|
system drw-- -1 3
|
||||||
init frwr- -1 ../bin/init
|
|
||||||
password frw-- -1 password
|
|
||||||
ttyin irwr- -1 6
|
ttyin irwr- -1 6
|
||||||
keyboard irwr- -1 7
|
keyboard irwr- -1 7
|
||||||
pptin irwr- -1 8
|
pptin irwr- -1 8
|
||||||
ttyout irwr- -1 11
|
ttyout irwr- -1 11
|
||||||
display irwr- -1 12
|
display irwr- -1 12
|
||||||
pptout irwr- -1 13
|
pptout irwr- -1 13
|
||||||
|
init frwr- -1 ../bin/init
|
||||||
|
password frw-- -1 password
|
||||||
sh frwr- -1 ../bin/sh
|
sh frwr- -1 ../bin/sh
|
||||||
$
|
$
|
||||||
|
|
||||||
as frwr- -1 ../bin/as
|
as frwr- -1 ../bin/as
|
||||||
cat frwr- -1 ../bin/cat
|
cat frwr- -1 ../bin/cat
|
||||||
chmod frwr- -1 ../bin/chmod
|
chmod frwr- -1 ../bin/chmod
|
||||||
|
|||||||
+12
-6
@@ -139,8 +139,11 @@ sub allocate_blocks {
|
|||||||
sub allocate_inode {
|
sub allocate_inode {
|
||||||
my $inum = shift;
|
my $inum = shift;
|
||||||
return ( $nextinum++ ) if ( !defined($inum) );
|
return ( $nextinum++ ) if ( !defined($inum) );
|
||||||
die("i-num $inum already allocated\n") if ( $inum < $nextinum );
|
if ( $inum < $nextinum ) {
|
||||||
|
print("i-num $inum already allocated, ignoring this\n")
|
||||||
|
} else {
|
||||||
$nextinum = $inum + 1;
|
$nextinum = $inum + 1;
|
||||||
|
}
|
||||||
return ($inum);
|
return ($inum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,10 +200,10 @@ sub fill_inode {
|
|||||||
$inum = allocate_inode() if ( !defined($inum) );
|
$inum = allocate_inode() if ( !defined($inum) );
|
||||||
my ( $blocknum, $offset ) = get_inode_block_offset($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_UID ] = $uid;
|
||||||
$Block[$blocknum][ $offset + I_SIZE ] = $size;
|
$Block[$blocknum][ $offset + I_SIZE ] = $size;
|
||||||
$Block[$blocknum][ $offset + I_NLKS ] = 1;
|
$Block[$blocknum][ $offset + I_NLKS ] = -1 & MAXINT;
|
||||||
|
|
||||||
my $i = $offset;
|
my $i = $offset;
|
||||||
foreach my $datablocknum (@blklist) {
|
foreach my $datablocknum (@blklist) {
|
||||||
@@ -289,7 +292,8 @@ sub add_direntry {
|
|||||||
# Move up to the next position in the directory.
|
# Move up to the next position in the directory.
|
||||||
$dirref->[1] += D_NUMWORDS;
|
$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 we have filled the directory up, allocate another block to it
|
||||||
if ( $dirref->[1] == WORDSPERBLK ) {
|
if ( $dirref->[1] == WORDSPERBLK ) {
|
||||||
@@ -324,8 +328,10 @@ sub make_dir {
|
|||||||
dprint("Pushing dir block $dirblock inum $inum to dirstack\n");
|
dprint("Pushing dir block $dirblock inum $inum to dirstack\n");
|
||||||
push( @Dirstack, [ $dirblock, 0, $inum ] );
|
push( @Dirstack, [ $dirblock, 0, $inum ] );
|
||||||
|
|
||||||
# Add a "dd" entry to this directory
|
# Add a "dd" entry to this directory. We get the i-num from
|
||||||
add_direntry( "dd", DD_INUM );
|
# 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",
|
dprintf( "Made directory %s perms %06o uid %d in inum %d\n\n",
|
||||||
$dirname, $perms, $uid, $inum );
|
$dirname, $perms, $uid, $inum );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user