Changeset 1451


Ignore:
Timestamp:
May 20, 2007, 10:53:34 PM (12 years ago)
Author:
bruno
Message:

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

Location:
branches/2.2.4/mondo/src
Files:
2 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}
  • branches/2.2.4/mondo/src/mondorestore/mondo-rstr-tools.c

    r1406 r1451  
    846846
    847847if (!strcmp(mpt, "/1")) {
    848 strcpy(mountpoint, "/");
    849 log_msg(3, "Mommm! SME is being a dildo!");
     848    strcpy(mountpoint, "/");
     849    log_msg(3, "Mommm! SME is being a dildo!");
    850850} else {
    851 strcpy(mountpoint, mpt);
     851    strcpy(mountpoint, mpt);
    852852}
    853853
    854854if (!strcmp(mountpoint, "lvm")) {
    855 return (0);
     855    return (0);
    856856}
    857857if (!strcmp(mountpoint, "image")) {
    858 return (0);
     858    return (0);
    859859}
    860860sprintf(tmp, "Mounting device %s   ", device);
    861861log_msg(1, tmp);
    862862if (writeable) {
    863 strcpy(additional_parameters, "-o rw");
     863    strcpy(additional_parameters, "-o rw");
    864864} else {
    865 strcpy(additional_parameters, "-o ro");
     865    strcpy(additional_parameters, "-o ro");
    866866}
    867867if (find_home_of_exe("setfattr")) {
    868 strcat(additional_parameters, ",user_xattr");
     868    strcat(additional_parameters, ",user_xattr");
    869869}
    870870if (find_home_of_exe("setfacl")) {
    871 strcat(additional_parameters, ",acl");
     871    strcat(additional_parameters, ",acl");
    872872}
    873873
    874874if (!strcmp(mountpoint, "swap")) {
    875 sprintf(command, "swapon %s", device);
     875    sprintf(command, "swapon %s", device);
    876876} else {
    877877if (!strcmp(mountpoint, "/")) {
     
    888888res = run_program_and_log_output(command, TRUE);
    889889if (res && (strstr(command, "xattr") || strstr(command, "acl"))) {
    890 log_msg(1, "Re-trying without the fancy extra parameters");
    891 sprintf(command, "mount -t %s %s %s 2>> %s", format, device,
     890    log_msg(1, "Re-trying without the fancy extra parameters");
     891    sprintf(command, "mount -t %s %s %s 2>> %s", format, device,
    892892        mountdir, MONDO_LOGFILE);
    893 res = run_program_and_log_output(command, TRUE);
     893    res = run_program_and_log_output(command, TRUE);
    894894}
    895895if (res) {
    896 log_msg(1, "Unable to mount device %s (type %s) at %s", device,
     896    log_msg(1, "Unable to mount device %s (type %s) at %s", device,
    897897        format, mountdir);
    898 log_msg(1, "command was '%s'", command);
    899 if (!strcmp(mountpoint, "swap")) {
    900     log_to_screen(tmp);
    901 } else {
    902     log_msg(2, "Retrying w/o the '-t' switch");
    903     sprintf(command, "mount %s %s 2>> %s", device, mountdir,
     898    log_msg(1, "command was '%s'", command);
     899    if (!strcmp(mountpoint, "swap")) {
     900        log_to_screen(tmp);
     901    } else {
     902        log_msg(2, "Retrying w/o the '-t' switch");
     903        sprintf(command, "mount %s %s 2>> %s", device, mountdir,
    904904            MONDO_LOGFILE);
    905     log_msg(2, "2nd command = '%s'", command);
    906     res = run_program_and_log_output(command, TRUE);
    907     if (res == 0) {
    908         log_msg(1,
     905        log_msg(2, "2nd command = '%s'", command);
     906        res = run_program_and_log_output(command, TRUE);
     907        if (res == 0) {
     908            log_msg(1,
    909909                "That's OK. I called mount w/o a filesystem type and it worked fine in the end.");
    910     } else {
    911         log_to_screen(tmp);
    912     }
    913 }
     910        } else {
     911            log_to_screen(tmp);
     912        }
     913    }
    914914}
    915915if (res && !strcmp(mountpoint, "swap")) {
    916 log_msg(2, "That's ok. It's just a swap partition.");
    917 log_msg(2, "Non-fatal error. Returning 0.");
    918 res = 0;
     916    log_msg(2, "That's ok. It's just a swap partition.");
     917    log_msg(2, "Non-fatal error. Returning 0.");
     918    res = 0;
    919919}
    920920
Note: See TracChangeset for help on using the changeset viewer.