Changeset 3830 in MondoRescue


Ignore:
Timestamp:
Mar 4, 2024, 5:33:57 PM (4 months ago)
Author:
Bruno Cornec
Message:

manages zip_exe and zip_suffix dynamically

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

Legend:

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

    r3829 r3830  
    422422
    423423    if (bkpinfo->use_lzo) {
    424         strcpy(bkpinfo->zip_exe, "lzop");
    425         strcpy(bkpinfo->zip_suffix, "lzo");
     424        mr_asprintf(bkpinfo->zip_exe, "%s", "lzop");
     425        mr_asprintf(bkpinfo->zip_suffix, "%s", "lzo");
    426426    } else if (bkpinfo->use_gzip) {
    427         strcpy(bkpinfo->zip_exe, "gzip");
    428         strcpy(bkpinfo->zip_suffix, "gz");
     427        mr_asprintf(bkpinfo->zip_exe, "%s", "gzip");
     428        mr_asprintf(bkpinfo->zip_suffix, "%s", "gz");
    429429    } else if (bkpinfo->use_lzma) {
    430         strcpy(bkpinfo->zip_exe, "lzma");
    431         strcpy(bkpinfo->zip_suffix, "lzma");
     430        mr_asprintf(bkpinfo->zip_exe, "%s", "xz");
     431        mr_asprintf(bkpinfo->zip_suffix, "%s", "xz");
    432432    } else if (bkpinfo->compression_level != 0) {
    433         strcpy(bkpinfo->zip_exe, "bzip2");
    434         strcpy(bkpinfo->zip_suffix, "bz2");
     433        mr_asprintf(bkpinfo->zip_exe, "%s", "bzip2");
     434        mr_asprintf(bkpinfo->zip_suffix, "%s", "bz2");
    435435    } else {
    436         bkpinfo->zip_exe[0] = bkpinfo->zip_suffix[0] = '\0';
     436        mr_free(bkpinfo->zip_exe);
     437        mr_free(bkpinfo->zip_suffix);
    437438    }
    438439
     
    818819    bkpinfo->boot_loader = '\0';
    819820    bkpinfo->boot_device = NULL;
    820     bkpinfo->zip_exe[0] = '\0';
    821     bkpinfo->zip_suffix[0] = '\0';
     821    bkpinfo->zip_exe = NULL;
     822    bkpinfo->zip_suffix = NULL;
    822823    bkpinfo->image_devs = NULL;
    823824    bkpinfo->compression_level = 3;
  • branches/3.3/mondo/src/common/libmondo-verify.c

    r3828 r3830  
    281281        slice_num = last_slice_num + 1;
    282282    }
    283     while (does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix))
    284            ||
    285            does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, ""))) {
     283    while (does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix))) {
    286284        // handle slices until end of CD
    287285        if (slice_num == 0) {
     
    427425    if (strstr(tarball_fname, ".lzo") && strcmp(bkpinfo->zip_suffix, "lzo")) {
    428426        log_msg(2, "OK, I'm going to start using lzop.");
    429         strcpy(bkpinfo->zip_exe, "lzop");
    430         strcpy(bkpinfo->zip_suffix, "lzo");
     427        mr_free(bkpinfo->zip_exe);
     428        mr_free(bkpinfo->zip_suffix);
     429        mr_asprintf(bkpinfo->zip_exe, "%s", "lzop");
     430        mr_asprintf(bkpinfo->zip_suffix, "%s", "lzo");
    431431        bkpinfo->use_lzo = TRUE;
    432432        bkpinfo->use_gzip = FALSE;
     
    435435    if (strstr(tarball_fname, ".gz") && strcmp(bkpinfo->zip_suffix, "gz")) {
    436436        log_msg(2, "OK, I'm going to start using gzip.");
    437         strcpy(bkpinfo->zip_exe, "gzip");
    438         strcpy(bkpinfo->zip_suffix, "gz");
     437        mr_free(bkpinfo->zip_exe);
     438        mr_free(bkpinfo->zip_suffix);
     439        mr_asprintf(bkpinfo->zip_exe, "%s", "gzip");
     440        mr_asprintf(bkpinfo->zip_suffix, "%s", "gz");
    439441        bkpinfo->use_lzo = FALSE;
    440442        bkpinfo->use_gzip = TRUE;
     
    443445    if (strstr(tarball_fname, ".bz2") && strcmp(bkpinfo->zip_suffix, "bz2")) {
    444446        log_msg(2, "OK, I'm going to start using bzip2.");
    445         strcpy(bkpinfo->zip_exe, "bzip2");
    446         strcpy(bkpinfo->zip_suffix, "bz2");
     447        mr_free(bkpinfo->zip_exe);
     448        mr_free(bkpinfo->zip_suffix);
     449        mr_asprintf(bkpinfo->zip_exe, "%s", "bzip2");
     450        mr_asprintf(bkpinfo->zip_suffix, "%s", "bz2");
    447451        bkpinfo->use_lzo = FALSE;
    448452        bkpinfo->use_gzip = FALSE;
    449453        bkpinfo->use_lzma = FALSE;
    450454    }
    451     if (strstr(tarball_fname, ".lzma") && strcmp(bkpinfo->zip_suffix, "lzma")) {
     455    if (strstr(tarball_fname, ".xz") && strcmp(bkpinfo->zip_suffix, "xz")) {
    452456        log_msg(2, "OK, I'm going to start using lzma.");
    453         strcpy(bkpinfo->zip_exe, "lzma");
    454         strcpy(bkpinfo->zip_suffix, "lzma");
     457        mr_free(bkpinfo->zip_exe);
     458        mr_free(bkpinfo->zip_suffix);
     459        mr_asprintf(bkpinfo->zip_exe, "%s", "xz");
     460        mr_asprintf(bkpinfo->zip_suffix, "%s", "xz");
    455461        bkpinfo->use_lzo = FALSE;
    456462        bkpinfo->use_gzip = FALSE;
    457463        bkpinfo->use_lzma = TRUE;
    458464    }
    459     if (bkpinfo->zip_exe == NULL) {
    460         strcpy(bkpinfo->zip_exe, "none");
    461     }
     465    // As suffix is used even when no compression make it non-NULL
    462466    if (bkpinfo->zip_suffix == NULL) {
    463         strcpy(bkpinfo->zip_suffix, "");
     467        mr_asprintf(bkpinfo->zip_suffix, "%s", "");
    464468    }
    465469    unlink(outlog);
  • branches/3.3/mondo/src/common/mondostructures.h

    r3829 r3830  
    377377   * compression_level is 0.
    378378   */
    379     char zip_exe[MAX_STR_LEN / 4];
    380 
    381   /**
    382    * The extension your compression program uses. lzop uses lzo, bzip uses
     379    char *zip_exe;
     380
     381  /**
     382   * The extension your compression program uses. lzop uses lzo, bzip2 uses
    383383   * bz2, gzip uses gz, etc. Do not include the dot.
    384384   */
    385     char zip_suffix[MAX_STR_LEN / 4];
     385    char *zip_suffix;
    386386
    387387  /**
  • branches/3.3/mondo/src/common/newt-specific.c

    r3829 r3830  
    437437        mr_free(bkpinfo->restore_path);
    438438        mr_free(bkpinfo->kernel_path);
     439        mr_free(bkpinfo->zip_exe);
     440        mr_free(bkpinfo->zip_suffix);
    439441        /* Then free the structure */
    440442        paranoid_free(bkpinfo);
  • branches/3.3/mondo/src/mondorestore/mondo-rstr-tools.c

    r3822 r3830  
    805805    bkpinfo->use_lzo = FALSE;
    806806    bkpinfo->use_gzip = FALSE;
    807     strcpy(bkpinfo->zip_exe, "lzma");
    808     strcpy(bkpinfo->zip_suffix, "lzma");
     807    mr_asprintf(bkpinfo->zip_exe, "%s", "lzma");
     808    mr_asprintf(bkpinfo->zip_suffix, "%s", "lzma");
    809809}
    810810
     
    814814    bkpinfo->use_lzo = TRUE;
    815815    bkpinfo->use_gzip = FALSE;
    816     strcpy(bkpinfo->zip_exe, "lzop");
    817     strcpy(bkpinfo->zip_suffix, "lzo");
     816    mr_asprintf(bkpinfo->zip_exe, "%s", "lzop");
     817    mr_asprintf(bkpinfo->zip_suffix, "%s", "lzo");
    818818}
    819819
     
    823823    bkpinfo->use_lzo = FALSE;
    824824    bkpinfo->use_gzip = TRUE;
    825     strcpy(bkpinfo->zip_exe, "gzip");
    826     strcpy(bkpinfo->zip_suffix, "gz");
     825    mr_asprintf(bkpinfo->zip_exe, "%s", "gzip");
     826    mr_asprintf(bkpinfo->zip_suffix, "%s", "gz");
    827827}
    828828
     
    832832    bkpinfo->use_lzo = FALSE;
    833833    bkpinfo->use_gzip = FALSE;
    834     strcpy(bkpinfo->zip_exe, "bzip2");
    835     strcpy(bkpinfo->zip_suffix, "bz2");
     834    mr_asprintf(bkpinfo->zip_exe, "%s", "xz");
     835    mr_asprintf(bkpinfo->zip_suffix, "%s", "xz");
    836836}
    837837
  • branches/3.3/mondo/src/mondorestore/mondorestore.c

    r3828 r3830  
    11541154    }
    11551155
    1156     if (!bkpinfo->zip_exe[0]) {
     1156    if (bkpinfo->zip_exe == NULL) {
    11571157        mr_asprintf(command, "cat > \"%s\"", file_to_openout);
    11581158    } else {
     
    12151215    paranoid_pclose(pout);
    12161216
    1217     if (bkpinfo->zip_exe[0]) {
     1217    if (bkpinfo->zip_exe != NULL) {
    12181218        if (strcmp(bkpinfo->zip_exe, "gzip") == 0) {
    12191219            /* Re-enable SIGPIPE for gzip */
Note: See TracChangeset for help on using the changeset viewer.