Changeset 3903 in MondoRescue for branches/3.3/mondo/src


Ignore:
Timestamp:
Dec 17, 2024, 11:42:58 PM (5 months ago)
Author:
Bruno Cornec
Message:

Avoid useless umount

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mondo/src/common/libmondo-devices.c

    r3893 r3903  
    11361136
    11371137    /*@ int's  ****************************************************** */
    1138     bool res;
     1138    bool res = FALSE;
    11391139
    11401140    /*@ end vars **************************************************** */
     
    11511151    }
    11521152
    1153     if ((bkpinfo->media_device == NULL) || (res = mount_media(mountpoint))) {
     1153    if ((bkpinfo->media_device == NULL) || ((res = mount_media(mountpoint)) == FALSE)) {
    11541154        mr_free(bkpinfo->media_device);
    11551155        if ((bkpinfo->media_device = mr_popup_and_get_string("CD-ROM device", "Please enter your CD-ROM's /dev device", "/dev/cdrom")) == NULL) {
    1156             res = TRUE;
     1156            res = FALSE;
    11571157        } else {
    11581158            res = mount_media(mountpoint);
    11591159        }
    11601160    }
    1161     if (res) {
     1161    if (!res) {
    11621162        log_msg(1, "mount failed");
    11631163    } else {
     
    15351535    char *mountdev = NULL;
    15361536    char *tmp = NULL;
     1537    bool res = FALSE;
    15371538
    15381539    assert(bkpinfo != NULL);
     
    15441545        cd_number = atoi(last_line_of_file(mountdev));
    15451546        mr_free(mountdev);
    1546         return (cd_number);
     1547        return(cd_number);
    15471548    }
    15481549
     
    15561557    }
    15571558    if (!is_this_device_mounted(MNT_CDROM)) {
    1558         mount_media(MNT_CDROM);
    1559     }
    1560 
    1561     cd_number = atoi(last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER"));
     1559        res = mount_media(MNT_CDROM);
     1560    }
     1561
     1562    if (res) {
     1563        cd_number = atoi(last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER"));
     1564    } else {
     1565        cd_number = 0;
     1566    }
    15621567    return(cd_number);
    15631568}
     
    15771582 * @param cd_number_i_want The CD number to ask for.
    15781583 */
    1579 void
    1580 insist_on_this_cd_number(int cd_number_i_want)
    1581 {
     1584void insist_on_this_cd_number(int cd_number_i_want) {
    15821585
    15831586    /*@ int ************************************************************* */
    15841587    int res = 0;
     1588    bool res1 = FALSE;
    15851589
    15861590
     
    15961600
    15971601    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    1598         log_msg(3,
    1599                 "No need to insist_on_this_cd_number when the backup type isn't CD-R(W) or NFS or ISO");
     1602        log_msg(3, "No need to insist_on_this_cd_number when the backup type isn't CD-R(W) or NFS or ISO");
    16001603        return;
    1601     }
    1602     if (!does_file_exist(MNT_CDROM)) {
    1603         mr_asprintf(tmp, "mkdir -p " MNT_CDROM);
    1604         run_program_and_log_output(tmp, 5);
    1605         mr_free(tmp);
    16061604    }
    16071605
     
    16111609    if ((res = what_number_cd_is_this()) != cd_number_i_want) {
    16121610        log_msg(3, "Currently, we hold %d but we want %d", res, cd_number_i_want);
    1613 
    1614         /* Now we need to umount the current media to have the next mounted after */
    1615         run_program_and_log_output("umount -d " MNT_CDROM, FALSE);
    1616         log_msg(3, "Mounting next media %d",cd_number_i_want);
    16171611        g_current_media_number = cd_number_i_want;
    1618         mount_media(MNT_CDROM);
    16191612
    16201613        mds = media_descriptor_string(bkpinfo->backup_media_type);
    1621         log_msg(3, "Insisting on %s #%d", mds, cd_number_i_want);
    16221614        mr_asprintf(request, "Please insert %s #%d and press Enter.", mds, cd_number_i_want);
    16231615        mr_free(mds);
    16241616
     1617        // what_number_cd_is_this mounts the device anyhow if not yet done.
     1618        log_msg(3, "Mounting next media %d",cd_number_i_want);
    16251619        while (what_number_cd_is_this() != cd_number_i_want) {
    16261620            sync();
    16271621            if (is_this_device_mounted(MNT_CDROM)) {
    1628                 res =
    1629                     run_program_and_log_output("umount -d " MNT_CDROM, FALSE);
     1622                /* Now we need to umount the current media to have the next mounted after */
     1623                res = run_program_and_log_output("umount -d " MNT_CDROM, FALSE);
    16301624            } else {
    16311625                res = 0;
Note: See TracChangeset for help on using the changeset viewer.