PROCEDURE dum$display_brief_avt_entry, display_brief_avt_entry, disbae (
  index, i: integer 1..150 = $optional
  output, o: file = $output
  help, h: file = $null
  status)


  "$FORMAT=OFF"
  VAR
    when_status: status
  VAREND
  "$FORMAT=ON"

  WHEN any_fault DO
    when_status = $previous_status
    put_line ' Invoked DISBAE condition handler due to the following abnormal status:'
    disv when_status
    put_line ' Enter commands, "exit_proc" to abort, or "exit_proc with when_status" to abort with status'
    include_file command prompt='disbae_ch'
  WHENEND

  IF $specified(help) THEN
COLLECT_TEXT o=help until='HELPEND'
DISPLAY_BRIEF_AVT_ENTRY or DISBAE

  This procedure has been designed to be called by procedure
Display_Active_Volume_Table.  Please use Display_Active_Volume_Table
rather than this procedure.

WARNINGS/KNOWN DEFICIENCIES:

ERROR HANDLER
  When any fatal error is encountered a condition handler is invoked and
the following messages will appear:
 "Invoked DISBAE condition handler due to the following abnormal status:"
 "< the error status message >"
 "Enter commands, "exit_proc" to abort, or "exit_proc with when_status"
  to abort with status"
To exit the handler enter:    "exit_proc"
To exit the handler with status, enter:   "exit_proc with when_status"

HELPEND
    EXIT_PROC
  IFEND

  IF NOT $specified(index) THEN
    EXIT_PROC WITH $status(false, 'US', 2, 'Parameter INDEX is required')
  IFEND

  "$FORMAT=OFF"
  VAR
    output_file: file
    blank_line: string = '                                                    '
    line_first_part: string
    line_secnd_part: string
    blank_fill_count: integer
    column_two_num: integer = 42
  VAREND
  "$FORMAT=ON"

  IF $file(output open_position) = '$BOI' THEN
    output_file = output.$asis
  ELSE
    output_file = output
  IFEND

" Get the base values required to look at the active volume table.  Use the knowlege that
" DMV$P_ACTIVE_VOLUME_TABLE is an adaptable array.

  p_avt = $mem($sa(dmv$p_active_volume_table), 6)
  avt_length = $mem($sa(dmv$p_active_volume_table)+6, 4)
  avt_start_index = $mem($sa(dmv$p_active_volume_table)+6+4, 4)
  avt_entry_size = $mem($sa(dmv$p_active_volume_table)+6+4+4, 4)
  number_of_avt_entries = avt_length / avt_entry_size

  IF index > number_of_avt_entries THEN
    EXIT_PROC WITH $status(false, 'US', 0, ' specified index > number of avt entries')
  IFEND

  "$FORMAT=OFF"
  VAR
    i: integer

" The following offsets were obtained from the output of the command Display_Symbol_Table
" for the type DMT$ACTIVE_VOLUME_TABLE_ENTRY.

    entry_locked: integer
    entry_locked_offset: integer = 0(16)
    entry_available_offset: integer = 8(16)
    lun: integer
    lun_offset: integer = 9(16)
    padding: integer
    padding_offset: integer = 0b(16)
    allocation_allowed: integer
    allocation_allowed_offset: integer = 10(16)
    space_low: integer
    space_low_offset: integer = 11(16)
    space_gone: integer
    space_gone_offset: integer = 12(16)
    dmt$disk_table_status: array 0..4 of string 1..$max_name = ('dmc$table_update_inhibited' ..
          'dmc$table_update_in_progress' 'dmc$dflt_update_required' 'dmc$no_available_dflt_entries' ..
          'dmc$volume_low_on_dfl_entries')
    disk_table_status: integer
    disk_table_status_offset: integer = 13(16)
    class_offset: integer = 14(16)
    sys_class_act_element_length: integer = 4(16)
    system_class_activity_offset: integer = 18(16)
    logged_in_for_recovery: boolean
    logged_in_for_recovery_offset: integer = 2c(16)
    update_lock: integer
    update_lock_offset: integer = 30(16)
    logging_lock: integer
    logging_lock_offset: integer = 38(16)
    internal_vsn_offset: integer = 40(16)
    dat_sfid: integer
    dat_sfid_offset: integer = 4b(16)
    dfl_sfid: integer
    dfl_sfid_offset: integer = 4f(16)
    dl_sfid: integer
    dl_sfid_offset: integer = 53(16)
    dir_sfid: integer
    dir_sfid_offset: integer = 57(16)
    lt_sfid: integer
    lt_sfid_offset: integer = 5b(16)
    mf_assign: integer
    mf_assign_offset: integer = 5f(16)
    p_mat: integer
    p_mat_offset: integer = 64(16)
    p_mfl: integer
    p_mfl_offset: integer = 76(16)
    recorded_vsn: string
    recorded_vsn_offset: integer = 88(16)
    set_name: string
    set_name_offset: integer = 8e(16)
    dmt$ms_volume_system_status: array 0..3 of string 1..$max_name = ('dmc$mainframe_mounted' ..
          'dmc$mainframe_dismounted' 'dmc$system_mounted' 'dmc$system_dismounted')
    status_field: integer
    status_field_offset: integer = 0ad(16)
    volume_owner: string
    volume_owner_offset: integer = 0ae(16)
    offset_in_log: integer
    offset_in_log_offset: integer = 0ec(16)
    allocated_log_size: integer
    allocated_log_size_offset: integer = 0f2(16)
    device_log_entry_count: integer
    device_log_entry_count_offset: integer = 0f8(16)
    volume_unavailable: boolean
    volume_unavailable_offset: integer = 100(16)
    previous_alloc_allowed: boolean
    previous_alloc_allowed_offset: integer = 101(16)
    logging_process_damaged: boolean
    logging_process_damaged_offset: integer = 102(16)
  VAREND
  "$FORMAT=ON"

  current_avt_entry = (p_avt + ((index - avt_start_index)* avt_entry_size))
