home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
UNIFLEX
/
UNIFLEX
/
UniFLEX_Std.Utils1.tar.Z
/
UniFLEX_Std.Utils1.tar
/
utils1
/
fcheck
< prev
next >
Wrap
Text File
|
1981-09-01
|
13KB
|
751 lines
opt nol,pag
ttl Free block check program
lib sysdef
opt lis
pag
org 0
* Free block check program
fch sys update update the system
ldd 0,s get arg count
cmpd #2 is it ok?
bne fch8 error?
ldd 4,s get arg
std iopn2 set sys call
sys ind,iopn open the device
bes fch8 error?
std dfd save file desc
* check for block type device
ldd dfd get file desc
sys seek,0,512,0 seek to sir
ldd dfd
sys read,sir,512 read in the sir
bes fch8
ldd sir+16 get fdn block count
std fdcnt save it
addd #2 set 1st avail block number
std frbl
tst sir+18 check if too big for this program (65000 max blocks)
bne fch8
ldd sir+19 get volume size
std vlcnt save it
ldx #bm point to bit map
ldd #0
fch4 std 0,x++ zero bit map
cmpx #bm+BMSZ end of map?
bne fch4
jsr frl find free list blocks
jsr fdn find allocated blocks
jsr filin fill in rest of map
jsr lost report lost blocks
jsr rprt report all data found
ldd #0
sys term exit
fch8 swi temp error routine
*
* report data collected
*
rprt ldx #rm1 header
jsr pms print it
ldx #rm2 total files
ldd bfc add up file counts
addd cfc
addd dfc
addd rfc
jsr npms
ldd rfc get regular file count
ldx #rm3
jsr npms
ldd dfc directory file count
ldx #rm4
jsr npms
ldd bfc block device count
ldx #rm5
jsr npms
ldd cfc character device count
ldx #rm6
jsr npms
ldd sindc single ind map blocks
addd dindc calc total blocks used
addd tindc
addd dirbc
addd rgfbc
ldx #rm7 print totals
jsr npms
ldd rgfbc regular file block count
ldx #rm8
jsr npms
ldd dirbc directory block count
ldx #rm9
jsr npms
ldd sindc single ind map blocks
ldx #rm10
jsr npms
ldd dindc double ind map blocks
ldx #rm11
jsr npms
ldd tindc triple ind map blocks
ldx #rm12
jsr npms
ldd fdcnt fdn block count
ldx #rm13
jsr npms
ldd fbc free block count
ldx #rm14
jsr npms
ldd ufdc used fdn count
ldx #rm15
jsr npms
ldd ffdc free fdn count
ldx #rm16
jsr npms
ldd oorfb out of range blocks
ldx #rm17
jsr npms
ldd dupbc dupd blocks in free
ldx #rm18
jsr npms
ldd oorflb bad file blocks
ldx #rm21
jsr npms
ldd dupfc dupd file blocks
ldx #rm19
jsr npms
ldd mbcnt missing block count
ldx #rm20
jmp npms return
*
* Output number in D
*
ostr ldx #stbf point to buffer
jsr decst convert number to string
std iwrt3 save in call
ldd #stbf set string begin
std iwrt2
ldd #1 set file desc
sys ind,iwrt output number
rts return
*
* print string routines
*
npms pshs x save string ptr
bsr ostr print number
puls x
pms stx iwrt2 set string in call
ldd #0 set counter
pms2 tst 0,x+ find string end
beq pms3
incb
bra pms2
pms3 std iwrt3 save count
ldd #1 set output
sys ind,iwrt
rts return
*
* Find all blocks in free list
*
frl ldd #0 zero counters
std fbc
std oorfb
std dupbc
ldx #sir+$bd point to incore free list
ldb 0,x+ get count
beq frl6 no free?
frl2 bsr gb get blocks from list
tst 0,x bad block?
bne frl8
ldd 1,x get link block
beq frl6 end of list?
cmpd vlcnt in range?
bhi frl8
cmpd frbl
blo frl8
jsr rfb read in block
ldx #bbuf point to block data
ldb #100 set block count
bra frl2
frl6 rts return
frl8 ldx #bdlne print error
jsr pms
ldd #0
sys term exit
*
* Get blocks from free list
*
gb pshs b save count
ldb 0,s
decb find block start location
lda #3 3 bytes per block
mul
leax d,x point to end of list
gb2 tst 0,x out of range?
beq gb4
gb3 ldd oorfb get counter
addd #1 bump by one
std oorfb save new
bra gb5
gb4 ldd 1,x get block number
beq gb5
cmpd vlcnt check if in range
bhi gb3
cmpd frbl
blo gb3
bsr smap set block in map
ldd fbc get free count
addd #1 bump it
std fbc
gb5 leax -3,x get to next entry
dec 0,s dec the count
bne gb2 finished?
leax 3,x fix pointer
puls b,pc return
*
* read in block in d
*
dfsk std isk3 save blocj number
clr isk2
lsl isk3+1 mult by 512 char per block
rol isk3
rol isk2
ldd dfd get file desc
sys ind,isk seek to block
ldd dfd
rts
*
rfb bsr dfsk
sys read,bbuf,512 read block
lbes drder error?
rts return
*
* Set bit map bit for block in d
*
smap pshs x save x
bsr map find map location
bita 0,x bit already set?
bne smap2
ora 0,x set bit
sta 0,x
puls x,pc return
smap2 ldd dupbc get dup count
addd #1 bump it
std dupbc
puls x,pc return
*
* Find bit map location
*
map ldx #bm point to map
pshs b save low byte
lsra divide by 8
rorb
lsra
rorb
lsra
rorb
leax d,x point to entry
lda #$80 set bit
puls b get low byte
andb #$7
beq map4
map2 lsra adjust bit pos
decb
bne map2
map4 rts return
*
* filin
*
filin ldd #0
pshs d
filin2 jsr map fill in system blocks
ora 0,x set bit
sta 0,x
ldd 0,s get block count
addd #1
std 0,s
cmpd frbl end of fdn blocks?
bne filin2
puls d,pc return
*
* Find all file blocks from the fdns
*
fdn ldd #0 set counter
pshs d
fdn2 addd #2 find fdn block number
jsr dfsk seek to it
sys read,fdbuf,512 read in fdn block
lbes drder error?
ldu #fdbuf point to fdns
ldb #512/64 set fdn per block count
pshs b
fdn4 pshs u
bsr dof process an fdn
puls u
leau 64,u move to next fdn
dec 0,s dec the count
bne fdn4
puls b
ldd 0,s get fdn counter
addd #1 bump by 1
std 0,s
cmpd fdcnt finished?
blo fdn2
puls d,pc return
*
* Process the data in the fdn pointed at by U.
*
dof clr dir clear mode flags
lda 0,u get modes
bne dof1 is it active?
ldd ffdc get free fdn counter
addd #1 update it
std ffdc
rts return
dof1 pshs a save modes
ldd ufdc get used fdn count
addd #1 update it
std ufdc
puls a
bita #$2 is it block device?
beq dof2
ldd bfc get count
addd #1 update
std bfc
rts return
dof2 bita #$4 is it char device?
beq dof3
ldd cfc get count
addd #1 update it
std cfc
rts return
dof3 bita #$8 is it a dir?
beq dof35
inc dir set dir flag
ldd dfc get counter
addd #1
std dfc
bra dof4
dof35 ldd rfc get reg file block counter
addd #1 update it
std rfc
dof4 bsr ffb procress blocks
rts return
*
* Find all blocks in the fdn pointed at by U.
*
ffb leau 9,u point to map
ldb #10 process direct map first
pshs b save counter
ffb2 jsr torfb in range?
bne ffb3
ldd 1,u get block number
beq ffb3 is it null?
jsr sfmap set bit in map
ffb3 leau 3,u get to next
dec 0,s end of direct?
bne ffb2
puls b
jsr torfb in range?
bne ffb4
ldd 1,u get single ind block
beq ffb4
bsr sind process it
ffb4 leau 3,u get double ind block
jsr torfb in range?
bne ffb5
ldd 1,u
beq ffb5
jsr dind process it
ffb5 leau 3,u get triple ind block
jsr torfb in range?
bne ffb6
ldd 1,u
beq ffb6
jsr tind process it
ffb6 rts return
*
* Process single ind block
*
sind inc sin set mode
pshs d save block
jsr sfmap set map bit
puls d
jsr rfb read in block
ldx #bbuf point to data
ldb #128 set counter
pshs b
sind2 jsr torbx in range?
bne sind4
ldd 1,x get block number
beq sind4
inc rbflg
jsr sfmap set block in map
clr rbflg
sind4 leax 3,x get next entry
dec 0,s dec the count
bne sind2
clr sin clear mode
puls b,pc return
*
* Process double ind block
*
dind inc din set mode
pshs d save block
jsr sfmap set map bit
puls d
jsr rdib read in block
ldx #dbuf point to data
ldb #128 set counter
pshs b
dind2 jsr torbx in range?
bne dind4
ldd 1,x get block number
beq dind4
pshs x
jsr sind process as single
puls x
dind4 leax 3,x get next entry
dec 0,s dec the count
bne dind2
clr din clear mode
puls b,pc return
*
* Process triple ind block
*
tind inc tin set mode
pshs d save block
jsr sfmap set map bit
puls d
jsr rtib read in block
ldx #tbuf point to data
ldb #128 set counter
pshs b
tind2 jsr torbx in range?
bne tind4
ldd 1,x get block number
beq tind4
pshs x
jsr dind process as double
puls x
tind4 leax 3,x get next entry
dec 0,s dec the count
bne tind2
clr tin clear mode
puls b,pc return
*
* Set bit map bit for file allocated block
*
sfmap pshs d,x
jsr tbnd in range?
bne sfmap8
tst rbflg reg block?
bne sfmap3
tst tin find the block type
beq sfmap1 and bump its counter
ldd tindc
addd #1
std tindc
bra sfmap5
sfmap1 tst din is it double?
beq sfmap2
ldd dindc
addd #1
std dindc
bra sfmap5
sfmap2 tst sin single ind block?
beq sfmap3
ldd sindc
addd #1
std sindc
bra sfmap5
sfmap3 tst dir is it dir block?
beq sfmap4
ldd dirbc
addd #1
std dirbc
bra sfmap5
sfmap4 ldd rgfbc must be reg file block
addd #1
std rgfbc
sfmap5 puls d get block number
jsr map find in bit map
bit a 0,x is it already there?
bne sfmap6
ora 0,x set bit on
sta 0,x
puls x,pc return
sfmap6 ldd dupfc get dup count
addd #1 bump it
std dupfc
puls x,pc return
sfmap8 puls d,x,pc return
*
* reads for double & triple indirection
*
rdib jsr dfsk do seek
sys read,dbuf,512
lbes drder error?
rts
*
rtib jsr dfsk do seek
sys read,tbuf,512
lbes drder error?
rts return
*
* lost
*
lost ldd vlcnt get volume block count
lsra divide by 8
rorb
lsra
rorb
lsra
rorb
pshs d save result
ldx #bm point to bit map
lost2 lda 0,x+ get a byte
cmpa #$ff all filled in?
beq lost5
ldb #8 set bit count
bsr cntms count missing blocks
lost5 ldd 0,s get block count
subd #1
std 0,s
bne lost2 finished?
ldb vlcnt+1 get remainder
andb #7
beq lost8
lda 0,x get reset of bits
bsr cntms count missing blocks
lost8 puls d,pc return
*
* count missing blocks
*
cntms rola
bcs cntms4 missing bit?
pshs d
ldd mbcnt get missing count
addd #1
std mbcnt
puls d
cntms4 decb dec the count
bne cntms
rts return
*
* out of range block tests
*
torbx tst 0,x hi byte set
bne torfb2
rts return
torfb tst 0,u in range?
bne torfb2
rts
torfb2 ldd oorflb get block counter
addd #1 bump it
std oorflb
rts return
*
tbnd cmpd vlcnt past volume end?
bhi torfb2
cmpd frbl in fdns?
blo torfb2
sez set status ok
rts return
*
* report read error
*
drder ldx #drdms
jsr pms
ldd #0
sys term exit
*
* decst
*
* Convert the number in D into an ascii string
* representing a decimal number. The string
* is pointed at by X (X should be set on entry!)
* Also on exit, D has the length of the string.
* The second entry point, 'decstn' will not print
* leading spaces for leading zeroes, but will
* suppress all leading zero info. All strings
* start with a space.
*
decst pshs x save user pointer
clr 0,-s set suppression flag
bra decst2
*
decstn pshs x save user pointer
clr 0,-s
inc 0,s set for no fielding
decst2 pshs a
lda #$20 setup leading space
sta 0,x+ save in buffer
puls a
clr 0,-s set up bookkeeping
clr 0,-s
decst3 ldy #conlst point to constants
decst4 cmpd 0,y compare number to constant
blo decst5
subd 0,y do subtraction of constant
inc 1,s bump digits counter
bra decst4
decst5 pshs a save number
tst 2,s zero digit?
bne decst6
tst 1,s any numbers output yet?
bne decst6
tst 3,s doing suppression?
bne decst8
lda #$20 set up space
bra decst7
decst6 lda 2,s get digit count
inc 1,s set 'got one' flag
ora #$30 make ascii
decst7 sta 0,x+ save in buffer
decst8 puls a reset number
clr 1,s clear out digit
leay 2,y bump constant ptr
cmpy #conend end of list?
bne decst4
leas 3,s clean up stack
orb #$30 make last digit
stb 0,x+ save in buffer
clr 0,x null terminate string
tfr x,d
subd 0,s calculate string length
puls x,pc return
* constants for convert
conlst fdb 10000
fdb 1000
fdb 100
fdb 10
conend equ * end of list
rm1 fcc $d,'Disk Summary',$d,$d,'Files:',$d,0
rm2 fcc ' total files',$d,0
rm3 fcc ' regular files',$d, 0
rm4 fcc ' directories',$d,0
rm5 fcc ' block device files',$d,0
rm6 fcc ' character device files',$d,$d,'Block usage:',$d,0
rm7 fcc ' total blocks used',$d,0
rm8 fcc ' regular blocks',$d,0
rm9 fcc ' directory blocks',$d,0
rm10 fcc ' blocks used for 1st level mapping',$d,0
rm11 fcc ' blocks used for 2nd level mapping',$d,0
rm12 fcc ' blocks used for 3rd level mapping',$d,0
rm13 fcc ' fdn blocks',$d,' 2 system blocks',$d,0
rm14 fcc ' unused blocks',$d,$d,'Fdn usage:',$d,0
rm15 fcc ' busy fdns',$d,0
rm16 fcc ' free fdns',$d,$d,'Error information:',$d,0
rm17 fcc ' out-of-range free blocks',$d,0
rm18 fcc ' duplicate blocks in free list',$d,0
rm19 fcc ' duplicate file blocks',$d,0
rm20 fcc ' missing blocks',$d,$d,0
rm21 fcc ' out-of-range file blocks',$d,0
bdlne fcc 'Bad link in free list - check aborted.',$d,0
drdms fcc 'Disk read error - check aborted.',$d,0
BMSZ equ 1024*8-512 bit map size
isk fcb seek
isk2 fcb 0
isk3 fdb 0
fcb 0,0,0
iwrt fcb write
iwrt2 fdb 0
iwrt3 fdb 0
iopn fcb open
iopn2 fdb 0,0
dfd rmb 2 file desc
fdcnt rmb 2 fdn block count
vlcnt rmb 2 volume block count
frbl rmb 2 first free block count
fbc rmb 2 free block count
oorfb rmb 2 out of range count (free list)
dupbc rmb 2 dup block count (free list)
ffdc rmb 2 free fdn count
ufdc rmb 2 used fdn count
dir rmb 1 dir mode flag
tin rmb 1 triple mode
din rmb 1 double mode
sin rmb 1 single mode
rbflg rmb 1 reg block flag
bfc rmb 2 block file count
cfc rmb 2 character file count
dfc rmb 2 dir file count
rfc rmb 2 reg file count
sindc rmb 2 single ind block count
dindc rmb 2 double ind block count
tindc rmb 2 triple ind block count
dirbc rmb 2 dir file block count
rgfbc rmb 2 reg file block count
dupfc rmb 2 dup blocks in files count
mbcnt rmb 2 missing block count
oorflb rmb 2 out of range file blocks
stbf rmb 16 string buffer
zzzzz equ *
org $800
fdbuf rmb 512
dbuf rmb 512
tbuf rmb 512
sir rmb 512
bbuf rmb 512
bm rmb BMSZ
end fch