Changeset 2049 in MondoRescue
- Timestamp:
- Oct 22, 2008, 7:50:04 PM (17 years ago)
- Location:
- branches/2.2.8/mondo/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.8/mondo/src/common/libmondo-fifo.c
r2030 r2049 194 194 195 195 /* @} - end of fifoGroup */ 196 197 int198 extract_config_file_from_ramdisk(char *ramdisk_fname,199 char *output_cfg_file,200 char *output_mountlist_file); -
branches/2.2.8/mondo/src/mondorestore/mondo-rstr-tools-EXT.h
r1736 r2049 29 29 extern int unmount_all_devices(struct mountlist_itself *); 30 30 extern int get_cfg_file_from_archive(); 31 extern int32 extract_config_file_from_ramdisk(33 char *ramdisk_fname,34 char *output_cfg_file,35 char *output_mountlist_file);36 37 31 extern void ask_about_these_imagedevs(char *infname, char *outfname); 38 32 -
branches/2.2.8/mondo/src/mondorestore/mondo-rstr-tools.c
r2030 r2049 202 202 * @ingroup restoreUtilityGroup 203 203 */ 204 int205 extract_config_file_from_ramdisk(char *ramdisk_fname,206 char *output_cfg_file,207 char *output_mountlist_file)208 {209 char *mountpt;210 char *command;211 char *orig_fname;212 int retval = 0;213 214 assert(bkpinfo != NULL);215 malloc_string(mountpt);216 malloc_string(command);217 malloc_string(orig_fname);218 assert_string_is_neither_NULL_nor_zerolength(ramdisk_fname);219 assert_string_is_neither_NULL_nor_zerolength(output_cfg_file);220 assert_string_is_neither_NULL_nor_zerolength(output_mountlist_file);221 sprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);222 sprintf(command, "mkdir -p %s", mountpt);223 run_program_and_log_output(command, FALSE);224 sprintf(command, "gzip -dc %s > %s/mindi.rd 2> /dev/null",225 ramdisk_fname, bkpinfo->tmpdir);226 227 run_program_and_log_output(command, FALSE);228 sprintf(command, "umount %s", mountpt);229 230 run_program_and_log_output(command, FALSE);231 232 sprintf(command, "mount -o loop %s/mindi.rd -t ext2 %s",233 bkpinfo->tmpdir, mountpt);234 235 run_program_and_log_output(command, FALSE);236 237 sprintf(command, "mkdir -p %s/tmp", bkpinfo->tmpdir);238 239 run_program_and_log_output(command, FALSE);240 241 sprintf(command, "cp -f %s/%s %s", // %s/%s becomes {mountpt}/tmp/m*ndo-restore.cfg242 mountpt, g_mondo_cfg_file, output_cfg_file);243 run_program_and_log_output(command, FALSE);244 245 sprintf(orig_fname, "%s/%s", mountpt, g_mountlist_fname);246 if (does_file_exist(orig_fname)) {247 sprintf(command, "cp -f %s %s", orig_fname, output_mountlist_file);248 run_program_and_log_output(command, FALSE);249 }250 sprintf(command, "umount %s", mountpt);251 run_program_and_log_output(command, FALSE);252 if (!does_file_exist(output_cfg_file)253 || (!does_file_exist(output_mountlist_file)254 && does_file_exist(orig_fname))) {255 log_msg(2, "Failed to extract %s and/or %s from ramdisk",256 output_cfg_file, output_mountlist_file);257 retval = 1;258 } else {259 retval = 0;260 }261 paranoid_free(mountpt);262 paranoid_free(command);263 paranoid_free(orig_fname);264 return (retval);265 266 }267 268 269 270 204 271 205 /** … … 1186 1120 int res = 0; 1187 1121 pid_t pid; 1122 bool extract_mountlist_stub = FALSE; 1188 1123 1189 1124 assert(bkpinfo != NULL); 1190 1125 malloc_string(command); 1191 1126 malloc_string(tmp); 1127 1128 /* If those files already exist, do not overwrite them later on */ 1129 if (does_file_exist("/"MOUNTLIST_FNAME_STUB)) { 1130 extract_mountlist_stub = FALSE; 1131 } else { 1132 extract_mountlist_stub = TRUE; 1133 } 1192 1134 1193 1135 if (does_file_exist(g_filelist_full) … … 1204 1146 unlink("/tmp/filelist.full"); 1205 1147 unlink(FILELIST_FULL_STUB); 1206 unlink("/" IWANTMYLVM_STUB);1207 1148 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1208 1149 sprintf(command, … … 1213 1154 BIGGIELIST_TXT_STUB, 1214 1155 FILELIST_FULL_STUB, 1215 IWANTMYLVM_STUB, 1156 IWANTMYLVM_STUB, 1216 1157 MONDO_CFG_FILE_STUB); 1217 1158 log_msg(1, "tarcommand = %s", command); … … 1228 1169 FILELIST_FULL_STUB, 1229 1170 IWANTMYLVM_STUB, 1230 1171 MONDO_CFG_FILE_STUB); 1231 1172 log_msg(1, "tarcommand = %s", command); 1232 1173 run_program_and_log_output(command, 1); … … 1245 1186 BIGGIELIST_TXT_STUB, 1246 1187 FILELIST_FULL_STUB, 1247 IWANTMYLVM_STUB, 1188 IWANTMYLVM_STUB, 1248 1189 MONDO_CFG_FILE_STUB); 1249 1190 … … 1259 1200 BIGGIELIST_TXT_STUB, 1260 1201 FILELIST_FULL_STUB, 1261 IWANTMYLVM_STUB, 1202 IWANTMYLVM_STUB, 1262 1203 MONDO_CFG_FILE_STUB); 1263 1204 … … 1290 1231 if (am_I_in_disaster_recovery_mode() 1291 1232 && 1233 /* If it was there, do not overwrite it */ 1234 (extract_mountlist_stub) 1235 && 1292 1236 ask_me_yes_or_no("Do you want to retrieve the mountlist as well?")) 1293 1237 { … … 1298 1242 1299 1243 chdir(tmp); 1300 1244 1301 1245 if (!does_file_exist(g_biggielist_txt)) { 1302 1246 log_msg(1, "Warning - %s not found", g_biggielist_txt); … … 2231 2175 char *ramdisk_fname; 2232 2176 char *mountlist_file; 2177 bool extract_mountlist_stub; 2178 bool extract_i_want_my_lvm; 2233 2179 2234 2180 bool try_plan_B; … … 2252 2198 unlink(FILELIST_FULL_STUB); 2253 2199 unlink(BIGGIELIST_TXT_STUB); 2254 unlink(IWANTMYLVM_STUB);2255 2200 sprintf(command, "mkdir -p %s", mountpt); 2256 2201 run_program_and_log_output(command, FALSE); 2257 2202 2258 // unlink( "tmp/mondo-restore.cfg" ); // superfluous, surely?2259 2260 2203 sprintf(cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB); 2261 sprintf(mountlist_file, "%s/%s", bkpinfo->tmpdir, 2262 MOUNTLIST_FNAME_STUB); 2204 sprintf(mountlist_file, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2263 2205 // make_hole_for_file( cfg_file ); 2264 2206 // make_hole_for_file( mountlist_file); … … 2316 2258 } 2317 2259 } else { 2260 if (does_file_exist("/"MOUNTLIST_FNAME_STUB)) { 2261 extract_mountlist_stub = FALSE; 2262 } else { 2263 extract_mountlist_stub = TRUE; 2264 } 2265 if (does_file_exist("/"IWANTMYLVM_STUB)) { 2266 extract_i_want_my_lvm = FALSE; 2267 } else { 2268 extract_i_want_my_lvm = TRUE; 2269 } 2270 2318 2271 log_msg(2, 2319 2272 "gcffa --- Plan B, a.k.a. untarring some file from all.tar.gz"); … … 2348 2301 } 2349 2302 sprintf(command, "cp -f %s/%s %s", 2350 2351 2303 call_program_and_get_last_line_of_output("pwd"), 2304 MOUNTLIST_FNAME_STUB, mountlist_file); 2352 2305 iamhere(command); 2353 if (strcmp(tmp, cfg_file) 2354 && run_program_and_log_output(command, 1)) { 2355 log_msg(1, "Failed to get mountlist"); 2356 } else { 2357 log_msg(1, "Got mountlist too"); 2358 sprintf(command, "cp -f %s %s", mountlist_file, 2359 g_mountlist_fname); 2360 if (run_program_and_log_output(command, 1)) { 2361 log_msg(1, "Failed to copy mountlist to /tmp"); 2306 if (extract_mountlist_stub) { 2307 if (strcmp(tmp, cfg_file) 2308 && run_program_and_log_output(command, 1)) { 2309 log_msg(1, "Failed to get mountlist"); 2362 2310 } else { 2363 log_msg(1, "Copied mountlist to /tmp as well OK"); 2364 sprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB); 2365 run_program_and_log_output(command, 1); 2311 log_msg(1, "Got mountlist too"); 2312 sprintf(command, "cp -f %s %s", mountlist_file, 2313 g_mountlist_fname); 2314 if (run_program_and_log_output(command, 1)) { 2315 log_msg(1, "Failed to copy mountlist to /tmp"); 2316 } else { 2317 log_msg(1, "Copied mountlist to /tmp as well OK"); 2318 sprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB); 2319 run_program_and_log_output(command, 1); 2320 } 2366 2321 } 2367 2322 } … … 2380 2335 log_to_screen("...but not mountlist.txt - a pity, really..."); 2381 2336 } 2382 /* start SAH */2383 2337 else { 2384 sprintf(command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, 2385 bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2386 run_program_and_log_output(command, FALSE); 2387 } 2388 /*--commented out by SAH 2389 sprintf( command, "cp -f %s %s/%s", cfg_file, bkpinfo->tmpdir, MONDO_CFG_FILE_STUB ); 2390 run_program_and_log_output( command, FALSE ); 2391 sprintf( command, "cp -f %s %s/%s", mountlist_file, bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB ); 2392 run_program_and_log_output( command, FALSE ); 2393 */ 2394 /* end SAH */ 2338 /* Is this code really useful ??? */ 2339 if (extract_mountlist_stub) { 2340 sprintf(command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, 2341 bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2342 run_program_and_log_output(command, FALSE); 2343 } 2344 } 2395 2345 2396 2346 sprintf(command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB); 2397 2347 run_program_and_log_output(command, FALSE); 2398 sprintf(command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB); 2399 run_program_and_log_output(command, FALSE); 2348 if (extract_mountlist_stub) { 2349 sprintf(command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB); 2350 run_program_and_log_output(command, FALSE); 2351 } 2400 2352 sprintf(command, "cp -f etc/raidtab /etc/"); 2401 2353 run_program_and_log_output(command, FALSE); 2402 sprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB); 2403 run_program_and_log_output(command, FALSE); 2354 if (extract_i_want_my_lvm) { 2355 sprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB); 2356 run_program_and_log_output(command, FALSE); 2357 } 2404 2358 g_backup_media_type = bkpinfo->backup_media_type; 2405 2359 paranoid_free(device);
Note:
See TracChangeset
for help on using the changeset viewer.