Changeset 900 in MondoRescue for trunk/mondo/src/common/libmondo-fork.c
- Timestamp:
- Oct 24, 2006, 8:49:18 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/common/libmondo-fork.c
r783 r900 10 10 #include "libmondo-files-EXT.h" 11 11 #include "libmondo-tools-EXT.h" 12 #include "mr_mem.h" 12 13 13 14 extern bool g_text_mode; … … 30 31 31 32 if ((fin = popen(call, "r"))) { 32 for ( getline(&result, &n, fin); !feof(fin);getline(&result, &n, fin));33 for (mr_getline(&result, &n, fin); !feof(fin); mr_getline(&result, &n, fin)); 33 34 paranoid_pclose(fin); 34 35 } else { … … 89 90 } 90 91 91 asprintf(&cd_number_str, "%d", cd_no);92 mr_asprintf(&cd_number_str, "%d", cd_no); 92 93 resolve_naff_tokens(midway_call, basic_call, isofile, "_ISO_"); 93 94 resolve_naff_tokens(tmp, midway_call, cd_number_str, "_CD#_"); 94 paranoid_free(cd_number_str);95 mr_free(cd_number_str); 95 96 96 97 resolve_naff_tokens(ultimate_call, tmp, MONDO_LOGFILE, "_ERR_"); … … 99 100 log_msg(4, "tmp = '%s'", tmp); 100 101 log_msg(4, "ultimate call = '%s'", ultimate_call); 101 asprintf(&command, "%s >> %s", ultimate_call, MONDO_LOGFILE);102 mr_asprintf(&command, "%s >> %s", ultimate_call, MONDO_LOGFILE); 102 103 103 104 log_to_screen … … 138 139 (what_i_am_doing, command); 139 140 } 140 paranoid_free(command);141 142 paranoid_free(midway_call);143 paranoid_free(ultimate_call);144 paranoid_free(tmp);141 mr_free(command); 142 143 mr_free(midway_call); 144 mr_free(ultimate_call); 145 mr_free(tmp); 145 146 return (retval); 146 147 } … … 181 182 log_if_failure = TRUE; 182 183 } 183 asprintf(&callstr,184 mr_asprintf(&callstr, 184 185 "%s > /tmp/mondo-run-prog-thing.tmp 2> /tmp/mondo-run-prog-thing.err", 185 186 program); … … 198 199 "--------------------------------start of output-----------------------------"); 199 200 } 200 paranoid_free(callstr);201 mr_free(callstr); 201 202 202 203 if (log_if_failure … … 210 211 fin = fopen("/tmp/mondo-run-prog-thing.tmp", "r"); 211 212 if (fin) { 212 for ( getline(&incoming, &n, fin); !feof(fin);213 getline(&incoming, &n, fin)) {213 for (mr_getline(&incoming, &n, fin); !feof(fin); 214 mr_getline(&incoming, &n, fin)) { 214 215 /* patch by Heiko Schlittermann */ 215 216 p = incoming; … … 227 228 } 228 229 } 229 paranoid_free(incoming);230 mr_free(incoming); 230 231 paranoid_fclose(fin); 231 232 } … … 273 274 assert_string_is_neither_NULL_nor_zerolength(basic_call); 274 275 275 asprintf(&lockfile, "/tmp/mojo-jojo.blah.XXXXXX");276 mr_asprintf(&lockfile, "/tmp/mojo-jojo.blah.XXXXXX"); 276 277 mkstemp(lockfile); 277 asprintf(&command,278 mr_asprintf(&command, 278 279 "echo hi > %s ; %s >> %s 2>> %s; res=$?; sleep 1; rm -f %s; exit $res", 279 280 lockfile, basic_call, MONDO_LOGFILE, MONDO_LOGFILE, lockfile); 280 281 open_evalcall_form(what_i_am_doing); 281 asprintf(&tmp, "Executing %s", basic_call);282 mr_asprintf(&tmp, "Executing %s", basic_call); 282 283 log_msg(2, tmp); 283 paranoid_free(tmp);284 mr_free(tmp); 284 285 285 286 if (!(fin = popen(command, "r"))) { 286 287 log_OS_error("Unable to popen-in command"); 287 asprintf(&tmp, _("Failed utterly to call '%s'"), command);288 mr_asprintf(&tmp, _("Failed utterly to call '%s'"), command); 288 289 log_to_screen(tmp); 289 paranoid_free(tmp);290 paranoid_free(lockfile);291 paranoid_free(command);290 mr_free(tmp); 291 mr_free(lockfile); 292 mr_free(command); 292 293 return (1); 293 294 } 294 paranoid_free(command);295 mr_free(command); 295 296 296 297 if (!does_file_exist(lockfile)) { … … 320 321 close_evalcall_form(); 321 322 unlink(lockfile); 322 paranoid_free(lockfile);323 mr_free(lockfile); 323 324 324 325 return (retval); … … 357 358 fin = f_orig; 358 359 fout = f_archived; 359 asprintf(&tmp, "%-64s", PIMP_START_SZ);360 mr_asprintf(&tmp, "%-64s", PIMP_START_SZ); 360 361 if (fwrite(tmp, 1, 64, fout) != 64) { 361 362 fatal_error("Can't write the introductory block"); 362 363 } 363 paranoid_free(tmp);364 mr_free(tmp); 364 365 365 366 while (1) { … … 368 369 break; 369 370 } 370 asprintf(&tmp, "%-64ld", bytes_read_in);371 mr_asprintf(&tmp, "%-64ld", bytes_read_in); 371 372 if (fwrite(tmp, 1, 64, fout) != 64) { 372 373 fatal_error("Cannot write introductory block"); 373 374 } 374 paranoid_free(tmp);375 mr_free(tmp); 375 376 376 377 log_msg(7, … … 378 379 subsliceno, bytes_read_in, bytes_to_be_read); 379 380 bytes_written_out += fwrite(buf, 1, bytes_read_in, fout); 380 asprintf(&tmp, "%-64ld", subsliceno);381 mr_asprintf(&tmp, "%-64ld", subsliceno); 381 382 if (fwrite(tmp, 1, 64, fout) != 64) { 382 383 fatal_error("Cannot write post-thingy block"); 383 384 } 384 paranoid_free(tmp);385 mr_free(tmp); 385 386 386 387 log_msg(7, "Subslice #%d written OK", subsliceno); 387 388 subsliceno++; 388 389 } 389 asprintf(&tmp, "%-64ld", 0L);390 mr_asprintf(&tmp, "%-64ld", 0L); 390 391 if (fwrite(tmp, 1, 64L, fout) != 64L) { 391 392 fatal_error("Cannot write final introductory block"); … … 436 437 437 438 if (direction == 'w') { 438 paranoid_free(tmp);439 asprintf(&tmp, "%-64s", PIMP_END_SZ);439 mr_free(tmp); 440 mr_asprintf(&tmp, "%-64s", PIMP_END_SZ); 440 441 if (fwrite(tmp, 1, 64L, fout) != 64L) { 441 442 fatal_error("Can't write the final block"); 442 443 } 443 paranoid_free(tmp);444 mr_free(tmp); 444 445 } else { 445 446 log_msg(1, "tmpA is %s", tmp); … … 456 457 fwrite(tmp, 1, bytes_read_in, ftmp); 457 458 458 paranoid_free(tmp);459 mr_free(tmp); 459 460 if (!(tmp = malloc(512))) { 460 461 fatal_error("Failed to malloc() tmp"); … … 471 472 } 472 473 } 473 paranoid_free(tmp);474 } 475 476 paranoid_free(buf);474 mr_free(tmp); 475 } 476 477 mr_free(buf); 477 478 log_msg(3, "Successfully copied %ld bytes", bytes_written_out); 478 479 return (retval); … … 499 500 fatal_error("ntfsclone not found"); 500 501 } 501 paranoid_free(tmp);502 503 asprintf(&command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device);502 mr_free(tmp); 503 504 mr_asprintf(&command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device); 504 505 res = run_program_and_log_output(command, 5); 505 paranoid_free(command);506 mr_free(command); 506 507 507 508 unlink(output_fname); … … 526 527 527 528 tempfile = call_program_and_get_last_line_of_output("mktemp -q /tmp/mondo.XXXXXXXX"); 528 asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile,529 mr_asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile, 529 530 tempfile); 530 531 log_msg(3, command); … … 533 534 if (!(pin = popen(command, "r"))) { 534 535 log_OS_error("fmt err"); 535 paranoid_free(command);536 paranoid_free(tempfile);536 mr_free(command); 537 mr_free(tempfile); 537 538 return (1); 538 539 } 539 paranoid_free(command);540 mr_free(command); 540 541 541 542 maxpc = 100; … … 562 563 } 563 564 unlink(tempfile); 564 paranoid_free(tempfile);565 mr_free(tempfile); 565 566 return (res); 566 567 } … … 608 609 *pchild_result = 999; 609 610 610 asprintf(&command, "%s 2>> %s", cmd, MONDO_LOGFILE);611 mr_asprintf(&command, "%s 2>> %s", cmd, MONDO_LOGFILE); 611 612 log_msg(3, "command = '%s'", command); 612 613 if ((res = … … 636 637 update_evalcall_form(percentage); 637 638 } 638 paranoid_free(command);639 mr_free(command); 639 640 640 641 log_file_end_to_screen(MONDO_LOGFILE, ""); … … 668 669 fatal_error("ntfsclone not found"); 669 670 } 670 paranoid_free(tmp);671 672 asprintf(&command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo);671 mr_free(tmp); 672 673 mr_asprintf(&command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo); 673 674 res = run_program_and_log_output(command, 5); 674 paranoid_free(command);675 mr_free(command); 675 676 return (res); 676 677 }
Note:
See TracChangeset
for help on using the changeset viewer.