.title show_lbn - show lbn's of all files by reading indexf.sys ; .library /sys$library:lib.mlb/ $fiddef ; file id definitions $fibdef ; fib definitions $iodef ; io definitions $fh2def ; file header definitions $fi2def ; file information definitions $fm2def ; file map pointer definitions $hm2def ; home block definitions $ssdef ; status return definitions ; .macro check_r0,?r0_dest ; macro to check status in R0 blbs r0,r0_dest $exit_s r0 r0_dest: .endm check_r0 ; .macro check_iosb,?iosb_dest ; macro to check status in iosb blbs iosb,iosb_dest movzwl iosb,r0 $exit_s r0 iosb_dest: .endm check_iosb ; .macro check_eof,?eof_dest1,?eof_dest2 ; macro to check r0 and iosb cmpl #ss$_endoffile,r0 ; for ss$_endoffile bneq eof_dest1 jmp deaccess_file eof_dest1: movzwl iosb,r1 cmpl #ss$_endoffile,r1 bneq eof_dest2 jmp deaccess_file eof_dest2: .endm check_eof ; ; .psect data,noexe,wrt disk_name_prompt: .ascid /Enter disk name (20 max): / disk_name_dsc: ; descriptor for disk name .long 20 .address disk_name disk_name: .blkb 20 ; disk name disk_name_length: ; disk name length .blkb 1 ; file_spec: .blkb 255 ; file spec file_spec_dsc: ; descriptor for file spec .long 255 .address file_spec file_spec_length: ; file spec length .blkw 1 ; fib: .blkb fib$k_length ; file information block fib_dsc: .long fib$k_length ; descriptor for fib .address fib disk_channel: .blkw 1 ; channel to disk vbn: .blkl 1 ; vbn for $qiow save_vbn: .blkl 1 ; saved vbn indexf_vbn: .blkl 1 ; vbn for indexf format: .blkl 1 ; retrieval pointer format iosb: .blkq 1 ; iosb file_header: .blkb fh2$s_fh2def ; buffer for file header primary_header: .blkb fh2$s_fh2def ; buffer for primary file hdr home_block: .blkb hm2$s_hm2def ; buffer for homeblock count: .blkw 1 ; lbn count .blkw 1 lbn: .blkw 1 ; logical block number .blkw 1 header_valid=0 ; header valid flag header_not_valid=1 ; header not valid flag ; name_fid_ctrl_str: ; file name and file id fao control string .ascid "!AS (!UW,!UW,!UW)" ; rtrvl_ptr_ctrl_str: ; count and lbn fao control string .ascid " Count: !10SL LBN: !10SL" ; nosuchfile_ctrl_str: ; NOSUCHFILE fao control string .ascid "NOSUCHFILE (!UW,!UW,!UW), VBN within INDEXF.SYS is !SL" ; fao_output_dsc: ; fao output descriptor .long 290 .address fao_output_buffer fao_output_buffer: .blkb 290 fao_length: .blkw 1 ; length returned by $fao fao_buffer_size=290 ; fao buffer size constant ; inv_format_msg: .ascid / retrieval pointer has invalid format/ rtrvl_ptr_msg: .ascid / Retrieval pointers/ exact_msg: .ascid / Placement control: Exact/ oncyl_msg: .ascid / Placement control: Cylinder boundry/ lbn_msg: .ascid / Placement control: Specific LBN/ rvn_msg: .ascid / Placement control: Specific RVN/ spaces_msg: .ascid / / ; .psect code,exe,nowrt .entry show_lbn,^m<> ; pushal disk_name_length ; get the disk name pushal disk_name_prompt ; from the terminal pushal disk_name_dsc calls #3,g^lib$get_input check_r0 ; check the status in r0 ; $assign_s devnam=disk_name_dsc,- ; assign a channel to chan=disk_channel ; the disk check_r0 ; check the status in r0 ; movw #fid$c_indexf,fib+fib$w_fid ; init fid of fib movw #fid$c_indexf,fib+fib$w_fid+2 ; to (1,1,0) for movw #0,fib+fib$w_fid+4 ; indexf.sys ; $qiow_s chan=disk_channel,- ; access the file, func=#io$_access!io$m_access,- ; (1,1,0) indexf.sys iosb=iosb,- p1=fib_dsc check_r0 ; check the status in r0 check_iosb ; check the status in the iosb ; $qiow_s chan=disk_channel,- ; read the home block func=#io$_readvblk,- iosb=iosb,- p1=home_block,- p2=#hm2$s_hm2def,- p3=#2 check_r0 ; check the status in r0 check_iosb ; check the status in the iosb ; moval home_block,r2 ; get the vbn for the movzwl hm2$w_ibmapvbn(r2),r3 ; file header for movzwl hm2$w_ibmapsize(r2),r4 ; indexf.sys addl3 r3,r4,vbn movl vbn,indexf_vbn ; save vbn for indexf ; read_headers: $qiow_s chan=disk_channel,- ; read the file header func=#io$_readvblk,- iosb=iosb,- p1=file_header,- p2=#fh2$s_fh2def,- p3=vbn ; check_eof ; check for ss$_endoffile check_r0 ; check the status in r0 check_iosb ; check the status in the iosb ; moval file_header,r2 ; put addr of file hdr in r2 jsb validate_header ; check for valid file hdr cmpl #header_valid,r1 ; compare r1 to header_valid beql chk_seg_num ; branch if equal jmp nxt_header ; otherwise read next hdr ; chk_seg_num: tstw fh2$w_seg_num(r2) ; check for extension file hdr beql get_filespec ; branch if equal jsb find_primary_header ; otherwise find primary hdr ; get_filespec: pushal file_spec_length ; get the filespec pushal file_spec_dsc ; by calling pushal fh2$w_fid(r2) ; lib$fid_to_name pushal disk_name_dsc calls #4,g^lib$fid_to_name cmpl r0,#ss$_nosuchfile ; check r0 for ss$_nosuchfile bneq display_filespec ; branch if not equal jsb filespec_not_found ; otherwise display nosuchfile ; display_filespec: check_r0 ; check the status in r0 movw file_spec_length,file_spec_dsc ; move returned length to desc moval file_header,r2 ; put addr of file hdr in r2 movzwl fh2$w_fid_num(r2),r3 ; move fid num to r3 movzwl fh2$w_fid_seq(r2),r4 ; move fid seq to r4 movzwl fh2$w_fid_rvn(r2),r5 ; move fid rvn to r5 $fao_s ctrstr=name_fid_ctrl_str,- ; call $fao to format outlen=fao_length,- ; the output string outbuf=fao_output_dsc,- ; that contains the p1=#file_spec_dsc,- ; filespec and the p2=r3,- ; file id p3=r4,- p4=r5 check_r0 ; check the status in r0 movw fao_length,fao_output_dsc ; move length to descriptor pushal spaces_msg ; display a line of spaces calls #1,g^lib$put_output check_r0 ; check the status in r0 pushal fao_output_dsc ; display the fao output calls #1,g^lib$put_output ; buffer check_r0 ; check the status in r0 movw #fao_buffer_size,fao_output_dsc ; reset length in descriptor movw #255,file_spec_dsc ; reset length in descriptor ; get_mpoffset: moval file_header,r2 ; put addr of file hdr in r2 movzbl fh2$b_mpoffset(r2),r3 ; put fh2$b_mpoffset in r3 movaw (r2)[r3],r3 ; ? ; tstb fh2$b_map_inuse(r2) ; check fh2$b_map_inuse and ; don't display the ; retrieval pointer message ; if it is 0 bneq display_rtrvl_ptr_msg ; branch if not equal jmp nxt_header ; jump to read next header ; display_rtrvl_ptr_msg: pushal rtrvl_ptr_msg ; display retrieval calls #1,g^lib$put_output ; pointer message check_r0 ; check the status in r0 ; check_map_inuse: tstb fh2$b_map_inuse(r2) ; check fh2$b_map_inuse for 0 bneq extzv_format ; branch if not equal jmp nxt_header ; jump to read next header ; extzv_format: extzv #fm2$v_format,#fm2$s_format,- ; extract format (r3),format ; casel format,#0,#3 ; case long on format 10$: .word format_0-10$ .word format_1-10$ .word format_2-10$ .word format_3-10$ ; pushal inv_format_msg ; display invalid format calls #1,g^lib$put_output ; message check_r0 ; check the status in r0 nxt_header: incl vbn ; add 1 to vbn jmp read_headers ; go read the next header ; format_0: bbc #fm2$v_exact,(r3),chk_oncyl ; check for exact placement pushal exact_msg ; display placement calls #1,g^lib$put_output ; control message check_r0 ; check the status in r0 ; chk_oncyl: bbc #fm2$v_oncyl,(r3),chk_lbn ; check for cylinder placement pushal oncyl_msg ; display placement calls #1,g^lib$put_output ; control message check_r0 ; check the status in r0 ; chk_lbn: bbc #fm2$v_lbn,(r3),chk_rvn ; check for specific lbn pushal lbn_msg ; display placement calls #1,g^lib$put_output ; control message check_r0 ; check the status in r0 ; chk_rvn: bbc #fm2$v_rvn,(r3),subtr_map_inuse ; check for specific rvn pushal rvn_msg ; display placement calls #1,g^lib$put_output ; control message check_r0 ; check the status in r0 ; subtr_map_inuse: subl2 #1,fh2$b_map_inuse(r2) ; subtract number of words ; from fh2$b_map_inuse addl2 #2,r3 ; add number of bytes to r3 jmp check_map_inuse ; go check for end of map area ; format_1: clrl count ; clear the count movb fm2$b_count1(r3),count ; move byte fm2$b_count1 ; to low order word of count incl count ; add 1 to the count extzv #fm2$v_highlbn,#fm2$s_highlbn,- ; extract fm2$v_highlbn (r3),lbn ; 6 bits to lbn rotl #16,lbn,lbn ; rotate highlbn 6 bits to ; high order 16 bits of lbn movw fm2$w_lowlbn(r3),lbn ; move fm2$w_lowlbn to low ; order word of lbn jsb display_retrieval_pointer ; display retrieval pointer subl2 #2,fh2$b_map_inuse(r2) ; subtract number of words ; from fh2$b_map_inuse addl2 #4,r3 ; add number of bytes to r3 jmp check_map_inuse ; go check for end of map area ; format_2: clrl count ; clear the count extzv #fm2$v_count2,#fm2$s_count2,- ; extract fm2$v_count2 14 (r3),count ; bits to count incl count ; add 1 to count movl fm2$l_lbn2(r3),lbn ; move lbn to symbol jsb display_retrieval_pointer ; display retrieval pointer subl2 #3,fh2$b_map_inuse(r2) ; subtract number of words ; from fh2$b_map_inuse addl2 #6,r3 ; add number of bytes to r3 jmp check_map_inuse ; go check for end of map area ; format_3: clrl count ; clear the count extzv #fm2$v_count2,#fm2$s_count2,- ; extract fm2$v_count2 14 (r3),count ; bits to count rotl #16,count,count ; rotate loworder bits to ; highorder bits of count movw fm2$w_lowcount(r3),count ; move fm2$w_lowcount to count incl count ; add 1 to count movl fm2$l_lbn3(r3),lbn ; move fm2$l_lbn3 to lbn jsb display_retrieval_pointer ; display retrival pointer subl2 #4,fh2$b_map_inuse(r2) ; subtract number of words ; from fh2$b_map_inuse addl2 #8,r3 ; add number of bytes to r3 jmp check_map_inuse ; go check for end of map area ; ; validate_header: ; subroutine to validate file header movl #header_valid,r1 ; assume file hdr is valid movzwl #255,r3 ; number of words in header clrl r4 ; clear the count movl r2,r0 ; copy address of buffer calc_checksum: addw2 (r0)+,r4 ; add up the words sobgtr r3,calc_checksum cmpw r4,fh2$w_checksum(r2) ; compare calculated checksum ; to file header checksum beql chk_idoffset ; branch if equal brw invalid_header ; otherwise invalid file hdr ; chk_idoffset: cmpb fh2$b_idoffset(r2),- ; compare fh2$b_idoffset #fh2$l_fileowner/2 ; to fh2$l_fileowner/2 bgequ chk_offsets ; branch if greater or equal brw invalid_header ; otherwise invalid file hdr ; chk_offsets: cmpb fh2$b_idoffset(r2),- ; compare fh2$b_idoffset fh2$b_mpoffset(r2) ; to fh2$b_mpoffset bgtru invalid_header ; branch if greater cmpb fh2$b_mpoffset(r2),- ; compare fh2$b_mpoffset fh2$b_acoffset(r2) ; to fh2$b_acoffset bgtru invalid_header ; branch if greater cmpb fh2$b_acoffset(r2),- ; compare fh2$b_acoffset fh2$b_rsoffset(r2) ; to fh2$b_rsoffset bgtru invalid_header ; branch if greater ; chk_struclev: cmpb #2,fh2$w_struclev+1(r2) ; check high byte of ; fh2$w_struclev for 2 beql chk_version ; branch if equal brw invalid_header ; otherwise invalid hdr ; chk_version: cmpb #1,fh2$w_struclev(r2) ; check low byte of ; fh2$w_struclev for 1 beql chk_fid_num ; branch if equal brw invalid_header ; otherwise invalid hdr ; chk_fid_num: tstw fh2$w_fid_num(r2) ; check fh2$w_fid_num for 0 bneq chk_fid_seq ; branch if not equal brw invalid_header ; otherwise invalid hdr ; chk_fid_seq: tstw fh2$w_fid_seq(r2) ; check fh2$w_fid_seq for 0 bneq chk_map_inuse ; branch if not equal brw invalid_header ; otherwise invalid hdr ; chk_map_inuse: subb3 fh2$b_mpoffset(r2),- ; subtract fh2$b_mpoffset fh2$b_acoffset(r2),r3 ; from fh2$b_acoffset cmpb fh2$b_map_inuse(r2),r3 ; compare fh2$b_map_inuse ; to value in r3 blequ valid_header ; branch if less than or equal ; invalid_header: movl #header_not_valid,r1 ; header is invalid rsb ; return ; valid_header: rsb ; return ; ; find_primary_header: ; subroutine to find primary header movl vbn,save_vbn ; save vbn calc_vbn: movzwl fh2$w_bk_fidnum(r2),r5 ; move backlink fidnum to r5 subl2 #1,r5 ; subtract 1 from r5 addl3 r5,indexf_vbn,vbn ; find vbn for file header ; $qiow_s chan=disk_channel,- ; read the primary func=#io$_readvblk,- ; file header iosb=iosb,- p1=primary_header,- p2=#fh2$s_fh2def,- p3=vbn ; check_eof ; check for ss$_endoffile check_r0 ; check the status in r0 check_iosb ; check the status in the iosb ; moval primary_header,r2 ; move address of file header ; into r2 tstw fh2$w_seg_num(r2) ; check segment number for 0 beql restore_vbn ; branch if equal brw calc_vbn ; otherwise keep searching restore_vbn: movl save_vbn,vbn ; restore the vbn rsb ; return ; ; filespec_not_found: ; subroutine to display nosuchfile msg movzwl file_header+fh2$w_fid_num,r3 ; move fid num to r3 movzwl file_header+fh2$w_fid_seq,r4 ; move fid seq to r4 movzwl file_header+fh2$w_fid_rvn,r5 ; move fid rvn to r5 $fao_s ctrstr=nosuchfile_ctrl_str,- ; call $fao to format outlen=fao_length,- ; the output message outbuf=fao_output_dsc,- p1=r3,- p2=r4,- p3=r5,- p4=vbn check_r0 ; check the status in r0 movw fao_length,fao_output_dsc ; move length to descriptor pushal spaces_msg ; output a line of spaces calls #1,g^lib$put_output check_r0 ; check the status in r0 pushal fao_output_dsc ; display nosuchfile msg calls #1,g^lib$put_output check_r0 ; check the status in r0 movw #fao_buffer_size,fao_output_dsc ; reset the length movw #255,file_spec_dsc ; reset the length rsb ; return ; ; display_retrieval_pointer: ; subroutine to display the ; retrieval pointer information $fao_s ctrstr=rtrvl_ptr_ctrl_str,- ; call $fao to format the outlen=fao_length,- ; output string that outbuf=fao_output_dsc,- ; contains the count p1=count,- ; and lbn p2=lbn check_r0 ; check status in r0 movw fao_length,fao_output_dsc ; move length to descriptor pushal fao_output_dsc ; display retrieval calls #1,g^lib$put_output ; pointer check_r0 ; check the status in r0 movw #fao_buffer_size,fao_output_dsc ; reset length in descriptor rsb ; deaccess_file: $qiow_s chan=disk_channel,- ; deaccess the file func=#io$_deaccess,- iosb=iosb,- p1=fib_dsc check_r0 ; check the status in r0 check_iosb ; check the status in the iosb ; $dassgn_s chan=disk_channel ; deassign the channel check_r0 ; check the status in r0 ; ret .end show_lbn