Class: Yast::PartitionsClass
- Inherits:
-
Module
- Object
- Module
- Yast::PartitionsClass
- Includes:
- Logger
- Defined in:
- ../../src/modules/Partitions.rb
Instance Method Summary (collapse)
- - (Object) assertInit
- - (Object) BootCyl
- - (Object) BootMount
-
- (boolean) BootPrimary
True iff the boot partition must be a primary partition (with MSDOS disk label).
- - (Object) BootSizeK
-
- (Object) CurMounted
Return a list with all mounted partition @return [Array].
- - (Object) DefaultBootFs
- - (Object) DefaultFs
- - (Object) DefaultHomeFs
- - (Object) EfiBoot
- - (Object) FsidBoot(dlabel)
- - (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) IsPrepPartition(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) SetDefaultHomeFs(new_default_home_fs)
- - (Object) SwapSizeMb(slot_size, suspend)
- - (Object) SwapSizeMbforSuspend
- - (Object) SwapSizeMbforSwap(slot_size)
- - (Object) ToHexString(num)
- - (Object) TranslateMapperName(device)
Instance Method Details
- (Object) assertInit
137 138 139 140 141 142 143 144 |
# File '../../src/modules/Partitions.rb', line 137 def assertInit if @sint == nil @sint = StorageInit.CreateInterface(false) Builtins.y2error("StorageInit::CreateInterface failed") if @sint == nil end nil end |
- (Object) BootCyl
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File '../../src/modules/Partitions.rb', line 266 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
209 210 211 212 213 214 215 216 |
# File '../../src/modules/Partitions.rb', line 209 def BootMount if @boot_mount_point == "" @boot_mount_point = "/boot" @boot_mount_point = "/boot/efi" if EfiBoot() @boot_mount_point = "/boot/zipl" if Arch.s390 end @boot_mount_point end |
- (boolean) BootPrimary
Returns true iff the boot partition must be a primary partition (with MSDOS disk label)
318 319 320 |
# File '../../src/modules/Partitions.rb', line 318 def BootPrimary() return PrepBoot() end |
- (Object) BootSizeK
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File '../../src/modules/Partitions.rb', line 219 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, 8032 ) Ops.set(@boot_size_k, :minimal, 8032 ) elsif Arch.board_mac Ops.set(@boot_size_k, :proposed, 32 * 1024) Ops.set(@boot_size_k, :minimal, 800) elsif Arch.s390 Ops.set(@boot_size_k, :proposed, 200 * 1024) Ops.set(@boot_size_k, :minimal, 100 * 1024) 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>]
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 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 |
# File '../../src/modules/Partitions.rb', line 547 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
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File '../../src/modules/Partitions.rb', line 180 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 elsif Arch.s390 @default_boot_fs = :ext2 end end @default_boot_fs end |
- (Object) DefaultFs
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File '../../src/modules/Partitions.rb', line 163 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) DefaultHomeFs
199 200 201 |
# File '../../src/modules/Partitions.rb', line 199 def DefaultHomeFs() @default_home_fs end |
- (Object) EfiBoot
147 148 149 150 151 152 |
# File '../../src/modules/Partitions.rb', line 147 def EfiBoot assertInit ret = @sint.getEfiBoot Builtins.y2milestone("EfiBoot ret:%1", ret) ret end |
- (Object) FsidBoot(dlabel)
323 324 325 326 327 328 329 330 331 332 333 |
# File '../../src/modules/Partitions.rb', line 323 def FsidBoot(dlabel) fsid_boot = @fsid_native if EfiBoot() || Arch.ia64() fsid_boot = @fsid_gpt_boot elsif PrepBoot() fsid_boot = dlabel == "gpt" ? @fsid_gpt_prep : @fsid_prep_chrp_boot elsif Arch.board_mac() fsid_boot = @fsid_mac_hfs end return fsid_boot end |
- (Object) FsIdToString(fs_id)
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 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 |
# File '../../src/modules/Partitions.rb', line 683 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 "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" when 264 return "GPT PReP" else return "unknown" end end |
- (Object) GetCrypto(pathname)
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 |
# File '../../src/modules/Partitions.rb', line 660 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)
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
# File '../../src/modules/Partitions.rb', line 643 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)
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 |
# File '../../src/modules/Partitions.rb', line 468 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)
889 890 891 892 893 894 895 896 897 898 |
# File '../../src/modules/Partitions.rb', line 889 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)
132 133 134 135 |
# File '../../src/modules/Partitions.rb', line 132 def InitSlib(value) @sint = value nil end |
- (Object) IsDosPartition(fsid)
346 347 348 349 |
# File '../../src/modules/Partitions.rb', line 346 def IsDosPartition(fsid) Builtins.contains(@fsid_dostypes, fsid) || Builtins.contains(@fsid_wintypes, fsid) end |
- (Object) IsDosWinNtPartition(fsid)
351 352 353 |
# File '../../src/modules/Partitions.rb', line 351 def IsDosWinNtPartition(fsid) IsDosPartition(fsid) || Builtins.contains(@fsid_ntfstypes, fsid) end |
- (Object) IsExtendedPartition(fsid)
355 356 357 |
# File '../../src/modules/Partitions.rb', line 355 def IsExtendedPartition(fsid) fsid == @fsid_extended || fsid == @fsid_extended_win end |
- (Object) IsLinuxPartition(fsid)
462 463 464 465 466 |
# File '../../src/modules/Partitions.rb', line 462 def IsLinuxPartition(fsid) fsid == @fsid_native || fsid == @fsid_swap || fsid == @fsid_lvm || fsid == @fsid_raid || fsid == @fsid_gpt_boot end |
- (Object) IsPrepPartition(fsid)
363 364 365 |
# File '../../src/modules/Partitions.rb', line 363 def IsPrepPartition(fsid) return fsid == @fsid_prep_chrp_boot || fsid == @fsid_gpt_prep end |
- (Object) IsResizable(fsid)
454 455 456 457 458 459 |
# File '../../src/modules/Partitions.rb', line 454 def IsResizable(fsid) ret = [@fsid_swap, @fsid_native, @fsid_gpt_boot].include?(fsid) || IsDosWinNtPartition(fsid) || IsExtendedPartition(fsid) log.info("IsResizable fsid:#{fsid} ret:#{ret}") return ret end |
- (Object) IsSwapPartition(fsid)
359 360 361 |
# File '../../src/modules/Partitions.rb', line 359 def IsSwapPartition(fsid) !IsDosWinNtPartition(fsid) && fsid == @fsid_swap end |
- (Object) main
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 126 127 128 129 130 |
# File '../../src/modules/Partitions.rb', line 40 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_gpt_prep = 264 @fsid_freebsd = 165 @fsid_openbsd = 166 @fsid_netbsd = 169 @fsid_beos = 235 @fsid_solaris = 191 @fsid_root = @fsid_native @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 @default_home_fs = :xfs @sint = nil @prep_boot_first = true end |
- (Object) MaximalBootsize
261 262 263 |
# File '../../src/modules/Partitions.rb', line 261 def MaximalBootsize Ops.multiply(1024, Ops.get(BootSizeK(), :maximal, 0)) end |
- (Object) MaxLogical(dlabel)
901 902 903 904 905 906 907 908 909 910 |
# File '../../src/modules/Partitions.rb', line 901 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)
877 878 879 880 881 882 883 884 885 886 |
# File '../../src/modules/Partitions.rb', line 877 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)
913 914 915 916 917 918 919 920 921 922 |
# File '../../src/modules/Partitions.rb', line 913 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
257 258 259 |
# File '../../src/modules/Partitions.rb', line 257 def MinimalBootsize Ops.multiply(1024, Ops.get(BootSizeK(), :minimal, 0)) end |
- (Object) MinimalNeededBootsize
249 250 251 |
# File '../../src/modules/Partitions.rb', line 249 def MinimalNeededBootsize Ops.multiply(1024, Ops.get(BootSizeK(), :proposed, 0)) end |
- (Object) NeedBoot
336 337 338 339 340 341 342 343 |
# File '../../src/modules/Partitions.rb', line 336 def NeedBoot ret = false if EfiBoot() || Arch.ia64 || Arch.ppc || Arch.sparc || Arch.alpha || Arch.s390 ret = true end Builtins.y2milestone("NeedBoot ret:%1", ret) ret end |
- (Object) PrepBoot
305 306 307 308 309 310 311 312 313 |
# File '../../src/modules/Partitions.rb', line 305 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
253 254 255 |
# File '../../src/modules/Partitions.rb', line 253 def ProposedBootsize Ops.multiply(1024, Ops.get(BootSizeK(), :proposed, 0)) end |
- (Object) RdonlyText(disk, expert_partitioner)
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 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 |
# File '../../src/modules/Partitions.rb', line 925 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)
155 156 157 158 159 160 |
# File '../../src/modules/Partitions.rb', line 155 def SetDefaultFs(new_default_fs) @default_fs = new_default_fs @default_boot_fs = :unknown nil end |
- (Object) SetDefaultHomeFs(new_default_home_fs)
204 205 206 |
# File '../../src/modules/Partitions.rb', line 204 def SetDefaultHomeFs(new_default_home_fs) @default_home_fs = new_default_home_fs end |
- (Object) SwapSizeMb(slot_size, suspend)
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
# File '../../src/modules/Partitions.rb', line 431 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
425 426 427 428 429 |
# File '../../src/modules/Partitions.rb', line 425 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)
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 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File '../../src/modules/Partitions.rb', line 368 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)
678 679 680 |
# File '../../src/modules/Partitions.rb', line 678 def ToHexString(num) sprintf("0x%02X", num) end |
- (Object) TranslateMapperName(device)
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 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
# File '../../src/modules/Partitions.rb', line 492 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 |