From b9fa7fb4fb6b6b30108bda9528deccf51d34cac7 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Sat, 19 Mar 2016 14:37:23 +1000 Subject: [PATCH] Fix up the link count code. --- tools/mkfs7 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/mkfs7 b/tools/mkfs7 index ed63bb7..aaf2e6a 100755 --- a/tools/mkfs7 +++ b/tools/mkfs7 @@ -203,7 +203,7 @@ sub fill_inode { # 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 & MAXINT; + $Block[$blocknum][ $offset + I_NLKS ] = 0; my $i = $offset; foreach my $datablocknum (@blklist) { @@ -233,6 +233,7 @@ sub increment_link_count { my $inum = shift; my ( $blocknum, $offset ) = get_inode_block_offset($inum); $Block[$blocknum][ $offset + I_NLKS ] --; + $Block[$blocknum][ $offset + I_NLKS ] &= MAXINT; } # Convert an ASCII string into an array of 18-bit word values @@ -332,8 +333,8 @@ sub make_dir { # Add this to the previous directory # and fill the i-node with the details - add_direntry( $dirname, $inum ); fill_inode( $inum, $perms, I_DIRECTORY, $uid, 0, $dirblock ); + add_direntry( $dirname, $inum ); # Make this the top directory on the dirstack dprint("Pushing dir block $dirblock inum $inum to dirstack\n");