Ignore:
Timestamp:
Oct 27, 2007, 5:07:52 PM (16 years ago)
Author:
Bruno Cornec
Message:
  • Verify should now work for USB devices
  • More log/mesages improvement for USB support
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.