1
0
mirror of https://github.com/DoctorWkt/pdp7-unix.git synced 2026-01-25 19:57:20 +00:00
This commit is contained in:
Warren Toomey
2016-03-28 21:57:11 +10:00
4 changed files with 47 additions and 36 deletions

View File

@@ -68,7 +68,7 @@
lac f.flags
and d1
sna
jms 1f
jmp 1f
lacq
jms betwen; d0; i.size
jms dacisize

View File

@@ -36,7 +36,17 @@ maxargs=10
lac d1
sys intrp " make shell uninterruptable
sys getuid
" see if reading from a special file
cla; sys seek; 1; 0 " try seeking stdin forward
sna " new offset non-zero?
jmp 1f " no: input is a special file (ttyin,keyboard)
dzm prompt " yes: regular file, kill prompt
cla; sys seek; 0; 0 " seek file back to start
jmp newline
" stdin is a special file, see if superuser
1: sys getuid
sma " <0?
jmp newline " no
lac hash " yes: superuser

View File

@@ -65,36 +65,36 @@
jmp sysexit
.seek:
jms seektell
tad u.base
jms seektell " fetch offset & whence (return seek base)
tad u.base " add offset
"** 01-s1.pdf page 8
spa
jms error
lmq
lac f.flags
and d1
sna
jms 1f
lacq
jms betwen; d0; i.size
jms dacisize
spa " positive?
jms error " no: error
lmq " save position in MQ
lac f.flags " get file flags
and d1 " get write bit
sna " open for write?
jmp 1f " no
lacq " yes: get position
jms betwen; d0; i.size " between zero and size?
jms dacisize " no: store new size
jmp 2f
1:
lacq
jms betwen; d0; i.size
lac i.size
lacq " reading: get position
jms betwen; d0; i.size " between zero and size?
lac i.size " no: get current size
2:
dac f.badd
dac u.ac
jms fput
jmp sysexit
dac f.badd " save as offset
dac u.ac " return in AC
jms fput " copy fnode back to user area
jmp sysexit " return to user
.tell:
jms seektell
jms seektell " fetch offset & whence (return seek base)
cma
tad d1
tad u.base
dac u.ac
tad d1 " negate base
tad u.base " add to user offset
dac u.ac " return in user AC
jmp sysexit
.link:

View File

@@ -278,20 +278,21 @@ argname: 0
jms error " failed: return error directly to user
jmp argname i
" common code for seek/tell system calls
seektell: 0
jms arg
dac u.base
jms arg " fetch 1st arg after sys
dac u.base " save in u.base
"** 01-s1.pdf page 32
jms arg
dac u.limit
jms finac
lac u.limit
sna
jmp seektell i
sad d1
jmp .+3
lac i.size
jms arg " fetch 2nd arg (whence??)
dac u.limit " save in u.limit
jms finac " fetch fnode & inode for fd in AC
lac u.limit " get whence arg back
sna " zero?
jmp seektell i " yes, return zero (relative to start)
sad d1 " one?
jmp .+3 " yes: return pos (relative to current)
lac i.size " no: return file size (relative to end)
jmp seektell i
lac f.badd
jmp seektell i