Ignore:
Timestamp:
Feb 12, 2007, 3:02:08 AM (17 years ago)
Author:
Bruno Cornec
Message:

Better mindi screen mesages
Still working on libmondo-archive.c (I know it's late :-)

File:
1 edited

Legend:

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

    r1139 r1142  
    20392039
    20402040    /*@ pointers ******************************************* */
    2041     FILE *fin;
    2042     char *p;
     2041    FILE *fin = NULL;
     2042    char *p = NULL;
    20432043
    20442044    /*@ buffers ******************************************** */
    2045     char *tmp;
     2045    char *tmp = NULL;
    20462046    char *bigfile_fname = NULL;
    2047     char *sz_devfile;
     2047    char *sz_devfile = NULL;
    20482048    char *ntfsprog_fifo = NULL;
    20492049    /*@ long *********************************************** */
     
    20652065    assert_string_is_neither_NULL_nor_zerolength(biggielist_fname);
    20662066
    2067     malloc_string(tmp);
    2068     malloc_string(bigfile_fname);
    2069     malloc_string(sz_devfile);
    20702067    estimated_total_noof_slices =
    20712068        size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
     
    20812078        return (0);
    20822079    }
    2083     sprintf(tmp, "I am now backing up all large files.");
     2080    mr_asprintf(&tmp, "I am now backing up all large files.");
    20842081    log_to_screen(tmp);
    20852082    noof_biggie_files = count_lines_in_file(biggielist_fname);
     
    20872084                       "Please wait. This may take some time.", "",
    20882085                       estimated_total_noof_slices);
     2086    mr_free(tmp);
     2087
    20892088    if (!(fin = fopen(biggielist_fname, "r"))) {
    20902089        log_OS_error("Unable to openin biggielist");
    20912090        return (1);
    20922091    }
    2093     for (fgets(bigfile_fname, MAX_STR_LEN, fin); !feof(fin);
    2094          fgets(bigfile_fname, MAX_STR_LEN, fin), biggie_file_number++) {
     2092    for (mr_getline(&bigfile_fname, &n, fin); !feof(fin);
     2093         mr_getline(&bigfile_fname, &n, fin), biggie_file_number++) {
    20952094        use_ntfsprog = FALSE;
    20962095        if (bigfile_fname[strlen(bigfile_fname) - 1] < 32) {
     
    21032102            ftmp = fopen(bigfile_fname, "w");
    21042103            paranoid_fclose(ftmp);
    2105             sprintf(tmp, "bigfile %s was deleted - creating a dummy",
    2106                     bigfile_fname);
    21072104            delete_when_done = TRUE;
    21082105        } else {
     
    21172114                        "Calling ntfsclone in background because %s is an NTFS partition",
    21182115                        bigfile_fname);
    2119                 sprintf(sz_devfile, "%s/%d.%d.000",
     2116                mr_asprintf(&sz_devfile, "%s/%d.%d.000",
    21202117                        bkpinfo->tmpdir,
    21212118                        (int) (random() % 32768),
     
    21312128                            bigfile_fname, sz_devfile);
    21322129                    res = feed_into_ntfsprog(bigfile_fname, sz_devfile);
     2130                    mr_free(sz_devfile);
    21332131                    exit(res);
    21342132                    break;
     
    21372135                            "feed_into_ntfsprog() called in background --- pid=%ld",
    21382136                            (long int) (pid));
     2137                    mr_free(sz_devfile);
     2138                    break;
    21392139                }
    21402140            }
    2141 // Otherwise, use good old 'dd' and 'bzip2'
     2141            // Otherwise, use good old 'dd' and 'bzip2'
    21422142            else {
    2143                 sz_devfile[0] = '\0';
    21442143                ntfsprog_fifo = NULL;
    21452144            }
    21462145
    2147 // Whether partition or biggiefile, just do your thang :-)
    2148             sprintf(tmp, "Bigfile #%ld is '%s' (%ld KB)",
     2146            // Whether partition or biggiefile, just do your thang :-)
     2147            mr_msg(5, "Bigfile #%ld is '%s' (%ld KB)",
    21492148                    biggie_file_number + 1, bigfile_fname,
    21502149                    (long) biggie_fsize >> 10);
     
    21722171                p = bigfile_fname;
    21732172            }
    2174             sprintf(tmp, "Archiving %s ... ", bigfile_fname);
    21752173            if (res) {
    2176                 strcat(tmp, "Failed!");
     2174                mr_asprintf(&tmp, "Archiving %s ... Failed!", bigfile_fname);
    21772175            } else {
    2178                 strcat(tmp, "OK");
    2179             }
     2176                mr_asprintf(&tmp, "Archiving %s ... OK!", bigfile_fname);
     2177            }
     2178            mr_msg(4,tmp);
     2179            mr_free(tmp);
    21802180            if (delete_when_done) {
    21812181                unlink(bigfile_fname);
     
    21832183            }
    21842184        }
    2185 #ifndef _XWIN
    21862185        if (!g_text_mode) {
    21872186            newtDrawRootText(0, g_noof_rows - 2, tmp);
    21882187            newtRefresh();
    21892188        }
    2190 #endif
    2191     }
     2189    }
     2190    mr_free(bigfile_fname);
     2191    paranoid_fclose(fin);
     2192
    21922193    mr_msg(1, "Finished backing up bigfiles");
    21932194    mr_msg(1, "estimated slices = %ld; actual slices = %ld",
    21942195            estimated_total_noof_slices, g_current_progress);
    21952196    close_progress_form();
    2196     paranoid_fclose(fin);
    2197     mr_free(tmp);
    2198     mr_free(bigfile_fname);
    2199     mr_free(sz_devfile);
    22002197    return (retval);
    22012198}
    2202 
    2203 
    22042199
    22052200
     
    22172212
    22182213    /*@ buffers ********************************************** */
    2219     char *curr_filelist_fname;
    2220     char *curr_afioball_fname;
    2221     char *curr_xattr_list_fname;
    2222     char *curr_acl_list_fname;
    2223     char *tmp;
    2224     char *media_usage_comment;
    2225 
    2226     malloc_string(curr_afioball_fname);
     2214    char *curr_filelist_fname = NULL;
     2215    char *curr_afioball_fname = NULL;
     2216    char *curr_xattr_list_fname = NULL;
     2217    char *curr_acl_list_fname = NULL;
     2218    char *media_usage_comment = NULL;
     2219    char *tmp= mr_malloc(MAX_STR_LEN * 2);
     2220
     2221    /* BERLIOS: Useless ?
     2222       mr_asprintf(&tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);
     2223     */
    22272224    malloc_string(media_usage_comment);
    2228     malloc_string(curr_filelist_fname);
    2229     malloc_string(curr_xattr_list_fname);
    2230     malloc_string(curr_acl_list_fname);
    2231 
    2232     tmp = mr_malloc(MAX_STR_LEN * 2);
    2233 
    2234     sprintf(tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);
    2235 
    22362225    log_to_screen("Archiving regular files");
    22372226
    2238     open_progress_form("Backing up filesystem",
    2239                        "I am backing up your live filesystem now.",
    2240                        "Please wait. This may take a couple of hours.",
    2241                        "Working...",
     2227    open_progress_form(_("Backing up filesystem"),
     2228                       _("I am backing up your live filesystem now."),
     2229                       _("Please wait. This may take a couple of hours."),
     2230                       _("Working..."),
    22422231                       get_last_filelist_number(bkpinfo) + 1);
    22432232
    2244     sprintf(curr_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir,
    2245             0L);
    2246 
    2247     for (curr_set_no = 0; does_file_exist(curr_filelist_fname);
    2248          sprintf(curr_filelist_fname, FILELIST_FNAME_RAW_SZ,
    2249                  bkpinfo->tmpdir, ++curr_set_no)) {
     2233    mr_asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir,
     2234             0L);
     2235
     2236    curr_set_no = 0;
     2237    while (does_file_exist(curr_filelist_fname)) {
    22502238        /* backup this set of files */
    2251         sprintf(curr_filelist_fname, FILELIST_FNAME_RAW_SZ,
    2252                 bkpinfo->tmpdir, curr_set_no);
    2253         sprintf(curr_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
    2254                 bkpinfo->tmpdir, curr_set_no, bkpinfo->zip_suffix);
     2239        mr_asprintf(&curr_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
     2240                 bkpinfo->tmpdir, curr_set_no, bkpinfo->zip_suffix);
    22552241
    22562242        mr_msg(1, "EXAT'g set %ld", curr_set_no);
    22572243        if (g_getfattr) {
    2258             sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
     2244            mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
    22592245                bkpinfo->tmpdir, curr_set_no);
    22602246            get_fattr_list(curr_filelist_fname, curr_xattr_list_fname);
    22612247        }
    22622248        if (g_getfacl) {
    2263             sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
     2249            mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
    22642250                bkpinfo->tmpdir, curr_set_no);
    22652251            get_acl_list(curr_filelist_fname, curr_acl_list_fname);
     
    22672253
    22682254        mr_msg(1, "Archiving set %ld", curr_set_no);
    2269         res =
    2270             archive_this_fileset(bkpinfo, curr_filelist_fname,
     2255        res = archive_this_fileset(bkpinfo, curr_filelist_fname,
    22712256                                 curr_afioball_fname, curr_set_no);
    22722257        retval += res;
    22732258        if (res) {
    2274             sprintf(tmp,
    2275                     "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?",
    2276                     curr_set_no);
     2259            mr_asprintf(&tmp,
     2260                     "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?",
     2261                     curr_set_no);
    22772262            log_to_screen(tmp);
     2263            mr_free(tmp);
    22782264        }
    22792265
     
    22872273                                                   curr_afioball_fname);
    22882274            iamhere("Writing EXAT files");
    2289             res +=
    2290                 write_EXAT_files_to_tape(bkpinfo, curr_xattr_list_fname,
    2291                                          curr_acl_list_fname);
    2292 // archives themselves
     2275            res += write_EXAT_files_to_tape(bkpinfo, curr_xattr_list_fname,
     2276                                            curr_acl_list_fname);
     2277            // archives themselves
    22932278            res = move_files_to_stream(bkpinfo, curr_afioball_fname, NULL);
    22942279        } else {
     
    23202305
    23212306        if (res) {
    2322             sprintf(tmp, "Failed to add archive %ld's files to CD dir\n",
    2323                     curr_set_no);
     2307            mr_asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n",
     2308                     curr_set_no);
    23242309            log_to_screen(tmp);
     2310            mr_free(tmp);
    23252311            fatal_error
    23262312                ("Is your hard disk is full? If not, please send the author the logfile.");
    23272313        }
    2328     }
     2314        mr_free(curr_filelist_fname);
     2315        mr_free(curr_afioball_fname);
     2316        mr_free(curr_xattr_list_fname);
     2317        mr_free(curr_acl_list_fname);
     2318        mr_asprintf(&curr_filelist_fname, FILELIST_FNAME_RAW_SZ,
     2319                 bkpinfo->tmpdir, ++curr_set_no);
     2320    }
     2321    mr_free(curr_filelist_fname);
    23292322    close_progress_form();
    2330     sprintf(tmp, "Your regular files have been archived ");
    23312323    if (retval) {
    2332         strcat(tmp, "(with errors).");
    2333     } else {
    2334         strcat(tmp, "successfully.");
    2335     }
    2336     log_to_screen(tmp);
    2337     mr_free(tmp);
    2338     mr_free(curr_filelist_fname);
    2339     mr_free(curr_afioball_fname);
     2324        log_to_screen
     2325            ("Your regular files have been archived (with errors).");
     2326    } else {
     2327        log_to_screen
     2328            ("Your regular files have been archived successfully.");
     2329    }
    23402330    mr_free(media_usage_comment);
    2341     mr_free(curr_xattr_list_fname);
    2342     mr_free(curr_acl_list_fname);
    23432331    return (retval);
    23442332}
Note: See TracChangeset for help on using the changeset viewer.