Changeset 2665 in MondoRescue


Ignore:
Timestamp:
Jun 24, 2010, 12:21:56 AM (14 years ago)
Author:
Bruno Cornec
Message:

r3925@localhost: bruno | 2010-06-23 00:13:12 +0200

  • Try to provide a workaround in code to the #401 (over-allocation of space due to rounding errors)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mondo/src/common/libmondo-mountlist.c

    r2516 r2665  
    324324        /* OK, continue with main loop */
    325325        amount_allocated += mountlist->el[pos].size / 1024L;
     326
     327        /* This should only happen at the end but not tested now */
     328        if (amount_allocated > physical_drive_size) {
     329            // Used to be +1, but what if you're 1 MB too high?
     330            mr_asprintf(&tmp, " %ld MB over-allocated on %s.",
     331                    amount_allocated - physical_drive_size, drive);
     332            log_it(tmp);
     333
     334            /* Do we have more than 1 MB per partition ? */
     335            if (amount_allocated - physical_drive_size <= curr_part_no) {
     336                /* Probably a rouding error, just passing over
     337                 * by reducing the last partition if possible */
     338                amount_allocated -= mountlist->el[pos].size / 1024L;
     339                mountlist->el[pos].size =  (mountlist->el[pos].size - curr_part_no*1024L);
     340                amount_allocated += mountlist->el[pos].size / 1024L;
     341            } else {
     342                mr_strcat(flaws_str, "%s", tmp);
     343                res++;
     344            }
     345            mr_free(tmp);
     346        }
    326347        prev_part_no = curr_part_no;
    327348    }
    328349
    329350    /* Over-allocated the disk? Unallocated space on disk? */
    330     if (amount_allocated > physical_drive_size) // Used to be +1, but what if you're 1 MB too high?
    331     {
    332         mr_asprintf(&tmp, " %ld MB over-allocated on %s.",
    333                 amount_allocated - physical_drive_size, drive);
    334         log_it(tmp);
    335         mr_strcat(flaws_str, "%s", tmp);
    336         mr_free(tmp);
    337         res++;
    338     } else if (amount_allocated < physical_drive_size - 1) {    /* NOT AN ERROR, JUST A WARNING :-) */
     351    if (amount_allocated < physical_drive_size - 1) {   /* NOT AN ERROR, JUST A WARNING :-) */
    339352        mr_asprintf(&tmp, " %ld MB unallocated on %s.",
    340353                physical_drive_size - amount_allocated, drive);
Note: See TracChangeset for help on using the changeset viewer.