Changeset 783 in MondoRescue for trunk/mondo/mondo/common/libmondo-files.c


Ignore:
Timestamp:
Aug 31, 2006, 5:09:20 PM (18 years ago)
Author:
Bruno Cornec
Message:
  • Massive rewrite continues for memory management.
  • main structure should now have all parameters allocated dynamically
  • new lib libmr.a + dir + build process reviewed to support it.
  • new include subdir to host external definitions of the new lib
  • code now compiles. Still one remaining link issues for mondorestore. This should allow for some tests soon.

(goal is to separate completely reviewed code and functions and provide clean interfaces)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/mondo/common/libmondo-files.c

    r764 r783  
    2525
    2626extern int g_currentY;
     27extern int g_noof_log_lines;
    2728extern char *g_mondo_home;
    2829
     
    7778    }
    7879    return (output);
    79 }
    80 
    81 
    82 /**
    83  * Get a not-quite-unique representation of some of the file's @c stat properties.
    84  * The returned string has the form <tt>size-mtime-ctime</tt>.
    85  * @param curr_fname The file to generate the "checksum" for.
    86  * @return The "checksum".
    87  * @note The returned string points to static storage that will be overwritten with each call.
    88  */
    89 char *calc_file_ugly_minichecksum(char *curr_fname)
    90 {
    91 
    92     /*@ buffers ***************************************************** */
    93     char *curr_cksum;
    94 
    95     /*@ pointers **************************************************** */
    96 
    97     /*@ structures ************************************************** */
    98     struct stat buf;
    99 
    100     /*@************************************************************** */
    101 
    102     assert_string_is_neither_NULL_nor_zerolength(curr_fname);
    103     if (lstat(curr_fname, &buf)) {
    104         asprintf(&curr_cksum, "");
    105     } else {
    106         asprintf(&curr_cksum, "%ld-%ld-%ld", (long) (buf.st_size),
    107             (long) (buf.st_mtime), (long) (buf.st_ctime));
    108     }
    109     return (curr_cksum);
    11080}
    11181
     
    275245    if (kernel == NULL) {
    276246        kernel = call_program_and_get_last_line_of_output
    277                ("mindi --findkernel 2> /dev/null"));
     247               ("mindi --findkernel 2> /dev/null");
    278248    }
    279249    // If we didn't get anything back, check whether mindi raised a fatal error
     
    481451        log_it(tmp);
    482452        paranoid_free(tmp);
    483         asprintf(&output, "");
    484 
    485         return (output);
     453        return (NULL);
    486454    }
    487455    asprintf(&command, "tail -n1 %s", filename);
     
    10331001    paranoid_free(command);
    10341002
    1035     if (bkpinfo->postnuke_tarball[0]) {
     1003    if (bkpinfo->postnuke_tarball) {
    10361004        asprintf(&command, "cp -f %s %s/post-nuke.tgz",
    10371005                bkpinfo->postnuke_tarball, bkpinfo->tmpdir);
     
    11871155{
    11881156    /*@ buffers *************** */
    1189     char *tmp;
     1157    char *tmp = NULL;
    11901158
    11911159    /*@ long long ************* */
     
    12141182        asprintf(&tmp,
    12151183                _("Your backup will probably occupy a single %s. Maybe two."),
    1216                 media_descriptor_string(bkpinfo->backup_media_type));
     1184                bkpinfo->backup_media_string);
    12171185    } else {
    12181186        asprintf(&tmp, _("Your backup will occupy approximately %s media."),
    12191187                number_to_text((int) (scratchLL + 1)));
    12201188    }
    1221     if (!bkpinfo->image_devs[0] && (scratchLL < 50)) {
     1189    if (!bkpinfo->image_devs && (scratchLL < 50)) {
    12221190        log_to_screen(tmp);
    12231191    }
     
    12351203bool is_this_file_compressed(char *filename)
    12361204{
    1237     char *do_not_compress_these;
    1238     char *tmp;
    1239     char *p;
     1205    char *do_not_compress_these = NULL;
     1206    char *tmp = NULL;
     1207    char *p = NULL;
    12401208
    12411209    asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);
Note: See TracChangeset for help on using the changeset viewer.