Skip to content

Commit

Permalink
fix activating partitions with number bigger then 4 on GPT disks (bnc…
Browse files Browse the repository at this point in the history
…#875757)
  • Loading branch information
jreidinger committed May 2, 2014
1 parent 40ecbe4 commit a1a2884
Showing 1 changed file with 43 additions and 44 deletions.
87 changes: 43 additions & 44 deletions src/include/bootloader/grub2/misc.rb
Expand Up @@ -112,7 +112,7 @@ def grub_getPartitionToActivate(loader_device)
end

if Ops.greater_than(num, 4)
Builtins.y2milestone("Bootloader partition type is logical")
Builtins.y2milestone("Bootloader partition type can be logical")
tm = Storage.GetTargetMap
partitions = Ops.get_list(tm, [mbr_dev, "partitions"], [])
Builtins.foreach(partitions) do |p|
Expand Down Expand Up @@ -431,50 +431,49 @@ def grub_updateMBR
Builtins.foreach(grub_getPartitionsToActivate) do |m_activate|
num = Ops.get_integer(m_activate, "num", 0)
mbr_dev = Ops.get_string(m_activate, "mbr", "")
if num != 0 && mbr_dev != ""
# if primary partition
if !Ops.is_integer?(num) || Ops.less_or_equal(num, 4)
Builtins.y2milestone("Activating partition %1 on %2", num, mbr_dev)
# FIXME: this is the most rotten code since molded sliced bread
# move to bootloader/Core/GRUB.pm or similar
# TESTME: make sure that parted does not destroy BSD
# slices (#suse24740): cf. section 5.1 of "info parted":
# Parted only supports the BSD disk label system.
# Parted is unlikely to support the partition slice
# system in the future because the semantics are rather
# strange, and don't work like "normal" partition tables
# do.
# FIXED: investigate proper handling of the activate flag
# (kernel ioctls in parted etc.) and fix parted

# this is needed only on gpt disks but we run it always
# anyway; parted just fails, then
command = Builtins.sformat(
"/usr/sbin/parted -s %1 set %2 legacy_boot on",
mbr_dev,
num
)
Builtins.y2milestone("Running command %1", command)
out = Convert.to_map(
WFM.Execute(path(".local.bash_output"), command)
)
Builtins.y2milestone("Command output: %1", out)
raise "INTERNAL ERROR: Data for partition to activate is invalid." if num == 0 || mbr_dev.empty?

gpt_disk = Storage.GetTargetMap[BootCommon.mbrDisk]["label"] == "gpt"
# if primary partition on old DOS MBR table, GPT do not have such limit
if gpt_disk || num <= 4
Builtins.y2milestone("Activating partition %1 on %2", num, mbr_dev)
# FIXME: this is the most rotten code since molded sliced bread
# move to bootloader/Core/GRUB.pm or similar
# TESTME: make sure that parted does not destroy BSD
# slices (#suse24740): cf. section 5.1 of "info parted":
# Parted only supports the BSD disk label system.
# Parted is unlikely to support the partition slice
# system in the future because the semantics are rather
# strange, and don't work like "normal" partition tables
# do.
# FIXED: investigate proper handling of the activate flag
# (kernel ioctls in parted etc.) and fix parted

# this is needed only on gpt disks but we run it always
# anyway; parted just fails, then
command = Builtins.sformat(
"/usr/sbin/parted -s %1 set %2 legacy_boot on",
mbr_dev,
num
)
Builtins.y2milestone("Running command %1", command)
out = Convert.to_map(
WFM.Execute(path(".local.bash_output"), command)
)
Builtins.y2milestone("Command output: %1", out)

command = Builtins.sformat(
"/usr/sbin/parted -s %1 set %2 boot on",
mbr_dev,
num
)
Builtins.y2milestone("Running command %1", command)
out = Convert.to_map(
WFM.Execute(path(".local.bash_output"), command)
)
exit = Ops.get_integer(out, "exit", 0)
Builtins.y2milestone("Command output: %1", out)
ret = ret && 0 == exit
end
else
Builtins.y2error("Cannot activate %1", m_activate)
command = Builtins.sformat(
"/usr/sbin/parted -s %1 set %2 boot on",
mbr_dev,
num
)
Builtins.y2milestone("Running command %1", command)
out = Convert.to_map(
WFM.Execute(path(".local.bash_output"), command)
)
exit = Ops.get_integer(out, "exit", 0)
Builtins.y2milestone("Command output: %1", out)
ret = ret && 0 == exit
end
end if activate
ret
Expand Down

0 comments on commit a1a2884

Please sign in to comment.