COMPILATION LISTING OF SEGMENT salvage_dir Compiled by: Multics PL/I Compiler, Release 28e, of February 14, 1985 Compiled at: Honeywell Multics Op. - System M Compiled on: 07/11/86 0918.2 mst Fri Options: optimize map 1 /****^ *********************************************************** 2* * * 3* * Copyright, (C) Honeywell Information Systems Inc., 1982 * 4* * * 5* * Copyright (c) 1972 by Massachusetts Institute of * 6* * Technology and Honeywell Information Systems, Inc. * 7* * * 8* *********************************************************** */ 9 10 /****^ HISTORY COMMENTS: 11* 1) change(86-05-23,Lippard), approve(86-06-17,MCR7433), 12* audit(86-06-24,Hartogs), install(86-07-11,MR12.0-1092): 13* Modified by Jim Lippard to mention -delete_connection_failure in 14* syntax line and display output on terminal when no output file 15* pathname is given. 16* END HISTORY COMMENTS */ 17 18 19 salvage_dir: proc; 20 21 /* This command rebuilds the directory specified. 22* 23* Usage: salvage_dir path {output_path} -debug -dump dump_path -compact -rebuild -check_vtoce 24* -delete_connection_failure 25* */ 26 27 /* AUTOMATIC */ 28 29 dcl arg char (arg_len) based (arg_ptr); /* argument specified with the call */ 30 dcl arg_len fixed bin; 31 dcl arg_ptr ptr; 32 dcl close_io bit (1) aligned; /* ON, if salv was open. */ 33 dcl detach_io bit (1) aligned; /* ON, if salv was attached. */ 34 dcl code fixed bin (35); 35 dcl path char (168); /* name of directory */ 36 dcl ename char (32); /* entry name */ 37 dcl nargs fixed bin; /* number of arguments. Must be 1 */ 38 dcl output char (output_len) var based (output_p); 39 dcl output_len fixed bin (21); 40 dcl output_p ptr; 41 dcl output_path char (168); /* Name of the output segment specified with the call */ 42 dcl dump_p ptr; /* ptr to copy of directory before salvage. */ 43 dcl temp_p (4) ptr; 44 dcl time char (24) aligned; 45 dcl dump_len fixed bin; 46 dcl p ptr; 47 dcl dump_dir char (168); 48 dcl dump_ename char (32); 49 dcl i fixed bin; 50 dcl 1 info aligned like salv_args; 51 dcl iocbp ptr; 52 53 dcl cleanup condition; 54 dcl copy (dump_len) bit (36) aligned based; /* director y */ 55 56 dcl (null, ptr, substr, string) builtin; 57 58 /* EXTERNAL */ 59 60 dcl get_temp_segments_ entry (char (*), (*) ptr, fixed bin (35)); 61 dcl release_temp_segments_ entry (char (*), (*) ptr, fixed bin (35)); 62 dcl absolute_pathname_ entry (char (*), char (*), fixed bin (35)); 63 dcl clock_ entry returns (fixed bin (52)); 64 dcl com_err_ entry options (variable); 65 dcl cu_$arg_count entry (fixed bin); 66 dcl cu_$arg_ptr entry (fixed bin, ptr, fixed bin, fixed bin (35)); 67 dcl date_time_ entry (fixed bin (52), char (*) aligned); 68 dcl error_table_$bad_arg fixed bin (35) ext; 69 dcl expand_pathname_ entry (char (*), char (*), char (*), fixed bin (35)); 70 dcl hcs_$make_seg entry (char (*), char (*), char (*), fixed bin (5), ptr, fixed bin (35)); 71 dcl hcs_$set_bc_seg entry (ptr, fixed bin (24), fixed bin (35)); 72 dcl hphcs_$salv_directory entry (ptr, char (*) var, ptr, fixed bin, fixed bin (35)); 73 dcl ioa_$ioa_switch entry options (variable); 74 dcl ioa_ entry options (variable); 75 dcl iox_$attach_ioname entry (char (*), ptr, char (*), fixed bin (35)); 76 dcl iox_$close entry (ptr, fixed bin (35)); 77 dcl iox_$detach_iocb entry (ptr, fixed bin (35)); 78 dcl iox_$open entry (ptr, fixed bin, bit (1) aligned, fixed bin (35)); 79 dcl iox_$put_chars entry (ptr, ptr, fixed bin (21), fixed bin (35)); 80 81 /* CONSTANT */ 82 83 dcl NAME char (11) int static options (constant) init ("salvage_dir"); 84 85 temp_p (*) = null; 86 output_path, path = ""; 87 close_io, detach_io = "0"b; 88 89 /* Argument parse */ 90 91 call cu_$arg_count (nargs); 92 if nargs = 0 then do; 93 call com_err_ (0, "salvage_dir", "Usage: salvage_dir dir_path {output_path} -compact -check_vtoce -delete_connection_failure -rebuild"); 94 return; 95 end; 96 97 string (info.options) = "0"b; 98 info.salv_time = bit (clock_ (), 36); 99 info.correct_oosw = "1"b; 100 do i = 1 to nargs; 101 call cu_$arg_ptr (i, arg_ptr, arg_len, code); 102 if code ^= 0 then do; 103 call com_err_ (code, "salvage_dir", arg); 104 return; 105 end; 106 if substr (arg, 1, 1) = "-" then do; 107 if arg = "-rebuild" then info.force_rebuild = "1"b; 108 else if arg = "-check_vtoce" then info.check_vtoce = "1"b; 109 else if arg = "-compact" then info.compact = "1"b; 110 else if arg = "-delete_connection_failure" | arg = "-dcf" then info.delete_connection_failure = "1"b; 111 112 /* -dump */ 113 else if arg = "-debug" | arg = "-db" then info.print_trace = "1"b; 114 else if arg = "-dump" then do; 115 info.dump = "1"b; 116 i = i + 1; 117 call cu_$arg_ptr (i, arg_ptr, arg_len, code); 118 if code ^= 0 then do; 119 call com_err_ (0, NAME, "-dump must be followed by the path of the dump directory"); 120 return; 121 end; 122 123 call absolute_pathname_ (arg, dump_dir, code); 124 if code ^= 0 | (substr (arg, 1, 1) = "-") then do; 125 call com_err_ (code, NAME, "-dump must be followed by the path of the dump directory ^a", arg); 126 return; 127 end; 128 end; 129 else do; 130 call com_err_ (error_table_$bad_arg, NAME, arg); 131 return; 132 end; 133 end; 134 else if path = "" then do; 135 call expand_pathname_ (arg, path, ename, code); 136 if code ^= 0 then do; 137 call com_err_ (code, NAME, arg); 138 return; 139 end; 140 if path = ">" then path = rtrim (path) || ename; 141 else path = rtrim (path) || ">" || ename; 142 end; 143 else if output_path = "" then do; 144 call absolute_pathname_ (arg, output_path, code); 145 if code ^= 0 then do; 146 call com_err_ (code, NAME, ""); 147 return; 148 end; 149 end; 150 else do; 151 call com_err_ (error_table_$bad_arg, NAME, arg); 152 return; 153 end; 154 end; 155 156 if path = "" then do; 157 call com_err_ (0, NAME, "Pathname missing. salvage_dir path {output_path}"); 158 return; 159 end; 160 161 info.check_vtoce = info.check_vtoce | info.delete_connection_failure; 162 163 /* Get temp segments */ 164 165 on cleanup call release; 166 call get_temp_segments_ (NAME, temp_p, code); 167 if code ^= 0 then do; 168 call com_err_ (code, NAME); 169 return; 170 end; 171 172 output_p = temp_p (1); 173 info.temp1_ptr = temp_p (2); 174 info.temp2_ptr = temp_p (3); 175 if info.dump then dump_p = temp_p (4); 176 else dump_p = null; 177 178 /* Salvage and print output. */ 179 180 output_len = 64 * 1024 * 4; 181 output = ""; 182 info.pathname = path; 183 call hphcs_$salv_directory (addr (info), output, dump_p, dump_len, code); 184 185 186 /* Attach output segment. */ 187 188 if output ^= "" then do; 189 if output_path ^= "" then do; 190 call iox_$attach_ioname ("salv", iocbp, "vfile_ " || rtrim (output_path) || " -append ", code); 191 if code ^= 0 then call com_err_ (code, NAME, output_path); 192 else do; 193 detach_io = "1"b; 194 call iox_$open (iocbp, Stream_output, "0"b, code); 195 if code ^= 0 then call com_err_ (code, NAME, output_path); 196 else do; 197 close_io = "1"b; 198 199 call ioa_$ioa_switch (iocbp, "^/^a:", path); 200 call iox_$put_chars (iocbp, ptr (output_p, 1), length (output), code); 201 end; 202 end; 203 end; 204 else do; 205 call ioa_ ("^/^a:", path); 206 call ioa_ ("^a", output); 207 end; 208 end; 209 210 /* If a copy of the directory, before salvage, is returned, then create a segment in the dump_dir with the name: 211* .