Changeset 3150


Ignore:
Timestamp:
Jun 21, 2013, 6:48:23 AM (6 years ago)
Author:
bruno
Message:
  • Fix #706 by removing usage of MAX_NOOF_MEDIA and an array for media_size in bkpinfo.
Location:
branches/3.0/mondo
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mondo/configure.in

    r3138 r3150  
    4545fi
    4646AC_SUBST(MONDORESTORE_STATIC)
    47 AC_DEFINE_UNQUOTED(MAX_NOOF_MEDIA, $max_noof_media, [Maximum number of media])
    4847AC_DEFINE_UNQUOTED(EXTTAPE, $exttape, [Tape blocksize])
    4948
  • branches/3.0/mondo/src/common/libmondo-archive.c

    r3060 r3150  
    562562
    563563    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    564         mr_asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]);
     564        mr_asprintf(&tape_size_sz, "%ld", bkpinfo->media_size);
    565565        ntapedev = get_non_rewind_dev(bkpinfo->media_device);
    566566        if ((bkpinfo->use_obdr) && (ntapedev != NULL)) {
     
    25462546    va_end(ap);
    25472547
    2548     if (bkpinfo->media_size[g_current_media_number] <= 0) {
     2548    if (bkpinfo->media_size <= 0) {
    25492549        fatal_error("move_files_to_cd() - unknown media size");
    25502550    }
    2551     if (would_occupy / 1024 > bkpinfo->media_size[g_current_media_number]) {
     2551    if (would_occupy / 1024 > bkpinfo->media_size) {
    25522552        res = write_iso_and_go_on(FALSE);   /* FALSE because this is not the last CD we'll write */
    25532553        retval += res;
     
    33473347    assert(bkpinfo != NULL);
    33483348    orig_vfy_flag_val = bkpinfo->verify_data;
    3349     if (bkpinfo->media_size[g_current_media_number] <= 0) {
     3349    if (bkpinfo->media_size <= 0) {
    33503350        fatal_error("write_iso_and_go_on() - unknown media size");
    33513351    }
     
    33803380        paranoid_fclose(fout);
    33813381    }
    3382     if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 >
    3383         bkpinfo->media_size[g_current_media_number]) {
     3382    if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 > bkpinfo->media_size) {
    33843383        sprintf(tmp,
    33853384                "Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.",
    33863385                (long) space_occupied_by_cd(bkpinfo->scratchdir),
    3387                 (long) bkpinfo->media_size[g_current_media_number]);
     3386                (long) bkpinfo->media_size);
    33883387        log_to_screen(tmp);
    33893388    }
     
    34453444    }
    34463445    g_current_media_number++;
    3447     if (g_current_media_number > MAX_NOOF_MEDIA) {
    3448         fatal_error("Too many media. Use tape or net.");
    3449     }
    34503446    wipe_archives(bkpinfo->scratchdir);
    34513447    sprintf(tmp, "rm -Rf %s/images/*gz %s/images/*data*img",
  • branches/3.0/mondo/src/common/libmondo-cli.c

    r3141 r3150  
    8686        flag_set[i] = FALSE;
    8787    }
    88     for (j = 1; j <= MAX_NOOF_MEDIA; j++) {
    89         bkpinfo->media_size[j] = 650;
    90     }                           /* default */
    91     res =
    92         retrieve_switches_from_command_line(argc, argv, flag_val,
    93                                             flag_set);
     88    bkpinfo->media_size = 650; /* default */
     89    res = retrieve_switches_from_command_line(argc, argv, flag_val, flag_set);
    9490    retval += res;
    9591    if (!retval) {
     
    145141    assert(value != NULL);
    146142
    147     bkpinfo->media_size[0] = -1;    /* dummy value */
    148     for (j = 1, p = value; j < MAX_NOOF_MEDIA && strchr(p, ',');
    149          j++, p = strchr(p, ',') + 1) {
    150         strncpy(tmp, p, MAX_STR_LEN);
    151         *(strchr(tmp, ',')) = '\0';
    152         bkpinfo->media_size[j] = friendly_sizestr_to_sizelong(tmp);
    153         sprintf(comment, "media_size[%d] = %ld", j,
    154                 bkpinfo->media_size[j]);
    155         log_msg(3, comment);
    156     }
    157     for (; j <= MAX_NOOF_MEDIA; j++) {
    158         bkpinfo->media_size[j] = friendly_sizestr_to_sizelong(p);
    159     }
    160 //      bkpinfo->media_size[0] = bkpinfo->media_size[MAX_NOOF_MEDIA];
    161     for (j = 1; j <= MAX_NOOF_MEDIA; j++) {
    162         if (bkpinfo->media_size[j] <= 0) {
    163             log_msg(1, "You gave media #%d an invalid size\n", j);
    164             return (-1);
    165         }
     143    bkpinfo->media_size = -1;   /* dummy value */
     144    bkpinfo->media_size = friendly_sizestr_to_sizelong(p);
     145    log_msg(3, "media_size = %ld", bkpinfo->media_size);
     146    if (bkpinfo->media_size <= 0) {
     147        log_msg(1, "You gave media an invalid size %s\n", p);
     148        return (-1);
    166149    }
    167150    return (0);
     
    461444                }
    462445            } else if (flag_set['u'] || flag_set['t']) {
    463                 for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    464                     bkpinfo->media_size[i] = 0;
    465                 }
     446                bkpinfo->media_size = 0;
    466447            } else {
    467448                retval++;
  • branches/3.0/mondo/src/common/libmondo-devices.c

    r3111 r3150  
    22772277                finish(1);
    22782278            }
    2279             for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    2280                 bkpinfo->media_size[i] = atoi(sz_size);
    2281             }
    2282             if (bkpinfo->media_size[0] <= 0) {
     2279            bkpinfo->media_size = atoi(sz_size);
     2280            if (bkpinfo->media_size <= 0) {
    22832281                log_to_screen("User has chosen not to backup the PC");
    22842282                finish(1);
     
    23572355
    23582356        if (bkpinfo->backup_media_type == cdstream) {
    2359             for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    2360                 bkpinfo->media_size[i] = 650;
    2361             }
     2357            bkpinfo->media_size = 650;
    23622358        }
    23632359        break;
     
    24152411
    24162412        if (sz_size[0] == '\0') {
    2417             bkpinfo->media_size[0] = 0;
     2413            bkpinfo->media_size = 0;
    24182414        } else {
    2419             bkpinfo->media_size[0] =
    2420                 friendly_sizestr_to_sizelong(sz_size) / 2 - 50;
    2421         }
    2422         log_msg(4, "media_size[0] = %ld", bkpinfo->media_size[0]);
    2423         if (bkpinfo->media_size[0] <= 0) {
    2424             bkpinfo->media_size[0] = 0;
    2425         }
    2426         for (i = 1; i <= MAX_NOOF_MEDIA; i++) {
    2427             bkpinfo->media_size[i] = bkpinfo->media_size[0];
     2415            bkpinfo->media_size = friendly_sizestr_to_sizelong(sz_size) / 2 - 50;
     2416        }
     2417        log_msg(4, "media_size = %ld", bkpinfo->media_size);
     2418        if (bkpinfo->media_size <= 0) {
     2419            bkpinfo->media_size = 0;
    24282420        }
    24292421        bkpinfo->use_obdr = ask_me_yes_or_no
     
    25112503                strcpy(sz_size, "0");
    25122504            }
    2513             for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    2514                 bkpinfo->media_size[i] = atoi(sz_size);
    2515             }
    2516             if (bkpinfo->media_size[0] < 0) {
     2505            bkpinfo->media_size = atoi(sz_size);
     2506            if (bkpinfo->media_size < 0) {
    25172507                log_to_screen("User has chosen not to backup the PC");
    25182508                finish(1);
     
    26582648                    finish(1);
    26592649                }
    2660                 for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    2661                     bkpinfo->media_size[i] = atoi(sz_size);
    2662                 }
     2650                bkpinfo->media_size = atoi(sz_size);
    26632651            } else {
    2664                 for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    2665                     bkpinfo->media_size[i] = 650;
    2666                 }
     2652                bkpinfo->media_size = 650;
    26672653            }
    26682654        }
     
    28702856
    28712857    log_it("media device = %s", bkpinfo->media_device);
    2872     log_it("media size = %ld", bkpinfo->media_size[1]);
     2858    log_it("media size = %ld", bkpinfo->media_size);
    28732859    log_it("media type = %s", bkptype_to_string(bkpinfo->backup_media_type));
    28742860    log_it("prefix = %s", bkpinfo->prefix);
     
    28882874    log_it("boot_device = '%s' (loader=%c)", bkpinfo->boot_device,
    28892875           bkpinfo->boot_loader);
    2890     if (bkpinfo->media_size[0] < 0) {
     2876    if (bkpinfo->media_size < 0) {
    28912877        if (archiving_to_media) {
    28922878            fatal_error("Media size is less than zero.");
    28932879        } else {
    28942880            log_msg(2, "Warning - media size is less than zero.");
    2895             bkpinfo->media_size[0] = 0;
     2881            bkpinfo->media_size = 0;
    28962882        }
    28972883    }
  • branches/3.0/mondo/src/common/libmondo-files.c

    r3074 r3150  
    12591259    long long scratchLL;
    12601260
    1261     if (bkpinfo->media_size[1] <= 0) {
     1261    if (bkpinfo->media_size <= 0) {
    12621262        log_to_screen("Number of media required: UNKNOWN");
    12631263        return;
     
    12681268        (long long) (noof_sets) * (long long) (bkpinfo->optimal_set_size)
    12691269        + (long long) (size_of_all_biggiefiles_K());
    1270     scratchLL = (scratchLL / 1024) / bkpinfo->media_size[1];
     1270    scratchLL = (scratchLL / 1024) / bkpinfo->media_size;
    12711271    scratchLL++;
    12721272    if (bkpinfo->use_lzo) {
  • branches/3.0/mondo/src/common/libmondo-stream.c

    r3116 r3150  
    199199        }
    200200        if (should_we_write_to_next_tape
    201             (bkpinfo->media_size[g_current_media_number], (off_t)256 * 1024)) {
     201            (bkpinfo->media_size, (off_t)256 * 1024)) {
    202202            start_to_write_to_next_tape();
    203203        }
     
    212212      {
    213213        fwrite (blk, 1, 256*1024, g_tape_stream);
    214         if (should_we_write_to_next_tape (bkpinfo->media_size[g_current_media_number], 256*1024))
     214        if (should_we_write_to_next_tape (bkpinfo->media_size, 256*1024))
    215215          {
    216216            start_to_write_to_next_tape ();
     
    14931493    log_it("New tape requested.");
    14941494    insist_on_this_tape_number(g_current_media_number + 1); // will increment g_current_media, too
    1495     if (g_current_media_number > MAX_NOOF_MEDIA) {
    1496         res++;
    1497         log_to_screen("Too many tapes. Man, you need to use nfs!");
    1498     }
    14991495    if (bkpinfo->backup_media_type == cdstream) {
    15001496        mr_asprintf(&command,
     
    16941690    filesize = length_of_file(infile);
    16951691    if (should_we_write_to_next_tape
    1696         (bkpinfo->media_size[g_current_media_number], filesize)) {
     1692        (bkpinfo->media_size, filesize)) {
    16971693        start_to_write_to_next_tape();
    16981694        write_backcatalog_to_tape();
  • branches/3.0/mondo/src/common/libmondo-string.c

    r3042 r3150  
    222222    assert_string_is_neither_NULL_nor_zerolength(incoming);
    223223
    224     malloc_string(tmp);
    225224    if (!incoming[0]) {
    226         free(tmp);
    227225        return (0);
    228226    }
     
    230228        fatal_error("Please use integers only. No decimal points.");
    231229    }
     230    malloc_string(tmp);
    232231    strcpy(tmp, incoming);
    233232    i = (int) strlen(tmp);
     
    10761075
    10771076
    1078     if (bkpinfo->media_size[g_current_media_number] <= 0)
     1077    if (bkpinfo->media_size <= 0)
    10791078//    { fatal_error( "percentage_media_full_comment() - unknown media size"); }
    10801079    {
     
    10861085/* update screen */
    10871086    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    1088         percentage =
    1089             (int) (g_tape_posK / 10 /
    1090                    bkpinfo->media_size[g_current_media_number]);
     1087        percentage = (int) (g_tape_posK / 10 / bkpinfo->media_size);
    10911088        if (percentage > 100) {
    10921089            percentage = 100;
     
    10951092    } else {
    10961093        percentage =
    1097             (int) (space_occupied_by_cd(bkpinfo->scratchdir) * 100 / 1024 /
    1098                    bkpinfo->media_size[g_current_media_number]);
     1094            (int) (space_occupied_by_cd(bkpinfo->scratchdir) * 100 / 1024 / bkpinfo->media_size);
    10991095        mds = media_descriptor_string(bkpinfo->backup_media_type);
    11001096        sprintf(outstr, "%s %d: [", mds, g_current_media_number);
  • branches/3.0/mondo/src/common/libmondo-tools.c

    r3060 r3150  
    788788
    789789    bkpinfo->media_device[0] = '\0';
    790     for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    791         bkpinfo->media_size[i] = -1;
    792     }
     790    bkpinfo->media_size = -1;
    793791    bkpinfo->boot_loader = '\0';
    794792    bkpinfo->boot_device[0] = '\0';
  • branches/3.0/mondo/src/common/mondostructures.h

    r3137 r3150  
    2323 */
    2424
    25 
    26 /** @def MAX_NOOF_MEDIA The maximum number of media that can be used in any one backup. */
    27 
    28 ///* So we can override it in config.h: */
    29 //#ifndef MAX_NOOF_MEDIA
    30 #define MAX_NOOF_MEDIA 50
    31 //#endif
    3225
    3326/**
     
    344337
    345338  /**
    346    * An array containing the sizes of each media in our backup set, in MB.
    347    * For example, media 1's size would be stored in media_size[1].
    348    * Element 0 is unused.
     339   * A field containing the sizes of the media in our backup set, in MB.
    349340   * If the size should be autodetected, make it -1 (preferable) or 0.
    350    * @bug This should probably be only one variable, not an array.
    351    */
    352     long media_size[MAX_NOOF_MEDIA + 1];
     341   */
     342    long media_size;
    353343
    354344  /**
  • branches/3.0/mondo/src/mondorestore/mondo-rstr-tools.c

    r3116 r3150  
    730730    if (bkpinfo->backup_media_type == cdstream) {
    731731        sprintf(bkpinfo->media_device, "/dev/cdrom");
    732 //          bkpinfo->media_size[0] = -1;
    733         bkpinfo->media_size[0] = 1999 * 1024;
    734         bkpinfo->media_size[1] = 650;   /* good guess */
     732        bkpinfo->media_size = 650;  /* good guess */
    735733    } else if (bkpinfo->backup_media_type == usb) {
    736734        envtmp1 = getenv("MRUSBDEV");
     
    752750        strcpy(bkpinfo->media_device, value);
    753751        read_cfg_var(cfg_file, "media-size", value);
    754         bkpinfo->media_size[1] = atol(value);
     752        bkpinfo->media_size = atol(value);
    755753        sprintf(tmp, "Backup medium is TAPE --- dev=%s",
    756754                bkpinfo->media_device);
     
    758756    } else {
    759757        strcpy(bkpinfo->media_device, "/dev/cdrom");    /* we don't really need this var */
    760         bkpinfo->media_size[0] = 1999 * 1024;   /* 650, probably, but we don't need this var anyway */
    761         bkpinfo->media_size[1] = 1999 * 1024;   /* 650, probably, but we don't need this var anyway */
     758        bkpinfo->media_size = 1999 * 1024;  /* 650, probably, but we don't need this var anyway */
    762759        log_msg(2, "Backup medium is CD-R[W]");
    763760    }
Note: See TracChangeset for help on using the changeset viewer.