Changeset 689 in MondoRescue for trunk/mondo/mondo/common
- Timestamp:
- Jul 17, 2006, 7:43:58 PM (18 years ago)
- Location:
- trunk/mondo/mondo/common
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/common/libmondo-archive.c
r688 r689 433 433 if (bkpinfo->backup_media_type == dvd) { 434 434 #ifdef DVDRWFORMAT 435 if (!find_home_of_exe("dvd+rw-format")) { 435 tmp = find_home_of_exe("dvd+rw-format"); 436 if (!tmp) { 436 437 fatal_error 437 438 ("Cannot find dvd+rw-format. Please install it or fix your PATH."); 438 439 } 440 paranoid_free(tmp); 439 441 #endif 440 if (!find_home_of_exe("growisofs")) { 442 tmp = find_home_of_exe("growisofs"); 443 if (!tmp) { 441 444 fatal_error 442 445 ("Cannot find growisofs. Please install it or fix your PATH."); 443 446 } 447 paranoid_free(tmp); 444 448 } 445 449 … … 3056 3060 "Not calculating checksum for %s: it would take too long", 3057 3061 biggie_filename); 3058 if ( !find_home_of_exe("ntfsresize")) { 3062 tmp = find_home_of_exe("ntfsresize"); 3063 if ( !tmp) { 3059 3064 fatal_error("ntfsresize not found"); 3060 3065 } 3061 sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename); 3066 paranoid_free(tmp); 3067 3068 asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename); 3062 3069 log_it("command = %s", command); 3063 3070 tmp = call_program_and_get_last_line_of_output(command); 3071 paranoid_free(command); 3072 3064 3073 log_it("res of it = %s", tmp); 3065 3074 totallength = (off_t)atoll(tmp); -
trunk/mondo/mondo/common/libmondo-devices.c
r688 r689 495 495 char *find_cdrw_device(void) 496 496 { 497 /*@ buffers ************************ */498 char * comment;499 char *tmp ;500 char *cdr_exe ;501 char *command ;502 char *cdrw_device ;497 char *comment = NULL; 498 char *tmp = NULL; 499 char *tmp1 = NULL; 500 char *cdr_exe = NULL; 501 char *command = NULL; 502 char *cdrw_device = NULL; 503 503 504 504 if (g_cdrw_drive_is_here != NULL) { … … 513 513 } 514 514 run_program_and_log_output("insmod ide-scsi", -1); 515 if (find_home_of_exe("cdrecord")) { 515 tmp = find_home_of_exe("cdrecord"); 516 if (tmp) { 516 517 asprintf(&cdr_exe, "cdrecord"); 517 518 } else { 518 519 asprintf(&cdr_exe, "dvdrecord"); 519 520 } 520 if (find_home_of_exe(cdr_exe)) { 521 paranoid_free(tmp); 522 523 tmp1 = find_home_of_exe(cdr_exe); 524 if (tmp1) { 521 525 asprintf(&command, 522 526 "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1", … … 527 531 asprintf(&tmp, " "); 528 532 } 533 paranoid_free(tmp1); 529 534 paranoid_free(cdr_exe); 530 535 … … 594 599 } 595 600 596 if (find_home_of_exe("cdrecord")) { 601 tmp = find_home_of_exe("cdrecord"); 602 if (tmp) { 597 603 asprintf(&cdr_exe, "cdrecord"); 598 604 } else { 599 605 asprintf(&cdr_exe, "dvdrecord"); 600 606 } 601 if (!find_home_of_exe(cdr_exe)) { 607 paranoid_free(tmp); 608 609 tmp = find_home_of_exe(cdr_exe); 610 if (!tmp) { 602 611 asprintf(&output, "/dev/cdrom"); 603 612 log_msg(4, "Can't find cdrecord; assuming %s", output); … … 612 621 } 613 622 } 623 paranoid_free(tmp); 614 624 615 625 asprintf(&command, "%s -scanbus 2> /dev/null", cdr_exe); -
trunk/mondo/mondo/common/libmondo-filelist.c
r688 r689 479 479 int get_acl_list(char *filelist, char *facl_fname) 480 480 { 481 char *command; 481 char *command = NULL; 482 char *tmp = NULL; 482 483 int retval = 0; 483 484 … … 486 487 paranoid_free(command); 487 488 488 if (find_home_of_exe("getfacl")) { 489 tmp = find_home_of_exe("getfacl"); 490 if (tmp) { 489 491 // sort_file(filelist); // FIXME - filelist chopper sorts, so this isn't necessary 490 492 asprintf(&command, … … 495 497 paranoid_free(command); 496 498 } 499 paranoid_free(tmp); 497 500 return (retval); 498 501 } … … 501 504 int get_fattr_list(char *filelist, char *fattr_fname) 502 505 { 503 char *command; 506 char *command = NULL; 507 char *tmp = NULL; 504 508 int retval = 0; 505 509 … … 508 512 paranoid_free(command); 509 513 510 if (find_home_of_exe("getfattr")) { 514 tmp = find_home_of_exe("getfattr"); 515 if (tmp) { 511 516 // sort_file(filelist); // FIXME - filelist chopper sorts, so this isn't necessary 512 517 retval = … … 514 519 fattr_fname); 515 520 } 521 paranoid_free(tmp); 516 522 return (retval); 517 523 } -
trunk/mondo/mondo/common/libmondo-files.c
r688 r689 738 738 if (0 == strncmp(fname, "/dev/", 5)) { 739 739 if (is_dev_an_NTFS_dev(fname)) { 740 if ( !find_home_of_exe("ntfsresize")) { 740 tmp = find_home_of_exe("ntfsresize"); 741 if (!tmp) { 741 742 fatal_error("ntfsresize not found"); 742 743 } 744 paranoid_free(tmp); 745 743 746 asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname); 744 747 log_it("command = %s", command); -
trunk/mondo/mondo/common/libmondo-fork.c
r688 r689 510 510 // BACKUP 511 511 int res = -1; 512 char*command; 512 char *command = NULL; 513 char *tmp = NULL; 513 514 514 515 if (!does_file_exist(input_device)) { 515 516 fatal_error("input device does not exist"); 516 517 } 517 if ( !find_home_of_exe("ntfsclone")) { 518 tmp = find_home_of_exe("ntfsclone"); 519 if (!tmp) { 518 520 fatal_error("ntfsclone not found"); 519 521 } 520 malloc_string(command); 521 sprintf(command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device); 522 paranoid_free(tmp); 523 524 asprintf(&command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device); 522 525 res = run_program_and_log_output(command, 5); 523 526 paranoid_free(command); 527 524 528 unlink(output_fname); 525 529 return (res); … … 678 682 // RESTORE 679 683 int res = -1; 680 char *command; 681 682 if ( !find_home_of_exe("ntfsclone")) { 684 char *command = NULL; 685 char *tmp = NULL; 686 687 tmp = find_home_of_exe("ntfsclone"); 688 if (!tmp) { 683 689 fatal_error("ntfsclone not found"); 684 690 } 691 paranoid_free(tmp); 692 685 693 asprintf(&command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo); 686 694 res = run_program_and_log_output(command, 5); -
trunk/mondo/mondo/common/libmondo-raid.c
r688 r689 403 403 * @return 0 if the line was read and stored successfully, 1 if we're at end of file. 404 404 */ 405 int get_next_raidtab_line(FILE * 405 int get_next_raidtab_line(FILE *fin, char *label, char *value) 406 406 { 407 407 char *incoming = NULL; 408 char *p ;408 char *p = NULL; 409 409 size_t n = 0; 410 410 411 411 assert(fin != NULL); 412 assert(label != NULL); 413 assert(value != NULL); 414 415 label[0] = value[0] = '\0'; 412 416 413 if (feof(fin)) { 417 414 return (1); … … 429 426 p++; 430 427 } 431 strcpy(label, incoming); 432 strcpy(value, p); 433 paranoid_free(incoming); 428 label = incoming; 429 value = p; 434 430 return (0); 435 431 } … … 576 572 char *fname) 577 573 { 578 FILE *fin ;579 char *label ;580 char *value ;574 FILE *fin = NULL; 575 char *label = NULL; 576 char *value = NULL; 581 577 int items; 582 578 int v; … … 596 592 items = 0; 597 593 log_it("Loading raidtab..."); 598 malloc_string(label);599 malloc_string(value);600 594 get_next_raidtab_line(fin, label, value); 601 595 while (!feof(fin)) { … … 605 599 /* find the 'raiddev' entry, indicating the start of the block of info */ 606 600 while (!feof(fin) && strcmp(label, "raiddev")) { 607 strcpy(raidlist->el[items].additional_vars.el[v].label, label);608 strcpy(raidlist->el[items].additional_vars.el[v].value, value);601 raidlist->el[items].additional_vars.el[v].label = label; 602 raidlist->el[items].additional_vars.el[v].value = value; 609 603 v++; 610 604 get_next_raidtab_line(fin, label, value); … … 616 610 } 617 611 log_msg(2, "Record #%d (%s) found", items, value); 618 strcpy(raidlist->el[items].raid_device, value);612 raidlist->el[items].raid_device = value; 619 613 for (get_next_raidtab_line(fin, label, value); 620 614 !feof(fin) && strcmp(label, "raiddev"); … … 628 622 log_msg(1, "Raidtab loaded successfully."); 629 623 log_msg(1, "%d RAID devices in raidtab", items); 630 paranoid_free(label);631 paranoid_free(value);632 624 return (0); 633 625 } … … 644 636 */ 645 637 void 646 process_raidtab_line(FILE * 638 process_raidtab_line(FILE *fin, 647 639 struct raid_device_record *raidrec, 648 640 char *label, char *value) … … 650 642 651 643 /*@ add mallocs * */ 652 char *tmp; 653 char *labelB; 654 char *valueB; 655 656 struct list_of_disks *disklist; 657 int index; 658 int v; 659 660 malloc_string(labelB); 661 malloc_string(valueB); 644 char *tmp = NULL; 645 char *labelB = NULL; 646 char *valueB = NULL; 647 648 struct list_of_disks *disklist = NULL; 649 int index = 0; 650 int v = 0; 651 662 652 assert(fin != NULL); 663 653 assert(raidrec != NULL); … … 716 706 add_disk_to_raid_device(disklist, value, index); 717 707 } 708 paranoid_free(labelB); 709 paranoid_free(valueB); 718 710 } else { 719 711 v = raidrec->additional_vars.entries; 720 strcpy(raidrec->additional_vars.el[v].label, label);721 strcpy(raidrec->additional_vars.el[v].value, value);712 raidrec->additional_vars.el[v].label = label; 713 raidrec->additional_vars.el[v].value = value; 722 714 raidrec->additional_vars.entries = ++v; 723 715 } 724 paranoid_free(labelB);725 paranoid_free(valueB);726 716 } 727 717 #endif -
trunk/mondo/mondo/common/libmondo-stream.c
r688 r689 222 222 dev = NULL; 223 223 siz = NULL; 224 if (find_home_of_exe("cdrecord")) { 224 tmp = find_home_of_exe("cdrecord"); 225 if (tmp) { 225 226 asprintf(&cdr_exe, "cdrecord"); 226 227 } else { 227 228 asprintf(&cdr_exe, "dvdrecord"); 228 229 } 230 paranoid_free(tmp); 231 229 232 asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", 230 233 cdr_exe); -
trunk/mondo/mondo/common/libmondo-tools.c
r688 r689 348 348 char *extra_cdrom_params = NULL; 349 349 char *mondo_mkisofs_sz = NULL; 350 char *command ;351 char *hostname , *ip_address;350 char *command = NULL; 351 char *hostname = NULL, *ip_address = NULL; 352 352 int retval = 0; 353 353 long avm = 0; 354 char *colon ;355 char *cdr_exe ;356 char *tmp ;357 char *tmp1 ;354 char *colon = NULL; 355 char *cdr_exe = NULL; 356 char *tmp = NULL; 357 char *tmp1 = NULL; 358 358 char call_before_iso_user[MAX_STR_LEN] = "\0"; 359 359 int rdsiz_MB; 360 char *iso_path ;360 char *iso_path = NULL; 361 361 362 362 assert(bkpinfo != NULL); … … 439 439 440 440 if (bkpinfo->backup_media_type == dvd) { 441 if (!(find_home_of_exe("growisofs"))) { 441 tmp = find_home_of_exe("growisofs"); 442 if (!tmp) { 442 443 fatal_error("Please install growisofs."); 443 444 } 445 paranoid_free(tmp); 446 444 447 if (bkpinfo->nonbootable_backup) { 445 448 asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT); … … 502 505 } 503 506 } 504 if (find_home_of_exe("cdrecord")) { 507 tmp = find_home_of_exe("cdrecord"); 508 tmp1 = find_home_of_exe("dvdrecord"); 509 if (tmp) { 505 510 asprintf(&cdr_exe, "cdrecord"); 506 } else if ( find_home_of_exe("dvdrecord")) {511 } else if (tmp1) { 507 512 asprintf(&cdr_exe, "dvdrecord"); 508 513 } else { 509 514 fatal_error("Please install either cdrecord or dvdrecord."); 510 515 } 516 paranoid_free(tmp); 517 paranoid_free(tmp1); 518 511 519 if (bkpinfo->nonbootable_backup) { 512 520 asprintf(&mondo_mkisofs_sz, "%s -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_", mrconf->mondo_iso_creation_cmd); … … 829 837 830 838 /*@ buffers ************ */ 831 char *tmp ;839 char *tmp = NULL; 832 840 833 841 /*@ int's *************** */ … … 913 921 /* IA64 always has one vfat partition for EFI even without Windows */ 914 922 // retval += 915 if (!find_home_of_exe("ms-sys")) { 923 tmp = find_home_of_exe("ms-sys"); 924 if (!tmp) { 916 925 log_to_screen(_("Please install ms-sys just in case.")); 917 926 } 918 #endif 919 } 920 921 if (!find_home_of_exe("cmp")) { 922 if (!find_home_of_exe("true")) { 923 whine_if_not_found("cmp"); 924 } else { 925 log_to_screen 926 (_("Your system lacks the 'cmp' binary. I'll create a dummy cmp for you.")); 927 if (run_program_and_log_output 928 ("cp -f `which true` /usr/bin/cmp", 0)) { 929 fatal_error("Failed to create dummy 'cmp' file."); 930 } 931 } 932 } 927 paranoid_free(tmp); 928 #endif 929 } 930 931 tmp = find_home_of_exe("cmp"); 932 if (!tmp) { 933 whine_if_not_found("cmp"); 934 } 935 paranoid_free(tmp); 936 933 937 run_program_and_log_output 934 938 ("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5);
Note:
See TracChangeset
for help on using the changeset viewer.