mirror of
https://github.com/DoctorWkt/pdp7-unix.git
synced 2026-02-06 08:35:14 +00:00
mkfs: I moved the order of ., .. and dd around to me more pleasing to the eye. I also
added some simple link count code.
This commit is contained in:
23
tools/mkfs7
23
tools/mkfs7
@@ -221,12 +221,20 @@ sub fill_inode {
|
||||
return ($inum);
|
||||
}
|
||||
|
||||
# Increase the file size of an i-node
|
||||
sub increment_file_length {
|
||||
my ( $inum, $incr) = @_;
|
||||
my ( $blocknum, $offset ) = get_inode_block_offset($inum);
|
||||
$Block[$blocknum][ $offset + I_SIZE ] += $incr;
|
||||
}
|
||||
|
||||
# Increase the link count of an i-node
|
||||
sub increment_link_count {
|
||||
my $inum = shift;
|
||||
my ( $blocknum, $offset ) = get_inode_block_offset($inum);
|
||||
$Block[$blocknum][ $offset + I_NLKS ] --;
|
||||
}
|
||||
|
||||
# Convert an ASCII string into an array of 18-bit word values
|
||||
# where two characters are packed into each word. Put NUL in
|
||||
# if the string has an odd number of characters. Return the array
|
||||
@@ -305,6 +313,9 @@ sub add_direntry {
|
||||
# And add this new block to the directory's i-node
|
||||
add_block_to_inode( $nextblock, $dirref->[2] );
|
||||
}
|
||||
|
||||
# Finally, increment the link count
|
||||
increment_link_count($inum);
|
||||
}
|
||||
|
||||
# Given a name, perms, a user-id and an optional i-node number, make a
|
||||
@@ -328,12 +339,7 @@ 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. 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] );
|
||||
|
||||
# Also add a "." entry to this directory
|
||||
# Add a "." entry to this directory if requested
|
||||
if ($wantdot) {
|
||||
add_direntry( ".", $inum );
|
||||
dprint("Added a . entry to ourselves\n");
|
||||
@@ -345,6 +351,11 @@ sub make_dir {
|
||||
dprintf("Added a .. entry to i-num %d\n", $Dirstack[-2]->[2] );
|
||||
}
|
||||
|
||||
# Finally, 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 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user