Changeset 1107 in MondoRescue for branches/stable/mondo/src/common/libmondo-fork.c
- Timestamp:
- Feb 8, 2007, 12:09:34 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-fork.c
r1080 r1107 102 102 /*@*********** End Variables ***************************************/ 103 103 104 log_msg(3, "Starting");104 mr_msg(3, "Starting"); 105 105 assert(bkpinfo != NULL); 106 106 assert_string_is_neither_NULL_nor_zerolength(basic_call); … … 122 122 resolve_naff_tokens(tmp, midway_call, cd_number_str, "_CD#_"); 123 123 resolve_naff_tokens(ultimate_call, tmp, MONDO_LOGFILE, "_ERR_"); 124 log_msg(4, "basic call = '%s'", basic_call);125 log_msg(4, "midway_call = '%s'", midway_call);126 log_msg(4, "tmp = '%s'", tmp);127 log_msg(4, "ultimate call = '%s'", ultimate_call);124 mr_msg(4, "basic call = '%s'", basic_call); 125 mr_msg(4, "midway_call = '%s'", midway_call); 126 mr_msg(4, "tmp = '%s'", tmp); 127 mr_msg(4, "ultimate call = '%s'", ultimate_call); 128 128 sprintf(command, "%s >> %s", ultimate_call, MONDO_LOGFILE); 129 129 130 130 log_to_screen 131 131 ("Please be patient. Do not be alarmed by on-screen inactivity."); 132 log_msg(4, "Calling open_evalcall_form() with what_i_am_doing='%s'",132 mr_msg(4, "Calling open_evalcall_form() with what_i_am_doing='%s'", 133 133 what_i_am_doing); 134 134 strcpy(tmp, command); … … 150 150 } 151 151 #endif 152 log_msg(1, "command = '%s'", command);152 mr_msg(1, "command = '%s'", command); 153 153 retval += system(command); 154 154 if (!g_text_mode) { … … 156 156 } 157 157 if (retval) { 158 log_msg(2, "Basic call '%s' returned an error.", basic_call);158 mr_msg(2, "Basic call '%s' returned an error.", basic_call); 159 159 popup_and_OK("Press ENTER to continue."); 160 160 popup_and_OK … … 164 164 /* if text mode then do the above & RETURN; if not text mode, do this... */ 165 165 else { 166 log_msg(3, "command = '%s'", command);166 mr_msg(3, "command = '%s'", command); 167 167 // yes_this_is_a_goto: 168 168 retval = … … 181 181 if (bkpinfo->backup_media_type == dvd && !bkpinfo->please_dont_eject_when_restoring) 182 182 { 183 log_msg(3, "Ejecting DVD device");183 mr_msg(3, "Ejecting DVD device"); 184 184 eject_device(bkpinfo->media_device); 185 185 } … … 220 220 assert(program != NULL); 221 221 if (!program[0]) { 222 log_msg(2, "Warning - asked to run zerolength program");222 mr_msg(2, "Warning - asked to run zerolength program"); 223 223 return (1); 224 224 } … … 256 256 res = system(callstr); 257 257 if (((res == 0) && log_if_success) || ((res != 0) && log_if_failure)) { 258 log_msg(0, "running: %s", callstr);259 log_msg(0,258 mr_msg(0, "running: %s", callstr); 259 mr_msg(0, 260 260 "--------------------------------start of output-----------------------------"); 261 261 } … … 284 284 if ((res == 0 && log_if_success) 285 285 || (res != 0 && log_if_failure)) { 286 log_msg(0, incoming);286 mr_msg(0, incoming); 287 287 } 288 288 } … … 291 291 unlink("/tmp/mondo-run-prog-thing.tmp"); 292 292 if ((res == 0 && log_if_success) || (res != 0 && log_if_failure)) { 293 log_msg(0,293 mr_msg(0, 294 294 "--------------------------------end of output------------------------------"); 295 295 if (res) { 296 log_msg(0, "...ran with res=%d", res);296 mr_msg(0, "...ran with res=%d", res); 297 297 } else { 298 log_msg(0, "...ran just fine. :-)");298 mr_msg(0, "...ran just fine. :-)"); 299 299 } 300 300 } 301 301 // else 302 // { log_msg (0, "-------------------------------ran w/ res=%d------------------------------", res); }302 // { mr_msg (0, "-------------------------------ran w/ res=%d------------------------------", res); } 303 303 return (res); 304 304 } … … 340 340 open_evalcall_form(what_i_am_doing); 341 341 sprintf(tmp, "Executing %s", basic_call); 342 log_msg(2, tmp);342 mr_msg(2, tmp); 343 343 if (!(fin = popen(command, "r"))) { 344 344 log_OS_error("Unable to popen-in command"); … … 350 350 log_to_screen("Waiting for external binary to start"); 351 351 for (i = 0; i < 60 && !does_file_exist(lockfile); sleep(1), i++) { 352 log_msg(3, "Waiting for lockfile %s to exist", lockfile);352 mr_msg(3, "Waiting for lockfile %s to exist", lockfile); 353 353 } 354 354 } … … 375 375 res = pclose(fin); 376 376 /* Log actual pclose errors. */ 377 if (errno) log_msg(5, "pclose err: %d", errno);377 if (errno) mr_msg(5, "pclose err: %d", errno); 378 378 /* Check if we have a valid status. If we do, extract the called program's exit code. */ 379 379 /* If we don't, highlight this fact by returning -1. */ … … 413 413 FILE *ftmp; 414 414 415 log_msg(5, "Opening.");415 mr_msg(5, "Opening."); 416 416 malloc_string(tmp); 417 417 tmp[0] = '\0'; … … 435 435 fatal_error("Cannot write introductory block"); 436 436 } 437 log_msg(7,437 mr_msg(7, 438 438 "subslice #%ld --- I have read %ld of %ld bytes in from f_orig", 439 439 subsliceno, bytes_read_in, bytes_to_be_read); … … 443 443 fatal_error("Cannot write post-thingy block"); 444 444 } 445 log_msg(7, "Subslice #%d written OK", subsliceno);445 mr_msg(7, "Subslice #%d written OK", subsliceno); 446 446 subsliceno++; 447 447 } … … 456 456 fatal_error("Cannot read the introductory block"); 457 457 } 458 log_msg(5, "tmp is %s", tmp);458 mr_msg(5, "tmp is %s", tmp); 459 459 if (!strstr(tmp, PIMP_START_SZ)) { 460 460 fatal_error("Can't find intro blk"); … … 465 465 bytes_to_be_read = atol(tmp); 466 466 while (bytes_to_be_read > 0) { 467 log_msg(7, "subslice#%ld, bytes=%ld", subsliceno,467 mr_msg(7, "subslice#%ld, bytes=%ld", subsliceno, 468 468 bytes_to_be_read); 469 469 bytes_read_in = fread(buf, 1, bytes_to_be_read, fin); … … 477 477 } 478 478 if (atol(tmp) != subsliceno) { 479 log_msg(1, "Wanted subslice %ld but got %ld ('%s')",479 mr_msg(1, "Wanted subslice %ld but got %ld ('%s')", 480 480 subsliceno, atol(tmp), tmp); 481 481 } 482 log_msg(7, "Subslice #%ld read OK", subsliceno);482 mr_msg(7, "Subslice #%ld read OK", subsliceno); 483 483 subsliceno++; 484 484 if (fread(tmp, 1, 64, fin) != 64) { … … 489 489 } 490 490 491 // log_msg(4, "Written %ld of %ld bytes", bytes_written_out, bytes_read_in);491 // mr_msg(4, "Written %ld of %ld bytes", bytes_written_out, bytes_read_in); 492 492 493 493 if (direction == 'w') { … … 497 497 } 498 498 } else { 499 log_msg(1, "tmpA is %s", tmp);499 mr_msg(1, "tmpA is %s", tmp); 500 500 if (!strstr(tmp, PIMP_END_SZ)) { 501 501 if (fread(tmp, 1, 64, fin) != 64) { 502 502 fatal_error("Can't read the final block"); 503 503 } 504 log_msg(5, "tmpB is %s", tmp);504 mr_msg(5, "tmpB is %s", tmp); 505 505 if (!strstr(tmp, PIMP_END_SZ)) { 506 506 ftmp = fopen("/tmp/out.leftover", "w"); 507 507 bytes_read_in = fread(tmp, 1, 64, fin); 508 log_msg(1, "bytes_read_in = %ld", bytes_read_in);508 mr_msg(1, "bytes_read_in = %ld", bytes_read_in); 509 509 // if (bytes_read_in!=128+64) { fatal_error("Can't read the terminating block"); } 510 510 fwrite(tmp, 1, bytes_read_in, ftmp); 511 511 sprintf(tmp, "I am here - %lld", (long long)ftello(fin)); 512 // log_msg(0, tmp);512 // mr_msg(0, tmp); 513 513 fread(tmp, 1, 512, fin); 514 log_msg(0, "tmp = '%s'", tmp);514 mr_msg(0, "tmp = '%s'", tmp); 515 515 fwrite(tmp, 1, 512, ftmp); 516 516 fclose(ftmp); … … 522 522 mr_free(buf); 523 523 mr_free(tmp); 524 log_msg(3, "Successfully copied %ld bytes", bytes_written_out);524 mr_msg(3, "Successfully copied %ld bytes", bytes_written_out); 525 525 return (retval); 526 526 } … … 588 588 sprintf(command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile, 589 589 tempfile); 590 log_msg(3, command);590 mr_msg(3, command); 591 591 open_evalcall_form(title); 592 592 if (!(pin = popen(command, "r"))) { … … 599 599 pcno = grab_percentage_from_last_line_of_file(MONDO_LOGFILE); 600 600 if (pcno < 0 || pcno > 100) { 601 log_msg(5, "Weird pc#");601 mr_msg(5, "Weird pc#"); 602 602 continue; 603 603 } … … 634 634 res = 999; 635 635 sz_command = (char *) info; 636 log_msg(4, "sz_command = '%s'", sz_command);636 mr_msg(4, "sz_command = '%s'", sz_command); 637 637 res = system(sz_command); 638 638 if (res > 256 && res != 4444) { 639 639 res = res / 256; 640 640 } 641 log_msg(4, "child res = %d", res);641 mr_msg(4, "child res = %d", res); 642 642 sz_command[0] = '\0'; 643 643 pthread_exit((void *) (&res)); … … 675 675 strcpy(title, tt); 676 676 sprintf(command, "%s 2>> %s", cmd, MONDO_LOGFILE); 677 log_msg(3, "command = '%s'", command);677 mr_msg(3, "command = '%s'", command); 678 678 if ((res = 679 679 pthread_create(&childthread, NULL, run_prog_in_bkgd_then_exit, … … 682 682 } 683 683 684 log_msg(8, "Parent running");684 mr_msg(8, "Parent running"); 685 685 open_evalcall_form(title); 686 686 for (sleep(1); command[0] != '\0'; sleep(1)) { 687 687 pcno = grab_percentage_from_last_line_of_file(MONDO_LOGFILE); 688 688 if (pcno <= 0 || pcno > 100) { 689 log_msg(8, "Weird pc#");689 mr_msg(8, "Weird pc#"); 690 690 continue; 691 691 } … … 711 711 res = 666; 712 712 } 713 log_msg(3, "Parent res = %d", res);713 mr_msg(3, "Parent res = %d", res); 714 714 mr_free(command); 715 715 mr_free(title);
Note:
See TracChangeset
for help on using the changeset viewer.