Changeset 538 in MondoRescue for branches/stable/mondo/mondo/common/libmondo-tools.c
- Timestamp:
- May 13, 2006, 6:39:55 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/mondo/common/libmondo-tools.c
r501 r538 472 472 #endif 473 473 } 474 475 476 /**477 * Log a trace message to the trace file.478 * @bug This function seems orphaned. Please remove.479 */480 void log_trace(char *o)481 {482 /*@ pointers **************************************************** */483 FILE *fout;484 485 /*@ buffers ***************************************************** */486 char output[MAX_STR_LEN];487 488 /*@ int ****************************************************** */489 int i;490 491 /*@ end vars *************************************************** */492 493 if (o[0] == '\0') {494 return;495 }496 strcpy(output, o);497 i = (int) strlen(output);498 if (i <= 0) {499 return;500 }501 if (output[i - 1] < 32) {502 output[i - 1] = '\0';503 }504 if (g_text_mode505 /* && !strstr(last_line_of_file(MONDO_LOGFILE),output) */ ) {506 printf("%s\n", output);507 }508 509 fout = fopen(MONDO_TRACEFILE, "a");510 if (fout) {511 fprintf(fout, "%s\n", output);512 paranoid_fclose(fout);513 } else {514 log_OS_error("Cannot write to tracefile");515 }516 }517 518 519 520 474 521 475 … … 969 923 strcpy(bkpinfo->isodir, "/"); 970 924 } else { 971 strcpy(bkpinfo->isodir, "/ root/images/mondo");925 strcpy(bkpinfo->isodir, "/var/cache/mondo/iso"); 972 926 } 973 927 strcpy(bkpinfo->prefix, STD_PREFIX); … … 1076 1030 #endif 1077 1031 1078 if ((Lres = free_space_on_given_partition("/ root")) == -1){1032 if ((Lres = free_space_on_given_partition("/var/cache/mondo")) == -1) /* { 1079 1033 Lres = free_space_on_given_partition("/"); 1080 1034 } 1035 */ 1081 1036 log_it("Free space on given partition = %ld MB", Lres); 1082 1037 1083 1038 if (Lres < 50) { 1084 run_program_and_log_output 1085 ("rm -Rf /root/images/mindi; mkdir -p /home/root/images/mindi; mkdir -p /root/images; ln -sf /home/root/images/mindi /root/images/mindi", 1086 3); 1087 // fatal_error("Your / (or /root) partition has <50MB free. Please adjust your partition table to something saner."); 1039 fatal_error("Your /var/cache/mondo partition has <50MB free. Please adjust your partition table to something saner."); 1088 1040 } 1089 1041 … … 1491 1443 } 1492 1444 1493 1494 /**1495 * The standard log_debug_msg() (log_msg() also due to a macro). Writes some describing1496 * information to the logfile.1497 */1498 void standard_log_debug_msg(int debug_level, const char *szFile,1499 const char *szFunction, int nLine,1500 const char *fmt, ...)1501 {1502 va_list args;1503 int i;1504 static int depth = 0;1505 char *tmp;1506 FILE *fout;1507 1508 if (depth > 5) {1509 depth--;1510 return;1511 }1512 depth++;1513 1514 malloc_string(tmp);1515 1516 if (debug_level <= g_loglevel) {1517 va_start(args, fmt);1518 if (!(fout = fopen(MONDO_LOGFILE, "a"))) {1519 return;1520 } // fatal_error("Failed to openout to logfile - sheesh..."); }1521 1522 // add tabs to distinguish log levels1523 if (debug_level > 0) {1524 for (i = 1; i < debug_level; i++)1525 fprintf(fout, "\t");1526 if (getpid() == g_main_pid)1527 fprintf(fout, "[Main] %s->%s#%d: ", szFile, szFunction,1528 nLine);1529 else if (getpid() == g_buffer_pid && g_buffer_pid > 0)1530 fprintf(fout, "[Buff] %s->%s#%d: ", szFile, szFunction,1531 nLine);1532 else1533 fprintf(fout, "[TH=%d] %s->%s#%d: ", getpid(), szFile,1534 szFunction, nLine);1535 }1536 vfprintf(fout, fmt, args);1537 1538 // do not slow down the progran if standard debug level1539 // must be enabled: if no flush, the log won't be up-to-date if there1540 // is a segfault1541 //if (g_dwDebugLevel != 1)1542 1543 va_end(args);1544 fprintf(fout, "\n");1545 paranoid_fclose(fout);1546 }1547 depth--;1548 paranoid_free(tmp);1549 }1550 1551 /**1552 * Function pointer to the @c log_debug_msg function to use. Points to standard_log_debug_msg() by default.1553 */1554 void (*log_debug_msg) (int, const char *, const char *, int, const char *,1555 ...) = standard_log_debug_msg;1556 1557 1558 1445 /** 1559 1446 * If @p y, malloc @p x, else free @p x. … … 1585 1472 paranoid_free(g_magicdev_command); 1586 1473 } 1587 1588 /*1589 char**list_of_arrays[] = {1590 &g_boot_mountpt,1591 &g_mondo_home,1592 &g_tmpfs_mountpt,1593 &g_erase_tmpdir_and_scratchdir,1594 &g_serial_string,1595 &g_magicdev_command,1596 NULL};1597 1598 char**ppcurr;1599 int i;1600 1601 for(i=0;list_of_arrays[i];i++)1602 {1603 log_msg(5, "Allocating %d", i);1604 ppcurr = list_of_arrays[i];1605 if (mal)1606 { *ppcurr = malloc(MAX_STR_LEN); }1607 else1608 {1609 if (*ppcurr)1610 {1611 free(*ppcurr);1612 }1613 }1614 }1615 log_msg(5, "Returning");1616 */1617 1474 } 1618 1475
Note:
See TracChangeset
for help on using the changeset viewer.