" putl ' Current_avt_entry at '//$strrep(current_avt_entry 16)//'(16)' o=output_file
" dism current_avt_entry 259 o=output_file

  put_line '   ' o=output_file
  IF $mem(current_avt_entry+entry_available_offset, 1) = 1 THEN
    put_line ' AVT index '//$strrep(index)//' is available (i.e., not in use)' o=output_file
    put_line '  ' o=output_file
  ELSE
    entry_locked = $mem(current_avt_entry+entry_locked_offset, 8)
    lun = $mem(current_avt_entry+lun_offset, 2)
    padding = $mem(current_avt_entry+padding_offset, 4)
    allocation_allowed = $mem(current_avt_entry+allocation_allowed_offset, 1)
    space_low = $mem(current_avt_entry+space_low_offset, 1)
    space_gone = $mem(current_avt_entry+space_gone_offset, 1)
    disk_table_status = $mem(current_avt_entry+disk_table_status_offset, 1)
    logged_in_for_recovery = ($mem(current_avt_entry+logged_in_for_recovery_offset, 1) = $integer(true))
    update_lock = $mem(current_avt_entry+update_lock_offset, 8)
    logging_lock = $mem(current_avt_entry+logging_lock_offset, 8)
    dat_sfid = $mem(current_avt_entry+dat_sfid_offset, 4)
    dfl_sfid = $mem(current_avt_entry+dfl_sfid_offset, 4)
    dl_sfid = $mem(current_avt_entry+dl_sfid_offset, 4)
    dir_sfid = $mem(current_avt_entry+dir_sfid_offset, 4)
    lt_sfid = $mem(current_avt_entry+lt_sfid_offset, 4)
    mf_assign = $mem(current_avt_entry+mf_assign_offset, 5)
    p_mat = $mem(current_avt_entry+p_mat_offset, 6)
    p_mfl = $mem(current_avt_entry+p_mfl_offset, 6)
    recorded_vsn = $ms(current_avt_entry+recorded_vsn_offset, 6)
    set_name = $ms(current_avt_entry+set_name_offset, 31)
    status_field = $mem(current_avt_entry+status_field_offset, 1)
    volume_owner = $ms(current_avt_entry+volume_owner_offset, 62)
    offset_in_log = $mem(current_avt_entry+offset_in_log_offset, 6)
    allocated_log_size = $mem(current_avt_entry+allocated_log_size_offset, 6)
    device_log_entry_count = $mem(current_avt_entry+device_log_entry_count_offset, 8)
    volume_unavailable = ($mem(current_avt_entry+volume_unavailable_offset, 1) = $integer(true))
    previous_alloc_allowed = ($mem(current_avt_entry+previous_alloc_allowed_offset, 1) = $integer(true))
    logging_process_damaged = ($mem(current_avt_entry+logging_process_damaged_offset, 1) = $integer(true))

    IF entry_locked <> 0 THEN
      put_line ' entry_locked = TRUE' o=output_file
    ELSE
      put_line ' entry_locked = FALSE' o=output_file
    IFEND

    put_line ' logical_unit_number = '//$strrep(lun 16)//'(16)' o=output_file

    put_line ' padding = '//$strrep(padding 16)//'(16)' o=output_file

    IF allocation_allowed = 1 THEN
      put_line ' allocation_allowed = TRUE' o=output_file
    ELSE
      put_line ' allocation_allowed = FALSE' o=output_file
    IFEND

    IF space_low = 1 THEN
      line_first_part = ' space_low = TRUE'
    ELSE
      line_first_part = ' space_low = FALSE'
    IFEND

    IF space_gone = 1 THEN
      line_secnd_part = ' space_gone = TRUE'
    ELSE
      line_secnd_part = ' space_gone = FALSE'
    IFEND

    blank_fill_count = (column_two_num)-($strlen(line_first_part))
    put_line line_first_part//$substr(blank_line, 1, blank_fill_count)//line_secnd_part o=output_file

    line = ' disk_table_status: {'
    FOR i = 59 TO 63 DO
      IF $bit(disk_table_status i) THEN
        line = line // ' ' // dmt$disk_table_status(i-59)
      IFEND
    FOREND
    put_line line//' }' o=output_file

    display_ms_classes current_avt_entry+class_offset o=output_file

    put_line ' system_class_activity:' o=output_file
    FOR i = 0 TO 4 DO
      put_line '   ['//..
