home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / vmsnet / internal / 1559 < prev    next >
Encoding:
Text File  |  1992-11-09  |  9.5 KB  |  234 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!news.service.uci.edu!unogate!mvb.saic.com!macro32
  2. From: "Brian J. Schenkenberger, VAXman"
  3. Newsgroups: vmsnet.internals
  4. Subject: Re: Need help clearing FH2$V_ALM_AIP
  5. Message-ID: <01GQWVO4SA3K96VXAJ@MONMOUTH-etdl1.Army.MIL>
  6. Date: Sun, 8 Nov 1992 14:58 EDT
  7. Organization: Macro32<==>Vmsnet.Internals Gateway
  8. X-Gateway-Source-Info: Mailing List
  9. Lines: 223
  10.  
  11. The other day I posted a routine to fix the file header of a file with
  12. the file characteristic bit ALM_AIP set.  The original posting is fine
  13. for standalone VAX systems;  however, VAXcluster members may still ex-
  14. perience problems accessing the file due to the fact that their caches
  15. have not been flushed.
  16.  
  17. I uncovered this accidentally when playing on my uV2K cluster to which
  18. I recently attached a RX23-AA.  At the time I thought it a bit useless
  19. since the 3.5 floppy can hold very little data (~2500 blocks);  however,
  20. it's a great commodity when you need to play with code that is modifying
  21. file and/or volume data.  I highly recommend to anyone working on such
  22. code to get themselves a floppy for their system.
  23.  
  24. BJS-
  25.  
  26. Anyway.... Here's the revised code...
  27.  
  28.  
  29.         .title  CLEAR_ALM_AIP   (**example compliments of BJS**)
  30.  
  31.         .library        "sys$library:lib.mlb"
  32.         .link           "sys$system:sys.stb"
  33.  
  34.         $ccbdef         ; channel control block definitions
  35.         $fchdef         ; file characteristics definitions
  36.         $fh2def         ; ODS2 file header definitions
  37.         $fibdef         ; file info. block definitions
  38.         $wcbdef         ; window control block definitions
  39. ;----------------------------------------------------------------------------
  40.         .macro  check_status,status_block,?lbl1,?lbl2
  41.         blbs    r0,lbl1
  42.         ret
  43. lbl1:
  44.         .if nb  status_block
  45.         movzwl  status_block,r0
  46.         blbs    r0,lbl2
  47.         ret
  48. lbl2:
  49.         .endc
  50.         .endm   check_status
  51. ;------------------------------------------------------------------------------
  52.         .psect  $$$data,wrt,noexe,page
  53.  
  54. get_channel:    $assign devnam=sys_disk,chan=xqp_function+qio$_chan
  55. xqp_function:   $qio    func=io$_access!io$m_access,iosb=iosb,p1=fib_descr
  56.  
  57. fib_descr:      .long           fib$k_length
  58.                 .address        .+4
  59.  
  60. fib:            .blkb           fib$k_length
  61.                 .=fib+fib$w_fid_num             ;INDEXF.SYS
  62.                 .word   1                       ;FID=(1,1,0) - Always!!!
  63.                 .=fib+fib$w_fid_seq
  64.                 .word   1
  65.                 .=fib+fib$b_fid_rvn
  66.                 .byte   0
  67.                 .=fib+fib$b_fid_nmx
  68.                 .byte   0
  69.                 .=fib+fib$w_did_num             ;DID=(4,4,0) - Always!!!
  70.                 .word   4
  71.                 .=fib+fib$w_did_seq
  72.                 .word   4
  73.                 .=fib+fib$b_did_rvn
  74.                 .byte   0
  75.                 .=fib+fib$b_did_nmx
  76.                 .byte   0
  77.                 .=fib+fib$w_cntrlfunc           ; specify REMAP to get all of
  78.                 .word           fib$c_remap     ; the file's mapping pointers
  79.                 .=fib+fib$w_nmctl
  80.                 .word           fib$m_findfid
  81.                 .=fib+fib$k_length
  82.  
  83. iosb:   .quad   0
  84. sys_disk:       .ascid          /CALVIN$DUA2:/  ;<<<*** you supply the drive
  85.  
  86. arglst:
  87. arglst.argcnt:  .long   3
  88. arglst.channel: .long   0
  89. arglst.vbn:     .long   16      ;<<<*** VBN of your file's file header in
  90. arglst.lbn:     .long   0       ;       INDEXF.SYS...
  91.  
  92. ;----------------------------------------------------------------------------
  93.         .align  page
  94. block:  .blkb   512
  95. ;------------------------------------------------------------------------------
  96.         .psect  $$$code,nowrt,exe,long
  97.         .entry  clralmaip,0
  98.  
  99.         $assign_g       get_channel     ; assign a channel to the disk
  100.         check_status                    ; should we continue?
  101.  
  102.         $qiow_g xqp_function            ; access the disk's INDEXF.SYS
  103.         check_status    iosb            ; should we continue?
  104.  
  105.         movl    #io$_acpcontrol,-       ; setup function to remap the
  106.                 xqp_function+qio$_func  ; -- entire file
  107.  
  108.         $qiow_g xqp_function            ; map the entire file, lots o' WCBs
  109.         check_status    iosb            ; should we continue?
  110.  
  111.         movw    xqp_function+qio$_chan,-  ; put channel number in arg. list
  112.                 arglst.channel
  113.  
  114.         $cmexec_s  routin=vbn_to_lbn,-  ; executive routine to convert
  115.                         arglst=arglst   ; -- VBNs to LBNs
  116.  
  117.         movl    #io$_deaccess,-         ; setup function to deaccess
  118.                 xqp_function+qio$_func  ; -- the INDEXF.SYS file
  119.  
  120.         $qiow_g xqp_function            ; let the INDEXF.SYS file go...
  121.         check_status    iosb            ; should we continue?
  122.  
  123.         $qiow_s chan=xqp_function+qio$_chan,-   ; read in the file header
  124.                 func=#io$_readlblk,-            ; -- so we may modify it
  125.                 iosb=iosb,-                     ; -- to our liking...
  126.                 p1=block,-
  127.                 p2=#512,-
  128.                 p3=arglst.lbn
  129.         check_status    iosb            ; should we continue?
  130.  
  131.         bbcc    #fh2$v_alm_aip,-        ; clear that damn ALM_AIP bit
  132.                 block+fh2$l_filechar,.+1
  133.  
  134.         clrq    r0                      ; init counter & checksum accumulator
  135.  
  136. 10$:    addw2   block[r0],r1            ; calculate the new checksum value
  137.         aoblss  #255,r0,10$             ; -- for our hand written file header
  138.         movw    r1,block[r0]
  139.  
  140.         $qiow_s chan=xqp_function+qio$_chan,-   ; put our hand written file
  141.                 func=#io$_writelblk,-           ; -- header back in the disk.
  142.                 iosb=iosb,-
  143.                 p1=block,-
  144.                 p2=#512,-
  145.                 p3=arglst.lbn
  146.         check_status    iosb            ; should we continue?
  147.  
  148.         movc5   #0,#0,#0,#fib$k_length,fib      ; start with a fresh fib block
  149.  
  150.         movw    #fib$c_flush_cache,-    ; need to flush file system caches
  151.                 fib+fib$w_cntrlfunc
  152.         movl    #fib$c_bfrd_cache,-     ; specifically, buffer desc. cache
  153.                 fib+fib$l_cntrlval
  154.  
  155.         movl    #io$_acpcontrol,-       ; setup function to flush the file
  156.                 xqp_function+qio$_func  ; -- system caches
  157.  
  158.         $qiow_g xqp_function            ; flush those buffers down the drain
  159.         check_status    iosb            ; should we continue?
  160.  
  161. ; At this point the file is accessible on the local node.  If node is in a
  162. ; cluster, we must force the fcb cached on the other VAXcluster nodes to be
  163. ; invalidated.  This can be done easily by modifying the file header in such
  164. ; a way as to require the file system to invalidate the fcb on other nodes.
  165. ; I do this with the extend subfunction; extending the file by zero blocks.
  166. ; RTFM: VMS File System Internals, Kirby McCoy, EY-F575E-DP
  167. ;       Sec.: 8.5.3, Title: FCB Invalidation,  ppg. 374-382
  168.  
  169.         movc5   #0,#0,#0,#fib$k_length,fib      ; start with a fresh fib block
  170.  
  171.         movc3   #fh2$s_fid,block+fh2$w_fid,-    ; get file id of original file
  172.                 fib+fib$w_fid
  173.         movc3   #fh2$s_backlink,-               ; get the directory backlink
  174.                 block+fh2$w_backlink,-          ; -- file id of original file
  175.                 fib+fib$w_did
  176.         movw    #fib$m_findfid,fib+fib$w_nmctl  ; access by file id
  177.         movl    #fib$m_writethru,fib+fib$l_acctl
  178.  
  179.         movl    #io$_access,-           ; setup function to access the file
  180.                 xqp_function+qio$_func  ; -- and fill in the fib
  181.  
  182.         $qiow_g xqp_function            ; access the file
  183.         check_status    iosb            ; should we continue?
  184.  
  185.         movw    #fib$m_extend,fib+fib$w_exctl   ; extend subfunction
  186.         clrl    fib+fib$l_exsz                  ; extend file zero blocks
  187.  
  188.         movl    #io$_modify,-           ; setup function to remap the
  189.                 xqp_function+qio$_func  ; -- entire file
  190.  
  191.         $qiow_g xqp_function            ; access the disk's INDEXF.SYS
  192.  
  193.         check_status    iosb            ; should we continue?
  194.  
  195.  
  196.         $exit_s r0                      ; to exit anyway)
  197. ;----------------------------------------------------------------------------
  198. argcnt  = 0
  199. channel = 4
  200. vbn     = 8
  201. lbn     = 12
  202.  
  203. stlbn   = 2
  204. stlbnsz = 4
  205.         .entry  vbn_to_lbn,0
  206.         movl    @#ctl$gl_ccbbase,r0     ; get base address oc CCB region
  207.         subl2   channel(ap),r0          ; get CCB of channel (rev. indexed)
  208.  
  209.         movl    ccb$l_wind(r0),r0       ; get 1st window mapping the file
  210. 10$:    movl    wcb$l_link(r0),r1       ; are there others???
  211.         beql    20$                     ; NO?? then branch to 20$
  212.         cmpl    vbn(ap),wcb$l_stvbn(r1) ; does our VBN map in this window?
  213.         blssu   20$                     ; NO?? then branch to 20$
  214.         movl    r1,r0                   ; use the next window
  215.         brb     10$                     ; ... and check it out again
  216.  
  217. 20$:    movzwl  wcb$w_nmap(r0),r1       ; how many map pointers in window
  218.         subl2   wcb$l_stvbn(r0),vbn(ap) ; offset by the window's start VBN
  219.         movab   wcb$w_p1_count(r0),r0   ; get the address of mapping pointers
  220. 30$:    cmpw    vbn(ap),(r0)            ; is our VBN in this map pointer?
  221.         blssu   40$                     ; YES?? then branch to 40$
  222.         subw2   (r0)+,vbn(ap)           ; offset our VBN by the mapping count
  223.         movab   stlbnsz(r0),r0          ; get address of next mapping pointer
  224.         sobgtr  r1,30$                  ; ... try, try again...
  225.         movl    #ss$_illblknum,r0
  226.         ret
  227.  
  228. 40$:    addl3   vbn(ap),stlbn(r0),lbn(ap)  ; VBN offset + Starting LBN = LBN
  229.         movl    #ss$_normal,r0          ; ok
  230.         ret
  231.  
  232.         .end    clralmaip
  233.  
  234.