Changeset 1365


Ignore:
Timestamp:
Apr 30, 2007, 1:50:20 AM (12 years ago)
Author:
bruno
Message:

MAX_NOOF_MEDIA is gone and media_size in bkpinfo struct is now a single long field and not an array anymore

Location:
branches/stable/mondo/src
Files:
8 edited

Legend:

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

    r1326 r1365  
    600600
    601601    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    602         mr_asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]);
     602        mr_asprintf(&tape_size_sz, "%ld", bkpinfo->media_size);
    603603        mr_asprintf(&tape_device, bkpinfo->media_device);
    604604    } else {
     
    843843        mr_fprintf(fd, "mindi_tape_device=%s\n", bkpinfo->media_device);
    844844        mr_fprintf(fd1, "media-dev=%s\n", bkpinfo->media_device);
    845         mr_fprintf(fd1, "media-size=%ld\n", bkpinfo->media_size[1]);
     845        mr_fprintf(fd1, "media-size=%ld\n", bkpinfo->media_size);
    846846    }
    847847    if (bkpinfo->compression_level > 0) {
     
    25402540    va_end(ap);
    25412541
    2542     if (bkpinfo->media_size[g_current_media_number] <= 0) {
     2542    if (bkpinfo->media_size <= 0L) {
    25432543        fatal_error("move_files_to_cd() - unknown media size");
    25442544    }
    2545     if (would_occupy / 1024 > bkpinfo->media_size[g_current_media_number]) {
     2545    if (would_occupy / 1024 > bkpinfo->media_size) {
    25462546        /* FALSE because this is not the last CD we'll write */
    25472547        res = write_iso_and_go_on(bkpinfo, FALSE);
     
    35703570    assert(bkpinfo != NULL);
    35713571    orig_vfy_flag_val = bkpinfo->verify_data;
    3572     if (bkpinfo->media_size[g_current_media_number] <= 0) {
     3572    if (bkpinfo->media_size <= 0L) {
    35733573        fatal_error("write_iso_and_go_on() - unknown media size");
    35743574    }
     
    36143614    mr_free(lastcd_fname);
    36153615
    3616     if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 >
    3617         bkpinfo->media_size[g_current_media_number]) {
     3616    if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 > bkpinfo->media_size) {
    36183617        mr_asprintf(&tmp,
    36193618                "Warning! %s is too big. It occupies %ld KB, which is more than the %ld KB allowed.",
    36203619                media_descriptor_string(bkpinfo->backup_media_type),
    36213620                (long) space_occupied_by_cd(bkpinfo->scratchdir),
    3622                 (long) bkpinfo->media_size[g_current_media_number]);
     3621                bkpinfo->media_size);
    36233622        log_to_screen(tmp);
    36243623        mr_free(tmp);
     
    36793678
    36803679    g_current_media_number++;
    3681     if (g_current_media_number > MAX_NOOF_MEDIA) {
    3682         fatal_error("Too many CD-R(W)'s. Use tape or net.");
    3683     }
    36843680    wipe_archives(bkpinfo->scratchdir);
    36853681    mr_asprintf(&tmp, "rm -Rf %s/images/*gz %s/images/*data*img",
  • branches/stable/mondo/src/common/libmondo-devices.c

    r1344 r1365  
    15261526            mr_free(comment);
    15271527
    1528             for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    1529                 bkpinfo->media_size[i] = atoi(sz_size);
    1530             }
     1528            bkpinfo->media_size = atol(sz_size);
    15311529            mr_free(sz_size);
    15321530
    1533             if (bkpinfo->media_size[0] <= 0) {
     1531            if (bkpinfo->media_size <= 0L) {
    15341532                log_to_screen(_("User has chosen not to backup the PC"));
    15351533                finish(1);
     
    15971595        }
    15981596        if (bkpinfo->backup_media_type == cdstream) {
    1599             for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    1600                 bkpinfo->media_size[i] = 650;
    1601             }
     1597            bkpinfo->media_size = (long)650;
    16021598        }
    16031599        break;
     
    16521648        mr_msg(4, "sz_size = %s", sz_size);
    16531649        mr_free(sz_size);
    1654         bkpinfo->media_size[0] = 0;
    1655         mr_msg(4, "media_size[0] = %ld", bkpinfo->media_size[0]);
    1656         if (bkpinfo->media_size[0] <= 0) {
    1657             bkpinfo->media_size[0] = 0;
    1658         }
    1659         for (i = 1; i <= MAX_NOOF_MEDIA; i++) {
    1660             bkpinfo->media_size[i] = bkpinfo->media_size[0];
     1650        bkpinfo->media_size = 0L;
     1651        mr_msg(4, "media_size = %ld", bkpinfo->media_size);
     1652        if (bkpinfo->media_size <= 0L) {
     1653            bkpinfo->media_size = 0L;
    16611654        }
    16621655        if (archiving_to_media) {
     
    17151708            }
    17161709            mr_free(comment);
    1717             for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    1718                 bkpinfo->media_size[i] = atoi(sz_size);
    1719             }
    1720             if (bkpinfo->media_size[0] <= 0) {
     1710            bkpinfo->media_size = atol(sz_size);
     1711            if (bkpinfo->media_size <= 0L) {
    17211712                log_to_screen(_("User has chosen not to backup the PC"));
    17221713                finish(1);
     
    17961787        mr_msg(3, "prefix set to %s", bkpinfo->prefix);
    17971788
    1798         for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    1799             bkpinfo->media_size[i] = 650;
    1800         }
     1789        bkpinfo->media_size = (long)650;
    18011790        mr_msg(3, "Just set nfs_remote_dir to %s",
    18021791                bkpinfo->nfs_remote_dir);
     
    18261815                    finish(1);
    18271816                }
    1828                 for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    1829                     bkpinfo->media_size[i] = atoi(sz_size);
    1830                 }
     1817                bkpinfo->media_size = atol(sz_size);
    18311818            } else {
    1832                 for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    1833                     bkpinfo->media_size[i] = 650;
    1834                 }
     1819                bkpinfo->media_size = (long)650;
    18351820            }
    18361821        }
     
    19861971
    19871972    log_it("media device = %s", bkpinfo->media_device);
    1988     log_it("media size = %ld", bkpinfo->media_size[1]);
     1973    log_it("media size = %ld", bkpinfo->media_size);
    19891974    log_it("media type = %s", bkpinfo->backup_media_string);
    19901975    log_it("prefix = %s", bkpinfo->prefix);
     
    19961981    log_it("boot_device = '%s' (loader=%c)", bkpinfo->boot_device,
    19971982           bkpinfo->boot_loader);
    1998     if (bkpinfo->media_size[0] < 0) {
     1983    if (bkpinfo->media_size < 0L) {
    19991984        if (archiving_to_media) {
    20001985            fatal_error("Media size is less than zero.");
    20011986        } else {
    20021987            mr_msg(2, "Warning - media size is less than zero.");
    2003             bkpinfo->media_size[0] = 0;
     1988            bkpinfo->media_size = 0L;
    20041989        }
    20051990    }
  • branches/stable/mondo/src/common/libmondo-files.c

    r1213 r1365  
    11631163    long long scratchLL;
    11641164
    1165     if (bkpinfo->media_size[1] <= 0 || bkpinfo->backup_media_type == nfs) {
     1165    if (bkpinfo->media_size <= 0L || bkpinfo->backup_media_type == nfs) {
    11661166        log_to_screen("Number of media required: UNKNOWN");
    11671167        return;
     
    11721172        (long long) (noof_sets) * (long long) (bkpinfo->optimal_set_size)
    11731173        + (long long) (size_of_all_biggiefiles_K(bkpinfo));
    1174     scratchLL = (scratchLL / 1024) / bkpinfo->media_size[1];
     1174    scratchLL = (scratchLL / 1024) / bkpinfo->media_size;
    11751175    scratchLL++;
    11761176    if (bkpinfo->use_lzo) {
  • branches/stable/mondo/src/common/libmondo-stream.c

    r1362 r1365  
    219219        (void) fwrite(blk, 1, 256 * 1024, g_tape_stream);
    220220        if (should_we_write_to_next_tape
    221             (bkpinfo->media_size[g_current_media_number], (off_t)256 * 1024)) {
     221            (bkpinfo->media_size, (off_t)256 * 1024)) {
    222222            start_to_write_to_next_tape(bkpinfo);
    223223        }
     
    13061306    log_it("New tape requested.");
    13071307    insist_on_this_tape_number(g_current_media_number + 1); // will increment g_current_media, too
    1308     if (g_current_media_number > MAX_NOOF_MEDIA) {
    1309         res++;
    1310         log_to_screen(_("Too many tapes. Man, you need to use nfs!"));
    1311     }
    13121308    if (bkpinfo->backup_media_type == cdstream) {
    13131309        mr_asprintf(&command,
     
    15021498    filesize = length_of_file(infile);
    15031499    if (should_we_write_to_next_tape
    1504         (bkpinfo->media_size[g_current_media_number], filesize)) {
     1500        (bkpinfo->media_size, filesize)) {
    15051501        start_to_write_to_next_tape(bkpinfo);
    15061502        write_backcatalog_to_tape(bkpinfo);
  • branches/stable/mondo/src/common/libmondo-string.c

    r1241 r1365  
    875875    assert(bkpinfo != NULL);
    876876
    877     if (bkpinfo->media_size[g_current_media_number] <= 0) {
     877    if (bkpinfo->media_size <= 0L) {
    878878        sprintf(outstr, _("Volume %d: %'lld kilobytes archived so far"),
    879879                g_current_media_number, g_tape_posK);
     
    885885        percentage =
    886886            (int) (g_tape_posK / 10 /
    887                    bkpinfo->media_size[g_current_media_number]);
     887                   bkpinfo->media_size);
    888888        if (percentage > 100) {
    889889            percentage = 100;
     
    893893        percentage =
    894894            (int) (space_occupied_by_cd(bkpinfo->scratchdir) * 100 / 1024 /
    895                    bkpinfo->media_size[g_current_media_number]);
     895                   bkpinfo->media_size);
    896896        sprintf(outstr, "%s %d: [",
    897897                bkpinfo->backup_media_string,
  • branches/stable/mondo/src/common/libmondo-tools.c

    r1344 r1365  
    709709    bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE;
    710710    bkpinfo->media_device[0] = '\0';
    711     for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    712         bkpinfo->media_size[i] = -1;
    713     }
     711    bkpinfo->media_size = 0L;
    714712    bkpinfo->boot_loader = '\0';
    715713    bkpinfo->boot_device[0] = '\0';
  • branches/stable/mondo/src/common/mondostructures.h

    r1364 r1365  
    66 */
    77
    8 
    9 /* @def MAX_NOOF_MEDIA The maximum number of media that can be used in any one backup. */
    10 
    11 /* So we can override it in config.h: */
    12 //#ifndef MAX_NOOF_MEDIA
    13 #define MAX_NOOF_MEDIA 50
    14 //#endif
    158
    169/**
     
    318311
    319312  /**
    320    * An array containing the sizes of each media in our backup set, in MB.
    321    * For example, media 1's size would be stored in media_size[1].
    322    * Element 0 is unused.
     313   *
     314   * The size of the media in our backup set, in MB.
    323315   * If the size should be autodetected, make it -1 (preferable) or 0.
    324    * @bug This should probably be only one variable, not an array.
    325    */
    326     long media_size[MAX_NOOF_MEDIA + 1];
     316   *
     317   */
     318    long media_size;
    327319
    328320  /**
  • branches/stable/mondo/src/mondoarchive/mondo-cli.c

    r1264 r1365  
    9292        flag_set[i] = FALSE;
    9393    }
    94     for (j = 1; j <= MAX_NOOF_MEDIA; j++) {
    95         bkpinfo->media_size[j] = 650;
    96     }                           /* default */
     94    bkpinfo->media_size = (long)650;
    9795    res =
    9896        retrieve_switches_from_command_line(argc, argv, flag_val,
     
    155153    assert(value != NULL);
    156154
    157     bkpinfo->media_size[0] = -1;    /* dummy value */
    158     for (j = 1, p = value; j < MAX_NOOF_MEDIA && strchr(p, ',');
    159          j++, p = strchr(p, ',') + 1) {
     155    bkpinfo->media_size = 0L;   /* dummy value */
     156    for ( p = value; strchr(p, ','); p = strchr(p, ',') + 1) {
    160157        mr_asprintf(&tmp, p);
    161158        q = strchr(tmp, ',');
     
    163160            *q = '\0';
    164161        }
    165         bkpinfo->media_size[j] = friendly_sizestr_to_sizelong(tmp);
     162        bkpinfo->media_size = friendly_sizestr_to_sizelong(tmp);
    166163        mr_free(tmp);
    167164
    168         mr_msg(3, "media_size[%d] = %ld", j,
    169                 bkpinfo->media_size[j]);
    170     }
    171     for (; j <= MAX_NOOF_MEDIA; j++) {
    172         bkpinfo->media_size[j] = friendly_sizestr_to_sizelong(p);
    173     }
    174     for (j = 1; j <= MAX_NOOF_MEDIA; j++) {
    175         if (bkpinfo->media_size[j] <= 0) {
    176             mr_msg(1, "You gave media #%d an invalid size\n", j);
    177             return (-1);
    178         }
     165        mr_msg(3, "media_size = %ld", bkpinfo->media_size);
     166    }
     167    if (bkpinfo->media_size <= 0L) {
     168        mr_msg(1, "You gave media an invalid size\n");
     169        return (-1);
    179170    }
    180171    return (0);
     
    469460                }
    470461            } else if (flag_set['u'] || flag_set['t']) {
    471                 for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    472                     bkpinfo->media_size[i] = 0;
    473                 }
     462                bkpinfo->media_size = 0L;
    474463            } else {
    475464                retval++;
Note: See TracChangeset for help on using the changeset viewer.