$strrep(i)//'] '//$strrep($mem(current_avt_entry+system_class_activity_offset+i*sys_class_act_element_length..
, sys_class_act_element_length) 16)//'(16)' o=output_file
    FOREND

    IF logged_in_for_recovery THEN
      put_line ' logged_in_for_recovery = TRUE' o=output_file
    ELSE
      put_line ' logged_in_for_recovery = FALSE' o=output_file
    IFEND

    IF update_lock <> 0 THEN
      line_first_part = ' update_lock = { task } '//$strrep(update_lock, 16)//'(16)'
    ELSE
      line_first_part = ' update_lock = '//$strrep(update_lock, 16)//'(16)'
    IFEND

    IF logging_lock <> 0 THEN
      line_secnd_part = ' logging_lock = { task } '//$strrep(logging_lock, 16)//'(16)'
    ELSE
      line_secnd_part = ' logging_lock = '//$strrep(logging_lock, 16)//'(16)'
    IFEND

    blank_fill_count = (column_two_num)-($strlen(line_first_part))
    put_line line_first_part//$substr(blank_line, 1, blank_fill_count)//line_secnd_part o=output_file

    display_binary_unique_name pva=current_avt_entry+internal_vsn_offset o=output cs=' internal_vsn = '

    put_line ' recorded_vsn = '//recorded_vsn o=output_file
    put_line ' set_name = '//set_name o=output_file

    put_line ' mf_assigned = '//$strrep(mf_assign, 16)//'(16)' o=output_file

    line_first_part = ' dat_sfid = '//$strrep(dat_sfid, 16)//'(16)'
    line_secnd_part = ' mat_pointer = '//$strrep(p_mat, 16)//'(16)'
    blank_fill_count = (column_two_num)-($strlen(line_first_part))
    put_line line_first_part//$substr(blank_line, 1, blank_fill_count)//line_secnd_part o=output_file

    line_first_part = ' dfl_sfid = '//$strrep(dfl_sfid, 16)//'(16)'
    line_secnd_part = ' mfl_pointer = '//$strrep(p_mfl, 16)//'(16)'
    blank_fill_count = (column_two_num)-($strlen(line_first_part))
    put_line line_first_part//$substr(blank_line, 1, blank_fill_count)//line_secnd_part o=output_file

    line_first_part = ' dlog_sfid = '//$strrep(dl_sfid, 16)//'(16)'
    line_secnd_part = ' log_offset = '//$strrep(offset_in_log, 16)//'(16)'
    blank_fill_count = (column_two_num)-($strlen(line_first_part))
    put_line line_first_part//$substr(blank_line, 1, blank_fill_count)//line_secnd_part o=output_file

    line_first_part = ' dir_sfid = '//$strrep(dir_sfid, 16)//'(16)'
    line_secnd_part = ' allocated_size = '//$strrep(allocated_log_size, 16)//'(16)'
    blank_fill_count = (column_two_num)-($strlen(line_first_part))
    put_line line_first_part//$substr(blank_line, 1, blank_fill_count)//line_secnd_part o=output_file

    line_first_part = ' ltable_sfid = '//$strrep(lt_sfid, 16)//'(16)'
    line_secnd_part = ' entry_count = '//$strrep(device_log_entry_count, 16)//'(16)'
    blank_fill_count = (column_two_num)-($strlen(line_first_part))
    put_line line_first_part//$substr(blank_line, 1, blank_fill_count)//line_secnd_part o=output_file

    IF volume_unavailable THEN
      line_first_part = ' volume_unavailable = TRUE'
    ELSE
      line_first_part = ' volume_unavailable = FALSE'
    IFEND

    IF previous_alloc_allowed THEN
      line_secnd_part = ' previous_allocation_allowed = TRUE'
    ELSE
      line_secnd_part = ' previous_allocation_allowed = FALSE'
    IFEND

    blank_fill_count = (column_two_num)-($strlen(line_first_part))
    put_line line_first_part//$substr(blank_line, 1, blank_fill_count)//line_secnd_part o=output_file

    line = ' status: {'
    FOR i = 60 TO 63 DO
      IF $bit(status_field i) THEN
        line = line // ' ' // dmt$ms_volume_system_status(i-60)
      IFEND
    FOREND
    put_line line//' }' o=output_file

    put_line ' volume_owner:' o=output_file
    line_first_part = '   user = '//$substr(volume_owner 1 31)
    line_secnd_part = ' family = '//$substr(volume_owner 32 31)
    blank_fill_count = (column_two_num)-($strlen(line_first_part))
    put_line line_first_part//$substr(blank_line, 1, blank_fill_count)//line_secnd_part o=output_file

    IF logging_process_damaged THEN
      put_line ' logging_process_damaged = TRUE' o=output_file
    ELSE
      put_line ' logging_process_damaged = FALSE' o=output_file
    IFEND

  IFEND

PROCEND dum$display_brief_avt_entry
