Changeset 1709 for branches/2.2.5


Ignore:
Timestamp:
Oct 27, 2007, 5:07:52 PM (12 years ago)
Author:
bruno
Message:
  • Verify should now work for USB devices
  • More log/mesages improvement for USB support
Location:
branches/2.2.5/mondo/src/common
Files:
3 edited

Legend:

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

    r1708 r1709  
    18951895    log_msg(1, message_to_screen);
    18961896
    1897     if (is_this_device_mounted(bkpinfo->media_device)) {
     1897    asprintf(&tmp1, "umount %s1", bkpinfo->media_device);
     1898    if (is_this_device_mounted(tmp1)) {
    18981899        log_msg(1, "USB device mounted. Remounting it at the right place");
    1899         asprintf(&tmp, "umount %s1", bkpinfo->media_device);
     1900        asprintf(&tmp, "umount %s", tmp1);
    19001901        run_program_and_log_output(tmp, FALSE);
    19011902        paranoid_free(tmp);
    19021903    }
     1904    1paranoid_free(tmp);
     1905
    19031906    log_msg(1, "Mounting USB device.");
    19041907    asprintf(&tmp1, "%s/usb", bkpinfo->tmpdir);
     
    39653968                 media_descriptor_string(g_backup_media_type));
    39663969            chdir("/");
    3967             iamhere("Before calling verify_cd_image()");
    3968             res += verify_cd_image();
    3969             iamhere("After calling verify_cd_image()");
     3970            iamhere("Before calling verification of image()");
     3971            if (bkpinfo->backup_media_type == usb) {
     3972                res += verify_usb_image();
     3973            } else {
     3974                res += verify_cd_image();
     3975            }
     3976            iamhere("After calling verification of image()");
    39703977        }
    39713978        if (!res) {
    39723979            that_one_was_ok = TRUE;
    39733980        } else {
    3974             sprintf(tmp, "Failed to burn %s #%d. Retry?",
     3981            sprintf(tmp, "Failed to create %s #%d. Retry?",
    39753982                    media_descriptor_string(bkpinfo->backup_media_type),
    39763983                    g_current_media_number);
     
    39984005    g_current_media_number++;
    39994006    if (g_current_media_number > MAX_NOOF_MEDIA) {
    4000         fatal_error("Too many CD-R(W)'s. Use tape or net.");
     4007        fatal_error("Too many media. Use tape or net.");
    40014008    }
    40024009    wipe_archives(bkpinfo->scratchdir);
     
    40104017
    40114018    if (last_cd) {
    4012         log_msg(2, "This was your last CD.");
     4019        log_msg(2, "This was your last media.");
    40134020    } else {
    40144021        log_msg(2, "Continuing to backup your data...");
  • branches/2.2.5/mondo/src/common/libmondo-devices.c

    r1708 r1709  
    721721
    722722
    723 
    724 /**
    725  * Locate a CD-R/W writer's SCSI node.
    726  * @param cdrw_device SCSI node will be placed here.
    727  * @return 0 for success, nonzero for failure.
    728  */
    729723
    730724
     
    19671961                                             MAX_STR_LEN / 4);
    19681962                } else {
    1969                     i = popup_and_get_string("/dev entry?",
     1963                    if (bkpinfo->backup_media_type == usb) {
     1964                        i = popup_and_get_string("/dev entry?",
     1965                                             "What is the /dev entry of your USB Disk/Key, please?",
     1966                                             bkpinfo->media_device,
     1967                                             MAX_STR_LEN / 4);
     1968                    } else {
     1969                        i = popup_and_get_string("/dev entry?",
    19701970                                             "What is the /dev entry of your CD (re)writer, please?",
    19711971                                             bkpinfo->media_device,
    19721972                                             MAX_STR_LEN / 4);
     1973                    }
    19731974                }
    19741975                if (!i) {
  • branches/2.2.5/mondo/src/common/libmondo-verify.c

    r1648 r1709  
    10381038
    10391039/**
     1040 * Verify the USB device
     1041 * @param bkpinfo The backup information structure. Fields used:
     1042 * - @c bkpinfo->isodir
     1043 * - @c bkpinfo->media_device
     1044 * - @c bkpinfo->tmpdir
     1045 * - @c bkpinfo->verify_data
     1046 *
     1047 * @return 0 for success (even if differences are found), nonzero for failure.
     1048 * @ingroup verifyGroup
     1049 */
     1050int verify_usb_image()
     1051{
     1052
     1053    /*@ int ************************************************************ */
     1054    int retval = 0;
     1055
     1056    /*@ buffers ******************************************************** */
     1057    char *mountpoint = NULL;
     1058    char *tmp = NULL;
     1059    char *tmp1 = NULL;
     1060    char *fname = NULL;
     1061#ifdef __FreeBSD__
     1062    char mdd[32];
     1063    char *mddevice = mdd;
     1064    int ret = 0;
     1065    int vndev = 2;
     1066#else
     1067//skip
     1068#endif
     1069
     1070    assert(bkpinfo != NULL);
     1071
     1072    asprintf(&fname, "%s1", bkpinfo->media_device);
     1073    if (is_this_device_mounted(fname)) {
     1074        log_msg(1, "USB device mounted. Remounting it at the right place");
     1075        asprintf(&tmp, "umount %s", fname);
     1076        run_program_and_log_output(tmp, FALSE);
     1077        paranoid_free(tmp);
     1078    }
     1079    paranoid_free(fname);
     1080
     1081    log_msg(1, "Mounting USB device.");
     1082    asprintf(&mountpoint, "%s/usb", bkpinfo->tmpdir);
     1083    asprintf(&tmp, "mkdir -p %s", mountpoint);
     1084    run_program_and_log_output(tmp, FALSE);
     1085    paranoid_free(tmp);
     1086    /* Mindi always create one single parition on the USB dev */
     1087    asprintf(&tmp, "mount %s1 %s", bkpinfo->media_device, mountpoint);
     1088    ret = run_program_and_log_output(tmp, FALSE);
     1089    paranoid_free(tmp);
     1090    if (ret) {
     1091        paranoid_free(mountpoint);
     1092        return(ret);
     1093    }
     1094
     1095    sync();
     1096    log_msg(2, "OK, I've mounted the USB Disk/Key\n");
     1097    asprintf(&tmp, "%s/archives/NOT-THE-LAST", mountpoint);
     1098    if (!does_file_exist(tmp)) {
     1099        log_msg
     1100            (2,
     1101             "This is the last USB device. I am therefore setting bkpinfo->verify_data to FALSE.");
     1102        bkpinfo->verify_data = FALSE;
     1103/*
     1104   (a) It's an easy way to tell the calling subroutine that we've finished &
     1105   there are no more device to be verified; (b) It stops the post-backup verifier
     1106   from running after the per-device verifier has run too.
     1107*/
     1108    }
     1109    paranoid_free(tmp);
     1110    verify_afioballs_on_CD(mountpoint);
     1111    iamhere("before verify_all_slices");
     1112    verify_all_slices_on_CD(mountpoint);
     1113
     1114    asprintf(&tmp1, "umount %s", mountpoint);
     1115#ifdef __FreeBSD__
     1116    ret = 0;
     1117    ret += system(tmp1);
     1118    ret += kick_vn(mddevice);
     1119    if (ret)
     1120#else
     1121    if (system(tmp1))
     1122#endif
     1123    {
     1124        asprintf(&tmp, "%s failed; unable to unmount USB device\n", tmp1);
     1125        log_to_screen(tmp);
     1126        paranoid_free(tmp);
     1127        retval++;
     1128    } else {
     1129        log_msg(2, "OK, I've unmounted the USB device\n");
     1130    }
     1131    paranoid_free(tmp1);
     1132    paranoid_free(mountpoint);
     1133    return (retval);
     1134}
     1135
     1136
     1137/**
    10401138 * Verify the CD indicated by @c g_current_media_number.
    10411139 * @param bkpinfo The backup information structure. Fields used:
Note: See TracChangeset for help on using the changeset viewer.