Skip to content

Commit

Permalink
ensure proper disk is asked when multi disk with different partition …
Browse files Browse the repository at this point in the history
…table type is used (bsc#1017776)
  • Loading branch information
jreidinger committed Jan 3, 2017
1 parent b154675 commit a579ff8
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/lib/bootloader/mbr_update.rb
Expand Up @@ -45,18 +45,18 @@ def create_backups
backups.each(&:write)
end

def mbr_is_gpt?
mbr_storage_object = target_map[mbr_disk]
raise "Cannot find in storage mbr disk #{mbr_disk}" unless mbr_storage_object
def is_gpt?(disk)
mbr_storage_object = target_map[disk]
raise "Cannot find in storage mbr disk #{disk}" unless mbr_storage_object
mbr_type = mbr_storage_object["label"]
log.info "mbr type = #{mbr_type}"
mbr_type == "gpt"
end

GPT_MBR = "/usr/share/syslinux/gptmbr.bin".freeze
DOS_MBR = "/usr/share/syslinux/mbr.bin".freeze
def generic_mbr_file
@generic_mbr_file ||= mbr_is_gpt? ? GPT_MBR : DOS_MBR
def generic_mbr_file_for(disk)
@generic_mbr_file ||= is_gpt?(disk) ? GPT_MBR : DOS_MBR
end

def install_generic_mbr
Expand All @@ -65,7 +65,7 @@ def install_generic_mbr
disks_to_rewrite.each do |disk|
log.info "Copying generic MBR code to #{disk}"
# added fix 446 -> 440 for Vista booting problem bnc #396444
command = ["/bin/dd", "bs=440", "count=1", "if=#{generic_mbr_file}", "of=#{disk}"]
command = ["/bin/dd", "bs=440", "count=1", "if=#{generic_mbr_file_for(disk)}", "of=#{disk}"]
Yast::Execute.locally(*command)
end
end
Expand Down Expand Up @@ -95,29 +95,29 @@ def reset_flag(disk, flag)
end
end

def can_activate_partition?(num)
def can_activate_partition?(disk, num)
# if primary partition on old DOS MBR table, GPT do not have such limit
gpt_disk = mbr_is_gpt?
gpt_disk = is_gpt?(disk)

!(Yast::Arch.ppc && gpt_disk) && (gpt_disk || num <= 4)
end

def activate_partitions
partitions_to_activate.each do |m_activate|
num = m_activate["num"]
mbr_dev = m_activate["mbr"]
if num.nil? || mbr_dev.nil?
disk = m_activate["mbr"]
if num.nil? || disk.nil?
raise "INTERNAL ERROR: Data for partition to activate is invalid."
end

next unless can_activate_partition?(num)
next unless can_activate_partition?(disk, num)

log.info "Activating partition #{num} on #{mbr_dev}"
log.info "Activating partition #{num} on #{disk}"
# set corresponding flag only bnc#930903
if mbr_is_gpt?
set_parted_flag(mbr_dev, num, "legacy_boot")
if is_gpt?(disk)
set_parted_flag(disk, num, "legacy_boot")
else
set_parted_flag(mbr_dev, num, "boot")
set_parted_flag(disk, num, "boot")
end
end
end
Expand Down

0 comments on commit a579ff8

Please sign in to comment.