Module: Yast::BootloaderRoutinesI386Include
- Defined in:
- src/include/bootloader/routines/i386.rb
Instance Method Summary (collapse)
-
- (Object) GetMBRContents(disk)
Get the contents of the MBR of a disk.
- - (Object) initialize_bootloader_routines_i386(include_target)
-
- (Boolean) PostUpdateMBR
Do updates of MBR after the bootloader is installed.
-
- (Boolean) ThinkPadMBR(disk)
Does MBR of the disk contain special IBM ThinkPad stuff?.
Instance Method Details
- (Object) GetMBRContents(disk)
Get the contents of the MBR of a disk
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'src/include/bootloader/routines/i386.rb', line 54 def GetMBRContents(disk) if @_old_mbr == nil || disk != @_old_mbr_disk @_old_mbr_disk = disk out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("dd if=%1 bs=512 count=1 | od -v -t x1 -", disk) ) ) if Ops.get_integer(out, "exit", 0) != 0 Builtins.y2error("Reading MBR contents failed") return nil end mbr = Ops.get_string(out, "stdout", "") mbrl = Builtins.splitstring(mbr, "\n") mbrl = Builtins.maplist(mbrl) do |s| l = Builtins.splitstring(s, " ") Ops.set(l, 0, "") Builtins.mergestring(l, "") end mbr = Builtins.mergestring(mbrl, "") Builtins.y2debug("MBR contents: %1", mbr) @_old_mbr = mbr end @_old_mbr end |
- (Object) initialize_bootloader_routines_i386(include_target)
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'src/include/bootloader/routines/i386.rb', line 23 def initialize_bootloader_routines_i386(include_target) textdomain "bootloader" # general MBR reading cache # The last disk that was checked for the sequence @_old_mbr_disk = nil # Contents of the last read MBR @_old_mbr = nil # info about ThinkPad # Does MBR contain special thinkpadd stuff? @_thinkpad_mbr = nil # The last disk that was checked for the sequence @_old_thinkpad_disk = nil # Info about keeping MBR contents # Keep the MBR contents? @_keep_mbr = nil # Sequence specific for IBM ThinkPad laptops, see bug 86762 @thinkpad_seq = "50e46124108ae0e461241038e074f8e2f458c332edb80103ba8000cd13c3be05068a04240cc0e802c3" end |
- (Boolean) PostUpdateMBR
Do updates of MBR after the bootloader is installed
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'src/include/bootloader/routines/i386.rb', line 110 def PostUpdateMBR ret = true if ThinkPadMBR(@mbrDisk) if @loader_device != @mbrDisk command = Builtins.sformat("/usr/lib/YaST2/bin/tp_mbr %1", @mbrDisk) Builtins.y2milestone("Running command %1", command) out = Convert.to_map( SCR.Execute(path(".target.bash_output"), command) ) exit = Ops.get_integer(out, "exit", 0) Builtins.y2milestone("Command output: %1", out) ret = ret && 0 == exit end end ret end |
- (Boolean) ThinkPadMBR(disk)
Does MBR of the disk contain special IBM ThinkPad stuff?
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'src/include/bootloader/routines/i386.rb', line 84 def ThinkPadMBR(disk) if @_thinkpad_mbr == nil || disk != @_old_thinkpad_disk @_old_thinkpad_disk = disk mbr = GetMBRContents(disk) x02 = Builtins.tointeger(Ops.add("0x", Builtins.substring(mbr, 4, 2))) x03 = Builtins.tointeger(Ops.add("0x", Builtins.substring(mbr, 6, 2))) x0e = Builtins.substring(mbr, 28, 2) x0f = Builtins.substring(mbr, 30, 2) Builtins.y2debug("Data: %1 %2 %3 %4", x02, x03, x0e, x0f) @_thinkpad_mbr = Ops.less_or_equal(2, x02) && Ops.less_or_equal(x02, Builtins.tointeger("0x63")) && Ops.less_or_equal(2, x03) && Ops.less_or_equal(x03, Builtins.tointeger("0x63")) && Builtins.tolower(x0e) == "4e" && Builtins.tolower(x0f) == "50" end Builtins.y2milestone( "MBR of %1 contains ThinkPad sequence: %2", disk, @_thinkpad_mbr ) @_thinkpad_mbr end |