Changeset 3464 in MondoRescue


Ignore:
Timestamp:
Sep 10, 2015, 11:52:41 AM (9 years ago)
Author:
Bruno Cornec
Message:
  • suppress function archive_this_fileset_with_star and handle the star case in the std archive_this_fileset function to benefit from std features. Should help solving the issue reported on scratchdir not emptied in star case. Removes also duplicated code.
Location:
branches/3.2/mondo/src/common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mondo/src/common/libmondo-archive-EXT.h

    r1885 r3464  
    22
    33
    4 extern int archive_this_fileset(char *filelist,
    5                                 char *fname, int setno);
     4extern int archive_this_fileset(char *filelist, char *fname, int setno);
    65extern int backup_data();
    76extern int call_mindi_to_supply_boot_disks();
     
    3534extern int call_growisofs(char *destfile);
    3635extern int make_afioballs_and_images_SINGLETHREAD();
    37 extern int archive_this_fileset_with_star(
    38                                           char *filelist, char *fname,
    39                                           int setno);
    4036extern void setenv_mondo_share(void);
  • branches/3.2/mondo/src/common/libmondo-archive.c

    r3460 r3464  
    187187extern int g_tape_buffer_size_MB;
    188188
    189 
    190 
    191 
    192 int
    193 archive_this_fileset_with_star(char *filelist, char *fname, int setno)
    194 {
    195     int retval = 0;
    196     unsigned int res = 0;
    197     int tries = 0;
    198     char *command = NULL;
    199     char *tmp = NULL;
    200     char *p;
    201 
    202 
    203     if (!does_file_exist(filelist)) {
    204         log_to_screen("(archive_this_fileset) - filelist %s does not exist", filelist);
    205         return (1);
    206     }
    207 
    208     mr_asprintf(tmp, "echo hi > %s 2> /dev/null", fname);
    209     if (system(tmp)) {
    210         mr_free(tmp);
    211         fatal_error("Unable to write tarball to scratchdir");
    212     }
    213     paranoid_free(tmp);
    214 
    215     mr_asprintf(command, "star H=exustar list=%s -c -sparse " STAR_ACL_SZ " file=%s", filelist, fname);
    216     if (bkpinfo->use_lzo) {
    217         mr_free(command);
    218         fatal_error("Can't use lzop");
    219     }
    220     if (bkpinfo->compression_level > 0) {
    221         mr_strcat(command, " -bz");
    222     }
    223     mr_strcat(command, " 2>> %s", MONDO_LOGFILE);
    224     log_msg(4, "command = '%s'", command);
    225 
    226     for (res = 99, tries = 0; tries < 3 && res != 0; tries++) {
    227         log_msg(5, "command='%s'", command);
    228         res = system(command);
    229         mr_asprintf(tmp, "%s", last_line_of_file(MONDO_LOGFILE));
    230         log_msg(1, "res=%d; tmp='%s'", res, tmp);
    231         if (bkpinfo->use_star && (res == 254 || res == 65024)
    232             && strstr(tmp, "star: Processed all possible files")
    233             && tries > 0) {
    234             log_msg(1, "Star returned nonfatal error");
    235             res = 0;
    236         }
    237         mr_free(tmp);
    238 
    239         if (res) {
    240             log_OS_error(command);
    241             p = strstr(command, "-acl ");
    242             if (p) {
    243                 p[0] = p[1] = p[2] = p[3] = ' ';
    244                 log_msg(1, "new command = '%s'", command);
    245             } else {
    246                 log_msg(3,
    247                         "Attempt #%d failed. Pausing 3 seconds and retrying...",
    248                         tries + 1);
    249                 sleep(3);
    250             }
    251         }
    252     }
    253     mr_free(command);
    254 
    255     retval += res;
    256     if (retval) {
    257         log_msg(3, "Failed to write set %d", setno);
    258     } else if (tries > 1) {
    259         log_msg(3, "Succeeded in writing set %d, on try #%d", setno,
    260                 tries);
    261     }
    262     return (retval);
    263 }
    264 
    265 
    266189/**
    267190 * Call @c afio to archive the filelist @c filelist to the file @c fname.
     
    286209    /*@ int *************************************************************** */
    287210    int retval = 0;
    288     int res = 0;
     211    unsigned int res = 0;
    289212    int tries = 0;
    290213    /*
     
    297220    char *zipparams = NULL;
    298221    char *tmp = NULL;
     222    char *p = NULL;
    299223
    300224    assert(bkpinfo != NULL);
     
    302226    assert_string_is_neither_NULL_nor_zerolength(fname);
    303227
    304     if (bkpinfo->compression_level > 0 && bkpinfo->use_star) {
    305         return (archive_this_fileset_with_star(filelist, fname, setno));
     228    if (!does_file_exist(bkpinfo->tmpdir)) {
     229        log_OS_error("tmpdir not found");
     230        fatal_error("tmpdir not found");
     231    }
     232    if (!does_file_exist(bkpinfo->scratchdir)) {
     233        log_OS_error("scratchdir not found");
     234        fatal_error("scratchdir not found");
    306235    }
    307236
     
    319248
    320249    if (bkpinfo->compression_level > 0) {
    321         mr_asprintf(tmp, "%s/do-not-compress-these", g_mondo_home);
    322         //       -b %ld, TAPE_BLOCK_SIZE
    323         mr_asprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe, bkpinfo->compression_level);
    324         if (does_file_exist(tmp)) {
    325             mr_strcat(zipparams, " -E %s",tmp);
     250        if (bkpinfo->use_star) {
     251            if (bkpinfo->use_lzo) {
     252                fatal_error("Can't use lzop with star");
     253            }
     254            mr_asprintf(zipparams, " -bz");
    326255        } else {
    327             log_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp);
    328         }
    329         mr_free(tmp);
     256            mr_asprintf(tmp, "%s/do-not-compress-these", g_mondo_home);
     257            //       -b %ld, TAPE_BLOCK_SIZE
     258            mr_asprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe, bkpinfo->compression_level);
     259            if (does_file_exist(tmp)) {
     260                mr_strcat(zipparams, " -E %s",tmp);
     261            } else {
     262                log_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp);
     263            }
     264            mr_free(tmp);
     265        }
    330266    } else {
    331267        mr_asprintf(zipparams, "");
    332268    }
    333269
    334     if (!does_file_exist(bkpinfo->tmpdir)) {
    335         log_OS_error("tmpdir not found");
    336         fatal_error("tmpdir not found");
    337     }
    338     if (!does_file_exist(bkpinfo->scratchdir)) {
    339         log_OS_error("scratchdir not found");
    340         fatal_error("scratchdir not found");
    341     }
    342270    mr_asprintf(command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname, fname, bkpinfo->zip_suffix);
    343271    paranoid_system(command);
    344272    mr_free(command);
    345273
    346     mr_asprintf(command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
     274    if (bkpinfo->use_star) {
     275        mr_asprintf(command, "star H=exustar list=%s -c -sparse " STAR_ACL_SZ " file=%s %s 2>> %s", filelist, fname, zipparams, MONDO_LOGFILE);
     276    } else {
     277        mr_asprintf(command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
     278    }
    347279    mr_free(zipparams);
    348 
    349     mr_asprintf(tmp, "echo hi > %s 2> /dev/null", fname);
    350     if (system(tmp)) {
    351         mr_free(tmp);
    352         fatal_error("Unable to write tarball to scratchdir");
    353     }
    354     mr_free(tmp);
     280    log_msg(4, "command = '%s'", command);
    355281
    356282    for (res = 99, tries = 0; tries < 3 && res != 0; tries++) {
    357283        log_msg(5, "command='%s'", command);
    358284        res = system(command);
     285
     286        if (bkpinfo->use_star) {
     287            mr_asprintf(tmp, "%s", last_line_of_file(MONDO_LOGFILE));
     288            log_msg(1, "res=%d; tmp='%s'", res, tmp);
     289            if ((res == 254 || res == 65024) && strstr(tmp, "star: Processed all possible files") && tries > 0) {
     290                log_msg(1, "Star returned nonfatal error");
     291                res = 0;
     292            }
     293            mr_free(tmp);
     294        }
    359295        if (res) {
    360296            log_OS_error(command);
    361             log_msg(3,
    362                     "Attempt #%d failed. Pausing 3 seconds and retrying...",
    363                     tries + 1);
     297            if (bkpinfo->use_star) {
     298                p = strstr(command, "-acl ");
     299                if (p) {
     300                    p[0] = p[1] = p[2] = p[3] = ' ';
     301                    log_msg(1, "new command = '%s'", command);
     302                }
     303            }
     304            log_msg(3, "Attempt #%d failed. Pausing 3 seconds and retrying...", tries + 1);
    364305            sleep(3);
    365306        }
    366307    }
    367     paranoid_free(command);
     308    mr_free(command);
    368309
    369310    retval += res;
     
    371312        log_msg(3, "Failed to write set %d", setno);
    372313    } else if (tries > 1) {
    373         log_msg(3, "Succeeded in writing set %d, on try #%d", setno,
    374                 tries);
     314        log_msg(3, "Succeeded in writing set %d, on try #%d", setno, tries);
    375315    }
    376316
     
    21382078
    21392079        log_msg(1, "Archiving set %ld", curr_set_no);
    2140         res =
    2141             archive_this_fileset(curr_filelist_fname,
    2142                                  curr_afioball_fname, curr_set_no);
     2080        res = archive_this_fileset(curr_filelist_fname, curr_afioball_fname, curr_set_no);
    21432081        retval += res;
    21442082        if (res) {
  • branches/3.2/mondo/src/common/libmondo-archive.h

    r1885 r3464  
    3636int call_growisofs(char *destfile);
    3737int make_afioballs_and_images_SINGLETHREAD();
    38 int archive_this_fileset_with_star(
    39                                    char *filelist, char *fname, int setno);
    4038void setenv_mondo_share(void);
Note: See TracChangeset for help on using the changeset viewer.