Ignore:
Timestamp:
May 20, 2007, 10:53:34 PM (13 years ago)
Author:
Bruno Cornec
Message:

Attempt to fix #117 (all paritions are now looked at if no grub or lilo found in MBR)

File:
1 edited

Legend:

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

    r1404 r1451  
    28012801        return ('G');
    28022802    } else {
    2803         log_it("Unknown boot loader");
    2804         return ('U');
     2803        // We need to look on each partition then
     2804        sprintf(list_drives_cmd,
     2805            "parted2fdisk -l 2>/dev/null | grep -E \"^/dev/\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/");
     2806        log_it("list_drives_cmd = %s", list_drives_cmd);
     2807
     2808        if (!(pdrives = popen(list_drives_cmd, "r"))) {
     2809            log_OS_error("Unable to open list of drives");
     2810            paranoid_free(list_drives_cmd);
     2811            paranoid_free(current_drive);
     2812            return ('\0');
     2813        }
     2814        for (fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives);
     2815            fgets(current_drive, MAX_STR_LEN, pdrives)) {
     2816            strip_spaces(current_drive);
     2817            log_it("looking at partition %s's BR", current_drive);
     2818            if (does_string_exist_in_boot_block(current_drive, "GRUB")) {
     2819                count_grubs++;
     2820                strcpy(which_device, current_drive);
     2821                break;
     2822            }
     2823            if (does_string_exist_in_boot_block(current_drive, "LILO")) {
     2824                count_lilos++;
     2825                strcpy(which_device, current_drive);
     2826                break;
     2827            }
     2828        }
     2829        if (pclose(pdrives)) {
     2830            log_OS_error("Cannot pclose pdrives");
     2831        }
     2832        log_it("%d grubs and %d lilos\n", count_grubs, count_lilos);
     2833        paranoid_free(list_drives_cmd);
     2834        paranoid_free(current_drive);
     2835        if (count_grubs && !count_lilos) {
     2836            return ('G');
     2837        } else if (count_lilos && !count_grubs) {
     2838            return ('L');
     2839        } else if (count_grubs == 1 && count_lilos == 1) {
     2840            log_it("I'll bet you used to use LILO but switched to GRUB...");
     2841            return ('G');
     2842        } else {
     2843            log_it("Unknown boot loader");
     2844            return ('U');
     2845        }
    28052846    }
    28062847}
Note: See TracChangeset for help on using the changeset viewer.