Changeset 541 in MondoRescue for branches/stable/mondo/mondo/common/libmondo-tools.c
- Timestamp:
- May 13, 2006, 8:47:23 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/mondo/common/libmondo-tools.c
r538 r541 174 174 #include "my-stuff.h" 175 175 #include "mondostructures.h" 176 #include "lib-common-externs.h" 176 177 #include "libmondo-tools.h" 177 #include " newt-specific-EXT.h"178 #include "libmondo-gui-EXT.h" 178 179 #include "libmondo-files-EXT.h" 179 180 #include "libmondo-fork-EXT.h" … … 270 271 newtSuspend(); 271 272 #endif 272 printf( _("ASSERTION FAILED: `%s'\n"), exp);273 printf( _("\tat %s:%d in %s\n\n"), file, line, function);274 printf( _("(I)gnore, ignore (A)ll, (D)ebug, a(B)ort, or (E)xit? "));273 printf("ASSERTION FAILED: `%s'\n", exp); 274 printf("\tat %s:%d in %s\n\n", file, line, function); 275 printf("(I)gnore, ignore (A)ll, (D)ebug, a(B)ort, or (E)xit? "); 275 276 do { 276 277 is_valid = TRUE; … … 299 300 case '\n': 300 301 printf 301 ( _("(I)gnore, ignore (A)ll, (D)ebug, a(B)ort, or (E)xit? "));302 ("(I)gnore, ignore (A)ll, (D)ebug, a(B)ort, or (E)xit? "); 302 303 break; 303 304 default: 304 305 is_valid = FALSE; 305 printf( _("Invalid choice.\n"));306 printf("Invalid choice.\n"); 306 307 break; 307 308 } … … 472 473 #endif 473 474 } 475 476 477 /** 478 * Log a trace message to the trace file. 479 * @bug This function seems orphaned. Please remove. 480 */ 481 void log_trace(char *o) 482 { 483 /*@ pointers **************************************************** */ 484 FILE *fout; 485 486 /*@ buffers ***************************************************** */ 487 char output[MAX_STR_LEN]; 488 489 /*@ int ****************************************************** */ 490 int i; 491 492 /*@ end vars *************************************************** */ 493 494 if (o[0] == '\0') { 495 return; 496 } 497 strcpy(output, o); 498 i = (int) strlen(output); 499 if (i <= 0) { 500 return; 501 } 502 if (output[i - 1] < 32) { 503 output[i - 1] = '\0'; 504 } 505 if (g_text_mode 506 /* && !strstr(last_line_of_file(MONDO_LOGFILE),output) */ ) { 507 printf("%s\n", output); 508 } 509 510 fout = fopen(MONDO_TRACEFILE, "a"); 511 if (fout) { 512 fprintf(fout, "%s\n", output); 513 paranoid_fclose(fout); 514 } else { 515 log_OS_error("Cannot write to tracefile"); 516 } 517 } 518 519 520 474 521 475 522 … … 923 970 strcpy(bkpinfo->isodir, "/"); 924 971 } else { 925 strcpy(bkpinfo->isodir, "/ var/cache/mondo/iso");972 strcpy(bkpinfo->isodir, "/root/images/mondo"); 926 973 } 927 974 strcpy(bkpinfo->prefix, STD_PREFIX); … … 1022 1069 if (atol(tmp) < 35000) { 1023 1070 retval++; 1024 log_to_screen( _("You must have at least 32MB of RAM to use Mondo."));1071 log_to_screen("You must have at least 32MB of RAM to use Mondo."); 1025 1072 } 1026 1073 if (atol(tmp) < 66000) { 1027 1074 log_to_screen 1028 ( _("WARNING! You have very little RAM. Please upgrade to 64MB or more."));1029 } 1030 #endif 1031 1032 if ((Lres = free_space_on_given_partition("/ var/cache/mondo")) == -1) /*{1075 ("WARNING! You have very little RAM. Please upgrade to 64MB or more."); 1076 } 1077 #endif 1078 1079 if ((Lres = free_space_on_given_partition("/root")) == -1) { 1033 1080 Lres = free_space_on_given_partition("/"); 1034 1081 } 1035 */1036 1082 log_it("Free space on given partition = %ld MB", Lres); 1037 1083 1038 1084 if (Lres < 50) { 1039 fatal_error("Your /var/cache/mondo partition has <50MB free. Please adjust your partition table to something saner."); 1085 run_program_and_log_output 1086 ("rm -Rf /root/images/mindi; mkdir -p /home/root/images/mindi; mkdir -p /root/images; ln -sf /home/root/images/mindi /root/images/mindi", 1087 3); 1088 // fatal_error("Your / (or /root) partition has <50MB free. Please adjust your partition table to something saner."); 1040 1089 } 1041 1090 … … 1051 1100 ("grep ramdisk /proc/devices", FALSE)) { 1052 1101 if (!ask_me_yes_or_no 1053 ( _("Your kernel has no ramdisk support. That's mind-numbingly stupid but I'll allow it if you're planning to use a failsafe kernel. Are you?")))1102 ("Your kernel has no ramdisk support. That's mind-numbingly stupid but I'll allow it if you're planning to use a failsafe kernel. Are you?")) 1054 1103 { 1055 1104 // retval++; 1056 1105 log_to_screen 1057 ( _("It looks as if your kernel lacks ramdisk and initrd support."));1106 ("It looks as if your kernel lacks ramdisk and initrd support."); 1058 1107 log_to_screen 1059 ( _("I'll allow you to proceed but FYI, if I'm right, your kernel is broken."));1108 ("I'll allow you to proceed but FYI, if I'm right, your kernel is broken."); 1060 1109 } 1061 1110 } … … 1079 1128 !run_program_and_log_output 1080 1129 ("mount | grep -w dos | grep -v /dev/fd | grep -v nexdisk", 0)) { 1081 log_to_screen( _("I think you have a Windows 9x partition."));1130 log_to_screen("I think you have a Windows 9x partition."); 1082 1131 retval += whine_if_not_found("parted"); 1083 1132 #ifndef __IA64__ … … 1085 1134 // retval += 1086 1135 if (!find_home_of_exe("ms-sys")) { 1087 log_to_screen( _("Please install ms-sys just in case."));1136 log_to_screen("Please install ms-sys just in case."); 1088 1137 } 1089 1138 #endif … … 1095 1144 } else { 1096 1145 log_to_screen 1097 ( _("Your system lacks the 'cmp' binary. I'll create a dummy cmp for you."));1146 ("Your system lacks the 'cmp' binary. I'll create a dummy cmp for you."); 1098 1147 if (run_program_and_log_output 1099 1148 ("cp -f `which true` /usr/bin/cmp", 0)) { … … 1110 1159 if (strstr(tmp, "autofs")) { 1111 1160 log_to_screen 1112 ( _("Your CD-ROM is mounted via autofs. I therefore cannot tell"));1161 ("Your CD-ROM is mounted via autofs. I therefore cannot tell"); 1113 1162 log_to_screen 1114 ( _("if a CD actually is inserted. If a CD is inserted, please"));1115 log_to_screen( _("eject it. Thank you."));1163 ("if a CD actually is inserted. If a CD is inserted, please"); 1164 log_to_screen("eject it. Thank you."); 1116 1165 log_it 1117 1166 ("Ignoring autofs CD-ROM 'mount' since we hope nothing's in it."); … … 1139 1188 retval++; 1140 1189 log_to_screen 1141 ( _("Please find out what happened to /etc/modules.conf"));1190 ("Please find out what happened to /etc/modules.conf"); 1142 1191 } 1143 1192 } … … 1152 1201 1153 1202 if (run_program_and_log_output("mindi -V", 1)) { 1154 log_to_screen( _("Could not ascertain mindi's version number."));1203 log_to_screen("Could not ascertain mindi's version number."); 1155 1204 log_to_screen 1156 ( _("You have not installed Mondo and/or Mindi properly."));1157 log_to_screen( _("Please uninstall and reinstall them both."));1205 ("You have not installed Mondo and/or Mindi properly."); 1206 log_to_screen("Please uninstall and reinstall them both."); 1158 1207 fatal_error("Please reinstall Mondo and Mindi."); 1159 1208 } … … 1161 1210 ("mindi --makemountlist /tmp/mountlist.txt.test", 5)) { 1162 1211 log_to_screen 1163 ( _("Mindi --makemountlist /tmp/mountlist.txt.test failed for some reason."));1212 ("Mindi --makemountlist /tmp/mountlist.txt.test failed for some reason."); 1164 1213 log_to_screen 1165 ( _("Please run that command by hand and examine /var/log/mindi.log"));1214 ("Please run that command by hand and examine /var/log/mindi.log"); 1166 1215 log_to_screen 1167 ( _("for more information. Perhaps your /etc/fstab file is insane."));1216 ("for more information. Perhaps your /etc/fstab file is insane."); 1168 1217 log_to_screen 1169 ( _("Perhaps Mindi's MakeMountlist() subroutine has a bug. We'll see."));1218 ("Perhaps Mindi's MakeMountlist() subroutine has a bug. We'll see."); 1170 1219 retval++; 1171 1220 } … … 1174 1223 && !does_file_exist("/etc/raidtab")) { 1175 1224 log_to_screen 1176 ( _("You have RAID partitions but no /etc/raidtab - creating one from /proc/mdstat"));1225 ("You have RAID partitions but no /etc/raidtab - creating one from /proc/mdstat"); 1177 1226 create_raidtab_from_mdstat("/etc/raidtab", "/proc/mdstat"); 1178 1227 } 1179 1228 1180 1229 if (retval) { 1181 mvaddstr_and_log_it(g_currentY++, 74, _("Failed."));1230 mvaddstr_and_log_it(g_currentY++, 74, "Failed."); 1182 1231 } else { 1183 mvaddstr_and_log_it(g_currentY++, 74, _("Done."));1232 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 1184 1233 } 1185 1234 return (retval); … … 1443 1492 } 1444 1493 1494 1495 /** 1496 * The standard log_debug_msg() (log_msg() also due to a macro). Writes some describing 1497 * information to the logfile. 1498 */ 1499 void standard_log_debug_msg(int debug_level, const char *szFile, 1500 const char *szFunction, int nLine, 1501 const char *fmt, ...) 1502 { 1503 va_list args; 1504 int i; 1505 static int depth = 0; 1506 char *tmp; 1507 FILE *fout; 1508 1509 if (depth > 5) { 1510 depth--; 1511 return; 1512 } 1513 depth++; 1514 1515 malloc_string(tmp); 1516 1517 if (debug_level <= g_loglevel) { 1518 va_start(args, fmt); 1519 if (!(fout = fopen(MONDO_LOGFILE, "a"))) { 1520 return; 1521 } // fatal_error("Failed to openout to logfile - sheesh..."); } 1522 1523 // add tabs to distinguish log levels 1524 if (debug_level > 0) { 1525 for (i = 1; i < debug_level; i++) 1526 fprintf(fout, "\t"); 1527 if (getpid() == g_main_pid) 1528 fprintf(fout, "[Main] %s->%s#%d: ", szFile, szFunction, 1529 nLine); 1530 else if (getpid() == g_buffer_pid && g_buffer_pid > 0) 1531 fprintf(fout, "[Buff] %s->%s#%d: ", szFile, szFunction, 1532 nLine); 1533 else 1534 fprintf(fout, "[TH=%d] %s->%s#%d: ", getpid(), szFile, 1535 szFunction, nLine); 1536 } 1537 vfprintf(fout, fmt, args); 1538 1539 // do not slow down the progran if standard debug level 1540 // must be enabled: if no flush, the log won't be up-to-date if there 1541 // is a segfault 1542 //if (g_dwDebugLevel != 1) 1543 1544 va_end(args); 1545 fprintf(fout, "\n"); 1546 paranoid_fclose(fout); 1547 } 1548 depth--; 1549 paranoid_free(tmp); 1550 } 1551 1552 /** 1553 * Function pointer to the @c log_debug_msg function to use. Points to standard_log_debug_msg() by default. 1554 */ 1555 void (*log_debug_msg) (int, const char *, const char *, int, const char *, 1556 ...) = standard_log_debug_msg; 1557 1558 1445 1559 /** 1446 1560 * If @p y, malloc @p x, else free @p x. … … 1472 1586 paranoid_free(g_magicdev_command); 1473 1587 } 1588 1589 /* 1590 char**list_of_arrays[] = { 1591 &g_boot_mountpt, 1592 &g_mondo_home, 1593 &g_tmpfs_mountpt, 1594 &g_erase_tmpdir_and_scratchdir, 1595 &g_serial_string, 1596 &g_magicdev_command, 1597 NULL}; 1598 1599 char**ppcurr; 1600 int i; 1601 1602 for(i=0;list_of_arrays[i];i++) 1603 { 1604 log_msg(5, "Allocating %d", i); 1605 ppcurr = list_of_arrays[i]; 1606 if (mal) 1607 { *ppcurr = malloc(MAX_STR_LEN); } 1608 else 1609 { 1610 if (*ppcurr) 1611 { 1612 free(*ppcurr); 1613 } 1614 } 1615 } 1616 log_msg(5, "Returning"); 1617 */ 1474 1618 } 1475 1619
Note:
See TracChangeset
for help on using the changeset viewer.