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 / printcheck < prev    next >
Text File  |  1981-09-01  |  14KB  |  784 lines

  1.  opt nol,pag
  2.  ttl Free block check program
  3.  lib sysdef
  4.  opt lis
  5.  pag
  6.  
  7.  info UniFLEX blockcheck
  8.  info Version 1, Released January 19, 1981
  9.  info Copyright, (C) 1981, by
  10.  info Technical Systems Consultants, Inc.
  11.  info All rights reserved.
  12.  
  13.  org 0
  14.  
  15. * Free block check program
  16.  
  17. fch sys update update the system
  18.  ldd 0,s get arg count
  19.  cmpd #2 is it ok?
  20.  bne fch8 error?
  21.  ldd 4,s get arg
  22.  std iopn2 set sys call
  23.  sys ind,iopn open the device
  24.  bes fch8 error?
  25.  std dfd save file desc
  26. * check for block type device
  27.  ldd dfd get file desc
  28.  sys seek,0,512,0 seek to sir
  29.  ldd dfd
  30.  sys read,sir,512 read in the sir
  31.  bes fch8
  32.  ldd sir+16 get fdn block count
  33.  std fdcnt save it
  34.  addd #2 set 1st avail block number
  35.  std frbl
  36.  tst sir+18 check if too big for this program (65000 max blocks)
  37.  bne fch8
  38.  ldd sir+19 get volume size
  39.  std vlcnt save it
  40.  ldx #bm point to bit map
  41.  ldd #0
  42. fch4 std 0,x++ zero bit map
  43.  cmpx #bm+BMSZ end of map?
  44.  bne fch4
  45.  jsr frl find free list blocks
  46.  jsr fdn find allocated blocks
  47.  jsr filin fill in rest of map
  48.  jsr lost report lost blocks
  49.  jsr rprt report all data found
  50.  ldd #0
  51.  sys term exit
  52. fch8 swi temp error
  53.  
  54. *
  55. * report data collected
  56. *
  57.  
  58. rprt ldx #rm1 header
  59.  jsr pms print it
  60.  ldx #rm2 total files
  61.  ldd bfc add up file counts
  62.  addd cfc
  63.  addd dfc
  64.  addd rfc
  65.  jsr npms
  66.  ldd rfc get regular file count
  67.  ldx #rm3
  68.  jsr npms
  69.  ldd dfc directory file count
  70.  ldx #rm4
  71.  jsr npms
  72.  ldd bfc block device count
  73.  ldx #rm5
  74.  jsr npms
  75.  ldd cfc character device count
  76.  ldx #rm6
  77.  jsr npms
  78.  ldd sindc single ind map blocks
  79.  addd dindc calc total blocks used
  80.  addd tindc
  81.  addd dirbc
  82.  addd rgfbc
  83.  ldx #rm7 print totals
  84.  jsr npms
  85.  ldd rgfbc regular file block count
  86.  ldx #rm8
  87.  jsr npms
  88.  ldd dirbc directory block count
  89.  ldx #rm9
  90.  jsr npms
  91.  ldd sindc single ind map blocks
  92.  addd dindc ***
  93.  addd tindc
  94.  ldx #rm10
  95.  jsr npms
  96.  bra outxx ***
  97.  ldd dindc double ind map blocks
  98.  ldx #rm11
  99.  jsr npms
  100.  ldd tindc triple ind map blocks
  101.  ldx #rm12
  102.  jsr npms
  103. outxx
  104.  ldd fdcnt fdn block count
  105.  ldx #rm13
  106.  jsr npms
  107.  ldd fbc free block count
  108.  ldx #rm14
  109.  jsr npms
  110.  ldd ufdc used fdn count
  111.  ldx #rm15
  112.  jsr npms
  113.  ldd ffdc free fdn count
  114.  ldx #rm16
  115.  jsr npms
  116.  ldd oorfb out of range blocks
  117.  ldx #rm17
  118.  jsr npms
  119.  ldd dupbc dupd blocks in free
  120.  ldx #rm18
  121.  jsr npms
  122.  ldd oorflb bad file blocks
  123.  ldx #rm21
  124.  jsr npms
  125.  ldd dupfc dupd file blocks
  126.  ldx #rm19
  127.  jsr npms
  128.  ldd mbcnt missing block count
  129.  ldx #rm20
  130.  jmp npms return
  131.  
  132. *
  133. * Output number in D
  134. *
  135.  
  136. ostr ldx #stbf point to buffer
  137.  jsr decst convert number to string
  138.  std iwrt3 save in call
  139.  ldd #stbf set string begin
  140.  std iwrt2
  141.  ldd #1 set file desc
  142.  sys ind,iwrt output number
  143.  rts return
  144.  
  145. *
  146. * print string routines
  147. *
  148.  
  149. npms pshs x save string ptr
  150.  bsr ostr print number
  151.  puls x
  152. pms stx iwrt2 set string in call
  153.  ldd #0 set counter
  154. pms2 tst 0,x+ find string end
  155.  beq pms3
  156.  incb
  157.  bra pms2
  158. pms3 std iwrt3 save count
  159.  ldd #1 set output
  160.  sys ind,iwrt
  161.  rts return
  162.  
  163. *
  164. * Find all blocks in free list
  165. *
  166.  
  167. frl ldd #0 zero counters
  168.  std fbc
  169.  std oorfb
  170.  std dupbc
  171.  ldx #sir+$bd point to incore free list
  172.  ldb 0,x+ get count
  173.  beq frl6 no free?
  174. frl2 bsr gb get blocks from list
  175.  tst 0,x bad block?
  176.  bne frl8
  177.  ldd 1,x get link block
  178.  beq frl6 end of list?
  179.  cmpd vlcnt in range?
  180.  bhi frl8
  181.  cmpd frbl
  182.  blo frl8
  183.  jsr rfb read in block
  184.  ldx #bbuf point to block data
  185.  ldb #100 set block count
  186.  bra frl2
  187. frl6 rts return
  188. frl8 ldx #bdlne print error
  189.  jsr pms
  190.  ldd #0
  191.  sys term exit
  192.  
  193. *
  194. * Get blocks from free list
  195. *
  196.  
  197. gb pshs b save count
  198.  ldb 0,s
  199.  decb find block start location
  200.  lda #3 3 bytes per block
  201.  mul
  202.  leax d,x point to end of list
  203. gb2 tst 0,x out of range?
  204.  beq gb4
  205. gb3 ldd oorfb get counter
  206.  addd #1 bump by one
  207.  std oorfb save new
  208.  bra gb5
  209. gb4 ldd 1,x get block number
  210.  beq gb5
  211.  cmpd vlcnt check if in range
  212.  bhi gb3
  213.  cmpd frbl
  214.  blo gb3
  215.  bsr smap set block in map
  216.  ldd fbc get free count
  217.  addd #1 bump it
  218.  std fbc
  219. gb5 leax -3,x get to next entry
  220.  dec 0,s dec the count
  221.  bne gb2 finished?
  222.  leax 3,x fix pointer
  223.  puls b,pc return
  224.  
  225. *
  226. * read in block in d
  227. *
  228.  
  229. dfsk std isk3 save blocj number
  230.  clr isk2
  231.  lsl isk3+1 mult by 512 char per block
  232.  rol isk3
  233.  rol isk2
  234.  ldd dfd get file desc
  235.  sys ind,isk seek to block
  236.  ldd dfd
  237.  rts
  238. *
  239. rfb bsr dfsk
  240.  sys read,bbuf,512 read block
  241.  lbes drder error?
  242.  rts return
  243.  
  244. *
  245. * Set bit map bit for block in d
  246. *
  247.  
  248. smap pshs d,x save x
  249.  bsr map find map location
  250.  bita 0,x bit already set?
  251.  bne smap2
  252.  ora 0,x set bit
  253.  sta 0,x
  254.  puls d,x,pc return
  255. smap2 ldd dupbc get dup count
  256.  addd #1 bump it
  257.  std dupbc
  258.  ldd 0,s get block number
  259.  ldx #pdpb
  260.  jsr npms print dup block
  261.  puls d,x,pc return
  262.  
  263. *
  264. * Find bit map location
  265. *
  266.  
  267. map ldx #bm point to map
  268.  pshs b save low byte
  269.  lsra divide by 8
  270.  rorb
  271.  lsra
  272.  rorb
  273.  lsra
  274.  rorb
  275.  leax d,x point to entry
  276.  lda #$80 set bit
  277.  puls b get low byte
  278.  andb #$7
  279.  beq map4
  280. map2 lsra adjust bit pos
  281.  decb
  282.  bne map2
  283. map4 rts return
  284.  
  285. *
  286. * filin
  287. *
  288.  
  289. filin ldd #0
  290.  pshs d
  291. filin2 jsr map fill in system blocks
  292.  ora 0,x set bit
  293.  sta 0,x
  294.  ldd 0,s get block count
  295.  addd #1
  296.  std 0,s
  297.  cmpd frbl end of fdn blocks?
  298.  bne filin2
  299.  puls d,pc return
  300.  
  301. *
  302. * Find all file blocks from the fdns
  303. *
  304.  
  305. fdn ldd #0 set counter
  306.  pshs d
  307. fdn2 addd #2 find fdn block number
  308.  jsr dfsk seek to it
  309.  sys read,fdbuf,512 read in fdn block
  310.  lbes drder error?
  311.  ldu #fdbuf point to fdns
  312.  ldb #512/64 set fdn per block count
  313.  pshs b
  314. fdn4 pshs u
  315.  bsr dof process an fdn
  316.  puls u
  317.  leau 64,u move to next fdn
  318.  dec 0,s dec the count
  319.  bne fdn4
  320.  puls b
  321.  ldd 0,s get fdn counter
  322.  addd #1 bump by 1
  323.  std 0,s
  324.  cmpd fdcnt finished?
  325.  blo fdn2
  326.  puls d,pc return
  327.  
  328. *
  329. * Process the data in the fdn pointed at by U.
  330. *
  331.  
  332. dof clr dir clear mode flags
  333.  lda 0,u get modes
  334.  bne dof1 is it active?
  335.  ldd ffdc get free fdn counter
  336.  addd #1 update it
  337.  std ffdc
  338.  rts return
  339. dof1 pshs a save modes
  340.  ldd ufdc get used fdn count
  341.  addd #1 update it
  342.  std ufdc
  343.  puls a
  344.  bita #$2 is it block device?
  345.  beq dof2
  346.  ldd bfc get count
  347.  addd #1 update
  348.  std bfc
  349.  rts return
  350. dof2 bita #$4 is it char device?
  351.  beq dof3
  352.  ldd cfc get count
  353.  addd #1 update it
  354.  std cfc
  355.  rts return
  356. dof3 bita #$8 is it a dir?
  357.  beq dof35
  358.  inc dir set dir flag
  359.  ldd dfc get counter
  360.  addd #1
  361.  std dfc
  362.  bra dof4
  363. dof35 ldd rfc get reg file block counter
  364.  addd #1 update it
  365.  std rfc
  366. dof4 bsr ffb procress blocks
  367.  rts return
  368.  
  369. *
  370. * Find all blocks in the fdn pointed at by U.
  371. *
  372.  
  373. ffb leau 9,u point to map
  374.  ldb #10 process direct map first
  375.  pshs b save counter
  376. ffb2 jsr torfb in range?
  377.  bne ffb3
  378.  ldd 1,u get block number
  379.  beq ffb3 is it null?
  380.  jsr sfmap set bit in map
  381. ffb3 leau 3,u get to next
  382.  dec 0,s end of direct?
  383.  bne ffb2
  384.  puls b
  385.  jsr torfb in range?
  386.  bne ffb4
  387.  ldd 1,u get single ind block
  388.  beq ffb4
  389.  bsr sind process it
  390. ffb4 leau 3,u get double ind block
  391.  jsr torfb in range?
  392.  bne ffb5
  393.  ldd 1,u
  394.  beq ffb5
  395.  jsr dind process it
  396. ffb5 leau 3,u get triple ind block
  397.  jsr torfb in range?
  398.  bne ffb6
  399.  ldd 1,u
  400.  beq ffb6
  401.  jsr tind process it
  402. ffb6 rts return
  403.  
  404. *
  405. * Process single ind block
  406. *
  407.  
  408. sind inc sin set mode
  409.  pshs d save block
  410.  jsr sfmap set map bit
  411.  puls d
  412.  jsr rfb read in block
  413.  ldx #bbuf point to data
  414.  ldb #128 set counter
  415.  pshs b
  416. sind2 jsr torbx in range?
  417.  bne sind4
  418.  ldd 1,x get block number
  419.  beq sind4
  420.  inc rbflg
  421.  jsr sfmap set block in map
  422.  clr rbflg
  423. sind4 leax 3,x get next entry
  424.  dec 0,s dec the count
  425.  bne sind2
  426.  clr sin clear mode
  427.  puls b,pc return
  428.  
  429. *
  430. * Process double ind block
  431. *
  432.  
  433. dind inc din set mode
  434.  pshs d save block
  435.  jsr sfmap set map bit
  436.  puls d
  437.  jsr rdib read in block
  438.  ldx #dbuf point to data
  439.  ldb #128 set counter
  440.  pshs b
  441. dind2 jsr torbx in range?
  442.  bne dind4
  443.  ldd 1,x get block number
  444.  beq dind4
  445.  pshs x
  446.  jsr sind process as single
  447.  puls x
  448. dind4 leax 3,x get next entry
  449.  dec 0,s dec the count
  450.  bne dind2
  451.  clr din clear mode
  452.  puls b,pc return
  453.  
  454. *
  455. * Process triple ind block
  456. *
  457.  
  458. tind inc tin set mode
  459.  pshs d save block
  460.  jsr sfmap set map bit
  461.  puls d
  462.  jsr rtib read in block
  463.  ldx #tbuf point to data
  464.  ldb #128 set counter
  465.  pshs b
  466. tind2 jsr torbx in range?
  467.  bne tind4
  468.  ldd 1,x get block number
  469.  beq tind4
  470.  pshs x
  471.  jsr dind process as double
  472.  puls x
  473. tind4 leax 3,x get next entry
  474.  dec 0,s dec the count
  475.  bne tind2
  476.  clr tin clear mode
  477.  puls b,pc return
  478.  
  479. *
  480. * Set bit map bit for file allocated block
  481. *
  482.  
  483. sfmap pshs d,x
  484.  jsr tbnd in range?
  485.  bne sfmap8
  486.  tst rbflg reg block?
  487.  bne sfmap3
  488.  tst tin find the block type
  489.  beq sfmap1 and bump its counter
  490.  ldd tindc
  491.  addd #1
  492.  std tindc
  493.  bra sfmap5
  494. sfmap1 tst din is it double?
  495.  beq sfmap2
  496.  ldd dindc
  497.  addd #1
  498.  std dindc
  499.  bra sfmap5
  500. sfmap2 tst sin single ind block?
  501.  beq sfmap3
  502.  ldd sindc
  503.  addd #1
  504.  std sindc
  505.  bra sfmap5
  506. sfmap3 tst dir is it dir block?
  507.  beq sfmap4
  508.  ldd dirbc
  509.  addd #1
  510.  std dirbc
  511.  bra sfmap5
  512. sfmap4 ldd rgfbc must be reg file block
  513.  addd #1
  514.  std rgfbc
  515. sfmap5 ldd 0,s get block number
  516.  jsr map find in bit map
  517.  bit a 0,x is it already there?
  518.  bne sfmap6
  519.  ora 0,x set bit on
  520.  sta 0,x
  521.  puls d,x,pc return
  522. sfmap6 ldd dupfc get dup count
  523.  addd #1 bump it
  524.  std dupfc
  525.  puls d get block number
  526.  ldx #pdpb
  527.  jsr npms
  528.  puls x,pc return
  529. sfmap8 puls d,x,pc return
  530.  
  531. *
  532. * reads for double & triple indirection
  533. *
  534.  
  535. rdib jsr dfsk do seek
  536.  sys read,dbuf,512
  537.  lbes drder error?
  538.  rts
  539. *
  540. rtib jsr dfsk do seek
  541.  sys read,tbuf,512
  542.  lbes drder error?
  543.  rts return
  544.  
  545. *
  546. * lost
  547. *
  548.  
  549. lost ldd vlcnt get volume block count
  550.  lsra divide by 8
  551.  rorb
  552.  lsra
  553.  rorb
  554.  lsra
  555.  rorb
  556.  pshs d save result
  557.  ldx #bm point to bit map
  558. lost2 lda 0,x+ get a byte
  559.  cmpa #$ff all filled in?
  560.  beq lost5
  561.  ldb #8 set bit count
  562.  bsr cntms count missing blocks
  563. lost5 ldd 0,s get block count
  564.  subd #1
  565.  std 0,s
  566.  bne lost2 finished?
  567.  ldb vlcnt+1 get remainder
  568.  andb #7
  569.  beq lost8
  570.  lda 0,x get reset of bits
  571.  bsr cntms count missing blocks
  572. lost8 puls d,pc return
  573.  
  574. *
  575. * count missing blocks
  576. *
  577.  
  578. cntms clr 0,-s
  579. cntms2 rola
  580.  bcs cntms4 missing bit?
  581.  pshs d,x
  582.  ldd mbcnt get missing count
  583.  addd #1
  584.  std mbcnt
  585.  tfr x,d get bm ptr
  586.  subd #bm+1 calc pos
  587.  aslb
  588.  rola
  589.  aslb
  590.  rola
  591.  aslb
  592.  rola
  593.  orb 4,s
  594.  ldx #pmsb
  595.  jsr npms
  596.  puls d,x
  597. cntms4 inc 0,s
  598. cntms5 decb dec the count
  599.  bne cntms2
  600.  leas 1,s
  601.  rts return
  602.  
  603. *
  604. * out of range block tests
  605. *
  606.  
  607. torbx tst 0,x hi byte set
  608.  bne torfb2
  609.  rts return
  610. torfb tst 0,u in range?
  611.  bne torfb2
  612.  rts
  613. torfb2 ldd oorflb get block counter
  614.  addd #1 bump it
  615.  std oorflb
  616.  rts return
  617. *
  618. tbnd cmpd vlcnt past volume end?
  619.  bhi torfb2
  620.  cmpd frbl in fdns?
  621.  blo torfb2
  622.  sez set status ok
  623.  rts return
  624.  
  625. *
  626. * report read error
  627. *
  628.  
  629. drder ldx #drdms
  630.  jsr pms
  631.  ldd #0
  632.  sys term exit
  633.  
  634. *
  635. * decst
  636. *
  637. * Convert the number in D into an ascii string
  638. * representing a decimal number.  The string
  639. * is pointed at by X (X should be set on entry!)
  640. * Also on exit, D has the length of the string.
  641. * The second entry point, 'decstn' will not print
  642. * leading spaces for leading zeroes, but will
  643. * suppress all leading zero info.  All strings
  644. * start with a space.
  645. *
  646.  
  647. decst pshs x save user pointer
  648.  clr 0,-s set suppression flag
  649.  bra decst2
  650. *
  651. decstn pshs x save user pointer
  652.  clr 0,-s
  653.  inc 0,s set for no fielding
  654. decst2 pshs a
  655.  lda #$20 setup leading space
  656.  sta 0,x+ save in buffer
  657.  puls a
  658.  clr 0,-s set up bookkeeping
  659.  clr 0,-s
  660. decst3 ldy #conlst point to constants
  661. decst4 cmpd 0,y compare number to constant
  662.  blo decst5
  663.  subd 0,y do subtraction of constant
  664.  inc 1,s bump digits counter
  665.  bra decst4
  666. decst5 pshs a save number
  667.  tst 2,s zero digit?
  668.  bne decst6
  669.  tst 1,s any numbers output yet?
  670.  bne decst6
  671.  tst 3,s doing suppression?
  672.  bne decst8
  673.  lda #$20 set up space
  674.  bra decst7
  675. decst6 lda 2,s get digit count
  676.  inc 1,s set 'got one' flag
  677.  ora #$30 make ascii
  678. decst7 sta 0,x+ save in buffer
  679. decst8 puls a reset number
  680.  clr 1,s clear out digit
  681.  leay 2,y bump constant ptr
  682.  cmpy #conend end of list?
  683.  bne decst4
  684.  leas 3,s clean up stack
  685.  orb #$30 make last digit
  686.  stb 0,x+ save in buffer
  687.  clr 0,x null terminate string
  688.  tfr x,d
  689.  subd 0,s calculate string length
  690.  puls x,pc return
  691.  
  692. * constants for convert
  693.  
  694. conlst fdb 10000
  695.  fdb 1000
  696.  fdb 100
  697.  fdb 10
  698. conend equ * end of list
  699.  
  700. rm1 fcc $d,'Disk Summary',$d,$d,'Files:',$d,0
  701. rm2 fcc ' total files',$d,0
  702. rm3 fcc ' regular files',$d,0
  703. rm4 fcc ' directories',$d,0
  704. rm5 fcc ' block device files',$d,0
  705. rm6 fcc ' character device files',$d,$d,'Block usage:',$d,0
  706. rm7 fcc ' total blocks used',$d,0
  707. rm8 fcc ' regular blocks',$d,0
  708. rm9 fcc ' directory blocks',$d,0
  709. *rm10 fcc ' blocks used for 1st level mapping',$d,0
  710. rm10 fcc ' blocks used for file mapping',$d,0
  711. rm11 fcc ' blocks used for 2nd level mapping',$d,0
  712. rm12 fcc ' blocks used for 3rd level mapping',$d,0
  713. rm13 fcc ' fdn blocks',$d,'     2 system blocks',$d,0
  714. rm14 fcc ' unused blocks',$d,$d,'Fdn usage:',$d,0
  715. rm15 fcc ' busy fdns',$d,0
  716. rm16 fcc ' free fdns',$d,$d,'Error information:',$d,0
  717. rm17 fcc ' out-of-range free blocks',$d,0
  718. rm18 fcc ' duplicate blocks in free list',$d,0
  719. rm19 fcc ' duplicate file blocks',$d,0
  720. rm20 fcc ' missing blocks',$d,$d,0
  721. rm21 fcc ' out-of-range file blocks',$d,0
  722. bdlne fcc 'Bad link in free list - check aborted.',$d,0
  723. drdms fcc 'Disk read error - check aborted.',$d,0
  724. pdpb fcc ' - dup',$d,0
  725. pmsb fcc ' - mis',$d,0
  726.  
  727. BMSZ equ 1024*8-512 bit map size
  728.  
  729. isk fcb seek
  730. isk2 fcb 0
  731. isk3 fdb 0
  732.  fcb 0,0,0
  733.  
  734. iwrt fcb write
  735. iwrt2 fdb 0
  736. iwrt3 fdb 0
  737.  
  738. iopn fcb open
  739. iopn2 fdb 0,0
  740.  
  741. dfd rmb 2 file desc
  742. fdcnt rmb 2 fdn block count
  743. vlcnt rmb 2 volume block count
  744. frbl rmb 2 first free block count
  745. fbc rmb 2 free block count
  746. oorfb rmb 2 out of range count (free list)
  747. dupbc rmb 2 dup block count (free list)
  748. ffdc rmb 2 free fdn count
  749. ufdc rmb 2 used fdn count
  750. dir rmb 1 dir mode flag
  751. tin rmb 1 triple mode
  752. din rmb 1 double mode
  753. sin rmb 1 single mode
  754. rbflg rmb 1 reg block flag
  755. bfc rmb 2 block file count
  756. cfc rmb 2 character file count
  757. dfc rmb 2 dir file count
  758. rfc rmb 2 reg file count
  759. sindc rmb 2 single ind block count
  760. dindc rmb 2 double ind block count
  761. tindc rmb 2 triple ind block count
  762. dirbc rmb 2 dir file block count
  763. rgfbc rmb 2 reg file block count
  764. dupfc rmb 2 dup blocks in files count
  765. mbcnt rmb 2 missing block count
  766. oorflb rmb 2 out of range file blocks
  767.  
  768. stbf rmb 16 string buffer
  769.  
  770. zzzzz equ *
  771.  
  772.  org $800
  773.  
  774. fdbuf rmb 512
  775. dbuf rmb 512
  776. tbuf rmb 512
  777. sir rmb 512
  778.  
  779. bbuf rmb 512
  780.  
  781. bm rmb BMSZ
  782.  
  783.  end fch
  784.