Changeset 3422 in MondoRescue
- Timestamp:
- Aug 26, 2015, 1:38:00 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mondo/src/common/libmondo-devices.c
r3413 r3422 3104 3104 /*@ end vars *************************************************** */ 3105 3105 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 3110 3106 #ifdef __IA64__ 3111 3107 /* No choice for it */ 3112 3108 return ('E'); 3113 3109 #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 3114 3121 assert(which_device != NULL); 3115 3122 … … 3120 3127 log_OS_error("Unable to open list of drives"); 3121 3128 mr_free(list_drives_cmd); 3122 paranoid_free(current_drive);3123 3129 return ('\0'); 3124 3130 } 3125 3131 mr_free(list_drives_cmd); 3126 3132 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)) { 3171 3136 strip_spaces(current_drive); 3172 log_it("looking at partition %s'sBR", current_drive);3137 log_it("looking at drive %s's MBR", current_drive); 3173 3138 if (does_string_exist_in_boot_block(current_drive, "GRUB")) { 3174 3139 count_grubs++; … … 3186 3151 } 3187 3152 log_it("%d grubs and %d lilos\n", count_grubs, count_lilos); 3188 paranoid_free(current_drive);3189 3153 if (count_grubs && !count_lilos) { 3154 paranoid_free(current_drive); 3190 3155 return ('G'); 3191 3156 } else if (count_lilos && !count_grubs) { 3157 paranoid_free(current_drive); 3192 3158 return ('L'); 3193 3159 } else if (count_grubs == 1 && count_lilos == 1) { 3194 3160 log_it("I'll bet you used to use LILO but switched to GRUB..."); 3161 paranoid_free(current_drive); 3195 3162 return ('G'); 3196 3163 } 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 } 3199 3207 } 3200 3208 }
Note:
See TracChangeset
for help on using the changeset viewer.