Changeset 1191 in MondoRescue
- Timestamp:
- Feb 20, 2007, 11:20:31 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/mondoarchive/mondo-cli.c
r1187 r1191 148 148 { 149 149 int j; 150 char tmp[MAX_STR_LEN], *p, comment[MAX_STR_LEN]; 150 char *tmp = NULL; 151 char *p = NULL; 152 char *q = NULL; 151 153 152 154 assert(bkpinfo != NULL); … … 156 158 for (j = 1, p = value; j < MAX_NOOF_MEDIA && strchr(p, ','); 157 159 j++, p = strchr(p, ',') + 1) { 158 strncpy(tmp, p, MAX_STR_LEN); 159 *(strchr(tmp, ',')) = '\0'; 160 mr_asprintf(&tmp, p); 161 q = strchr(tmp, ','); 162 if (q != NULL) { 163 *q = '\0'; 164 } 160 165 bkpinfo->media_size[j] = friendly_sizestr_to_sizelong(tmp); 161 sprintf(comment, "media_size[%d] = %ld", j, 166 mr_free(tmp); 167 168 mr_msg(3, "media_size[%d] = %ld", j, 162 169 bkpinfo->media_size[j]); 163 mr_msg(3, comment);164 170 } 165 171 for (; j <= MAX_NOOF_MEDIA; j++) { … … 197 203 198 204 /*@ buffers ** */ 199 char *tmp; 200 char *tmp1; 201 char *psz; 202 char *p; 203 char *q; 205 char *tmp = NULL; 206 char *tmp1 = NULL; 207 char *tmp2 = NULL; 208 char *psz = NULL; 209 char *p = NULL; 210 char *q = NULL; 204 211 205 212 long itbs = 0L; … … 208 215 209 216 malloc_string(tmp); 210 malloc_string(psz);211 217 212 218 assert(bkpinfo != NULL); … … 216 222 bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE; 217 223 218 /* compulsory */224 /* compulsory */ 219 225 i = flag_set['c'] + flag_set['i'] + flag_set['n'] + 220 226 flag_set['t'] + flag_set['u'] + flag_set['r'] + … … 222 228 if (i == 0) { 223 229 retval++; 224 log_to_screen( "You must specify the media type\n");230 log_to_screen(_("You must specify the media type\n")); 225 231 } 226 232 if (i > 1) { 227 233 retval++; 228 log_to_screen( "Please specify only one media type\n");234 log_to_screen(_("Please specify only one media type\n")); 229 235 } 230 236 if (flag_set['K']) { … … 236 242 if (flag_set['L'] && flag_set['0']) { 237 243 retval++; 238 log_to_screen( "You cannot have 'no compression' _and_ LZOP.\n");244 log_to_screen(_("You cannot have 'no compression' _and_ LZOP.\n")); 239 245 } 240 246 bkpinfo->backup_data = flag_set['O']; 241 247 bkpinfo->verify_data = flag_set['V']; 242 248 if (flag_set['I'] && !bkpinfo->backup_data) { 243 log_to_screen( "-I switch is ignored if just verifying");249 log_to_screen(_("-I switch is ignored if just verifying")); 244 250 } 245 251 if (flag_set['E'] && !bkpinfo->backup_data) { 246 log_to_screen( "-E switch is ignored if just verifying");252 log_to_screen(_("-E switch is ignored if just verifying")); 247 253 } 248 254 … … 272 278 if (flag_set['f'] || flag_set['l']) { 273 279 log_to_screen 274 ( "You don't need to specify bootloader or bootdevice");280 (_("You don't need to specify bootloader or bootdevice")); 275 281 } 276 282 } … … 317 323 if (bkpinfo->include_paths[0] == '-') { 318 324 retval++; 319 log_to_screen( "Please supply a sensible value with '-I'\n");325 log_to_screen(_("Please supply a sensible value with '-I'\n")); 320 326 } 321 327 } … … 327 333 } 328 334 329 330 335 if (flag_set['J']) { 331 336 if (flag_set['I']) { 332 337 retval++; 333 338 log_to_screen 334 ( "Please do not use -J in combination with -I. If you want to make a list of files to backup, that's fine, use -J <filename> but please don't muddy the waters by combining -J with -I. Thanks. :-)");339 (_("Please do not use -J in combination with -I. If you want to make a list of files to backup, that's fine, use -J <filename> but please don't combine -J with -I. Thanks. :-)")); 335 340 } 336 341 bkpinfo->make_filelist = FALSE; 337 342 strcpy(bkpinfo->include_paths, flag_val['J']); 338 343 } 344 339 345 if (flag_set['c'] || flag_set['w'] || flag_set['C'] || flag_set['r']) { 340 346 if (!flag_set['r'] && g_kernel_version <= 2.5 … … 350 356 if (g_kernel_version >= 2.6 && !strstr(flag_val['d'], "/dev/")) { 351 357 log_to_screen 352 ( "Linus says 2.6 has a broken ide-scsi module. Proceed at your own risk...");358 (_("Linus says 2.6 has a broken ide-scsi module. Proceed at your own risk...")); 353 359 } 354 360 … … 366 372 if (!flag_set['L']) { 367 373 log_to_screen 368 ( "You must use -L with -C. Therefore I am setting it for you.");374 (_("You must use -L with -C. Therefore I am setting it for you.")); 369 375 flag_set['L'] = 1; 370 376 flag_val['L'][0] = '\0'; … … 373 379 mr_msg(3, "flag_val['c'] = %s", flag_val['c']); 374 380 mr_msg(3, "flag_val['w'] = %s", flag_val['w']); 375 // mr_msg(3, "flag_set['r'] = %i", flag_set['r'] );376 381 if (flag_set['c']) { 377 382 bkpinfo->cdrw_speed = atoi(flag_val['c']); … … 388 393 } 389 394 } 395 390 396 if (flag_set['t'] && !flag_set['d']) { 391 397 log_it("Hmm! No tape drive specified. Let's see what we can do."); … … 395 401 } 396 402 flag_set['d'] = TRUE; 397 sprintf(tmp,398 "You didn't specify a tape streamer device. I'm assuming %s",403 mr_asprintf(&tmp2, 404 _("You didn't specify a tape streamer device. I'm assuming %s"), 399 405 flag_val['d']); 400 log_to_screen(tmp); 406 log_to_screen(tmp2); 407 mr_free(tmp2); 401 408 percent = 0; 402 409 } … … 422 429 if (!find_dvd_device(flag_val['d'], FALSE)) { 423 430 flag_set['d'] = TRUE; 424 log_to_screen( "I guess DVD drive is at %s", flag_val['d']);431 log_to_screen(_("I guess DVD drive is at %s"), flag_val['d']); 425 432 } 426 433 } … … 441 448 strcat(flag_val['s'], "m"); 442 449 log_to_screen 443 ( "You did not specify a size (-s) for DVD. I'm guessing %s.",450 (_("You did not specify a size (-s) for DVD. I'm guessing %s."), 444 451 flag_val['s']); 445 452 flag_set['s'] = 1; 446 453 } 447 /*448 if (flag_set['Z']) {449 bkpinfo->blank_dvd_first = TRUE;450 }451 */452 454 } 453 455 … … 490 492 strncpy(bkpinfo->nfs_remote_dir, "/", MAX_STR_LEN); 491 493 } 492 sprintf(tmp, "mount | grep -E \"^%s .*\"| cut -d' ' -f3",494 mr_asprintf(&tmp2, "mount | grep -E '^%s .*$' | cut -d' ' -f3", 493 495 bkpinfo->nfs_mount); 494 496 strncpy(bkpinfo->isodir, 495 call_program_and_get_last_line_of_output(tmp ),497 call_program_and_get_last_line_of_output(tmp2), 496 498 MAX_STR_LEN / 4); 499 mr_free(tmp2); 497 500 if (strlen(bkpinfo->isodir) < 3) { 498 501 retval++; 499 log_to_screen( "NFS share is not mounted. Please mount it.\n");502 log_to_screen(_("NFS share is not mounted. Please mount it.\n")); 500 503 } 501 504 mr_msg(3, "mount = %s", bkpinfo->nfs_mount); 502 505 mr_msg(3, "isodir= %s", bkpinfo->isodir); 503 506 } 507 504 508 if (flag_set['c']) { 505 509 bkpinfo->backup_media_type = cdr; … … 586 590 if (flag_set['N']) // exclude NFS mounts & devices 587 591 { 588 strncpy(psz, list_of_NFS_mounts_only(), MAX_STR_LEN);592 mr_asprintf(&psz, list_of_NFS_mounts_only()); 589 593 if (bkpinfo->exclude_paths[0]) { 590 594 strncat(bkpinfo->exclude_paths, " ", MAX_STR_LEN); 591 595 } 592 596 strncat(bkpinfo->exclude_paths, psz, MAX_STR_LEN); 597 mr_free(psz); 593 598 mr_msg(3, "-N means we're now excluding %s", 594 599 bkpinfo->exclude_paths); … … 599 604 } 600 605 if (flag_set['b']) { 601 strcpy(psz, flag_val['b']);606 mr_asprintf(&psz, flag_val['b']); 602 607 mr_msg(1, "psz = '%s'", psz); 603 608 if (psz[strlen(psz) - 1] == 'k') { … … 607 612 itbs = atol(psz); 608 613 } 614 mr_free(psz); 615 609 616 mr_msg(1, "'%s' --> %ld", flag_val['b'], itbs); 610 617 mr_msg(1, "Internal tape block size is now %ld bytes", itbs); … … 615 622 bkpinfo->internal_tape_block_size = itbs; 616 623 } 624 617 625 if (flag_set['D']) { 618 626 bkpinfo->differential = 1; … … 623 631 } 624 632 } 633 625 634 if (flag_set['x']) { 626 635 strncpy(bkpinfo->image_devs, flag_val['x'], MAX_STR_LEN / 4); … … 640 649 && !does_file_exist(bkpinfo->kernel_path)) { 641 650 retval++; 642 sprintf(tmp,643 "You specified kernel '%s', which does not exist\n",651 mr_asprintf(&tmp2, 652 _("You specified kernel '%s', which does not exist\n"), 644 653 bkpinfo->kernel_path); 645 log_to_screen(tmp); 646 } 647 } 654 log_to_screen(tmp2); 655 mr_free(tmp2); 656 } 657 } 658 648 659 if (flag_set['p']) { 649 660 strncpy(bkpinfo->prefix, flag_val['p'], MAX_STR_LEN / 4); 650 661 } 651 652 662 653 663 if (flag_set['d']) { /* backup directory (if ISO/NFS/USB) */ 654 664 if (flag_set['i']) { 655 665 strncpy(bkpinfo->isodir, flag_val['d'], MAX_STR_LEN / 4); 656 sprintf(tmp, "ls -l %s", bkpinfo->isodir);657 if (run_program_and_log_output(tmp , FALSE)) {666 mr_asprintf(&tmp2, "ls -l %s", bkpinfo->isodir); 667 if (run_program_and_log_output(tmp2, FALSE)) { 658 668 fatal_error 659 669 ("output folder does not exist - please create it"); 660 670 } 671 mr_free(tmp2); 661 672 } else if (flag_set['n']) { 662 673 strncpy(bkpinfo->nfs_remote_dir, flag_val['d'], MAX_STR_LEN); … … 667 678 668 679 if (flag_set['n']) { 669 sprintf(tmp, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir,680 mr_asprintf(&tmp2, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir, 670 681 bkpinfo->nfs_remote_dir); 671 if (run_program_and_log_output(tmp , FALSE)) {682 if (run_program_and_log_output(tmp2, FALSE)) { 672 683 retval++; 673 sprintf(tmp, 674 "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n", 684 mr_free(tmp2); 685 mr_asprintf(&tmp2, 686 _("Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n"), 675 687 bkpinfo->nfs_remote_dir, bkpinfo->nfs_mount); 676 log_to_screen(tmp); 677 } 688 log_to_screen(tmp2); 689 } 690 mr_free(tmp2); 678 691 } 679 692 … … 682 695 if (g_kernel_version >= 2.6) { 683 696 if (popup_and_get_string 684 ( "Device", "Please specify the device",697 (_("Device"), _("Please specify the device"), 685 698 bkpinfo->media_device, MAX_STR_LEN / 4)) { 686 699 retval++; 687 log_to_screen( "User opted to cancel.");700 log_to_screen(_("User opted to cancel.")); 688 701 } 689 702 } else if (find_cdrw_device(bkpinfo->media_device)) { 690 703 retval++; 691 704 log_to_screen 692 ( "Tried and failed to find CD-R[W] drive automatically.\n");705 (_("Tried and failed to find CD-R[W] drive automatically.\n")); 693 706 } else { 694 707 flag_set['d'] = TRUE; … … 699 712 if (!flag_set['d'] && !flag_set['n'] && !flag_set['C']) { 700 713 retval++; 701 log_to_screen( "Please specify the backup device/directory.\n");714 log_to_screen(_("Please specify the backup device/directory.\n")); 702 715 fatal_error 703 716 ("You didn't use -d to specify the backup device/directory."); … … 716 729 sprintf(bkpinfo->tmpdir, "%s/tmp.mondo.%ld", flag_val['T'], 717 730 random() % 32768); 718 sprintf(tmp, "touch %s/.foo.dat", flag_val['T']);719 if (run_program_and_log_output(tmp , 1)) {731 mr_asprintf(&tmp2, "touch %s/.foo.dat", flag_val['T']); 732 if (run_program_and_log_output(tmp2, 1)) { 720 733 retval++; 721 734 log_to_screen 722 ( "Please specify a tempdir which I can write to. :)");735 (_("Please specify a tempdir which I can write to. :)")); 723 736 fatal_error("I cannot write to the tempdir you specified."); 724 737 } 725 sprintf(tmp, "ln -sf %s/.foo.dat %s/.bar.dat", flag_val['T'], 738 mr_free(tmp2); 739 740 mr_asprintf(&tmp2, "ln -sf %s/.foo.dat %s/.bar.dat", flag_val['T'], 726 741 flag_val['T']); 727 if (run_program_and_log_output(tmp , 1)) {742 if (run_program_and_log_output(tmp2, 1)) { 728 743 retval++; 729 744 log_to_screen 730 ( "Please don't specify a SAMBA or VFAT or NFS tmpdir.");745 (_("Please don't specify a SAMBA or VFAT or NFS tmpdir.")); 731 746 fatal_error("I cannot write to the tempdir you specified."); 732 747 } 733 } 748 mr_free(tmp2); 749 } 750 734 751 if (flag_set['A']) { 735 752 strncpy(bkpinfo->call_after_iso, flag_val['A'], MAX_STR_LEN); … … 757 774 (BOOT_LOADER_CHARS, 758 775 (bkpinfo->boot_loader = flag_val['l'][0]))) { 759 mr_msg(1, "%c? W TFis %c? I need G, L, E or R.",776 mr_msg(1, "%c? What is %c? I need G, L, E or R.", 760 777 bkpinfo->boot_loader, bkpinfo->boot_loader); 761 778 fatal_error … … 764 781 #undef BOOT_LOADER_CHARS 765 782 } 783 766 784 if (flag_set['f']) { 767 785 strncpy(bkpinfo->boot_device, … … 770 788 MAX_STR_LEN / 4); 771 789 } 790 791 if (flag_set['Q']) { 792 if (bkpinfo->boot_device == NULL) { 793 fatal_error("-f option required when using -Q\n"); 794 } 795 i = which_boot_loader(bkpinfo->boot_device); 796 mr_msg(3, "boot loader is %c, residing at %s", i, bkpinfo->boot_device); 797 log_to_screen(_("boot loader is %c, residing at %s\n"), i, tmp); 798 finish(0); 799 } 800 772 801 if (flag_set['P']) { 773 802 strncpy(bkpinfo->postnuke_tarball, flag_val['P'], MAX_STR_LEN); 774 803 } 775 if (flag_set['Q']) { 776 i = which_boot_loader(tmp); 777 mr_msg(3, "boot loader is %c, residing at %s", i, tmp); 778 printf("boot loader is %c, residing at %s\n", i, tmp); 779 finish(0); 780 } 804 781 805 if (flag_set['L']) { 782 806 bkpinfo->use_lzo = TRUE; … … 784 808 retval++; 785 809 log_to_screen 786 ( "Please install LZOP. You can't use '-L' until you do.\n");810 (_("Please install LZOP. You can't use '-L' until you do.\n")); 787 811 } 788 812 } … … 803 827 bkpinfo->make_cd_use_lilo = TRUE; 804 828 log_to_screen 805 ("Forcing you to use LILO. SuSE 9.0 (64-bit) has a broken mkfs.vfat binary."); 806 } 829 (_("Forcing you to use LILO. SuSE 9.0 (64-bit) has a broken mkfs.vfat binary.")); 830 } 831 807 832 if (flag_set['o']) { 808 833 bkpinfo->make_cd_use_lilo = TRUE; … … 813 838 bkpinfo->make_cd_use_lilo = TRUE; 814 839 log_to_screen 815 ( "Your kernel appears not to support vfat filesystems. I am therefore");816 log_to_screen 817 ( "using LILO instead of SYSLINUX as the CD/floppy's boot loader.");840 (_("Your kernel appears not to support vfat filesystems. I am therefore")); 841 log_to_screen 842 (_("using LILO instead of SYSLINUX as the CD/floppy's boot loader.")); 818 843 } 819 844 if (run_program_and_log_output("which mkfs.vfat", FALSE)) { … … 821 846 #ifdef __IA32__ 822 847 log_to_screen 823 ( "Your filesystem is missing 'mkfs.vfat', so I cannot use SYSLINUX as");824 log_to_screen 825 ( "your boot loader. I shall therefore use LILO instead.");848 (_("Your filesystem is missing 'mkfs.vfat', so I cannot use SYSLINUX as")); 849 log_to_screen 850 (_("your boot loader. I shall therefore use LILO instead.")); 826 851 #endif 827 852 #ifdef __IA64__ 828 853 log_to_screen 829 ( "Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI");830 log_to_screen( "environment correctly. Please install it.");854 (_("Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI")); 855 log_to_screen(_("environment correctly. Please install it.")); 831 856 fatal_error("Aborting"); 832 857 #endif … … 846 871 if (i == 0) { 847 872 retval++; 848 log_to_screen( "Specify backup (-O), verify (-V) or both (-OV).\n");873 log_to_screen(_("Specify backup (-O), verify (-V) or both (-OV).\n")); 849 874 } 850 875 … … 852 877 853 878 mr_free(tmp); 854 mr_free(psz);855 879 return (retval); 856 880 } 857 858 881 859 882 … … 876 899 /*@ ints ** */ 877 900 int opt = 0; 878 char tmp[MAX_STR_LEN];901 char *tmp = NULL; 879 902 int i = 0; 880 int len ;903 int len = 0; 881 904 882 905 /*@ bools *** */ … … 900 923 if (flag_set[optopt]) { 901 924 bad_switches = TRUE; 902 sprintf(tmp, "Switch -%c previously defined as %s\n", opt,925 mr_asprintf(&tmp, _("Switch -%c previously defined as %s\n"), opt, 903 926 flag_val[i]); 904 927 log_to_screen(tmp); 928 mr_free(tmp); 905 929 } else { 906 930 flag_set[opt] = TRUE; … … 910 934 optarg[--len] = '\0'; 911 935 log_to_screen 912 ( "Warning - param '%s' should not have trailing slash!",936 (_("Warning - param '%s' should not have trailing slash!"), 913 937 optarg); 914 938 } … … 916 940 if (strchr(flag_val[opt], '/') 917 941 && flag_val[opt][0] != '/') { 918 sprintf(tmp,919 "-%c flag --- must be absolute path --- '%s' isn't absolute",942 mr_asprintf(&tmp, 943 _("-%c flag --- must be absolute path --- '%s' isn't absolute"), 920 944 opt, flag_val[opt]); 921 945 log_to_screen(tmp); 946 mr_free(tmp); 922 947 bad_switches = TRUE; 923 948 } … … 930 955 for (i = optind; i < argc; i++) { 931 956 bad_switches = TRUE; 932 sprintf(tmp, "Invalid arg -- %s\n", argv[i]);957 mr_asprintf(&tmp, _("Invalid arg -- %s\n"), argv[i]); 933 958 log_to_screen(tmp); 959 mr_free(tmp); 934 960 } 935 961 return (bad_switches); 936 962 } 937 938 939 963 940 964 … … 955 979 void terminate_daemon(int sig) 956 980 { 957 char tmp[64]; 958 char tmp2[MAX_STR_LEN]; 959 // char command[512]; 960 // pid_t pid; 981 char *tmp = NULL; 982 char *tmp2 = NULL; 961 983 962 984 switch (sig) { 963 985 case SIGINT: 964 sprintf(tmp, "SIGINT");965 strcpy(tmp2, "You interrupted me :-)");986 mr_asprintf(&tmp, _("SIGINT signal received from OS")); 987 mr_asprintf(&tmp2, _("You interrupted me :-)")); 966 988 break; 967 989 case SIGKILL: 968 sprintf(tmp, "SIGKILL");969 strcpy(tmp2,970 "I seriously have no clue how this signal even got to me. Something's wrong with your system.");990 mr_asprintf(&tmp, _("SIGKILL signal received from OS")); 991 mr_asprintf(&tmp2, 992 _("I seriously have no clue how this signal even got to me. Something's wrong with your system.")); 971 993 break; 972 994 case SIGTERM: 973 sprintf(tmp, "SIGTERM");974 strcpy(tmp2, "Got terminate signal");995 mr_asprintf(&tmp, _("SIGTERM signal received from OS")); 996 mr_asprintf(&tmp2, _("Got terminate signal")); 975 997 break; 976 998 case SIGHUP: 977 sprintf(tmp, "SIGHUP");978 strcpy(tmp2, "Hangup on line");999 mr_asprintf(&tmp, _("SIGHUP signal received from OS")); 1000 mr_asprintf(&tmp2, _("Hangup on line")); 979 1001 break; 980 1002 case SIGSEGV: 981 sprintf(tmp, "SIGSEGV");982 strcpy(tmp2,983 "Internal programming error. Please send a backtrace as well as your log.");1003 mr_asprintf(&tmp, _("SIGSEGV signal received from OS")); 1004 mr_asprintf(&tmp2, 1005 _("Internal programming error. Please send a backtrace as well as your log.")); 984 1006 break; 985 1007 case SIGPIPE: 986 sprintf(tmp, "SIGPIPE");987 strcpy(tmp2, "Pipe was broken");1008 mr_asprintf(&tmp, _("SIGPIPE signal received from OS")); 1009 mr_asprintf(&tmp2, _("Pipe was broken")); 988 1010 break; 989 1011 case SIGABRT: 990 sprintf(tmp, "SIGABRT");991 sprintf(tmp2,992 "Abort - probably failed assertion. I'm sleeping for a few seconds so you can read the message.");1012 mr_asprintf(&tmp, _("SIGABRT signal received from OS")); 1013 mr_asprintf(&tmp2, 1014 _("Abort - probably failed assertion. I'm sleeping for a few seconds so you can read the message.")); 993 1015 break; 994 1016 default: 995 sprintf(tmp, "(Unknown)");996 }997 998 strcat(tmp, " signal received from OS"); 1017 mr_asprintf(&tmp, _("(Unknown)")); 1018 mr_asprintf(&tmp2, _("(Unknown)")); 1019 } 1020 999 1021 log_to_screen(tmp); 1000 1022 log_to_screen(tmp2); 1023 mr_free(tmp); 1024 mr_free(tmp2); 1001 1025 if (sig == SIGABRT) { 1002 1026 sleep(10); … … 1007 1031 finish(254); // just in case 1008 1032 } 1009 1010 1011 1033 1012 1034 … … 1030 1052 } 1031 1053 } 1032 1033 1034 1054 1035 1055
Note:
See TracChangeset
for help on using the changeset viewer.