Changeset 3161 in MondoRescue for branches/3.1/mondo/src/common
- Timestamp:
- Jun 25, 2013, 10:53:14 PM (12 years ago)
- Location:
- branches/3.1/mondo/src/common
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/mondo/src/common/libmondo-archive.c
r3148 r3161 686 686 fatal_error("The de facto standard location for your boot loader's config file is /boot/grub/menu.lst, /boot/grub/grub.cfg, or /boot/grub2/grub.cfg but I cannot find it there. What is wrong with your Linux distribution?"); 687 687 } 688 mr_asprintf( &bootldr_ver, "%s", call_program_and_get_last_line_of_output("grub --version"));688 mr_asprintf(bootldr_ver, "%s", call_program_and_get_last_line_of_output("grub --version", TRUE)); 689 689 } else if (bkpinfo->boot_loader == 'E') { 690 690 mr_asprintf(bootldr_str, "ELILO"); … … 722 722 log_to_screen("Your boot loader is %s and it boots from %s", bootldr_str, bkpinfo->boot_device); 723 723 if (bootldr_ver != NULL) { 724 mr_asprintf( &tmp, "Boot loader version string: %s", bootldr_ver);724 mr_asprintf(tmp, "Boot loader version string: %s", bootldr_ver); 725 725 log_to_screen(tmp); 726 726 mr_free(tmp); 727 727 } 728 728 if (bootldr_ver != NULL) { 729 mr_asprintf( &tmp, "Boot loader version string: %s", bootldr_ver);729 mr_asprintf(tmp, "Boot loader version string: %s", bootldr_ver); 730 730 log_to_screen(tmp); 731 731 mr_free(tmp); … … 1590 1590 /*@ buffers ****************************************** */ 1591 1591 char *tmp = NULL; 1592 char *tmp2 = NULL; 1592 1593 char *old_pwd; 1593 1594 char *result_sz = NULL; … … 1614 1615 log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s", bkpinfo->scratchdir, destfile); 1615 1616 tmp2 = getcwd(old_pwd, MAX_STR_LEN - 1); 1617 if (! tmp2) { 1618 //FIXME 1619 } 1616 1620 mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir); 1617 1621 run_program_and_log_output(tmp, FALSE); … … 1733 1737 mr_free(mds); 1734 1738 if (find_home_of_exe("genisoimage")) { 1735 mr_asprintf( &isofs_cmd, "%s", MONDO_GENISOIMAGE_CMD);1739 mr_asprintf(isofs_cmd, "%s", MONDO_GENISOIMAGE_CMD); 1736 1740 } else { 1737 mr_asprintf( &isofs_cmd, "%s", MONDO_MKISOFS_CMD);1741 mr_asprintf(isofs_cmd, "%s", MONDO_MKISOFS_CMD); 1738 1742 } 1739 1743 if (bkpinfo->nonbootable_backup) { 1740 1744 log_msg(1, "Making nonbootable backup"); 1741 1745 mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS); 1742 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE,message_to_screen);1746 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, message_to_screen); 1743 1747 mr_free(full_isofs_cmd); 1744 1748 } else { … … 1756 1760 log_msg(1, "IA64 --> elilo"); 1757 1761 mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS_REGULAR_ELILO); 1758 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE,message_to_screen);1762 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, message_to_screen); 1759 1763 mr_free(full_isofs_cmd); 1760 1764 #else … … 1762 1766 mr_asprintf(full_isofs_cmd, "%s%s-b images/mindi-bootroot.2880.img -c boot.cat -o '_ISO_' -J -V _CD#_ .",isofs_cmd,MONDO_MKISOFS); 1763 1767 // FIXME: fixed boot size probably wrong. lilo to be removed 1764 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE,message_to_screen);1768 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, message_to_screen); 1765 1769 #endif 1766 1770 } else { … … 1768 1772 log_msg(1, "Isolinux"); 1769 1773 mr_asprintf(full_isofs_cmd, "%s%s-o '_ISO_' -V _CD#_ .",isofs_cmd,MONDO_MKISOFS_REGULAR_SYSLINUX); 1770 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, MONDO_LOGFILE,message_to_screen);1774 res = eval_call_to_make_ISO(full_isofs_cmd, destfile, g_current_media_number, message_to_screen); 1771 1775 } 1772 1776 mr_free(full_isofs_cmd); … … 1884 1888 /*@ pointers ******************************************* */ 1885 1889 FILE *fin = NULL; 1886 char *q;1887 char *q;1888 1890 1889 1891 /*@ buffers ******************************************** */ -
branches/3.1/mondo/src/common/libmondo-cli.c
r3148 r3161 507 507 mr_asprintf(tmp1, "sshfs %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount); 508 508 } else if (strstr(bkpinfo->netfs_proto, "smbfs")) { 509 sprintf(tmp, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user);509 mr_asprintf(tmp1, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user); 510 510 } else if (strstr(bkpinfo->netfs_proto, "smbfs")) { 511 sprintf(tmp, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user);511 mr_asprintf(tmp1, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user); 512 512 } else if (strstr(bkpinfo->netfs_proto, "nfs")) { 513 513 mr_asprintf(tmp1, "mount %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount); … … 520 520 mr_asprintf(tmp1, "sshfs %s", bkpinfo->netfs_mount); 521 521 } else if (strstr(bkpinfo->netfs_proto, "smbfs")) { 522 sprintf(tmp, "mount -t cifs %s", bkpinfo->netfs_mount);522 mr_asprintf(tmp1, "mount -t cifs %s", bkpinfo->netfs_mount); 523 523 } else if (strstr(bkpinfo->netfs_proto, "smbfs")) { 524 sprintf(tmp, "mount -t cifs %s", bkpinfo->netfs_mount);524 mr_asprintf(tmp1, "mount -t cifs %s", bkpinfo->netfs_mount); 525 525 } else if (strstr(bkpinfo->netfs_proto, "nfs")) { 526 526 mr_asprintf(tmp1, "mount %s", bkpinfo->netfs_mount); -
branches/3.1/mondo/src/common/libmondo-devices.c
r3148 r3161 330 330 char *incoming = NULL; 331 331 char *searchstr = NULL; 332 char *tmp = NULL;333 char *p;334 char *p;335 332 336 333 /*@ ints ******************************************************* */ … … 339 336 /*@ pointers *************************************************** */ 340 337 FILE *fin; 341 342 338 343 339 /*@ end vars *************************************************** */ … … 354 350 mr_free(program); 355 351 return (res); 356 #else357 /* To avoid compiler warnings */358 tmp = NULL;359 352 #endif 360 353 … … 984 977 char *command = NULL; 985 978 char *format_sz = NULL; 986 char *p;987 char *p;988 979 989 980 FILE *pin; … … 2032 2023 mr_strcat(bkpinfo->exclude_paths,"|%s",mounted_on_dsf); 2033 2024 } else { 2034 mr_asprintf( &(bkpinfo->exclude_paths),"%s",mounted_on_dsf);2025 mr_asprintf(bkpinfo->exclude_paths,"%s",mounted_on_dsf); 2035 2026 } 2036 2027 if (bkpinfo->exclude_devs) { 2037 2028 mr_strcat(bkpinfo->exclude_devs,"|%s",token); 2038 2029 } else { 2039 mr_asprintf( &(bkpinfo->exclude_devs),"%s",token);2030 mr_asprintf(bkpinfo->exclude_devs,"%s",token); 2040 2031 } 2041 2032 } … … 2052 2043 mr_strcat(bkpinfo->exclude_paths, "|%s",not_mounted_on_dsf); 2053 2044 } else { 2054 mr_asprintf( &(bkpinfo->exclude_paths),"%s",not_mounted_on_dsf);2045 mr_asprintf(bkpinfo->exclude_paths,"%s",not_mounted_on_dsf); 2055 2046 } 2056 2047 } … … 2065 2056 /* Adds a | to ensure correct detection even at both ends */ 2066 2057 mr_asprintf(tmp1,"|%s",token); 2067 mr_asprintf( &tmp2,"|%s|",token);2058 mr_asprintf(tmp2,"|%s|",token); 2068 2059 if (mode == 'E') { 2069 2060 /* Add the token if not already in the list */ … … 2984 2975 2985 2976 } 2986 <<<<<<< .courant2987 2977 p = popup_and_get_string("Network protocol", "Which Network protocol should I use (nfs/sshfs/smbfs) ?", bkpinfo->netfs_proto); 2988 2978 if (p == NULL) { … … 3006 2996 strcpy(tmp1, ""); 3007 2997 } 3008 if (!popup_and_get_string 3009 ("Network user", "Which user should I use if any ?", 3010 tmp1, MAX_STR_LEN)) { 2998 if (!popup_and_get_string("Network user", "Which user should I use if any ?",tmp1)) { 3011 2999 log_to_screen("User has chosen not to backup the PC"); 3012 3000 finish(1); … … 3014 3002 mr_free(bkpinfo->netfs_user); 3015 3003 if (strcmp(tmp1, "") != 0) { 3016 mr_asprintf( &(bkpinfo->netfs_user), "%s", tmp1);3004 mr_asprintf(bkpinfo->netfs_user, "%s", tmp1); 3017 3005 } 3018 3006 -
branches/3.1/mondo/src/common/libmondo-filelist.c
r3148 r3161 399 399 char *tmp = NULL; 400 400 401 char *p;402 403 char *p;404 405 401 pattr = popen(syscall, "r"); 406 402 if (!pattr) { … … 434 430 char *strtmp = NULL; 435 431 char *tmp = NULL; 436 char *p = NULL;437 432 int i; 438 433 … … 521 516 int retval = 0; 522 517 int i; 523 char *p, *q , *r;518 char *p, *q; 524 519 char *tmp = NULL; 525 520 FILE *pin, *pout, *faclin; … … 1404 1399 1405 1400 mr_asprintf(find_skeleton_marker, "mv -f %s.new %s", g_skeleton_filelist, g_skeleton_filelist); 1406 (void)system(find_skeleton_marker); 1401 if (system(find_skeleton_marker)) { 1402 //FIXME 1403 } 1407 1404 time(&this_time); 1408 1405 if (this_time != last_time) { -
branches/3.1/mondo/src/common/libmondo-files.c
r3148 r3161 51 51 /*@ pointers **************************************************** */ 52 52 char *p = NULL; 53 char *q;54 char *q;55 53 FILE *fin; 56 54 … … 128 126 char *command = NULL; 129 127 char *incoming = NULL; 130 char *q;131 char *q;132 128 133 129 /*@ long ******************************************************** */ … … 208 204 char *tmp = NULL; 209 205 char *incoming = NULL; 210 char *q;211 char *q;212 206 213 207 /*@ int ********************************************************* */ … … 477 471 char *output = NULL; 478 472 char *command = NULL; 479 char *p = NULL;480 char *p = NULL;481 473 482 474 /*@ pointers **************************************************** */ … … 548 540 char *curr_cksum = NULL; 549 541 char *tmp = NULL; 550 char *q;551 char *q;552 542 553 543 /*@ long [long] ************************************************* */ … … 689 679 /*@ buffers **************************************************** */ 690 680 char *incoming = NULL; 691 char *p = NULL;692 char *p = NULL;693 681 694 682 /*@ end vars *************************************************** */ … … 755 743 char *tmp = NULL; 756 744 char *command = NULL; 757 char *comment;758 745 759 746 /*@ long ******************************************************** */ -
branches/3.1/mondo/src/common/libmondo-fork.c
r3148 r3161 42 42 char *newcall = NULL; 43 43 char *tmp = NULL; 44 char *p;45 char *p;46 44 47 45 /*@ pointers **************************************************** */ 48 46 FILE *fin = NULL; 47 int res = 0; 49 48 50 49 /*@******************************************************************** */ … … 60 59 mr_asprintf(result, ""); 61 60 62 system(newcall); 61 res = system(newcall); 62 if (res != 0) { 63 //FIXME 64 } 63 65 mr_free(newcall); 64 66 -
branches/3.1/mondo/src/common/libmondo-mountlist.c
r3147 r3161 805 805 char *tmp = NULL; 806 806 char *p = NULL; 807 char *q = NULL;808 807 809 808 int items = 0; -
branches/3.1/mondo/src/common/libmondo-raid.c
r3147 r3161 430 430 char *incoming = NULL; 431 431 char *p; 432 char *q;433 432 434 433 assert(fin != NULL); … … 974 973 char type; 975 974 char *strtmp = NULL; 976 char *strtmp2 = NULL; 977 978 // open file 979 if (!(fin = fopen(MDSTAT_FILE, "r"))) { 980 log_msg(1, "Could not open %s.\n", MDSTAT_FILE); 981 return 1; 982 } 983 // initialise record, build progress and row counters 984 raidlist->entries = 0; 985 raidlist->el[raidlist->entries].progress = 999; 986 row = 1; 987 // skip first output row - contains registered RAID levels 988 res = getline(&string, &len, fin); 989 // parse the rest 990 while ( !feof_unlocked(fin) ) { 991 res = getline(&string, &len, fin); 992 if (res <= 0) break; 993 // trim leading spaces 994 pos = string; 995 while (*pos == ' ') pos += 1; 996 mr_asprintf(strtmp, "%s", pos); 997 strcpy(string, strtmp); 998 mr_free(strtmp); 999 // if we have newline after only spaces, this is a blank line, update 1000 // counters, otherwise do normal parsing 1001 if (*string == '\n') { 1002 row = 1; 1003 raidlist->entries++; 1004 raidlist->el[raidlist->entries].progress = 999; 1005 } else { 1006 switch (row) { 1007 case 1: // device information 1008 // check whether last line of record and if so skip 1009 pos = strcasestr(string, "unused devices: "); 1010 if (pos == string) { 1011 //raidlist->entries--; 1012 break; 1013 } 1014 // tokenise string 1015 token = mr_strtok(string, delims, &lastpos); 1016 // get RAID device name 1017 mr_asprintf(strtmp,"%s%s", device_prefix, token); 1018 strcpy(raidlist->el[raidlist->entries].raid_device, strtmp); 975 976 // open file 977 if (!(fin = fopen(MDSTAT_FILE, "r"))) { 978 log_msg(1, "Could not open %s.\n", MDSTAT_FILE); 979 return 1; 980 } 981 // initialise record, build progress and row counters 982 raidlist->entries = 0; 983 raidlist->el[raidlist->entries].progress = 999; 984 row = 1; 985 // skip first output row - contains registered RAID levels 986 res = getline(&string, &len, fin); 987 // parse the rest 988 while ( !feof_unlocked(fin) ) { 989 res = getline(&string, &len, fin); 990 if (res <= 0) break; 991 // trim leading spaces 992 pos = string; 993 while (*pos == ' ') pos += 1; 994 mr_asprintf(strtmp, "%s", pos); 995 strcpy(string, strtmp); 1019 996 mr_free(strtmp); 1020 mr_free(token); 1021 // skip ':' and status 1022 token = mr_strtok(string, delims, &lastpos); 1023 mr_free(token); 1024 token = mr_strtok(string, delims, &lastpos); 1025 if (!strcmp(token, "inactive")) { 1026 log_msg(1, "RAID device '%s' inactive.\n", 1027 raidlist->el[raidlist->entries].raid_device); 1028 paranoid_free(string); 1029 mr_free(token); 1030 return 1; 1031 } 1032 mr_free(token); 1033 1034 // get RAID level 1035 token = mr_strtok(string, delims, &lastpos); 1036 // skip potential auto-read-only entry 1037 if (!strcmp(token, "(auto-read-only)")) { 1038 mr_free(token); 1039 token = mr_strtok (string, delims, &lastpos); 1040 } 1041 if (!strcmp(token, "multipath")) { 1042 raidlist->el[raidlist->entries].raid_level = -2; 1043 } else if (!strcmp(token, "linear")) { 1044 raidlist->el[raidlist->entries].raid_level = -1; 1045 } else if (!strcmp(token, "raid0")) { 1046 raidlist->el[raidlist->entries].raid_level = 0; 1047 } else if (!strcmp(token, "raid1")) { 1048 raidlist->el[raidlist->entries].raid_level = 1; 1049 } else if (!strcmp(token, "raid4")) { 1050 raidlist->el[raidlist->entries].raid_level = 4; 1051 } else if (!strcmp(token, "raid5")) { 1052 raidlist->el[raidlist->entries].raid_level = 5; 1053 } else if (!strcmp(token, "raid6")) { 1054 raidlist->el[raidlist->entries].raid_level = 6; 1055 } else if (!strcmp(token, "raid10")) { 1056 raidlist->el[raidlist->entries].raid_level = 10; 997 // if we have newline after only spaces, this is a blank line, update 998 // counters, otherwise do normal parsing 999 if (*string == '\n') { 1000 row = 1; 1001 raidlist->entries++; 1002 raidlist->el[raidlist->entries].progress = 999; 1057 1003 } else { 1058 1004 switch (row) { 1059 1005 case 1: // device information 1060 1006 // check whether last line of record and if so skip 1061 log_msg(8, "This is the device line\n");1062 1007 pos = strcasestr(string, "unused devices: "); 1063 if (pos != NULL) { 1008 if (pos == string) { 1009 //raidlist->entries--; 1064 1010 break; 1065 1011 } … … 1071 1017 } 1072 1018 // get RAID device name 1073 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1074 strncpy(raidlist->el[raidlist->entries].raid_device, strtmp, 63); 1075 raidlist->el[raidlist->entries].raid_device[63] = '\0'; 1019 mr_asprintf(strtmp,"%s%s", device_prefix, token); 1020 strcpy(raidlist->el[raidlist->entries].raid_device, strtmp); 1076 1021 mr_free(strtmp); 1077 1022 mr_free(token); … … 1079 1024 v = raidlist->el[raidlist->entries].additional_vars.entries; 1080 1025 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "UUID"); 1081 mr_asprintf( &cmd,"mdadm --detail %s | grep UUID | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device);1082 mr_asprintf( &strtmp, "%s", call_program_and_get_last_line_of_output(cmd));1026 mr_asprintf(cmd,"mdadm --detail %s | grep UUID | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device); 1027 mr_asprintf(strtmp, "%s", call_program_and_get_last_line_of_output(cmd, TRUE)); 1083 1028 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp); 1084 1029 mr_free(strtmp); … … 1086 1031 // store the Version value in the additional_vars structure 1087 1032 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "Version"); 1088 mr_asprintf( &cmd,"mdadm --detail %s | grep Version | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device);1089 mr_asprintf( &strtmp, "%s", call_program_and_get_last_line_of_output(cmd));1033 mr_asprintf(cmd,"mdadm --detail %s | grep Version | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device); 1034 mr_asprintf(strtmp, "%s", call_program_and_get_last_line_of_output(cmd, TRUE)); 1090 1035 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp); 1091 1036 mr_free(strtmp); … … 1093 1038 raidlist->el[raidlist->entries].additional_vars.entries = v; 1094 1039 // skip ':' and status 1095 token = mr_strtok 1040 token = mr_strtok(string, delims, &lastpos); 1096 1041 if (token == NULL) { 1097 1042 // should not happen ! … … 1099 1044 } 1100 1045 mr_free(token); 1101 token = mr_strtok 1046 token = mr_strtok(string, delims, &lastpos); 1102 1047 if (token == NULL) { 1103 1048 // should not happen ! … … 1105 1050 } 1106 1051 if (!strcmp(token, "inactive")) { 1107 log_msg(1, "RAID device '%s' inactive.\n", 1108 raidlist->el[raidlist->entries].raid_device); 1052 log_msg(1, "RAID device '%s' inactive.\n", raidlist->el[raidlist->entries].raid_device); 1109 1053 mr_free(string); 1110 1054 mr_free(token); … … 1113 1057 mr_free(token); 1114 1058 1115 // get RAID devices (type, index, device) 1116 // Note: parity disk for RAID4 is last normal disk, there is no '(P)' 1117 raidlist->el[raidlist->entries].data_disks.entries = 0; 1118 raidlist->el[raidlist->entries].spare_disks.entries = 0; 1119 raidlist->el[raidlist->entries].failed_disks.entries = 0; 1120 while((token = mr_strtok (string, delims, &lastpos))) { 1121 if ((pos = strstr(token, "("))) { 1122 type = *(pos+1); 1123 } else { 1124 type = ' '; 1125 } 1126 pos = strstr(token, "["); 1127 *pos = '\0'; 1128 switch(type) { 1129 case ' ': // normal data disks 1130 raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].index = atoi(pos + 1); 1131 mr_asprintf(strtmp,"%s%s", device_prefix, token); 1132 strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp); 1133 mr_free(strtmp); 1134 raidlist->el[raidlist->entries].data_disks.entries++; 1135 break; 1136 case 'S': // spare disks 1137 raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].index = atoi(pos + 1); 1138 mr_asprintf(strtmp,"%s%s", device_prefix, token); 1139 strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp); 1140 mr_free(strtmp); 1141 raidlist->el[raidlist->entries].spare_disks.entries++; 1142 break; 1143 case 'F': // failed disks 1144 raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].index = atoi(pos + 1); 1145 mr_asprintf(strtmp,"%s%s", device_prefix, token); 1146 strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp); 1147 mr_free(strtmp); 1148 raidlist->el[raidlist->entries].failed_disks.entries++; 1149 log_it("At least one failed disk found in RAID array.\n"); 1150 break; 1151 default: // error 1152 log_msg(1, "Unknown device type '%c'\n", type); 1153 paranoid_free(string); 1154 paranoid_free(token); 1155 return 1; 1156 break; 1157 } 1158 mr_free(token); 1159 } 1160 1161 // get RAID devices (type, index, device) 1162 // Note: parity disk for RAID4 is last normal disk, there is no '(P)' 1163 raidlist->el[raidlist->entries].data_disks.entries = 0; 1164 raidlist->el[raidlist->entries].spare_disks.entries = 0; 1165 raidlist->el[raidlist->entries].failed_disks.entries = 0; 1166 while((token = mr_strtok (string, delims, &lastpos))) { 1167 if ((pos = strstr(token, "("))) { 1168 type = *(pos+1); 1169 } else { 1170 type = ' '; 1171 } 1172 pos = strstr(token, "["); 1173 *pos = '\0'; 1174 switch(type) { 1175 case ' ': // normal data disks 1176 raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].index = atoi(pos + 1); 1177 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1178 strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp); 1179 mr_free(strtmp); 1180 raidlist->el[raidlist->entries].data_disks.entries++; 1181 break; 1182 case 'S': // spare disks 1183 raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].index = atoi(pos + 1); 1184 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1185 strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp); 1186 mr_free(strtmp); 1187 raidlist->el[raidlist->entries].spare_disks.entries++; 1188 break; 1189 case 'F': // failed disks 1190 raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].index = atoi(pos + 1); 1191 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1192 strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp); 1193 mr_free(strtmp); 1194 raidlist->el[raidlist->entries].failed_disks.entries++; 1195 log_it("At least one failed disk found in RAID array.\n"); 1196 break; 1197 default: // error 1198 log_msg(1, "Unknown device type '%c'\n", type); 1199 mr_free(string); 1200 mr_free(token); 1201 return 1; 1202 break; 1203 } 1204 mr_free(token); 1205 } 1206 1207 // adjust index for each device so that it starts with 0 for every type 1208 index_min = 99; 1209 for (i=0; i<raidlist->el[raidlist->entries].data_disks.entries;i++) { 1210 if (raidlist->el[raidlist->entries].data_disks.el[i].index < index_min) { 1211 index_min = raidlist->el[raidlist->entries].data_disks.el[i].index; 1212 } 1213 } 1214 if (index_min > 0) { 1215 for (i=0; i<raidlist->el[raidlist->entries].data_disks.entries;i++) { 1216 raidlist->el[raidlist->entries].data_disks.el[i].index = raidlist->el[raidlist->entries].data_disks.el[i].index - index_min; 1217 } 1218 } 1219 index_min = 99; 1220 for (i=0; i<raidlist->el[raidlist->entries].spare_disks.entries;i++) { 1221 if (raidlist->el[raidlist->entries].spare_disks.el[i].index < index_min) { 1222 index_min = raidlist->el[raidlist->entries].spare_disks.el[i].index; 1223 } 1224 } 1225 if (index_min > 0) { 1226 for (i=0; i<raidlist->el[raidlist->entries].spare_disks.entries;i++) { 1227 raidlist->el[raidlist->entries].spare_disks.el[i].index = raidlist->el[raidlist->entries].spare_disks.el[i].index - index_min; 1228 } 1229 } 1230 index_min = 99; 1231 for (i=0; i<raidlist->el[raidlist->entries].failed_disks.entries;i++) { 1232 if (raidlist->el[raidlist->entries].failed_disks.el[i].index < index_min) { 1233 index_min = raidlist->el[raidlist->entries].failed_disks.el[i].index; 1234 } 1235 } 1236 if (index_min > 0) { 1237 for (i=0; i<raidlist->el[raidlist->entries].failed_disks.entries;i++) { 1238 raidlist->el[raidlist->entries].failed_disks.el[i].index = raidlist->el[raidlist->entries].failed_disks.el[i].index - index_min; 1239 } 1240 } 1241 break; 1242 case 2: // config information 1243 // check for persistent super block 1244 if (strcasestr(string, "super non-persistent")) { 1059 // get RAID level 1060 token = mr_strtok(string, delims, &lastpos); 1061 if (token == NULL) { 1062 // should not happen ! 1063 break; 1064 } 1065 // skip potential auto-read-only entry 1066 if (!strcmp(token, "(auto-read-only)")) { 1067 mr_free(token); 1068 token = mr_strtok (string, delims, &lastpos); 1069 if (token == NULL) { 1070 // should not happen ! 1071 break; 1072 } 1073 } 1074 if (!strcmp(token, "multipath")) { 1075 raidlist->el[raidlist->entries].raid_level = -2; 1076 } else if (!strcmp(token, "linear")) { 1077 raidlist->el[raidlist->entries].raid_level = -1; 1078 } else if (!strcmp(token, "raid0")) { 1079 raidlist->el[raidlist->entries].raid_level = 0; 1080 } else if (!strcmp(token, "raid1")) { 1081 raidlist->el[raidlist->entries].raid_level = 1; 1082 } else if (!strcmp(token, "raid4")) { 1083 raidlist->el[raidlist->entries].raid_level = 4; 1084 } else if (!strcmp(token, "raid5")) { 1085 raidlist->el[raidlist->entries].raid_level = 5; 1086 } else if (!strcmp(token, "raid6")) { 1087 raidlist->el[raidlist->entries].raid_level = 6; 1088 } else if (!strcmp(token, "raid10")) { 1089 raidlist->el[raidlist->entries].raid_level = 10; 1090 } else { 1091 log_msg(1, "Unknown RAID level '%s'.\n", token); 1092 mr_free(string); 1093 mr_free(token); 1094 return 1; 1095 } 1096 mr_free(token); 1097 1098 // get RAID devices (type, index, device) 1099 // Note: parity disk for RAID4 is last normal disk, there is no '(P)' 1100 raidlist->el[raidlist->entries].data_disks.entries = 0; 1101 raidlist->el[raidlist->entries].spare_disks.entries = 0; 1102 raidlist->el[raidlist->entries].failed_disks.entries = 0; 1103 while((token = mr_strtok (string, delims, &lastpos))) { 1104 if ((pos = strstr(token, "("))) { 1105 type = *(pos+1); 1106 } else { 1107 type = ' '; 1108 } 1109 pos = strstr(token, "["); 1110 *pos = '\0'; 1111 switch(type) { 1112 case ' ': // normal data disks 1113 raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].index = atoi(pos + 1); 1114 mr_asprintf(strtmp,"%s%s", device_prefix, token); 1115 strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp); 1116 mr_free(strtmp); 1117 raidlist->el[raidlist->entries].data_disks.entries++; 1118 break; 1119 case 'S': // spare disks 1120 raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].index = atoi(pos + 1); 1121 mr_asprintf(strtmp,"%s%s", device_prefix, token); 1122 strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp); 1123 mr_free(strtmp); 1124 raidlist->el[raidlist->entries].spare_disks.entries++; 1125 break; 1126 case 'F': // failed disks 1127 raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].index = atoi(pos + 1); 1128 mr_asprintf(strtmp,"%s%s", device_prefix, token); 1129 strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp); 1130 mr_free(strtmp); 1131 raidlist->el[raidlist->entries].failed_disks.entries++; 1132 log_it("At least one failed disk found in RAID array.\n"); 1133 break; 1134 default: // error 1135 log_msg(1, "Unknown device type '%c'\n", type); 1136 mr_free(string); 1137 mr_free(token); 1138 return 1; 1139 break; 1140 } 1141 mr_free(token); 1142 } 1143 1144 // adjust index for each device so that it starts with 0 for every type 1145 index_min = 99; 1146 for (i=0; i<raidlist->el[raidlist->entries].data_disks.entries;i++) { 1147 if (raidlist->el[raidlist->entries].data_disks.el[i].index < index_min) { 1148 index_min = raidlist->el[raidlist->entries].data_disks.el[i].index; 1149 } 1150 } 1151 if (index_min > 0) { 1152 for (i=0; i<raidlist->el[raidlist->entries].data_disks.entries;i++) { 1153 raidlist->el[raidlist->entries].data_disks.el[i].index = raidlist->el[raidlist->entries].data_disks.el[i].index - index_min; 1154 } 1155 } 1156 index_min = 99; 1157 for (i=0; i<raidlist->el[raidlist->entries].spare_disks.entries;i++) { 1158 if (raidlist->el[raidlist->entries].spare_disks.el[i].index < index_min) { 1159 index_min = raidlist->el[raidlist->entries].spare_disks.el[i].index; 1160 } 1161 } 1162 if (index_min > 0) { 1163 for (i=0; i<raidlist->el[raidlist->entries].spare_disks.entries;i++) { 1164 raidlist->el[raidlist->entries].spare_disks.el[i].index = raidlist->el[raidlist->entries].spare_disks.el[i].index - index_min; 1165 } 1166 } 1167 index_min = 99; 1168 for (i=0; i<raidlist->el[raidlist->entries].failed_disks.entries;i++) { 1169 if (raidlist->el[raidlist->entries].failed_disks.el[i].index < index_min) { 1170 index_min = raidlist->el[raidlist->entries].failed_disks.el[i].index; 1171 } 1172 } 1173 if (index_min > 0) { 1174 for (i=0; i<raidlist->el[raidlist->entries].failed_disks.entries;i++) { 1175 raidlist->el[raidlist->entries].failed_disks.el[i].index = raidlist->el[raidlist->entries].failed_disks.el[i].index - index_min; 1176 } 1177 } 1178 break; 1179 case 2: // config information 1180 // check for persistent super block 1181 if (strcasestr(string, "super non-persistent")) { 1245 1182 raidlist->el[raidlist->entries].persistent_superblock = 0; 1246 1183 } else { … … 1252 1189 } else { 1253 1190 while (*pos != ' ') { 1254 1255 1256 1257 1258 1259 1191 pos -= 1; 1192 if (pos < string) { 1193 log_it("String underflow!\n"); 1194 mr_free(string); 1195 return 1; 1196 } 1260 1197 } 1261 1198 raidlist->el[raidlist->entries].chunk_size = atoi(pos + 1); … … 1271 1208 if (!(pos = strchr(string, '\%'))) { 1272 1209 if (strcasestr(string, "delayed")) { 1273 1210 raidlist->el[raidlist->entries].progress = -1; // delayed (therefore, stuck at 0%) 1274 1211 } else { 1275 1212 raidlist->el[raidlist->entries].progress = 999; // not found 1276 1213 } 1277 1214 } else { 1278 1215 while (*pos != ' ') { 1279 1280 1281 1282 1283 1284 1216 pos -= 1; 1217 if (pos < string) { 1218 printf("ERROR: String underflow!\n"); 1219 mr_free(string); 1220 return 1; 1221 } 1285 1222 } 1286 1223 raidlist->el[raidlist->entries].progress = atoi(pos); 1287 1224 } 1288 1225 break; 1289 1226 default: // error or IN PROGRESS 1290 1227 if (raidlist->el[raidlist->entries].progress != -1 && 1291 1228 raidlist->el[raidlist->entries].progress != 999) { … … 1293 1230 } 1294 1231 break; 1295 1296 1297 } 1298 1299 1232 } 1233 row++; 1234 } 1235 // free string 1236 mr_free(string); 1300 1237 } 1301 1238 // close file -
branches/3.1/mondo/src/common/libmondo-stream.c
r3147 r3161 535 535 536 536 bufsize_K = (long long) (1024LL * (1 + g_tape_buffer_size_MB)); 537 if (strstr(latest_fname, ".afio.") || strstr(latest_fname, ".star.")) {538 type = fileset;539 } else if (strstr(latest_fname, "slice")) {540 type = biggieslice;541 } else {542 log_it("fname = %s", latest_fname);543 fatal_error("Unknown type. Internal error in maintain_collection_of_recent_archives()");544 }545 537 mr_asprintf(tmpdir, "%s/tmpfs/backcatalog", bkpinfo->tmpdir); 546 538 mkdir(tmpdir, 0x700); … … 744 736 745 737 /* restore compression mode on */ 746 mr_asprintf( &command, "mt -f %s compression on",bkpinfo->media_device);738 mr_asprintf(command, "mt -f %s compression on",bkpinfo->media_device); 747 739 res = run_program_and_log_output(command, 1); 748 740 paranoid_free(command); … … 1313 1305 char *pA; 1314 1306 char *pB; 1307 int ctrl_chr; 1315 1308 int res; 1316 int ctrl_chr;1317 1309 char *temp_fname; 1318 1310 char *datablock; … … 1342 1334 while (ctrl_chr != BLK_START_FILE) { 1343 1335 res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1336 if (res) { 1337 //FIXME 1338 } 1344 1339 if (ctrl_chr == BLK_START_FILE) { 1345 1340 break; -
branches/3.1/mondo/src/common/libmondo-tools.c
r3147 r3161 643 643 colon++; 644 644 hent = gethostbyname(colon); 645 mr_asprintf( &(bkpinfo->netfs_user),"%s", hostname);645 mr_asprintf(bkpinfo->netfs_user,"%s", hostname); 646 646 } else { 647 647 hent = gethostbyname(hostname); -
branches/3.1/mondo/src/common/libmondo-verify.c
r3147 r3161 305 305 log_to_screen("%s/%s not found on live filesystem", bkpinfo->restore_path, biggiestruct.filename); 306 306 mr_asprintf(tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", bkpinfo->restore_path, biggiestruct.filename, bkpinfo->tmpdir); 307 system(tmp); 307 if (system(tmp)) { 308 //FIXME 309 } 308 310 mr_free(tmp); 309 311 … … 412 414 char *outlog = NULL; 413 415 char *tmp = NULL; 414 char *p = NULL;415 416 416 417 /*@ pointers ******************************************************* */ -
branches/3.1/mondo/src/common/newt-specific.c
r3148 r3161 171 171 /*@ buffer *********************************************************** */ 172 172 char *tmp = NULL; 173 char *p;174 char *p;175 173 int i; 176 174 … … 442 440 char *command = NULL; 443 441 char *tmp = NULL; 444 char *p = NULL;445 442 446 443 /*@ pointers ********************************************************* */ … … 468 465 for (err_log_lines[i][0] = '\0'; 469 466 strlen(err_log_lines[i]) < 2 && !feof(fin);) { 470 (void) fgets(err_log_lines[i], MAX_NEWT_COMMENT_LEN, fin); 467 if (fgets(err_log_lines[i], MAX_NEWT_COMMENT_LEN, fin)) { 468 //FIXME 469 } 471 470 /* Commented to make valgrind happy and avoid crash 472 471 strip_spaces(err_log_lines[i]); … … 782 781 /*@ buffers *********************************************************** */ 783 782 char *prompt = NULL; 784 char *q;785 char *q;786 783 787 784 /*@ newt ************************************************************** */ … … 1151 1148 static char *possible_responses[] = { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev", "netfs", "iso", NULL }; 1152 1149 char *outstr = NULL; 1153 char *p;1154 char *p;1155 1150 t_bkptype backup_type; 1156 1151 int i; … … 1350 1345 bool done; 1351 1346 char *tmp = NULL; 1352 char *p;1353 char *p;1354 1347 char *tmp1 = NULL; 1355 1348 FILE *fin, *fout;
Note:
See TracChangeset
for help on using the changeset viewer.