PROCEDURE dum$display_dfd, display_dfd, disdfd (
  pva: integer = $optional
  output, o: file = $output
  display_option, do: key
      (brief, b), (full, f)
    keyend = brief
  fmd_p: (VAR) integer = $optional
  help, h: file = $null
  status)


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

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

  IF $specified(help) THEN
COLLECT_TEXT o=help until='HELPEND'
DISPLAY_DFD or DISDFD

  This procedure will display a file's disk file descriptor when given a
process virtual address to the entry.  This procedure assumes the user has
selected the correct exchange package by available analyze_dump commands.

PARAMETERS:

PVA: integer
  This parameter passes the processor virtual address of the file medium
descriptor to be displayed.  This parameter is required.

OUTPUT, O: file
  This parameter selects the file name to receive the data.  This para-
meter is defaulted to $output.  If a file name other than $output is
entered the data will be formated correctly for printer disposition and
will be sent to the file  "$asis".

DISPLAY_OPTIONS, DO: key full, f, brief, b
  This parameter selects the option of displaying the contents of memory
and the description of the selected fields (full), or the brief mode of
the descriptions only.  This parameter defaults to brief.

FMD_P: integer
  This parameter is returned to the caller and specifies the pointer to
the first File Medium Descriptor (FMD).  This parameter is optional.

STATUS

WARNINGS/KNOWN DEFICIENCIES:

ERROR HANDLER
  When any fatal error is encountered a condition handler is invoked and
the following messages will appear:
 "Invoked DISDFD 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(pva) THEN
    EXIT_PROC WITH $status(false, 'US', 6, 'Parameter PVA is required')
  IFEND

  "$FORMAT=OFF"
  VAR
    output_file: file

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

    read_write_count_offset: integer = 0(16)
    delete_count_offset: integer = 2(16)
    purged_offset: integer = 5(16)
    restricted_attach_offset: integer = 6(16)
    bytes_per_allocation_offset: integer = 7(16)
    file_allocation_table_offset: integer = 0A(16)
    fat_upper_bound_offset: integer = 10(16)
    current_fmd_index_offset: integer = 12(16)
    highest_offset_allocated_offset: integer = 13(16)
    bytes_per_level_2_offset: integer = 19(16)
    dfd_modified_offset: integer = 1F(16)
    overflow_allowed_offset: integer = 20(16)
    requested_alloc_size_offset: integer = 21(16)
    requested_class_offset: integer = 24(16)
    requested_class_ordinal_offset: integer = 25(16)
    requested_transfer_size_offset: integer = 26(16)
    requested_volume_offset: integer = 29(16)
    recorded_vsn_offset: integer = 0(16)
    setname_offset: integer = 6(16)
    number_of_fmds_offset: integer = 4E(16)
    p_fmd_offset: integer = 4F(16)
    file_damaged_offset: integer = 55(16)
    damage_detection_enabled_offset: integer = 56(16)
    fmd_modified_offset: integer = 57(16)
  VAREND
  "$FORMAT=ON"

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

  IF output = :$local.$output THEN
    putl '1DISK FILE DESCRIPTOR ' o=output_file
  IFEND

  IF display_option = 'FULL' THEN
    display_memory pva bytes=58(16) t='DISK FILE DESCRIPTOR' o=output_file
  IFEND

  start_of_dfd = pva
  putl '   ' o=output_file

  putl ' read_write_count = '//$strrep($mem(start_of_dfd+read_write_count_offset 2) 16)//'(16)' ..
        o=output_file

  putl ' delete_count = '//$strrep($mem(start_of_dfd+delete_count_offset 3) 16)//'(16)' o=output_file

  IF $mem(start_of_dfd+purged_offset, 1) = 1 THEN
    putl ' purged = TRUE' o=output_file
  ELSE
    putl ' purged = FALSE' o=output_file
  IFEND

  IF $mem(start_of_dfd+restricted_attach_offset, 1) = 1 THEN
    putl ' restricted_attach = TRUE' o=output_file
  ELSE
    putl ' restricted_attach = FALSE' o=output_file
  IFEND

  putl ' bytes_per_allocation = '//$strrep($mem(start_of_dfd+bytes_per_allocation_offset 3) 16)//'(16)' ..
        o=output_file

  putl ' file_allocation_table = '//$strrep($mem(start_of_dfd+file_allocation_table_offset 6) 16)//'(16)' ..
        o=output_file

  putl ' fat_upper_bound = '//$strrep($mem(start_of_dfd+fat_upper_bound_offset 2) 16)//'(16)' ..
        o=output_file

  putl ' current_fmd_index = '//$strrep($mem(start_of_dfd+current_fmd_index_offset 1) 16)//'(16)' ..
        o=output_file

  putl ' highest_offset_allocated = '//..
$strrep($mem(start_of_dfd+highest_offset_allocated_offset 6) 16)//'(16)' o=output_file

  putl ' bytes_per_level_2 = '//$strrep($mem(start_of_dfd+bytes_per_level_2_offset 6) 16)//'(16)' ..
        o=output_file

  IF $mem(start_of_dfd+dfd_modified_offset, 1) = 1 THEN
    putl ' dfd_modified = TRUE' o=output_file
  ELSE
    putl ' dfd_modified = FALSE' o=output_file
  IFEND

  IF $mem(start_of_dfd+overflow_allowed_offset, 1) = 1 THEN
    putl ' overflow_allowed = TRUE' o=output_file
  ELSE
    putl ' overflow_allowed = FALSE' o=output_file
  IFEND

  putl ' requested_allocation_size = '//..
$strrep($mem(start_of_dfd+requested_alloc_size_offset, 3), 16)//'(16)' o=output_file

  putl ' requested_class = '//$ms(start_of_dfd+requested_class_offset, 1) o=output_file

  putl ' requested_class_ordinal = '//..
$strrep($memory(start_of_dfd+requested_class_ordinal_offset, 1), 16)//'(16)' o=output_file

  putl ' requested_transfer_size = '//..
$strrep($memory(start_of_dfd+requested_transfer_size_offset, 3), 16)//'(16)' o=output_file

  putl ' requested_volume:' o=output_file
  putl '   recorded_vsn = '//$memory_string(start_of_dfd+requested_volume_offset+recorded_vsn_offset, 6) ..
        o=output_file
  putl '   setname = '//$memory_string(start_of_dfd+requested_volume_offset+setname_offset, 31) ..
        o=output_file

  putl ' number_of_fmds = '//$strrep($memory(start_of_dfd+number_of_fmds_offset, 1), 16)//'(16)' ..
        o=output_file

  putl ' p_fmd = '//$strrep($memory(start_of_dfd+p_fmd_offset, 6), 16)//'(16)' o=output_file

  IF $memory(start_of_dfd+file_damaged_offset, 1) = 1 THEN
    putl ' file_damaged_offset = TRUE' o=output_file
  ELSE
    putl ' file_damaged_offset = FALSE' o=output_file
  IFEND

  IF $memory(start_of_dfd+damage_detection_enabled_offset, 1) = 1 THEN
    putl ' damage_detection_enabled = TRUE' o=output_file
  ELSE
    putl ' damage_detection_enabled = FALSE' o=output_file
  IFEND

  IF $memory(start_of_dfd+fmd_modified_offset, 1) = 1 THEN
    putl ' fmd_modified = TRUE' o=output_file
  ELSE
    putl ' fmd_modified = FALSE' o=output_file
  IFEND

  IF $specified(fmd_p) THEN
    fmd_p = $memory(start_of_dfd+p_fmd_offset, 6)
  IFEND

PROCEND dum$display_dfd
