?? RIGHT := 110 ??
*copy osd$default_pragmats
?? NEWTITLE := 'NOS/VE Device Management' ??
MODULE dmm$access_volume_device_files ALIAS 'DMMDIS1';
?? RIGHT := 110 ??
?? TITLE := '  Common Decks', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc rmd$volume_declarations
*copyc dmt$assigned_ms_vol_attributes
*copyc dmt$error_condition_codes
*copyc dmt$ms_device_allocation_table
*copyc dmt$ms_device_file_list_entry
*copyc dmt$ms_volume_directory
*copyc dmt$ms_volume_label
*copyc ost$status
?? POP ??
*copyc dmp$attach_device_file
*copyc dmp$close_file
*copyc dmp$get_active_vol_attributes
*copyc dmp$open_dat
*copyc dmp$open_dflt
*copyc dmp$open_directory
*copyc dmp$open_file
*copyc dmp$open_label
*copyc dmp$open_login_table
*copyc dmp$search_avt_by_rvsn
*copyc osp$set_status_abnormal
?? TITLE := '  dmp$close_dat_r3', EJECT ??

  PROCEDURE [XDCL, #GATE] dmp$close_dat_r3
    (    p_dat: ^dmt$ms_device_allocation_table;
     VAR status: ost$status);

    dmp$close_file (p_dat, status);

  PROCEND dmp$close_dat_r3;
?? TITLE := '  dmp$close_dfl_r3', EJECT ??

  PROCEDURE [XDCL, #GATE] dmp$close_dfl_r3
    (    p_dfl: ^dmt$ms_device_file_list_table;
     VAR status: ost$status);

    dmp$close_file (p_dfl, status);

  PROCEND dmp$close_dfl_r3;
?? TITLE := '  dmp$close_directory_r3', EJECT ??

  PROCEDURE [XDCL, #GATE] dmp$close_directory_r3
    (    p_directory: ^dmt$ms_volume_directory;
     VAR status: ost$status);

    dmp$close_file (p_directory, status);

  PROCEND dmp$close_directory_r3;
?? TITLE := ' dmp$close_label_r3', EJECT ??

  PROCEDURE [XDCL, #GATE] dmp$close_label_r3
    (    p_label: ^dmt$ms_volume_label;
     VAR status: ost$status);

    dmp$close_file (p_label, status);

  PROCEND dmp$close_label_r3;
?? TITLE := ' dmp$close_log_r3', EJECT ??

  PROCEDURE [XDCL, #GATE] dmp$close_log_r3
    (    p_log: ^SEQ ( * );
     VAR status: ost$status);

    dmp$close_file (p_log, status);

  PROCEND dmp$close_log_r3;
?? TITLE := '  dmp$close_login_table_r3', EJECT ??

  PROCEDURE [XDCL, #GATE] dmp$close_login_table_r3
    (    p_login_table: ^dmt$ms_mainframe_login_table;
     VAR status: ost$status);

    dmp$close_file (p_login_table, status);

  PROCEND dmp$close_login_table_r3;
?? TITLE := '  dmp$open_dat_r3', EJECT ??

  PROCEDURE [XDCL, #GATE] dmp$open_dat_r3
    (    recorded_vsn: rmt$recorded_vsn;
     VAR p_dat: ^dmt$ms_device_allocation_table;
     VAR status: ost$status);

    VAR
      dat_sfid: gft$system_file_identifier;

    retrieve_file_sfid (recorded_vsn, dmc$ms_device_allocation_table, dat_sfid, status);
    IF status.normal THEN
      dmp$open_dat (dat_sfid, osc$os_ring_1, osc$tsrv_ring, mmc$sar_read, mmc$as_sequential, p_dat, status);
    IFEND;

  PROCEND dmp$open_dat_r3;
?? TITLE := '  dmp$open_dfl_r3', EJECT ??

  PROCEDURE [XDCL, #GATE] dmp$open_dfl_r3
    (    recorded_vsn: rmt$recorded_vsn;
     VAR p_dfl: ^dmt$ms_device_file_list_table;
     VAR status: ost$status);

    VAR
      dfl_sfid: gft$system_file_identifier;

    retrieve_file_sfid (recorded_vsn, dmc$ms_device_file_list_table, dfl_sfid, status);
    IF status.normal THEN
      dmp$open_dflt (dfl_sfid, osc$os_ring_1, osc$tsrv_ring, mmc$sar_read, mmc$as_sequential, p_dfl, status);
    IFEND;

  PROCEND dmp$open_dfl_r3;
?? TITLE := '  dmp$open_directory_r3', EJECT ??

  PROCEDURE [XDCL, #GATE] dmp$open_directory_r3
    (    recorded_vsn: rmt$recorded_vsn;
     VAR p_directory: ^dmt$ms_volume_directory;
     VAR status: ost$status);

    VAR
      directory_sfid: gft$system_file_identifier;

    retrieve_file_sfid (recorded_vsn, dmc$ms_volume_directory, directory_sfid, status);
    IF status.normal THEN
      dmp$open_directory (directory_sfid, osc$os_ring_1, osc$tsrv_ring, mmc$sar_read, mmc$as_sequential,
            p_directory, status);
    IFEND;

  PROCEND dmp$open_directory_r3;
?? TITLE := '  dmp$open_label_r3', EJECT ??

  PROCEDURE [XDCL, #GATE] dmp$open_label_r3
    (    recorded_vsn: rmt$recorded_vsn;
     VAR p_label: ^dmt$ms_volume_label;
     VAR status: ost$status);

    VAR
      avt_index: dmt$active_volume_table_index,
      found: boolean,
      system_file_id: gft$system_file_identifier,
      user_supplied_name: ost$name;

    status.normal := TRUE;
    dmp$search_avt_by_rvsn (recorded_vsn, avt_index, found);
    IF NOT found THEN
      osp$set_status_abnormal (dmc$device_manager_ident, dme$avt_entry_not_found,
            'unable to find recorded vsn in active_volume_table', status);
      RETURN;
    IFEND;

    user_supplied_name := 'LABEL';
    user_supplied_name (6, rmc$recorded_vsn_size) := recorded_vsn;

    dmp$attach_device_file (recorded_vsn, user_supplied_name, system_file_id, status);
    IF status.normal THEN
      dmp$open_label (system_file_id, osc$os_ring_1, osc$tsrv_ring, mmc$sar_read, mmc$as_sequential, p_label,
            status);
    IFEND;

  PROCEND dmp$open_label_r3;
?? TITLE := '  dmp$open_log_r3', EJECT ??

  PROCEDURE [XDCL, #GATE] dmp$open_log_r3
    (    recorded_vsn: rmt$recorded_vsn;
     VAR p_log: ^SEQ ( * );
     VAR status: ost$status);

    VAR
      active: boolean,
      attributes: array [1 .. 2] of dmt$assigned_ms_vol_attribute,
      length: integer,
      segment_pointer: mmt$segment_pointer,
      sfid: gft$system_file_identifier;

    status.normal := TRUE;
    attributes [1].keyword := dmc$ms_device_log;
    attributes [2].keyword := dmc$ms_current_log_position;

    dmp$get_active_vol_attributes (recorded_vsn, 0 {avt_index} , attributes, active);

    IF active THEN
      sfid := attributes [1].p_dlog;
      length := attributes [2].current_log_position + 1;
      segment_pointer.kind := mmc$sequence_pointer;
      dmp$open_file (sfid, osc$os_ring_1, osc$tsrv_ring, mmc$sar_read, mmc$as_sequential, segment_pointer,
            status);
      IF status.normal THEN
        RESET segment_pointer.seq_pointer;
        NEXT p_log: [[REP length OF cell]] IN segment_pointer.seq_pointer;
      IFEND;
    ELSE
      osp$set_status_abnormal (dmc$device_manager_ident, dme$avt_entry_not_found,
            'Unable to find recorded vsn in active_volume_table.', status);
    IFEND;

  PROCEND dmp$open_log_r3;
?? TITLE := '  dmp$open_login_table_r3', EJECT ??

  PROCEDURE [XDCL, #GATE] dmp$open_login_table_r3
    (    recorded_vsn: rmt$recorded_vsn;
     VAR p_login_table: ^dmt$ms_mainframe_login_table;
     VAR status: ost$status);

    VAR
      login_table_sfid: gft$system_file_identifier;

    retrieve_file_sfid (recorded_vsn, dmc$ms_volume_login_table, login_table_sfid, status);
    IF status.normal THEN
      dmp$open_login_table (login_table_sfid, osc$os_ring_1, osc$tsrv_ring, mmc$sar_read, mmc$as_sequential,
            p_login_table, status);
    IFEND;

  PROCEND dmp$open_login_table_r3;
?? TITLE := '  retrieve_file_sfid', EJECT ??

  PROCEDURE [INLINE] retrieve_file_sfid
    (    recorded_vsn: rmt$recorded_vsn;
         file_keyword: dmt$assigned_ms_volume_keywords;
     VAR file_sfid: gft$system_file_identifier;
     VAR status: ost$status);

    VAR
      volume_active: boolean,
      active_vol_attributes: array [1 .. 1] of dmt$assigned_ms_vol_attribute;

    status.normal := TRUE;
    active_vol_attributes [1].keyword := file_keyword;

    dmp$get_active_vol_attributes (recorded_vsn, 0, active_vol_attributes, volume_active);
    IF NOT volume_active THEN
      osp$set_status_abnormal (dmc$device_manager_ident, dme$avt_entry_not_found,
            'unable to locate avt entry - DMMDIS1', status);
      RETURN; {----->
    IFEND;

    CASE file_keyword OF
    = dmc$ms_device_file_list_table =
      file_sfid := active_vol_attributes [1].p_dflt;
    = dmc$ms_volume_directory =
      file_sfid := active_vol_attributes [1].directory_sfid;
    = dmc$ms_device_allocation_table =
      file_sfid := active_vol_attributes [1].p_dat;
    = dmc$ms_volume_login_table =
      file_sfid := active_vol_attributes [1].p_vlgt;
    CASEND;

  PROCEND retrieve_file_sfid;
MODEND dmm$access_volume_device_files;
