Class: Yast::PartitionsClass
- Inherits:
-
Module
- Object
- Module
- Yast::PartitionsClass
- Defined in:
- ../../src/modules/Partitions.rb
Instance Method Summary (collapse)
- - (Object) assertInit
- - (Object) BootCyl
- - (Object) BootMount
- - (Object) BootPrimary
- - (Object) BootSizeK
-
- (Object) CurMounted
Return a list with all mounted partition @return [Array].
- - (Object) DefaultBootFs
- - (Object) DefaultFs
- - (Object) EfiBoot
- - (Object) FsidBoot
- - (Object) FsIdToString(fs_id)
- - (Object) GetCrypto(pathname)
- - (Object) GetFstab(pathname)
- - (Object) GetLoopOn(device)
- - (Object) HasExtended(dlabel)
- - (Object) InitSlib(value)
- - (Object) IsDosPartition(fsid)
- - (Object) IsDosWinNtPartition(fsid)
- - (Object) IsExtendedPartition(fsid)
- - (Object) IsLinuxPartition(fsid)
- - (Object) IsResizable(fsid)
- - (Object) IsSwapPartition(fsid)
- - (Object) main
- - (Object) MaximalBootsize
- - (Object) MaxLogical(dlabel)
- - (Object) MaxPrimary(dlabel)
- - (Object) MaxSectors(dlabel)
- - (Object) MinimalBootsize
- - (Object) MinimalNeededBootsize
- - (Object) NeedBoot
- - (Object) PrepBoot
- - (Object) ProposedBootsize
- - (Object) RdonlyText(disk, expert_partitioner)
- - (Object) SetDefaultFs(new_default_fs)
- - (Object) SwapSizeMb(slot_size, suspend)
- - (Object) SwapSizeMbforSuspend
- - (Object) SwapSizeMbforSwap(slot_size)
- - (Object) ToHexString(num)
- - (Object) TranslateMapperName(device)
Instance Method Details
- (Object) assertInit
132 133 134 135 136 137 138 139 |
# File '../../src/modules/Partitions.rb', line 132 def assertInit if @sint == nil @sint = StorageInit.CreateInterface(false) Builtins.y2error("StorageInit::CreateInterface failed") if @sint == nil end nil end |
- (Object) BootCyl
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File '../../src/modules/Partitions.rb', line 245 def BootCyl if @boot_cyl == 0 @boot_cyl = 1024 if !Arch.i386 # Assume on non-i386 archs machine can boot from every cylinder @boot_cyl = 4 * 1024 * 1024 * 1024 else internal_bios = Convert.convert( SCR.Read(path(".probe.bios")), :from => "any", :to => "list <map>" ) lba = Ops.get_boolean(internal_bios, [0, "lba_support"], false) Builtins.y2milestone("BootCyl lba_support %1", lba) if !lba st = Convert.to_map( SCR.Read(path(".target.stat"), "/proc/xen/capabilities") ) Builtins.y2milestone("BootCyl /proc/xen/capabilities %1", st) if Ops.greater_than(Builtins.size(st), 0) lba = Ops.greater_than( Convert.to_integer( SCR.Execute( path(".target.bash"), "grep control_d /proc/xen/capabilities" ) ), 0 ) end Builtins.y2milestone("BootCyl lba_support %1", lba) end @boot_cyl = 4 * 1024 * 1024 * 1024 if lba end end @boot_cyl end |
- (Object) BootMount
192 193 194 195 196 197 198 |
# File '../../src/modules/Partitions.rb', line 192 def BootMount if @boot_mount_point == "" @boot_mount_point = "/boot" @boot_mount_point = "/boot/efi" if EfiBoot() end @boot_mount_point end |
- (Object) BootPrimary
293 294 295 296 |
# File '../../src/modules/Partitions.rb', line 293 def BootPrimary ret = PrepBoot() ret end |
- (Object) BootSizeK
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File '../../src/modules/Partitions.rb', line 201 def BootSizeK if Builtins.isempty(@boot_size_k) @boot_size_k = { :proposed => 400 * 1024, :minimal => 90 * 1024, :maximal => 750 * 1024 } Ops.set(@boot_size_k, :proposed, 150 * 1024) if EfiBoot() if Arch.ia64 Ops.set(@boot_size_k, :proposed, 200 * 1024) Ops.set(@boot_size_k, :minimal, 180 * 1024) elsif Arch.board_chrp || Arch.board_prep || Arch.board_iseries Ops.set(@boot_size_k, :proposed, 200 * 1024) Ops.set(@boot_size_k, :minimal, 180 * 1024) elsif Arch.board_mac Ops.set(@boot_size_k, :proposed, 32 * 1024) Ops.set(@boot_size_k, :minimal, 800) end Builtins.y2milestone("BootSizeK boot_size_k:%1", @boot_size_k) end deep_copy(@boot_size_k) end |
- (Object) CurMounted
Return a list with all mounted partition @return [Array<Hash>]
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 |
# File '../../src/modules/Partitions.rb', line 520 def CurMounted SCR.UnmountAgent(path(".proc.mounts")) SCR.UnmountAgent(path(".proc.swaps")) SCR.UnmountAgent(path(".etc.mtab")) mounts = Convert.convert( SCR.Read(path(".proc.mounts")), :from => "any", :to => "list <map>" ) swaps = Convert.convert( SCR.Read(path(".proc.swaps")), :from => "any", :to => "list <map>" ) mtab = Convert.convert( SCR.Read(path(".etc.mtab")), :from => "any", :to => "list <map>" ) if mounts == nil || swaps == nil || mtab == nil Builtins.y2error( "failed to read .proc.mounts or .proc.swaps or .etc.mtab" ) return [] end Builtins.foreach(swaps) do |swap| swap_entry = { "file" => "swap", "spec" => Ops.get_string(swap, "file", "") } mounts = Builtins.add(mounts, swap_entry) end mtab_root = Builtins.find(mtab) do |mount| Ops.get_string(mount, "file", "") == "/" end root_map = Builtins.find(mounts) do |mount| Ops.get_string(mount, "spec", "") == "/dev/root" end root_map = Builtins.find(mounts) do |mount| Ops.get_string(mount, "spec", "") != "rootfs" && Ops.get_string(mount, "file", "") == "/" end if root_map == nil Builtins.y2milestone("mtab_root %1 root_map %2", mtab_root, root_map) # root_map = add (root_map, "spec", mtab_root["spec"]:""); if Ops.get_string(root_map, "spec", "") == "/dev/root" Ops.set(root_map, "spec", Ops.get_string(mtab_root, "spec", "")) end if (Builtins.search(Ops.get_string(root_map, "spec", ""), "LABEL=") == 0 || Builtins.search(Ops.get_string(root_map, "spec", ""), "UUID=") == 0) && !Stage.initial bo = Convert.to_map( SCR.Execute(path(".target.bash_output"), "fsck -N /", {}) ) Builtins.y2milestone("CurMounted bo:%1", bo) dev = "" if Ops.get_integer(bo, "exit", 1) == 0 tmp = Builtins.filter( Builtins.splitstring(Ops.get_string(bo, "stdout", ""), " \n") ) { |k| Ops.greater_than(Builtins.size(k), 0) } if Ops.greater_than(Builtins.size(tmp), 0) dev = Ops.get_string(tmp, Ops.subtract(Builtins.size(tmp), 1), "") end Builtins.y2milestone("CurMounted LABEL/UUID dev:%1", dev) end if Ops.greater_than(Builtins.size(dev), 0) Ops.set(root_map, "spec", dev) end end Builtins.y2milestone("root_map %1", root_map) # this version makes some problems with interpreter, above lookup/add is OK mounts = Builtins.filter(mounts) do |mount| Ops.get_string(mount, "file", "") != "/" end mounts = Builtins.add(mounts, root_map) ret = [] Builtins.foreach(mounts) do |p| if Builtins.search(Ops.get_string(p, "spec", ""), "/dev/loop") != nil r = GetLoopOn(Ops.get_string(p, "spec", "")) if Ops.get_boolean(r, "blockdev", false) Ops.set(p, "loop_on", Ops.get_string(r, "file", "")) end end ret = Builtins.add(ret, p) end ret = Builtins.maplist(ret) do |p| Ops.set(p, "spec", TranslateMapperName(Ops.get_string(p, "spec", ""))) deep_copy(p) end Builtins.y2milestone("CurMounted all mounts %1", ret) deep_copy(ret) end |
- (Object) DefaultBootFs
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File '../../src/modules/Partitions.rb', line 175 def DefaultBootFs if @default_boot_fs == :unknown if DefaultFs() != :btrfs @default_boot_fs = DefaultFs() else @default_boot_fs = :ext4 end if EfiBoot() @default_boot_fs = :vfat elsif Arch.board_mac @default_boot_fs = :hfs end end @default_boot_fs end |
- (Object) DefaultFs
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File '../../src/modules/Partitions.rb', line 158 def DefaultFs if @default_fs == :unknown tmp = Convert.to_string(SCR.Read(path(".sysconfig.storage.DEFAULT_FS"))) if tmp == nil || !Builtins.contains( ["ext2", "ext3", "ext4", "reiser", "xfs", "btrfs"], Builtins.tolower(tmp) ) tmp = "ext4" end @default_fs = Builtins.tosymbol(Builtins.tolower(tmp)) end @default_fs end |
- (Object) EfiBoot
142 143 144 145 146 147 |
# File '../../src/modules/Partitions.rb', line 142 def EfiBoot assertInit ret = @sint.getEfiBoot Builtins.y2milestone("EfiBoot ret:%1", ret) ret end |
- (Object) FsidBoot
299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File '../../src/modules/Partitions.rb', line 299 def FsidBoot if @fsid_boot == 0 @fsid_boot = @fsid_native if EfiBoot() || Arch.ia64 @fsid_boot = @fsid_gpt_boot elsif PrepBoot() @fsid_boot = @fsid_prep_chrp_boot elsif Arch.board_mac @fsid_boot = @fsid_mac_hfs end end @fsid_boot end |
- (Object) FsIdToString(fs_id)
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 |
# File '../../src/modules/Partitions.rb', line 656 def FsIdToString(fs_id) case fs_id when 0 return "empty" when 1 return "FAT12" when 2 return "XENIX root" when 3 return "XENIX usr" when 4 return "FAT16 <32M" when 5 return "Extended" when 6 return "FAT16" when 7 return "HPFS/NTFS" when 8 return "AIX" when 9 return "AIX boot" when 10 return "OS/2 boot manager" when 11 return "Win95 FAT32" when 12 return "Win95 FAT32 LBA" when 14 return "Win95 FAT16" when 15 return "Extended" when 167 return "NeXTSTEP" when 183 return "BSDI fs" when 184 return "BSDI swap" when 193 return "DRDOS/sec" when 196 return "DRDOS/sec" when 198 return "DRDOS/sec" when 199 return "Syrinx" when 218 return "Non-Fs data" when 219 return "CP/M / CTOS" when 222 return "Dell Utility" when 225 return "DOS access" when 227 return "DOS R/O" when 228 return "SpeedStor" when 235 return "BeOS fs" when 238 return "EFI GPT" when 239 return "EFI (FAT-12/16)" when 241 return "SpeedStor" when 244 return "SpeedStor" when 242 return "DOS secondary" when 253 return "Linux RAID" when 254 return "LANstep" when 255 return "BBT or NBO reserved" when 16 return "OPUS" when 17 return "Hidden FAT12" when 18 return "Vendor diag" when 20 return "Hidden FAT16" when 22 return "Hidden FAT16" when 23 return "Hidden HPFS/NTFS" when 24 return "AST Windows" when 27 return "Hidden Win95" when 28 return "Hidden Win95" when 30 return "Hidden Win95" when 36 return "NEC DOS" when 57 return "Plan 9" when 60 return "PartitionMagic" when 64 return "Venix 80286" when 65 return "PPC PReP Boot" when 66 return "SFS" when 77 return "QNX4.x" when 78 return "QNX4.x 2nd par" when 79 return "QNX4.x 3rd par" when 80 return "OnTrack DM" when 81 return "OnTrack DM6" when 82 return "CP/M" when 83 return "OnTrack DM6" when 84 return "OnTrack DM6" when 85 return "EZ-Drive" when 86 return "Golden Bow" when 92 return "Priam Edisk" when 97 return "SpeedStor" when 99 return "GNU HURD" when 100 return "Novell NetWare" when 101 return "Novell NetWare" when 112 return "DiskSecure" when 117 return "PC/IX" when 128 return "Old Minix" when 129 return "Minix" when 130 return "Linux swap" when 131 return "Linux native" when 132 return "OS/2 hidden" when 133 return "Linux extended" when 134 return "NTFS volume" when 135 return "NTFS volume" when 142 return "Linux LVM" when 147 return "Amoeba" when 148 return "Amoeba BBT" when 159 return "BSD/OS" when 160 return "Hibernation" when 165 return "FreeBSD" when 166 return "OpenBSD" when 169 return "NetBSD" when 258 return "Apple_HFS" when 259 return "EFI boot" when 260 return "Service" when 261 return "Microsoft reserved" when 262 return "Apple_UFS" when 263 return "BIOS Grub" else return "unknown" end end |
- (Object) GetCrypto(pathname)
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
# File '../../src/modules/Partitions.rb', line 633 def GetCrypto(pathname) file = {} file_ref = arg_ref(file) AsciiFile.SetComment(file_ref, "^[ \t]*#") file = file_ref.value file_ref = arg_ref(file) AsciiFile.SetDelimiter(file_ref, " \t") file = file_ref.value file_ref = arg_ref(file) AsciiFile.SetListWidth(file_ref, [11, 15, 20, 10, 10, 1]) file = file_ref.value file_ref = arg_ref(file) AsciiFile.ReadFile(file_ref, pathname) file = file_ref.value deep_copy(file) end |
- (Object) GetFstab(pathname)
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 |
# File '../../src/modules/Partitions.rb', line 616 def GetFstab(pathname) file = {} file_ref = arg_ref(file) AsciiFile.SetComment(file_ref, "^[ \t]*#") file = file_ref.value file_ref = arg_ref(file) AsciiFile.SetDelimiter(file_ref, " \t") file = file_ref.value file_ref = arg_ref(file) AsciiFile.SetListWidth(file_ref, [20, 20, 10, 21, 1, 1]) file = file_ref.value file_ref = arg_ref(file) AsciiFile.ReadFile(file_ref, pathname) file = file_ref.value deep_copy(file) end |
- (Object) GetLoopOn(device)
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
# File '../../src/modules/Partitions.rb', line 441 def GetLoopOn(device) ret = {} cmd = Builtins.sformat("/sbin/losetup %1", device) bash_call = Convert.to_map( SCR.Execute(path(".target.bash_output"), cmd, {}) ) if Ops.get_integer(bash_call, "exit", 1) == 0 text = Ops.get_string(bash_call, "stdout", "") fi = Builtins.search(text, ")") if fi != nil && Ops.greater_than(fi, 0) text = Builtins.substring(text, 0, fi) fi = Builtins.search(text, "(") if fi != nil && Ops.greater_than(fi, 0) text = Builtins.substring(text, Ops.add(fi, 1)) Ops.set(ret, "file", text) stat = Convert.to_map(SCR.Read(path(".target.stat"), text)) Ops.set(ret, "blockdev", Ops.get_boolean(stat, "isblock", false)) end end end Builtins.y2milestone("dev %1 ret %2", device, ret) deep_copy(ret) end |
- (Object) HasExtended(dlabel)
860 861 862 863 864 865 866 867 868 869 |
# File '../../src/modules/Partitions.rb', line 860 def HasExtended(dlabel) ret = false assertInit caps = ::Storage::DlabelCapabilities.new() if( @sint.getDlabelCapabilities( dlabel, caps)) ret = caps.extendedPossible end Builtins.y2milestone("HasExtended dlabel:%1 ret:%2", dlabel, ret) ret end |
- (Object) InitSlib(value)
127 128 129 130 |
# File '../../src/modules/Partitions.rb', line 127 def InitSlib(value) @sint = value nil end |
- (Object) IsDosPartition(fsid)
324 325 326 327 |
# File '../../src/modules/Partitions.rb', line 324 def IsDosPartition(fsid) Builtins.contains(@fsid_dostypes, fsid) || Builtins.contains(@fsid_wintypes, fsid) end |
- (Object) IsDosWinNtPartition(fsid)
329 330 331 |
# File '../../src/modules/Partitions.rb', line 329 def IsDosWinNtPartition(fsid) IsDosPartition(fsid) || Builtins.contains(@fsid_ntfstypes, fsid) end |
- (Object) IsExtendedPartition(fsid)
333 334 335 |
# File '../../src/modules/Partitions.rb', line 333 def IsExtendedPartition(fsid) fsid == @fsid_extended || fsid == @fsid_extended_win end |
- (Object) IsLinuxPartition(fsid)
435 436 437 438 439 |
# File '../../src/modules/Partitions.rb', line 435 def IsLinuxPartition(fsid) fsid == @fsid_native || fsid == @fsid_swap || fsid == @fsid_lvm || fsid == @fsid_raid || fsid == @fsid_gpt_boot end |
- (Object) IsResizable(fsid)
426 427 428 429 430 431 432 433 |
# File '../../src/modules/Partitions.rb', line 426 def IsResizable(fsid) ret = false ret = IsDosWinNtPartition(fsid) || fsid == @fsid_swap || fsid == @fsid_native || IsExtendedPartition(fsid) Builtins.y2milestone("IsResizable fsid:%1 ret:%2", fsid, ret) ret end |
- (Object) IsSwapPartition(fsid)
337 338 339 |
# File '../../src/modules/Partitions.rb', line 337 def IsSwapPartition(fsid) !IsDosWinNtPartition(fsid) && fsid == @fsid_swap end |
- (Object) main
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File '../../src/modules/Partitions.rb', line 35 def main textdomain "storage" Yast.import "Arch" Yast.import "Mode" Yast.import "Stage" Yast.import "AsciiFile" Yast.import "StorageInit" # The filesystem ids for the partitions @fsid_empty = 0 @fsid_native = 131 @fsid_swap = 130 @fsid_lvm = 142 @fsid_raid = 253 @fsid_hibernation = 160 @fsid_extended = 5 @fsid_extended_win = 15 @fsid_fat16 = 6 @fsid_fat32 = 12 @fsid_prep_chrp_boot = 65 @fsid_mac_hidden = 257 @fsid_mac_hfs = 258 @fsid_mac_ufs = 262 @fsid_gpt_boot = 259 @fsid_gpt_service = 260 @fsid_gpt_msftres = 261 @fsid_bios_grub = 263 @fsid_freebsd = 165 @fsid_openbsd = 166 @fsid_netbsd = 169 @fsid_beos = 235 @fsid_solaris = 191 @fsid_root = @fsid_native @fsid_boot = 0 @boot_cyl = 0 @boot_mount_point = "" @memory_size = 0 @no_fsid_menu = Arch.s390 @raid_name = "MD RAID" @lv_name = "LV" @dm_name = "DM" @loop_name = "Loop Device" @dmraid_name = "DM RAID" @dmmultipath_name = "DM Multipath" @nfs_name = "NFS" @btrfs_name = "BTRFS" @tmpfs_name = "TMPFS" # filesystems for /win @fsid_wintypes = [6, 11, 12, 14] # FAT32, Win95-Fat32, Win95LBA, Win95-Fat16 # filesystems for /dos @fsid_dostypes = [1, 4] # FAT12, FAT16 # filesystems for /windows @fsid_ntfstypes = [7, 23] # NTFS # filesystems mounted read-only @fsid_readonly = [7, 23] # filesystems skipped on sparc and axp @fsid_skipped = [0, 5] # partition ids not to delete when suggesting to use whole disk @do_not_delete = [18, 222, @fsid_mac_hfs, @fsid_gpt_service] # partition ids not to display as windows when fat32 is on it @no_windows = [ 18, 130, 222, @fsid_gpt_boot, @fsid_gpt_service, @fsid_gpt_msftres ] @boot_size_k = {} @default_fs = :unknown @default_boot_fs = :unknown @sint = nil @prep_boot_first = true end |
- (Object) MaximalBootsize
240 241 242 |
# File '../../src/modules/Partitions.rb', line 240 def MaximalBootsize Ops.multiply(1024, Ops.get(BootSizeK(), :maximal, 0)) end |
- (Object) MaxLogical(dlabel)
872 873 874 875 876 877 878 879 880 881 |
# File '../../src/modules/Partitions.rb', line 872 def MaxLogical(dlabel) ret = 0 assertInit caps = ::Storage::DlabelCapabilities.new() if( @sint.getDlabelCapabilities( dlabel, caps)) ret = caps.maxLogical end Builtins.y2milestone("MaxLogical dlabel:%1 ret:%2", dlabel, ret) ret end |
- (Object) MaxPrimary(dlabel)
848 849 850 851 852 853 854 855 856 857 |
# File '../../src/modules/Partitions.rb', line 848 def MaxPrimary(dlabel) ret = 0 assertInit caps = ::Storage::DlabelCapabilities.new() if( @sint.getDlabelCapabilities(dlabel, caps)) ret = caps.maxPrimary end Builtins.y2milestone("MaxPrimary dlabel:%1 ret:%2", dlabel, ret) ret end |
- (Object) MaxSectors(dlabel)
884 885 886 887 888 889 890 891 892 893 |
# File '../../src/modules/Partitions.rb', line 884 def MaxSectors(dlabel) ret = 0 assertInit caps = ::Storage::DlabelCapabilities.new() if( @sint.getDlabelCapabilities( dlabel, caps)) ret = caps.maxSectors end Builtins.y2milestone("MaxSizeK dlabel:%1 ret:%2", dlabel, ret) ret end |
- (Object) MinimalBootsize
236 237 238 |
# File '../../src/modules/Partitions.rb', line 236 def MinimalBootsize Ops.multiply(1024, Ops.get(BootSizeK(), :minimal, 0)) end |
- (Object) MinimalNeededBootsize
228 229 230 |
# File '../../src/modules/Partitions.rb', line 228 def MinimalNeededBootsize Ops.multiply(1024, Ops.get(BootSizeK(), :proposed, 0)) end |
- (Object) NeedBoot
314 315 316 317 318 319 320 321 |
# File '../../src/modules/Partitions.rb', line 314 def NeedBoot ret = false if EfiBoot() || Arch.ia64 || Arch.ppc || Arch.sparc || Arch.alpha ret = true end Builtins.y2milestone("NeedBoot ret:%1", ret) ret end |
- (Object) PrepBoot
283 284 285 286 287 288 289 290 291 |
# File '../../src/modules/Partitions.rb', line 283 def PrepBoot ret = Arch.ppc && (Arch.board_chrp || Arch.board_prep || Arch.board_iseries) if ret && @prep_boot_first Builtins.y2milestone("PrepBoot ret:%1", ret) @prep_boot_first = false end ret end |
- (Object) ProposedBootsize
232 233 234 |
# File '../../src/modules/Partitions.rb', line 232 def ProposedBootsize Ops.multiply(1024, Ops.get(BootSizeK(), :proposed, 0)) end |
- (Object) RdonlyText(disk, expert_partitioner)
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 |
# File '../../src/modules/Partitions.rb', line 896 def RdonlyText(disk, expert_partitioner) disk = deep_copy(disk) text = "" if expert_partitioner text = Builtins.sformat( _("Operation not permitted on disk %1.\n"), Ops.get_string(disk, "device", "") ) end if !Ops.get_boolean(disk, "has_fake_partition", false) # popup text %1 is replaced by disk name e.g. /dev/hda text = Ops.add( text, Builtins.sformat( _( "\n" + "The partitioning on your disk %1 is either not readable or not \n" + "supported by the partitioning tool parted used to change the\n" + "partition table.\n" + "\n" + "You can use the partitions on disk %1 as they are or\n" + "format them and assign mount points, but you cannot add, edit, \n" + "resize, or remove partitions from that disk here.\n" ), Ops.get_string(disk, "device", "") ) ) else # popup text %1 is replaced by disk name e.g. /dev/dasda text = Ops.add( text, Builtins.sformat( _( "\n" + "The disk %1 does not contain a partition table but for\n" + "compatibility the kernel has automatically generated a\n" + "partition spanning almost the entire disk.\n" + "\n" + "You can use the partition on disk %1 as it is or\n" + "format it and assign a mount point, but you cannot resize\n" + "or remove the partition from that disk here.\n" ), Ops.get_string(disk, "device", "") ) ) end if expert_partitioner # popup text text = Ops.add( text, _( "\n" + "\n" + "You can initialize the disk partition table to a sane state in the Expert\n" + "Partitioner by selecting \"Expert\"->\"Create New Partition Table\", \n" + "but this will destroy all data on all partitions of this disk.\n" ) ) else # popup text text = Ops.add( text, _( "\n" + "\n" + "Safely ignore this message if you do not intend to use \n" + "this disk during installation.\n" ) ) end text end |
- (Object) SetDefaultFs(new_default_fs)
150 151 152 153 154 155 |
# File '../../src/modules/Partitions.rb', line 150 def SetDefaultFs(new_default_fs) @default_fs = new_default_fs @default_boot_fs = :unknown nil end |
- (Object) SwapSizeMb(slot_size, suspend)
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File '../../src/modules/Partitions.rb', line 404 def SwapSizeMb(slot_size, suspend) if @memory_size == 0 mem_info_map = Convert.to_map(SCR.Read(path(".proc.meminfo"))) @memory_size = Ops.divide( Ops.get_integer(mem_info_map, "memtotal", 0), 1024 ) Builtins.y2milestone( "mem_info_map:%1 mem:%2", mem_info_map, @memory_size ) end sw = SwapSizeMbforSwap(slot_size) if suspend news = SwapSizeMbforSuspend() sw = news if Ops.greater_than(news, sw) end Builtins.y2milestone("SwapSizeMb suspend:%1 ret:%2", suspend, sw) sw end |
- (Object) SwapSizeMbforSuspend
398 399 400 401 402 |
# File '../../src/modules/Partitions.rb', line 398 def SwapSizeMbforSuspend ret = Ops.multiply(Ops.divide(Ops.add(@memory_size, 511), 512), 512) Builtins.y2milestone("SwapSizeMbforSuspend %1", ret) ret end |
- (Object) SwapSizeMbforSwap(slot_size)
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
# File '../../src/modules/Partitions.rb', line 341 def SwapSizeMbforSwap(slot_size) swap_size = 0 if slot_size == 0 if Ops.less_or_equal(@memory_size, 256) swap_size = Ops.multiply(@memory_size, 2) else swap_size = Ops.add(@memory_size, Ops.divide(@memory_size, 2)) end else if Ops.less_than(Ops.multiply(@memory_size, 9), slot_size) swap_size = Ops.multiply(@memory_size, 2) elsif Ops.less_than(Ops.multiply(@memory_size, 5), slot_size) swap_size = @memory_size elsif Ops.less_than(Ops.multiply(@memory_size, 3), slot_size) swap_size = Ops.divide(@memory_size, 2) elsif Ops.less_than(Ops.multiply(@memory_size, 2), slot_size) swap_size = Ops.divide(@memory_size, 3) else swap_size = Ops.divide(@memory_size, 4) end end swap_size = 2048 if Ops.greater_than(swap_size, 2048) swap_size = 0 if Ops.less_than(swap_size, 0) # look for a min size # 1G -> 128MB # 2G -> 256MB # 10G -> 512MB # 40G -> 1GB if Ops.greater_than(slot_size, 40 * 1024) && Ops.less_than(Ops.add(swap_size, @memory_size), 1024) swap_size = Ops.subtract(1024, @memory_size) elsif Ops.greater_than(slot_size, 10 * 1024) && Ops.less_than(Ops.add(swap_size, @memory_size), 512) swap_size = Ops.subtract(512, @memory_size) elsif Ops.greater_than(slot_size, 2 * 1024) && Ops.less_than(Ops.add(swap_size, @memory_size), 256) swap_size = Ops.subtract(256, @memory_size) elsif Ops.greater_than(slot_size, 1 * 1024) && Ops.less_than(Ops.add(swap_size, @memory_size), 128) swap_size = Ops.subtract(128, @memory_size) end swap_size = -1 if swap_size == 0 Builtins.y2milestone( "SwapSizeMbforSwap mem %1 slot_size %2 swap_size %3", @memory_size, slot_size, swap_size ) swap_size end |
- (Object) ToHexString(num)
651 652 653 |
# File '../../src/modules/Partitions.rb', line 651 def ToHexString(num) sprintf("0x%02X", num) end |
- (Object) TranslateMapperName(device)
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File '../../src/modules/Partitions.rb', line 465 def TranslateMapperName(device) ret = device regex = "[^-](--)*-[^-]" if Builtins.search(device, "/dev/mapper/") == 0 pos = Builtins.regexppos(device, regex) Builtins.y2milestone("pos=%1", pos) if Ops.greater_than(Builtins.size(pos), 0) ret = Ops.add( Ops.add( Ops.add( "/dev/", Builtins.substring( device, 12, Ops.subtract( Ops.add(Ops.get(pos, 0, 0), Ops.get(pos, 1, 0)), 14 ) ) ), "/" ), Builtins.substring( device, Ops.subtract(Ops.add(Ops.get(pos, 0, 0), Ops.get(pos, 1, 0)), 1) ) ) spos = 4 newpos = Builtins.search(Builtins.substring(ret, spos), "--") if newpos != nil spos = Ops.add(spos, newpos) else spos = -1 end while Ops.greater_or_equal(spos, 0) ret = Ops.add( Builtins.substring(ret, 0, Ops.add(spos, 1)), Builtins.substring(ret, Ops.add(spos, 2)) ) spos = Ops.add(spos, 1) newpos = Builtins.search(Builtins.substring(ret, spos), "--") if newpos != nil spos = Ops.add(spos, newpos) else spos = -1 end end end Builtins.y2milestone("TranslateMapperName %1 -> %2", device, ret) end ret end |