Changeset 3866 in MondoRescue for branches/3.3/mondo/src/common
- Timestamp:
- Mar 7, 2024, 1:55:18 PM (4 months ago)
- Location:
- branches/3.3/mondo/src/common
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mondo/src/common/libmondo-archive.c
r3860 r3866 344 344 if (bkpinfo->backup_media_type == dvd) { 345 345 #ifdef DVDRWFORMAT 346 if (!find_home_of_exe("dvd+rw-format")) { 346 if ((tmp = find_home_of_exe("dvd+rw-format")) == NULL) { 347 mr_free(tmp); 347 348 fatal_error("Cannot find dvd+rw-format. Please install it or fix your PATH."); 348 349 } 350 mr_free(tmp); 349 351 #endif 350 if (!find_home_of_exe("growisofs")) { 352 if ((tmp = find_home_of_exe("growisofs")) == NULL) { 353 mr_free(tmp); 351 354 fatal_error("Cannot find growisofs. Please install it or fix your PATH."); 352 355 } 356 mr_free(tmp); 353 357 } 354 358 … … 1695 1699 mr_asprintf(result_sz, "Call to mkisofs to make ISO (%s #%d) ", mds, g_current_media_number); 1696 1700 mr_free(mds); 1697 if (find_home_of_exe("xorriso")) { 1698 mr_asprintf(isofs_cmd, "%s", MONDO_XORRISO_CMD); 1699 } else if (find_home_of_exe("genisoimage")) { 1700 mr_asprintf(isofs_cmd, "%s", MONDO_GENISOIMAGE_CMD); 1701 if ((tmp = find_home_of_exe("xorriso")) != NULL) { 1702 mr_asprintf(isofs_cmd, "%s %s", tmp, MONDO_XORRISO_OPT); 1703 } else if ((tmp = find_home_of_exe("genisoimage")) != NULL) { 1704 mr_asprintf(isofs_cmd, "%s %s", tmp, MONDO_GENISOIMAGE_OPT); 1705 } else if ((tmp = find_home_of_exe("mkisofs")) != NULL) { 1706 mr_asprintf(isofs_cmd, "%s %s", tmp, MONDO_MKISOFS_OPT); 1707 } else if ((tmp = find_home_of_exe("wodim")) != NULL) { 1708 mr_asprintf(isofs_cmd, "%s %s", tmp, MONDO_WODIM_OPT); 1701 1709 } else { 1702 mr_asprintf(isofs_cmd, "%s", MONDO_MKISOFS_CMD); 1703 } 1710 fatal_error("Unable to find a command to create ISO among xorriso, genisoimage, mksiofs or wodim, please install one"); 1711 } 1712 mr_free(tmp); 1704 1713 if (bkpinfo->nonbootable_backup) { 1705 1714 log_msg(1, "Making nonbootable backup"); … … 2744 2753 mr_asprintf(checksum_line, "IGNORE"); 2745 2754 log_msg(2, "Not calculating checksum for %s: it would take too long", biggie_filename); 2746 if ( !find_home_of_exe("ntfsresize")) {2755 if ((tmp = find_home_of_exe("ntfsresize")) == NULL) { 2747 2756 fatal_error("ntfsresize not found"); 2748 2757 } 2749 mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename); 2758 mr_asprintf(command, "%s --force --info %s|grep '^You might resize at '|cut -d' ' -f5", tmp, biggie_filename); 2759 mr_free(tmp); 2750 2760 log_it("command = %s", command); 2751 2761 tmp = call_program_and_get_last_line_of_output(command); -
branches/3.3/mondo/src/common/libmondo-cli.c
r3857 r3866 207 207 } 208 208 209 if (!find_home_of_exe("afio")) { 210 if (find_home_of_exe("star")) { 209 if ((tmp = find_home_of_exe("afio")) == NULL) { 210 mr_free(tmp); 211 if ((tmp = find_home_of_exe("star")) != NULL) { 212 mr_free(tmp); 211 213 flag_set['R'] = TRUE; 212 214 log_msg(1, "Using star instead of afio"); 213 215 } else { 216 mr_free(tmp); 214 217 fatal_error("Neither afio nor star is installed. Please install at least one."); 215 218 } … … 221 224 fatal_error("You may not use star and lzop at the same time."); 222 225 } 223 if (!find_home_of_exe("star")) { 224 fatal_error("Please install 'star' RPM or tarball if you are going to use -R. Thanks."); 225 } 226 if ((tmp = find_home_of_exe("star")) == NULL) { 227 mr_free(tmp); 228 fatal_error("Please install 'star' if you are going to use -R. Thanks."); 229 } 230 mr_free(tmp); 226 231 } 227 232 … … 363 368 } 364 369 if (! bkpinfo->restore_data) { 365 if (!find_home_of_exe("growisofs")) {366 fatal_error("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it.");367 }368 if (!find_home_of_exe("dvd+rw-format")) {369 fatal_error("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it.");370 }371 370 if (!flag_set['s']) { 372 371 sprintf(flag_val['s'], "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4582 MB … … 555 554 } 556 555 if (flag_set['z']) { 557 if ( find_home_of_exe("getfattr")) {556 if ((tmp = find_home_of_exe("getfattr")) != NULL) { 558 557 mr_asprintf(g_getfattr,"getfattr"); 559 558 } 560 if (find_home_of_exe("getfacl")) { 561 mr_asprintf(g_getfacl,"getfacl"); 562 } 559 mr_free(tmp); 560 if ((tmp = find_home_of_exe("getfacl")) != NULL) { 561 mr_asprintf(g_getfattr,"getfaacl"); 562 } 563 mr_free(tmp); 563 564 } 564 565 -
branches/3.3/mondo/src/common/libmondo-devices.c
r3859 r3866 535 535 } 536 536 run_program_and_log_output("insmod ide-scsi", -1); 537 if ( find_home_of_exe("cdrecord")) {538 mr_asprintf(cdr_exe, "cdrecord");539 } else {540 mr_asprintf(cdr_exe, "dvdrecord");541 } 542 if ( find_home_of_exe(cdr_exe)) {537 if ((cdr_exe = find_home_of_exe("cdrecord")) == NULL) { 538 if ((cdr_exe = find_home_of_exe("wodim")) == NULL) { 539 cdr_exe = find_home_of_exe("dvdrecord"); 540 } 541 } 542 if (cdr_exe != NULL) { 543 543 mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -E '[D|C][V|D]' | cut -d' ' -f2 | head -n1", cdr_exe); 544 544 tmp = call_program_and_get_last_line_of_output(command); … … 594 594 static char the_last_place_i_found_it[MAX_STR_LEN] = ""; 595 595 596 /*@ intialize *************************************************** */ 597 malloc_string(tmp); 598 malloc_string(phrase_one); 599 malloc_string(mountpoint); 600 596 assert_string_is_neither_NULL_nor_zerolength(output); 601 597 output[0] = '\0'; 602 phrase_one[0] = '\0';603 604 /*@ end vars **************************************************** */605 598 606 599 if (g_cdrom_drive_is_here[0] && !isdigit(g_cdrom_drive_is_here[0])) { 607 600 strcpy(output, g_cdrom_drive_is_here); 608 601 log_msg(3, "Been there, done that. Returning %s", output); 609 retval = 0; 610 goto end_of_find_cdrom_device; 602 return(0); 611 603 } 612 604 if (the_last_place_i_found_it[0] != '\0' && !try_to_mount) { 613 605 strcpy(output, the_last_place_i_found_it); 614 606 log_msg(3, "find_cdrom_device() --- returning last found location - '%s'", output); 615 retval = 0; 616 goto end_of_find_cdrom_device; 617 } 618 619 sprintf(mountpoint, "%s/cd.mnt", bkpinfo->tmpdir); 620 make_hole_for_dir(mountpoint); 621 622 if (find_home_of_exe("cdrecord")) { 623 mr_asprintf(cdr_exe, "cdrecord"); 624 } else { 625 mr_asprintf(cdr_exe, "dvdrecord"); 626 } 627 tmp[0] = '\0'; 628 if (!find_home_of_exe(cdr_exe)) { 607 return(0); 608 } 609 610 if ((cdr_exe = find_home_of_exe("cdrecord")) == NULL) { 611 if ((cdr_exe = find_home_of_exe("wodim")) == NULL) { 612 cdr_exe = find_home_of_exe("dvdrecord"); 613 } 614 } 615 616 if (cdr_exe == NULL) { 629 617 strcpy(output, "/dev/cdrom"); 630 618 log_msg(4, "Can't find cdrecord; assuming %s", output); 631 619 if (!does_device_exist(output)) { 632 620 log_msg(4, "That didn't work. Sorry."); 633 retval = 1; 634 goto end_of_find_cdrom_device; 621 return(1) 635 622 } else { 636 retval = 0; 637 goto end_of_find_cdrom_device; 623 return(0) 638 624 } 639 625 } … … 646 632 mr_free(cdr_exe); 647 633 mr_free(command); 648 return 634 return(1); 649 635 } 650 636 mr_free(command); 637 638 /*@ intialize *************************************************** */ 639 malloc_string(tmp); 640 malloc_string(phrase_one); 641 642 phrase_one[0] = '\0'; 643 tmp[0] = '\0'; 644 645 /*@ end vars **************************************************** */ 646 651 647 652 648 for (tmp1 = fgets(tmp, MAX_STR_LEN, fin); !feof(fin) && (tmp1 != NULL); … … 810 806 #endif 811 807 808 mr_asprintf(mountpoint, "%s/cd.mnt", bkpinfo->tmpdir); 809 make_hole_for_dir(mountpoint); 810 812 811 if (found_it && try_to_mount) { 813 812 if (mount_CDROM_here(output, mountpoint)) { … … 829 828 } 830 829 unlink(mountpoint); 830 mr_free(mountpoint); 831 831 832 832 if (found_it) { … … 865 865 paranoid_free(tmp); 866 866 paranoid_free(phrase_one); 867 paranoid_free(mountpoint);868 867 return (retval); 869 868 } … … 2805 2804 2806 2805 if (ask_me_yes_or_no("Do you want to backup extended attributes?")) { 2807 if (find_home_of_exe("getfattr")) { 2808 mr_free(g_getfattr); 2809 mr_asprintf(g_getfattr,"getfattr"); 2810 } 2811 if (find_home_of_exe("getfacl")) { 2812 mr_free(g_getfacl); 2813 mr_asprintf(g_getfacl,"getfacl"); 2814 } 2806 mr_free(g_getfattr); 2807 g_getfattr = find_home_of_exe("getfattr"); 2808 mr_free(g_getfacl); 2809 g_getfacl = find_home_of_exe("getfacl"); 2815 2810 log_it("Backup of extended attributes"); 2816 2811 } -
branches/3.3/mondo/src/common/libmondo-filelist.c
r3753 r3866 654 654 655 655 656 int set_fattr_list(char *masklist, char *fattr_fname) 657 { 658 if (find_home_of_exe("setfattr")) { 659 return (set_EXAT_list(masklist, fattr_fname, "setfattr")); 656 int set_fattr_list(char *masklist, char *fattr_fname) { 657 658 int i = 0; 659 char * tmp = NULL; 660 661 if ((tmp = find_home_of_exe("setfattr")) != NULL) { 662 i = set_EXAT_list(masklist, fattr_fname, tmp) 663 mr_free(tmp); 660 664 } else { 661 665 log_msg(1, "ERROR: set_EXAT_list: setfattr doesn't exist"); 662 return(0); 663 } 664 } 665 666 667 668 int set_acl_list(char *masklist, char *acl_fname) 669 { 670 if (find_home_of_exe("setfacl")) { 671 return (set_EXAT_list(masklist, acl_fname, "setfacl")); 666 } 667 return(i); 668 } 669 670 671 672 int set_acl_list(char *masklist, char *acl_fname) { 673 674 int i = 0; 675 char * tmp = NULL; 676 677 if ((tmp = find_home_of_exe("setfacl")) != NULL) { 678 i = set_EXAT_list(masklist, facl_fname, tmp) 679 mr_free(tmp); 672 680 } else { 673 681 log_msg(1, "ERROR: set_EXAT_list: setfacl doesn't exist"); 674 return(0);675 }682 } 683 return(i); 676 684 } 677 685 -
branches/3.3/mondo/src/common/libmondo-files-EXT.h
r3861 r3866 11 11 extern void exclude_nonexistent_files(char *inout); 12 12 extern int figure_out_kernel_path_interactively_if_necessary(char *kernel); 13 extern char *find_home_of_exe(c har *fname);13 extern char *find_home_of_exe(const char *fname); 14 14 extern int get_trackno_from_logfile(char *logfile); 15 15 extern int grab_percentage_from_last_line_of_file(char *filename); -
branches/3.3/mondo/src/common/libmondo-files.c
r3861 r3866 317 317 * Find location of specified executable in user's PATH. 318 318 * @param fname The basename of the executable to search for (e.g. @c afio). 319 * @return The full path to the executable, or "" if it does not exist, or NULLif @c file could not be found.320 * @note The returned string points to static storage that will be overwritten with each call.319 * @return The full path to the executable, or NULL if it does not exist, or if @c file could not be found. 320 * @note The returned string points to an allocated string that needs to be freed by caller 321 321 * @bug The checks with @c file and @c dirname seem pointless. If @c incoming is "", then you're calling 322 322 * <tt>dirname 2\>/dev/null</tt> or <tt>file 2\>/dev/null | cut -d':' -f1 2\>/dev/null</tt>, which basically amounts 323 323 * to nothing. 324 324 */ 325 char *find_home_of_exe(c har *fname)325 char *find_home_of_exe(const char *fname) 326 326 { 327 327 /*@ buffers ********************* */ 328 static char output[MAX_STR_LEN]; 329 char *incoming = NULL; 328 char *output = NULL; 330 329 char *command = NULL; 331 330 … … 333 332 334 333 assert_string_is_neither_NULL_nor_zerolength(fname); 335 mr_asprintf(command, "which %s 2> /dev/null", fname); 336 incoming = call_program_and_get_last_line_of_output(command); 334 335 mr_asprintf(command, "whereis %s 2>/dev/null | awk '{ print $2 }'", fname); 336 /* either "" or the string can't be NULL*/ 337 output = call_program_and_get_last_line_of_output(command); 337 338 mr_free(command); 338 339 339 if (incoming[0] == '\0') { 340 if (system("which file > /dev/null 2> /dev/null")) { 341 mr_free(incoming); 342 output[0] = '\0'; 343 return(NULL); // forget it :) 344 } 345 mr_asprintf(command, "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", incoming); 346 mr_free(incoming); 347 348 incoming = call_program_and_get_last_line_of_output(command); 340 if (output[0] == '\0') { 341 mr_asprintf(command, "which %s 2> /dev/null", fname); 342 /* either "" or the string can't be NULL*/ 343 mr_free(output); 344 output = call_program_and_get_last_line_of_output(command); 349 345 mr_free(command); 350 346 } 351 if (incoming[0] == '\0') { 352 mr_asprintf(command, "dirname %s 2> /dev/null", incoming); 353 mr_free(incoming); 354 355 incoming = call_program_and_get_last_line_of_output(command); 356 mr_free(command); 357 } 358 strcpy(output, incoming); 347 359 348 if (output[0] != '\0' && does_file_exist(output)) { 360 log_msg(4, "find_home_of_exe --- Found %s at %s", fname, incoming); 349 log_msg(4, "find_home_of_exe --- Found %s at %s", fname, output); 350 return(output); 361 351 } else { 362 output[0] = '\0';363 352 log_msg(4, "find_home_of_exe --- Could not find %s", fname); 364 }365 mr_free(incoming);366 if (!output[0]) {367 353 return(NULL); 368 } else {369 return(output);370 354 } 371 355 } … … 777 761 if (0 == strncmp(fname, "/dev/", 5)) { 778 762 if (is_dev_an_NTFS_dev(fname)) { 779 if ( !find_home_of_exe("ntfsresize")) {763 if ((tmp = find_home_of_exe("ntfsresize")) == NULL) { 780 764 mr_free(tmp); 781 765 mr_free(fname); 782 766 fatal_error("ntfsresize not found"); 783 767 } 768 mr_asprintf(command, "%s --force --info %s|grep '^You might resize at '|cut -d' ' -f5", tmp, fname); 784 769 mr_free(tmp); 785 786 mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);787 770 log_it("command = %s", command); 788 771 tmp = call_program_and_get_last_line_of_output(command); … … 903 886 { 904 887 /*@ buffers *** */ 905 char *command = NULL; 906 int res = 0; 907 908 mr_asprintf(command, "which %s > /dev/null 2> /dev/null", fname); 909 res = system(command); 910 mr_free(command); 911 912 if (res) { 888 char *tmp = NULL; 889 890 tmp = find_home_of_exe(fname); 891 if (tmp == NULL) { 913 892 log_to_screen("Please install '%s'. I cannot find it on your system.", fname); 914 log_to_screen("There may be hyperlink at http://www.mondorescue.org which");915 log_to_screen("will take you to the relevant (missing) package.");916 893 return(1); 917 894 } else { 895 mr_free(tmp); 918 896 return(0); 919 897 } 920 898 } 921 922 923 924 899 925 900 -
branches/3.3/mondo/src/common/libmondo-files.h
r3861 r3866 12 12 void exclude_nonexistent_files(char *inout); 13 13 int figure_out_kernel_path_interactively_if_necessary(char *kernel); 14 char *find_home_of_exe(char *fname);15 14 int get_trackno_from_logfile(char *logfile); 16 15 int grab_percentage_from_last_line_of_file(char *filename); -
branches/3.3/mondo/src/common/libmondo-fork.c
r3863 r3866 608 608 int res = -1; 609 609 char *command = NULL; 610 char *tmp = NULL; 610 611 611 612 if (!does_file_exist(input_device)) { 612 613 fatal_error("input device does not exist"); 613 614 } 614 if ( !find_home_of_exe("ntfsclone")) {615 if ((tmp = find_home_of_exe("ntfsclone")) == NULL) { 615 616 fatal_error("ntfsclone not found"); 616 617 } 617 mr_asprintf(command, "ntfsclone --rescue --force --save-image --overwrite %s %s", output_fname, input_device); 618 mr_asprintf(command, "%s --rescue --force --save-image --overwrite %s %s", tmp, output_fname, input_device); 619 mr_free(tmp); 618 620 res = run_program_and_log_output(command, 5); 619 621 mr_free(command); … … 717 719 int res = -1; 718 720 char *command = NULL; 719 720 if ( !find_home_of_exe("ntfsclone")) { 721 char *tmp = NULL; 722 723 if ((tmp = find_home_of_exe("ntfsclone")) == NULL) { 721 724 fatal_error("ntfsclone not found"); 722 725 } 723 mr_asprintf(command, "ntfsclone --rescue --force --restore-image --overwrite %s %s", output_device, input_fifo); 726 mr_asprintf(command, "%s --rescue --force --restore-image --overwrite %s %s", tmp, output_device, input_fifo); 727 mr_free(tmp); 724 728 res = run_program_and_log_output(command, 5); 725 729 mr_free(command); -
branches/3.3/mondo/src/common/libmondo-stream.c
r3860 r3866 315 315 log_to_screen("I am looking for your tape streamer. Please wait."); 316 316 mr_free(dev); 317 if ( find_home_of_exe("cdrecord")) {318 mr_asprintf(cdr_exe, "cdrecord");319 } else {320 mr_asprintf(cdr_exe, "dvdrecord");317 if ((cdr_exe = find_home_of_exe("cdrecord")) != NULL) { 318 if ((cdr_exe = find_home_of_exe("wodim")) != NULL) { 319 cdr_exe = find_home_of_exe("dvdrecord"); 320 } 321 321 } 322 322 mr_asprintf(command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", cdr_exe);
Note:
See TracChangeset
for help on using the changeset viewer.