Changeset 2325 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-tools.c
- Timestamp:
- Aug 18, 2009, 3:19:15 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-tools.c
r2324 r2325 419 419 char *p = NULL; 420 420 char call_before_iso_user[MAX_STR_LEN] = "\0"; 421 /*422 long avm = 0;423 int rdsiz_MB;424 */425 421 char *iso_dev = NULL; 426 422 char *iso_mnt = NULL; … … 449 445 if (bkpinfo->backup_media_type == tape) { 450 446 log_msg(1, "Bar"); 447 if (bkpinfo->media_device == NULL) { 448 return(1); 449 } 451 450 mr_asprintf(tmp, "mt -f %s status", bkpinfo->media_device); 452 451 log_msg(1, "tmp = '%s'", tmp); … … 526 525 // -m isn't supported by growisofs, BTW... 527 526 } else { 527 if (bkpinfo->media_device == NULL) { 528 return(1); 529 } 528 530 sprintf(bkpinfo->call_make_iso, 529 531 "%s %s -Z %s . 2>> _ERR_", … … 594 596 } 595 597 log_it("bkpinfo->call_before_iso = %s", bkpinfo->call_before_iso); 598 if (bkpinfo->media_device == NULL) { 599 return(1); 600 } 596 601 sprintf(bkpinfo->call_make_iso, 597 602 "%s %s -v %s fs=4m dev=%s speed=%d %s/"MONDO_TMPISOS, … … 667 672 668 673 if (bkpinfo->backup_media_type == nfs) { 669 strcpy(hostname, bkpinfo->nfs_mount); 674 if (bkpinfo->nfs_mount) { 675 strcpy(hostname, bkpinfo->nfs_mount); 676 } else { 677 log_it("nfs_mount is NULL"); 678 retval++; 679 strcpy(hostname, ""); 680 } 670 681 colon = strchr(hostname, ':'); 671 682 if (!colon) { … … 678 689 hent = gethostbyname(hostname); 679 690 if (!hent) { 680 log_it("Can't resolve NFS mount (%s): %s", hostname, 681 hstrerror(h_errno)); 691 log_it("Can't resolve NFS mount (%s): %s", hostname, hstrerror(h_errno)); 682 692 retval++; 683 693 } else { 684 694 mr_asprintf(ip_address, "%s", inet_ntoa((struct in_addr) *((struct in_addr *) hent->h_addr))); 685 695 mr_strcat(ip_address, strchr(bkpinfo->nfs_mount, ':')); 686 strcpy(bkpinfo->nfs_mount, ip_address);687 paranoid_free(ip_address);696 mr_free(bkpinfo->nfs_mount); 697 bkpinfo->nfs_mount = ip_address; 688 698 } 689 699 } … … 746 756 } 747 757 g_current_media_number = 1; 748 bkpinfo->postnuke_tarball[0] = bkpinfo->nfs_mount[0] ='\0';758 bkpinfo->postnuke_tarball[0] = '\0'; 749 759 return (res); 750 760 } … … 787 797 void mr_free_bkpinfo() { 788 798 799 mr_free(bkpinfo->media_device); 800 mr_free(bkpinfo->isodir); 801 mr_free(bkpinfo->prefix); 789 802 mr_free(bkpinfo->scratchdir); 790 803 mr_free(bkpinfo->tmpdir); 791 804 mr_free(bkpinfo->include_paths); 792 805 mr_free(bkpinfo->exclude_paths); 806 mr_free(bkpinfo->nfs_mount); 807 mr_free(bkpinfo->nfs_remote_dir); 793 808 mr_free(bkpinfo->nfs_user); 794 809 … … 804 819 { 805 820 int i; 806 char *p = NULL;807 808 821 log_msg(1, "Hi"); 809 822 810 823 /* Initialized in same order as in the structure declaration to detect errors more easily */ 811 bkpinfo->media_device [0] = '\0';824 bkpinfo->media_device = NULL; 812 825 for (i = 0; i <= MAX_NOOF_MEDIA; i++) { 813 826 bkpinfo->media_size[i] = -1; … … 846 859 bkpinfo->call_after_iso[0] = '\0'; 847 860 bkpinfo->kernel_path[0] = '\0'; 848 bkpinfo->nfs_mount [0] = '\0';849 bkpinfo->nfs_remote_dir [0] = '\0';861 bkpinfo->nfs_mount = NULL; 862 bkpinfo->nfs_remote_dir = NULL; 850 863 bkpinfo->nfs_user = NULL; 851 864 bkpinfo->postnuke_tarball[0] = '\0'; … … 1072 1085 * @return 0 for success, 1 for failure. 1073 1086 */ 1074 int read_cfg_var(char *config_file, char *label, char *value)1087 char *read_cfg_var(char *config_file, char *label) 1075 1088 { 1076 1089 /*@ buffer ****************************************************** */ 1077 1090 char *command = NULL; 1091 char *value = NULL; 1078 1092 1079 1093 /*@ end vars *************************************************** */ … … 1083 1097 if (!does_file_exist(config_file)) { 1084 1098 log_to_screen("(read_cfg_var) Cannot find %s config file", config_file); 1085 value[0] = '\0';1086 return (1);1099 return (NULL); 1100 /* BERLIOS: not sure the sage of this one ? 1087 1101 } else if ((value != NULL) && (strstr(value, "/dev/") && strstr(value, "t0") && !strcmp(label, "media-dev"))) { 1088 1102 log_msg(2, "FYI, I can't read new value for %s - already got %s", label, value); 1089 1103 return (0); 1104 */ 1090 1105 } else { 1091 1106 mr_asprintf(command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5", label, config_file); 1092 strcpy(value, call_program_and_get_last_line_of_output(command));1107 mr_asprintf(value, "%s", call_program_and_get_last_line_of_output(command)); 1093 1108 mr_free(command); 1094 1109 1095 1110 if (strlen(value) == 0) { 1096 return ( 1);1111 return (NULL); 1097 1112 } else { 1098 return ( 0);1113 return (value); 1099 1114 } 1100 1115 }
Note:
See TracChangeset
for help on using the changeset viewer.