Ignore:
Timestamp:
May 13, 2006, 6:39:55 PM (18 years ago)
Author:
bcornec
Message:

Begining of modifications => DOS NOT WORK FOR NOW.
This is done to be merged in trunk. stable will later point back to current 2.0.8 content

Use of mindi conf file in mindi + /var/cache/mindi as a default place
Use of mondo conf file in mondo + separation of messages.
Ultimate goal is to have a cleaner design of files vs functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/mondo/common/libmondo-tools.c

    r501 r538  
    472472#endif
    473473}
    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_mode
    505         /* && !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 
    520474
    521475
     
    969923        strcpy(bkpinfo->isodir, "/");
    970924    } else {
    971         strcpy(bkpinfo->isodir, "/root/images/mondo");
     925        strcpy(bkpinfo->isodir, "/var/cache/mondo/iso");
    972926    }
    973927    strcpy(bkpinfo->prefix, STD_PREFIX);
     
    10761030#endif
    10771031
    1078     if ((Lres = free_space_on_given_partition("/root")) == -1) {
     1032    if ((Lres = free_space_on_given_partition("/var/cache/mondo")) == -1) /* {
    10791033        Lres = free_space_on_given_partition("/");
    10801034    }
     1035    */
    10811036    log_it("Free space on given partition = %ld MB", Lres);
    10821037
    10831038    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.");
    10881040    }
    10891041
     
    14911443}
    14921444
    1493 
    1494 /**
    1495  * The standard log_debug_msg() (log_msg() also due to a macro). Writes some describing
    1496  * 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 levels
    1523         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             else
    1533                 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 level
    1539         // must be enabled: if no flush, the log won't be up-to-date if there
    1540         // is a segfault
    1541         //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 
    15581445/**
    15591446 * If @p y, malloc @p x, else free @p x.
     
    15851472        paranoid_free(g_magicdev_command);
    15861473    }
    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        else
    1608        {
    1609        if (*ppcurr)
    1610        {
    1611        free(*ppcurr);
    1612        }
    1613        }
    1614        }
    1615        log_msg(5, "Returning");
    1616      */
    16171474}
    16181475
Note: See TracChangeset for help on using the changeset viewer.