Changeset 3422 in MondoRescue for branches


Ignore:
Timestamp:
Aug 26, 2015, 1:38:00 PM (9 years ago)
Author:
Bruno Cornec
Message:
  • Add UEFI support in which_boot_loader (for now always return grub for UEFI boot mode)
File:
1 edited

Legend:

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

    r3413 r3422  
    31043104    /*@ end vars *************************************************** */
    31053105
    3106     malloc_string(current_drive);
    3107 
    3108     /* UEFI is not supported here - but should be managed as a BIOS/UEFI option not a Boot Loader one per se */
    3109 
    31103106#ifdef __IA64__
    31113107    /* No choice for it */
    31123108    return ('E');
    31133109#endif
     3110    if (bkpinfo->boot_type == EFI) {
     3111        /* No choice for it */
     3112        return ('E');
     3113    }
     3114
     3115    if (bkpinfo->boot_type == UEFI) {
     3116        /*  hardcoded for now. We can for sure do abetter job here ! */
     3117        /* RHEL, SLES, Mageia, Debian, Ubuntu use grub as boot loader as it seems for UEFI */
     3118        return ('G');
     3119    }
     3120
    31143121    assert(which_device != NULL);
    31153122
     
    31203127        log_OS_error("Unable to open list of drives");
    31213128        mr_free(list_drives_cmd);
    3122         paranoid_free(current_drive);
    31233129        return ('\0');
    31243130    }
    31253131    mr_free(list_drives_cmd);
    31263132
    3127     for (tmp = fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives) && (tmp != NULL);
    3128          tmp = fgets(current_drive, MAX_STR_LEN, pdrives)) {
    3129         strip_spaces(current_drive);
    3130         log_it("looking at drive %s's MBR", current_drive);
    3131         if (does_string_exist_in_boot_block(current_drive, "GRUB")) {
    3132             count_grubs++;
    3133             strcpy(which_device, current_drive);
    3134             break;
    3135         }
    3136         if (does_string_exist_in_boot_block(current_drive, "LILO")) {
    3137             count_lilos++;
    3138             strcpy(which_device, current_drive);
    3139             break;
    3140         }
    3141     }
    3142     if (pclose(pdrives)) {
    3143         log_OS_error("Cannot pclose pdrives");
    3144     }
    3145     log_it("%d grubs and %d lilos\n", count_grubs, count_lilos);
    3146     if (count_grubs && !count_lilos) {
    3147         paranoid_free(current_drive);
    3148         return ('G');
    3149     } else if (count_lilos && !count_grubs) {
    3150         paranoid_free(current_drive);
    3151         return ('L');
    3152     } else if (count_grubs == 1 && count_lilos == 1) {
    3153         log_it("I'll bet you used to use LILO but switched to GRUB...");
    3154         paranoid_free(current_drive);
    3155         return ('G');
    3156     } else {
    3157         // We need to look on each partition then
    3158         mr_asprintf(list_drives_cmd, "mr-parted2fdisk -l 2>/dev/null | grep -E \"^/dev/\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/");
    3159         log_it("list_drives_cmd = %s", list_drives_cmd);
    3160 
    3161         if (!(pdrives = popen(list_drives_cmd, "r"))) {
    3162             log_OS_error("Unable to open list of drives");
    3163             mr_free(list_drives_cmd);
    3164             paranoid_free(current_drive);
    3165             return ('\0');
    3166         }
    3167         mr_free(list_drives_cmd);
    3168 
    3169         for (tmp = fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives) && (tmp != NULL);
    3170             tmp = fgets(current_drive, MAX_STR_LEN, pdrives)) {
     3133    malloc_string(current_drive);
     3134    if (bkpinfo->boot_type == BIOS) {
     3135        for (tmp = fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives) && (tmp != NULL); tmp = fgets(current_drive, MAX_STR_LEN, pdrives)) {
    31713136            strip_spaces(current_drive);
    3172             log_it("looking at partition %s's BR", current_drive);
     3137            log_it("looking at drive %s's MBR", current_drive);
    31733138            if (does_string_exist_in_boot_block(current_drive, "GRUB")) {
    31743139                count_grubs++;
     
    31863151        }
    31873152        log_it("%d grubs and %d lilos\n", count_grubs, count_lilos);
    3188         paranoid_free(current_drive);
    31893153        if (count_grubs && !count_lilos) {
     3154            paranoid_free(current_drive);
    31903155            return ('G');
    31913156        } else if (count_lilos && !count_grubs) {
     3157            paranoid_free(current_drive);
    31923158            return ('L');
    31933159        } else if (count_grubs == 1 && count_lilos == 1) {
    31943160            log_it("I'll bet you used to use LILO but switched to GRUB...");
     3161            paranoid_free(current_drive);
    31953162            return ('G');
    31963163        } else {
    3197             log_it("Unknown boot loader");
    3198             return ('U');
     3164            // We need to look on each partition then
     3165            mr_asprintf(list_drives_cmd, "mr-parted2fdisk -l 2>/dev/null | grep -E \"^/dev/\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/");
     3166            log_it("list_drives_cmd = %s", list_drives_cmd);
     3167   
     3168            if (!(pdrives = popen(list_drives_cmd, "r"))) {
     3169                log_OS_error("Unable to open list of drives");
     3170                mr_free(list_drives_cmd);
     3171                paranoid_free(current_drive);
     3172                return ('\0');
     3173            }
     3174            mr_free(list_drives_cmd);
     3175   
     3176            for (tmp = fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives) && (tmp != NULL);
     3177                tmp = fgets(current_drive, MAX_STR_LEN, pdrives)) {
     3178                strip_spaces(current_drive);
     3179                log_it("looking at partition %s's BR", current_drive);
     3180                if (does_string_exist_in_boot_block(current_drive, "GRUB")) {
     3181                    count_grubs++;
     3182                    strcpy(which_device, current_drive);
     3183                    break;
     3184                }
     3185                if (does_string_exist_in_boot_block(current_drive, "LILO")) {
     3186                    count_lilos++;
     3187                    strcpy(which_device, current_drive);
     3188                    break;
     3189                }
     3190            }
     3191            if (pclose(pdrives)) {
     3192                log_OS_error("Cannot pclose pdrives");
     3193            }
     3194            log_it("%d grubs and %d lilos\n", count_grubs, count_lilos);
     3195            paranoid_free(current_drive);
     3196            if (count_grubs && !count_lilos) {
     3197                return ('G');
     3198            } else if (count_lilos && !count_grubs) {
     3199                return ('L');
     3200            } else if (count_grubs == 1 && count_lilos == 1) {
     3201                log_it("I'll bet you used to use LILO but switched to GRUB...");
     3202                return ('G');
     3203            } else {
     3204                log_it("Unknown boot loader");
     3205                return ('U');
     3206            }
    31993207        }
    32003208    }
Note: See TracChangeset for help on using the changeset viewer.