From 7fcf1d230c87707ae629d2ac81fcfe3766a0a2e1 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Wed, 23 Mar 2016 11:25:22 +1000 Subject: [PATCH] I added a way for a file to be given a specific i-number, needed for i-num 1. --- build/proto | 3 ++- tools/mkfs7 | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/build/proto b/build/proto index ea2a82d..3b96e62 100644 --- a/build/proto +++ b/build/proto @@ -1,7 +1,7 @@ # Prototype file for PDP-7 Unix filesystem layout # # Entries are one of: -# filename f[r-][w-][r-][w-] uid local_file_to_insert +# filename f[r-][w-][r-][w-] uid local_file_to_insert [inumber] # dirname d[r-][w-][r-][w-] uid [inumber] # device i[r-][w-][r-][w-] uid inumber # link l---- inumber @@ -12,6 +12,7 @@ # Format was inspired by 6th Edition mkfs # dd drwr- -1 4 + core frwrw -1 /dev/null 1 system drwr- -1 3 ttyin irwr- -1 6 keyboard irwr- -1 7 diff --git a/tools/mkfs7 b/tools/mkfs7 index 90242b1..f5cf81e 100755 --- a/tools/mkfs7 +++ b/tools/mkfs7 @@ -378,7 +378,7 @@ sub read_word { # filesystem. Add an entry to this file in the current directory on # the dirstack. sub add_file { - my ( $name, $perms, $uid, $extfile ) = @_; + my ( $name, $perms, $uid, $extfile, $inum ) = @_; dprintf( "Adding file %s perms %06o uid %d extfile %s\n", $name, $perms, $uid, $extfile ); @@ -389,11 +389,11 @@ sub add_file { my $isbinary = 0; my $c = getc($IN); seek( $IN, 0, 0 ); - $isbinary = 1 if ( ( ord($c) & 0300 ) == 0200 ); + $isbinary = 1 if ($c && (( ord($c) & 0300 ) == 0200 )); # Read the whole file into a buffer, converting from ASCII or sixbit encoding my @buf; - my $size; + my $size=0; while (1) { if ($isbinary) { @@ -418,13 +418,15 @@ sub add_file { # Put the contents of the file into the blocks my ($blocknum, $offset)= ($blklist[0], 0); + if ($blocknum) { dprint("Filling block $blocknum with content from $extfile\n"); - foreach my $i (0 .. $size-1) { - $Block[$blocknum][$offset++]= $buf[$i]; - if ( $offset == WORDSPERBLK ) { - $offset = 0; - $blocknum++; - dprint("Filling block $blocknum with content from $extfile\n"); + foreach my $i (0 .. $size-1) { + $Block[$blocknum][$offset++]= $buf[$i]; + if ( $offset == WORDSPERBLK ) { + $offset = 0; + $blocknum++; + dprint("Filling block $blocknum with content from $extfile\n"); + } } } @@ -437,7 +439,7 @@ sub add_file { } # Allocate and fill in the i-node - my $inum = allocate_inode(); + $inum = allocate_inode($inum); if ($large) { fill_inode( $inum, $perms, I_FILE, $uid, $size, @indblocks ); } else { @@ -517,8 +519,8 @@ sub parse_proto_file { next; } if ( $type eq I_FILE ) { - my ( $name, $permstr, $uid, $extfile ) = @words; - add_file( $name, $perms, $uid, $extfile ); + my ( $name, $permstr, $uid, $extfile, $inum ) = @words; + add_file( $name, $perms, $uid, $extfile, $inum ); next; } if ( $type eq I_SPECIAL ) {