Changeset 3856 in MondoRescue


Ignore:
Timestamp:
Mar 6, 2024, 5:29:44 PM (3 months ago)
Author:
Bruno Cornec
Message:

remove snprintf usage and use bkpinfo for serial_string

Location:
branches/3.3/mondo/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mondo/src/common/libmondo-archive.c

    r3849 r3856  
    6767extern bool g_cd_recovery;
    6868extern char *g_mondo_home;
    69 
    70 /**
    71  * The serial string (used to differentiate between backups) of the current backup.
    72  */
    73 char *g_serial_string = NULL;
    7469
    7570extern char *g_getfacl;
     
    11241119 * - @c scratchdir
    11251120 * - @c tmpdir
     1121 * - @c serial_string
    11261122 * @return The number of errors encountered (0 for success).
    11271123 * @ingroup MLarchiveGroup
     
    11401136    mr_asprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
    11411137
    1142         tmp = call_program_and_get_last_line_of_output("dd if=/dev/urandom bs=16 count=1 2> /dev/null | hexdump | tr -s ' ' '0' | head -n1");
    1143     snprintf(g_serial_string, MAX_STR_LEN - 8, "%s", tmp);
    1144         mr_free(tmp);
    1145     strip_spaces(g_serial_string);
    1146     strcat(g_serial_string, "...word.");
    1147     log_msg(2, "g_serial_string = '%s'", g_serial_string);
    1148     assert(strlen(g_serial_string) < MAX_STR_LEN);
     1138    tmp = call_program_and_get_last_line_of_output("dd if=/dev/urandom bs=16 count=1 2> /dev/null | hexdump | tr -s ' ' '0' | head -n1");
     1139    bkpinfo->serial_string = mr_strip_spaces(tmp);
     1140    mr_free(tmp);
     1141    mr_strcat(bkpinfo->serial_string, "...word.");
     1142    log_msg(2, "bkpinfo->serial_string = '%s'", bkpinfo->serial_string);
    11491143
    11501144    mr_asprintf(tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
    1151     if (write_one_liner_data_file(tmpfile, g_serial_string)) {
     1145    if (write_one_liner_data_file(tmpfile, bkpinfo->serial_string)) {
    11521146        log_msg(1, "%ld: Failed to write serial string", __LINE__);
    11531147    }
     
    25842578
    25852579        log_msg(2, "paafcd: cd_number = %d", cd_number);
    2586         log_msg(2, "our serial str = %s; g_serial_string = %s", our_serial_str, g_serial_string);
    2587         if (cd_number > 0 && !strcmp(our_serial_str, g_serial_string)) {
     2580        log_msg(2, "our serial str = %s; bkpinfo->serial_string = %s", our_serial_str, bkpinfo->serial_string);
     2581        if (cd_number > 0 && !strcmp(our_serial_str, bkpinfo->serial_string)) {
    25882582            mds = media_descriptor_string(g_backup_media_type);
    25892583            log_msg(2, "This %s is part of this backup set!", mds);
  • branches/3.3/mondo/src/common/libmondo-tools.c

    r3836 r3856  
    5656 */
    5757extern char *g_mondo_home;
    58 
    59 /**
    60  * The serial string (used to differentiate between backups) of the current backup.
    61  */
    62 extern char *g_serial_string;
    6358
    6459/**
     
    13591354        malloc_string(g_boot_mountpt);
    13601355        malloc_string(g_mondo_home);
    1361         malloc_string(g_serial_string);
    13621356        malloc_string(g_magicdev_command);
    13631357    } else {
     
    13651359        paranoid_free(g_mondo_home);
    13661360        paranoid_free(g_magicdev_command);
    1367 
    1368         mr_free(g_serial_string);
    13691361    }
    13701362}
  • branches/3.3/mondo/src/common/mondostructures.h

    r3838 r3856  
    654654    t_boot boot_type;
    655655
     656    /**
     657     * The serial string (used to differentiate between backups)
     658     * of the current backup.
     659    */
     660    char *serial_string;
    656661};
    657662
  • branches/3.3/mondo/src/common/newt-specific.c

    r3854 r3856  
    442442        mr_free(bkpinfo->prefix);
    443443        mr_free(bkpinfo->isodir);
     444        mr_free(bkpinfo->serial_string);
    444445        /* Then free the structure */
    445446        paranoid_free(bkpinfo);
  • branches/3.3/mondo/src/mondorestore/mondo-rstr-newt.c

    r3614 r3856  
    14361436    for (;;) {
    14371437        int i;
    1438         char headerstr[MAX_STR_LEN];
    1439         snprintf(headerstr, MAX_STR_LEN, "%-14s %-8s  %11s  %8s",
    1440                  "Plex", "Level", "Stripe Size", "Subdisks");
     1438        char *headerstr = NULL;
     1439        mr_asprintf(headerstr, "%-14s %-8s  %11s  %8s", "Plex", "Level", "Stripe Size", "Subdisks");
    14411440
    14421441        bOK = newtCompactButton(2, 13, "  OK  ");
     
    14491448            newtListbox(2, 3, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
    14501449        plexesHeader = newtLabel(2, 2, headerstr);
     1450        mr_free(headerstr);
    14511451        editraidForm = newtForm(NULL, NULL, 0);
    14521452
     
    14551455            keylist[i] = (void *) i;
    14561456            if (i < raidrec->plexes) {
    1457                 char pname[64], entry[MAX_STR_LEN];
     1457                char *pname;
     1458                char *entry;
    14581459                switch (raidrec->plex[i].raidlevel) {
    14591460                case -1:
     
    14761477                    mr_asprintf(chunksize, "%dk", raidrec->plex[i].stripesize);
    14771478                }
    1478                 snprintf(pname, 64, "%s.p%i", raidrec->volname, i);
    1479                 snprintf(entry, MAX_STR_LEN, "%-14s %-8s  %11s  %8d",
    1480                          pname, raidlevel, chunksize,
    1481                          raidrec->plex[i].subdisks);
     1479                mr_asprintf(pname, "%s.p%i", raidrec->volname, i);
     1480                mr_asprintf(entry, "%-14s %-8s  %11s  %8d", pname, raidlevel, chunksize, raidrec->plex[i].subdisks);
     1481                mr_free(pname);
    14821482                mr_free(raidlevel);
    14831483                mr_free(chunksize);
    14841484
    14851485                newtListboxAppendEntry(plexesListbox, entry, keylist[i]);
     1486                mr_free(entry);
    14861487            }
    14871488        }
Note: See TracChangeset for help on using the changeset viewer.