From d33ce4c69fbe4517070ac99bafd108cf5c8b1203 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Thu, 3 Mar 2016 16:35:05 +1000 Subject: [PATCH] Based on the details of the directory structure that Phil found, I've modified the a7out and the wktls.s program to reflect this. --- src/other/wktls.s | 14 +++++++++----- tools/a7out | 19 +++++++++++++++---- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/other/wktls.s b/src/other/wktls.s index e911900..f8dba88 100644 --- a/src/other/wktls.s +++ b/src/other/wktls.s @@ -20,17 +20,21 @@ fileloop: lac ibufptr " Point bufptr at the base of the buffer dac bufptr +" Each directory entry is eight words. We need to print out +" the filename which is in words 2 to 5. printloop: + + isz bufptr " Move up to the filename lac d1 sys write; bufptr:0; 4 " Write a filename out to stdout lac d1 sys write; newline; 1 " followed by a newline - lac bufptr " Add 4 to the bufptr - tad d4 + lac bufptr " Add 7 to the bufptr + tad d7 dac bufptr - -4 - tad count " Decrement the count of words by 4 + -8 + tad count " Decrement the count of words by 8 dac count sza " Anything left in the buffer to print? jmp printloop " Yes, stuff left to print @@ -47,7 +51,7 @@ newline: 012000 fd: 0 d1: 1 " stdout fd -d4: 4 +d7: 7 count: 0 " Input buffer for read diff --git a/tools/a7out b/tools/a7out index 9412614..2fa19cd 100755 --- a/tools/a7out +++ b/tools/a7out @@ -666,16 +666,27 @@ sub opensomething { return($FH); } - # It's a directory. For now, until we fully understand the code, - # I'm going to write space-padded filenames to a temporary - # directory, open and unlink it, and return the FH + # It's a directory. The on-disk format for this was: + # d.i: .=.+1 " inode number + # d.name: .=.+4 " name (space padded) + # d.uniq: .=.+1 " unique number from directory inode + # followed by two unused words + # The code creates a temporary file and fills in the i-node numbers + # and space padded filenames from the directory. The file is closed + # opened read-only and unlinked, and the open filehandle is returned. opendir(my $dh, $filename) || return(undef); open( $FH, ">", $tempfile) || return(undef); dprintf("Converting directory $filename\n"); my @list= sort(readdir($dh)); foreach my $name (@list) { - printf( $FH "%-8s", substr( $name, 0, 8 ) ); + # Get the file's i-node number + my (undef,$inode)= stat($name); + + # ARGH! For now we are still read/writing ASCII files, so there's + # no way to represent a proper 18-bit value. For now I'll pad + # with spaces to create the record + printf( $FH " %-8s ", substr( $name, 0, 8 ) ); } closedir($dh); close($FH);