1
0
mirror of https://github.com/livingcomputermuseum/pdp7-unix.git synced 2026-02-10 10:20:38 +00:00

I've written some code for the sys status syscall in a7out but I've not tested it yet.

This commit is contained in:
Warren Toomey
2016-03-03 14:15:35 +10:00
parent dd5e5bc2b3
commit 72473c411b

View File

@@ -551,7 +551,7 @@ sub cal {
# 22 badcal
# 23 capt
# 24 rele
# 25 status
25 => \&sys_status,
# 26 badcal
27 => \&sys_smes,
28 => \&sys_rmes,
@@ -946,6 +946,61 @@ sub sys_time {
return;
}
# Status system call
sub sys_status {
# This seems to called as follows:
# law statbuf
# sys status; scrname; dd
# but I can't tell if PC+1 or PC+2 holds the filename pointer.
# For now, I'll use PC+1. $AC seems to hold the pointer to the statbuf
# which, as far as we can tell is:
# word 0: permission bits
# words 1-7: disk block pointers
# word 8: user-id
# word 9: number of links
# word 10: size in words
# word 11: uniq, I have no idea what this is.
# The permission bits are:
# 200000 large file, bigger than 4096 words
# 000020 directory
# 000010 owner read
# 000004 owner write
# 000002 user write
# 000001 user write
# Get the start address of the string
# Convert this to a sensible ASCII filename
my $start = $Mem[ $PC + 1 ];
my $filename = mem2arg($start);
dprintf( "status file %s statbuf %06o\n", $filename, $AC );
# Get the file's details
my (undef,undef,$mode,$nlink,$uid,undef,undef,$size)= stat($filename);
# Set up the statbuf if we got a result
if ($nlink) {
$Mem[ $AC+8 ]= $uid & MAXINT;
$Mem[ $AC+9 ]= $nlink & MAXINT;
$Mem[ $AC+10 ]= $size & MAXINT; # Yes, I know, not words
my $perms=0;
$perms= 01 if ($mode & 02); # World writable
$perms|= 02 if ($mode & 04); # World readable
$perms|= 04 if ($mode & 0200); # Owner writable
$perms|= 010 if ($mode & 0400); # Owner readable
$perms|= 020 if ( -d $filename); # Directory
$perms|= 0200000 if ($size > 4096); # Large file
$Mem[ $AC ] = $perms;
# Set AC to zero as we got something, else return -1
$AC= 0;
} else {
$AC= MAXINT;
}
$PC += 3;
return;
}
# Convert an 18-bit word into two ASCII characters and return them.
# Don't return NUL characters
sub word2ascii {