Class: Yast::StorageClass

Inherits:
Module
  • Object
show all
Includes:
Logger
Defined in:
../../src/modules/Storage.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) ActivateCrypt(device, on)



3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
# File '../../src/modules/Storage.rb', line 3449

def ActivateCrypt(device, on)
  Builtins.y2milestone("ActivateCrypt device:%1 on:%2", device, on)
  ret = @sint.activateEncryption(device, on)
  if ret<0
    Builtins.y2error("ActivateCrypt ret:%1", ret)
  else
    Builtins.y2milestone("ActivateCrypt ret:%1", ret)
  end
  ret == 0
end

- (Object) ActivateHld(val)



6110
6111
6112
6113
6114
6115
# File '../../src/modules/Storage.rb', line 6110

def ActivateHld(val)
  Builtins.y2milestone("ActivateHld val:%1", val)
  @sint.activateHld(val)

  nil
end

- (Object) ActivateMultipath(val)



6118
6119
6120
6121
6122
6123
# File '../../src/modules/Storage.rb', line 6118

def ActivateMultipath(val)
  Builtins.y2milestone("ActivateMultipath val:%1", val)
  @sint.activateMultipath(val)

  nil
end

- (Fixnum) AddFstabEntry(e)

Adds an entry into the fstab

Parameters:

  • map

    entry

Returns:

  • (Fixnum)

    (0 and higher == OK, otherwise error)



6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
# File '../../src/modules/Storage.rb', line 6094

def AddFstabEntry(e)
  e = deep_copy(e)
  Builtins.y2milestone("AddFstabEntry entry:%1", e)
  ret = 0
  freq = Ops.get_integer(e, "freq", 0)
  passno = Ops.get_integer(e, "passno", 0)
  dev = Ops.get_string(e, "spec", "")
  m = Ops.get_string(e, "mount", "")
  vfs = Ops.get_string(e, "vfstype", "auto")
  opts = Ops.get_string(e, "mntops", "defaults")
  ret = @sint.addFstabEntry(dev, m, vfs, opts, freq, passno)
  Builtins.y2error("ret:%1 entry:%2", ret, e) if ret<0
  ret
end

- (Object) AddHwPackages(names)



6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
# File '../../src/modules/Storage.rb', line 6834

def AddHwPackages(names)
  names = deep_copy(names)
  Builtins.y2milestone(
    "AddHwPackages names:%1 list:%2",
    names,
    @hw_packages
  )
  @hw_packages = Convert.convert(
    Builtins.union(@hw_packages, names),
    :from => "list",
    :to   => "list <string>"
  )
  Builtins.y2milestone("AddHwPackages list:%1", @hw_packages)

  nil
end

- (Object) AddMountPointsForWin(targets)



3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
# File '../../src/modules/Storage.rb', line 3798

def AddMountPointsForWin(targets)
  targets = deep_copy(targets)
  if false # no mount points for windows any more bnc#763630
    Builtins.y2milestone("AddMountPointsForWin called")
    foreign_nr = 0

    Builtins.foreach(targets) do |disk, data|
      if !Ops.get_boolean(data, "hotpluggable", false) &&
          Ops.get_symbol(data, "used_by_type", :UB_NONE) == :UB_NONE
        foreign_nr_ref = arg_ref(foreign_nr)
        AddMountPointsForWinParts(
          Ops.get_list(data, "partitions", []),
          true,
          Ops.get_integer(data, "max_primary", 4),
          foreign_nr_ref
        )
        foreign_nr = foreign_nr_ref.value
      end
    end
    Builtins.foreach(targets) do |disk, data|
      if !Ops.get_boolean(data, "hotpluggable", false) &&
          Ops.get_symbol(data, "used_by_type", :UB_NONE) == :UB_NONE
        foreign_nr_ref = arg_ref(foreign_nr)
        AddMountPointsForWinParts(
          Ops.get_list(data, "partitions", []),
          false,
          Ops.get_integer(data, "max_primary", 4),
          foreign_nr_ref
        )
        foreign_nr = foreign_nr_ref.value
      end
    end
  end

  nil
end

- (Array) AddMountPointsForWinParts(partitions, primary, max_prim, foreign_nr)

Search in the list partitions for windows partitions and add the key “mount” to the found windows partitions.

Returns:

  • (Array)

    new partitions with windows mountpoints



3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
# File '../../src/modules/Storage.rb', line 3734

def AddMountPointsForWinParts(partitions, primary, max_prim, foreign_nr)
  partitions = deep_copy(partitions)
  return if !Arch.i386 && !Arch.ia64 && !Arch.x86_64

  foreign_ids = "CDEFGHIJKLMNOPQRSTUVW"

  Builtins.foreach(partitions) do |partition|
    new_partition = deep_copy(partition)
    fsid = Ops.get_integer(partition, "fsid", Partitions.fsid_native)
    partnum = 0
    if Builtins.haskey(partition, "nr") &&
        Ops.is_integer?(Ops.get(partition, "nr", 0))
      partnum = Ops.get_integer(partition, "nr", 0)
    end
    if !Builtins.haskey(partition, "mount") &&
        !Ops.get_boolean(partition, "delete", false) &&
        Ops.less_or_equal(partnum, max_prim) == primary &&
        Ops.less_than(foreign_nr.value, 24) &&
        Partitions.IsDosWinNtPartition(fsid) &&
        !Arch.ia64 &&
        !IsEfiPartition(partition) &&
        Ops.greater_or_equal(
          Ops.get_integer(partition, "size_k", 0),
          1024 * 1024
        ) &&
        Builtins.contains(
          [:vfat, :ntfs],
          Ops.get_symbol(partition, "used_fs", :none)
        )
      Ops.set(
        new_partition,
        "fstopt",
        FileSystems.DefaultFstabOptions(partition)
      )
      if Builtins.contains(Partitions.fsid_dostypes, fsid)
        Ops.set(
          new_partition,
          "mount",
          Ops.add(
            "/dos/",
            Builtins.substring(foreign_ids, foreign_nr.value, 1)
          )
        )
        foreign_nr.value = Ops.add(foreign_nr.value, 1)
      else
        Ops.set(
          new_partition,
          "mount",
          Ops.add(
            "/windows/",
            Builtins.substring(foreign_ids, foreign_nr.value, 1)
          )
        )
        foreign_nr.value = Ops.add(foreign_nr.value, 1)
      end
      ChangeVolumeProperties(new_partition)
      Builtins.y2milestone("win part %1", new_partition)
    end
  end

  nil
end

- (Object) AddNfsVolume(nfsdev, opts, sz, mp, nfs4)



3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
# File '../../src/modules/Storage.rb', line 3200

def AddNfsVolume(nfsdev, opts, sz, mp, nfs4)
  Builtins.y2milestone(
    "AddNfsVolume dev:%1 opts:%2 size:%3 mp:%4 nfs4:%5",
    nfsdev,
    opts,
    sz,
    mp,
    nfs4
  )
  ret = @sint.addNfsDevice(nfsdev, opts, sz, mp, nfs4)
  Builtins.y2error("AddNfsVolume sint ret:%1", ret) if ret<0
  UpdateTargetMapDisk("/dev/nfs")
  ret == 0
end

- (Object) AddPackageList



5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
# File '../../src/modules/Storage.rb', line 5922

def AddPackageList
  pl = deep_copy(@hw_packages)

  target_map = GetTargetMap()

  need_lvm = false
  need_nfs = false
  need_quota = false
  need_crypt = false
  need_iscsi = false

  Builtins.foreach(target_map) do |k, e|
    need_lvm = true if Ops.get_symbol(e, "type", :CT_UNKNOWN) == :CT_LVM
    need_nfs = true if Ops.get_symbol(e, "type", :CT_UNKNOWN) == :CT_NFS
    need_iscsi = true if e.fetch("iscsi", false)
    if Builtins.find(Ops.get_list(e, "partitions", [])) do |part2|
        FileSystems.HasQuota(part2)
      end != nil
      need_quota = true
    end
    if Builtins.find(Ops.get_list(e, "partitions", [])) do |part2|
        Ops.get_symbol(part2, "enc_type", :none) != :none
      end != nil
      need_crypt = true
    end
  end

  Builtins.y2milestone(
    "AddPackageList need_lvm:%1 need_nfs:%2 need_quota:%3 need_crypt:%4 need_iscsi:%5",
    need_lvm, need_nfs, need_quota, need_crypt, need_iscsi
  )

  if need_lvm
    pl << "lvm2"
  end

  # nfs-client needs to be marked for installation if we have some NFS
  # shares. It will pull in portmapper package(#436897)
  if need_nfs
    pl << "nfs-client" << "yast2-nfs-client"
  end

  if need_quota
    pl << "quota"
  end

  if need_crypt
    pl << "cryptsetup" << "cryptsetup-mkinitrd" << "pam_mount"
  end

  if need_iscsi
    pl << "open-iscsi"
  end

  part = GetEntryForMountpoint("/")
  if Ops.get_symbol(part, "used_fs", :unknown) == :btrfs
    pl << "snapper"
  end

  Builtins.y2milestone("AddPackageList ret %1", pl)
  deep_copy(pl)
end

- (Object) AddProposalName(target_map)



4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
# File '../../src/modules/Storage.rb', line 4322

def AddProposalName(target_map)
  target_map = deep_copy(target_map)
  ide_disk_count = 0
  scsi_disk_count = 0
  generic_disk_count = 0
  dm_raid_count = 0
  md_raid_count = 0

  Builtins.mapmap(target_map) do |device, disk|
    s = KByteToHumanString(Ops.get_integer(disk, "size_k", 0))
    case Ops.get_symbol(disk, "type", :CT_UNKNOWN)
      when :CT_DISK
        proposal_name = ""

        bus = Ops.get_string(disk, "bus", "")
        if bus == "IDE"
          ide_disk_count = Ops.add(ide_disk_count, 1)
          proposal_name = Ops.add(
            Builtins.sformat("%1. ", ide_disk_count),
            _("IDE Disk")
          )
        elsif bus == "SCSI"
          scsi_disk_count = Ops.add(scsi_disk_count, 1)
          proposal_name = Ops.add(
            Builtins.sformat("%1. ", scsi_disk_count),
            _("SCSI Disk")
          )
        else
          generic_disk_count = Ops.add(generic_disk_count, 1)
          proposal_name = Ops.add(
            Builtins.sformat("%1. ", generic_disk_count),
            _("Disk")
          )
        end

        proposal_name = Ops.add(
          Ops.add(
            Ops.add(Ops.add(Ops.add(proposal_name, ", "), s), ", "),
            device
          ),
          ", "
        )

        if !Builtins.isempty(Ops.get_string(disk, "vendor", ""))
          proposal_name = Ops.add(
            Ops.add(proposal_name, Ops.get_string(disk, "vendor", "")),
            "-"
          )
        end
        proposal_name = Ops.add(
          proposal_name,
          Ops.get_string(disk, "model", "")
        )

        Ops.set(disk, "proposal_name", proposal_name)
      when :CT_DMRAID
        dm_raid_count = Ops.add(dm_raid_count, 1)
        proposal_name = Ops.add(
          Builtins.sformat("%1. ", dm_raid_count),
          _("DM RAID")
        )

        proposal_name = Ops.add(
          Ops.add(Ops.add(Ops.add(proposal_name, ", "), s), ", "),
          device
        )

        Ops.set(disk, "proposal_name", proposal_name)
      when :CT_MDPART
        md_raid_count = Ops.add(md_raid_count, 1)
        proposal_name = Ops.add(
          Builtins.sformat("%1. ", md_raid_count),
          _("MD RAID")
        )

        proposal_name = Ops.add(
          Ops.add(Ops.add(Ops.add(proposal_name, ", "), s), ", "),
          device
        )

        Ops.set(disk, "proposal_name", proposal_name)
    end
    { device => disk }
  end
end

- (Object) AddSubvolRoot(part)



4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
# File '../../src/modules/Storage.rb', line 4951

def AddSubvolRoot(part)
  part = deep_copy(part)

  def_subvol = [
    "home",
    "opt",
    "srv",
    "tmp",
    "usr/local",
    "var/crash",
    "var/lib/mailman",
    "var/lib/named",
    "var/lib/pgsql",
    "var/log",
    "var/opt",
    "var/spool",
    "var/tmp"
  ]

  if Arch.i386 || Arch.x86_64
    def_subvol.push("boot/grub2/i386-pc")
  end

  if Arch.x86_64
    def_subvol.push("boot/grub2/x86_64-efi")
  end

  if Arch.ppc
    def_subvol.push("boot/grub2/powerpc-ieee1275")
  end

  if Arch.s390
    def_subvol.push("boot/grub2/s390x-emu")
  end

  def_subvol.sort!()

  sv_prepend = ""
  lst = part.fetch("subvol",[])
  Builtins.y2milestone("AddSubvolRoot subvol:%1", lst)
  if FileSystems.default_subvol != ""
    sv_prepend = FileSystems.default_subvol+"/"
  end
  fmt = part.fetch("format",false)
  names = []
  if !fmt
	names = lst.select { |s| !s.fetch("delete", false) }.each { |s| s.fetch("name", "") }
  else
	lst = []
  end
  Builtins.y2milestone("AddSubvolRoot subvol names:%1 lst:%2", names, lst)
  def_subvol.each do |s|
    svn = sv_prepend+s
    if !names.include?( svn )
	  lst.push( { "create" => true, "name" => svn } )
    end
  end
  part["subvol"] = lst;
  Builtins.y2milestone("AddSubvolRoot part:%1", part)
  part
end

- (Hash{String => map}) AddSwapMp(target)

mark swap-partitions with pseudo Mountpoint swap in targetMap

Parameters:

  • target (Hash{String => map})

    Disk map

Returns:

  • (Hash{String => map})

    modified target



3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
# File '../../src/modules/Storage.rb', line 3864

def AddSwapMp(target)
  target = deep_copy(target)
  swaps = SwappingPartitions()
  Builtins.y2milestone("AddSwapMp swaps %1", swaps)
  Builtins.foreach(target) do |diskdev, disk|
    Ops.set(
      disk,
      "partitions",
      Builtins.maplist(Ops.get_list(disk, "partitions", [])) do |part|
        if Stage.initial &&
            !Partitions.IsDosWinNtPartition(
              Ops.get_integer(part, "fsid", 0)
            ) &&
            Ops.get_symbol(part, "detected_fs", :unknown) == :swap &&
            !Ops.get_boolean(part, "old_swap", false) &&
            Builtins.search(diskdev, "/dev/evms") != 0 ||
            Builtins.contains(swaps, Ops.get_string(part, "device", ""))
          Builtins.y2milestone("AddSwapMp %1", part)
          ok = true
          if !Builtins.contains(swaps, Ops.get_string(part, "device", ""))
            dev = Ops.get_string(part, "device", "")
            if !Builtins.isempty(Ops.get_string(part, "crypt_device", ""))
              dev = Ops.get_string(part, "crypt_device", "")
            end
            ok = CheckSwapable(dev)
            Builtins.y2milestone("AddSwapMp initial ok:%1", ok)
          end
          if ok
            Ops.set(part, "mount", "swap")
            ChangeVolumeProperties(part)
            Builtins.y2milestone("AddSwapMp %1", part)
          end
        end
        deep_copy(part)
      end
    )
    Ops.set(target, diskdev, disk)
  end
  deep_copy(target)
end

- (Object) AddTmpfsVolume(mount, opts)



3235
3236
3237
3238
3239
3240
3241
3242
3243
# File '../../src/modules/Storage.rb', line 3235

def AddTmpfsVolume(mount, opts)
  Builtins.y2milestone("AddTmpfsVolume mount:%1 opts:%2", mount, opts)
  ret = @sint.addTmpfsMount(mount, opts)
  if ret<0
    Builtins.y2error("AddTmpfsVolume sint ret:%1", ret)
  end
  UpdateTargetMapDisk("/dev/tmpfs")
  ret == 0
end

- (Object) AllowedParity(mdtype, sz)



6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
# File '../../src/modules/Storage.rb', line 6975

def AllowedParity(mdtype, sz)
  mdt = Ops.get(@conv_mdstring, mdtype, 0)
  pars = @sint.getMdAllowedParity(mdt, sz)
  ret = []
  pars.each do |i|
    l = [toSymbol(@conv_mdparity, i), Ops.get(@rev_conv_parstring, i, "")]
	ret.push(l)
  end
  Builtins.y2milestone("ret:%1", ret)
  ret
end

- (Object) AskCryptPasswords(target)



4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
# File '../../src/modules/Storage.rb', line 4187

def AskCryptPasswords(target)
  target = deep_copy(target)
  crvol = GetCryptLists(target)
  ret = true
  rescan_done = false
  # text in help field
  helptext = _(
    "Enter encryption password for any of the\n" +
      "devices in the locked devices list.\n" +
      "Password will be tried for all devices."
  )
  # header text
  header = _("Enter Encryption Password")

  if Mode.normal && Builtins.size(Ops.get_list(crvol, "inactive", [])) == 0
    Popup.Error(_("There are no encrypted volume to unlock."))
  end
  while Ops.greater_than(
      Builtins.size(Ops.get_list(crvol, "inactive", [])),
      0
    ) && ret
    ret = CryptVolPopup(
      Ops.get_list(crvol, "inactive", []),
      Ops.get_list(crvol, "active", [])
    )
    Builtins.y2milestone("ret:%1", ret)
    if ret
      # label text, multiple device names follow
      label = _("Provide password for any of the following devices:")
      if Builtins.size(Ops.get_list(crvol, "inactive", [])) == 1
        # label text, one device name follows
        label = _("Provide password for the following device:")
      end
      Builtins.foreach(Ops.get_list(crvol, "inactive", [])) do |s|
        label = Ops.add(label, Builtins.sformat("\n%1", s))
      end
      pw = PasswdPopup(helptext, header, label, false, 1, false)
      if Ops.greater_than(Builtins.size(pw), 0)
        UI.OpenDialog(
          Opt(:decorated),
          VBox(
            VSpacing(1),
            HBox(
              HSpacing(1),
              Label(_("Trying to unlock encrypted volumes...")),
              HSpacing(1)
            ),
            VSpacing(1)
          )
        )
        unlock = false
        rl = []
        Builtins.foreach(Ops.get_list(crvol, "inactive", [])) do |d|
          if CheckCryptOk(d, pw, true, false) && SetCryptPwd(d, pw) &&
              SetCrypt(d, true, false) &&
              ActivateCrypt(d, true)
            Builtins.y2milestone("AskCryptPasswords activated %1", d)
            unlock = true
            Ops.set(
              crvol,
              "active",
              Builtins.add(Ops.get_list(crvol, "active", []), d)
            )
            rl = Builtins.add(rl, d)
          end
        end
        UI.CloseDialog
        if !unlock
          Popup.Error(_("Password did not unlock any volume."))
        else
          Ops.set(
            crvol,
            "inactive",
            Builtins.filter(Ops.get_list(crvol, "inactive", [])) do |s|
              !Builtins.contains(rl, s)
            end
          )
          RescanCrypted()
          rescan_done = true
        end
      end
    end
  end
  if rescan_done
    Ops.set(@StorageMap, @targets_key, target)
    UpdateTargetMap()
    target = Ops.get_map(@StorageMap, @targets_key, {})
  end
  deep_copy(target)
end

- (Object) BuildDiskmap(oldv)



6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
# File '../../src/modules/Storage.rb', line 6372

def BuildDiskmap(oldv)
  oldv = deep_copy(oldv)
  d = Convert.to_map(
    SCR.Read(
      path(".target.stat"),
      Ops.add(Installation.destdir, "/var/lib/hardware")
    )
  )
  Builtins.y2milestone(
    "BuildDiskmap oldv:%1 Vers:%2",
    oldv,
    @DiskMapVersion
  )
  Builtins.y2milestone(
    "dir:%1 d:%2",
    Ops.add(Installation.destdir, "/var/lib/hardware"),
    d
  )
  if Ops.get_boolean(d, "isdir", false) &&
      (oldv != @DiskMapVersion || Builtins.size(oldv) == 0)
    @DiskMap = {}
    cmd = ""
    cmd = Ops.add(
      Ops.add(
        Ops.add("LIBHD_HDDB_DIR=", Installation.destdir),
        "/var/lib/hardware "
      ),
      "hwinfo --verbose --map"
    )
    Builtins.y2milestone("BuildDiskmap cmd %1", cmd)
    bo = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd))
    Builtins.y2milestone("BuildDiskmap bo %1", bo)
    if Ops.get_integer(bo, "exit", 1) == 0 &&
        Ops.greater_than(Builtins.size(Ops.get_string(bo, "stdout", "")), 0)
      lines = Builtins.splitstring(Ops.get_string(bo, "stdout", ""), "\n")
      Builtins.foreach(lines) do |line|
        disks = Builtins.filter(Builtins.splitstring(line, " \t")) do |d2|
          Ops.greater_than(Builtins.size(d2), 0)
        end
        if Ops.greater_than(Builtins.size(disks), 1)
          index = 1
          while Ops.less_than(index, Builtins.size(disks))
            Ops.set(
              @DiskMap,
              Ops.get(disks, index, ""),
              Ops.get(disks, 0, "")
            )
            index = Ops.add(index, 1)
          end
        end
      end
    end
    if Ops.get_integer(bo, "exit", 1) == 0
      @DiskMapVersion = deep_copy(oldv)
    else
      @DiskMapVersion = {}
    end
  end
  Builtins.y2milestone("BuildDiskmap DiskMap %1", @DiskMap)
  Builtins.y2milestone("BuildDiskmap DiskMapVersion %1", @DiskMapVersion)
  deep_copy(@DiskMap)
end

- (Object) ByteToHumanString(bytes)



384
385
386
# File '../../src/modules/Storage.rb', line 384

def ByteToHumanString(bytes)
  return ::Storage::byteToHumanString(bytes, false, 2, false).force_encoding("UTF-8")
end

- (Object) ByteToHumanStringOmitZeroes(bytes)



394
395
396
# File '../../src/modules/Storage.rb', line 394

def ByteToHumanStringOmitZeroes(bytes)
  return ::Storage::byteToHumanString(bytes, false, 2, true).force_encoding("UTF-8")
end

- (Object) CallInsserv(on, name)



6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
# File '../../src/modules/Storage.rb', line 6482

def CallInsserv(on, name)
  Builtins.y2milestone("CallInsserv on:%1 name:%2", on, name)
  scrname = Ops.add("/etc/init.d/", name)
  if Ops.greater_than(SCR.Read(path(".target.size"), scrname), 0)
    cmd = "cd / && /sbin/insserv "
    cmd = Ops.add(cmd, "-r ") if !on
    cmd = Ops.add(cmd, scrname)
    Builtins.y2milestone("CallInsserv cmd %1", cmd)
    bo = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd))
    Builtins.y2milestone("CallInsserv bo %1", bo)
  end

  nil
end

- (Object) CanCreate(disk, verbose)



5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
# File '../../src/modules/Storage.rb', line 5157

def CanCreate(disk, verbose)

  ret = true

  if ret && IsUsedBy(disk)
    if verbose
      # TRANSLATORS: error popup
      txt = _("The disk is in use and cannot be modified.")
      Popup.Message(txt)
    end
    ret = false
  end

  if ret && disk.fetch("label", "") == "dasd"
    if disk.fetch("partitions", []).any? do |partition|
        !DeviceMounted(partition["device"]).empty? || IsUsedBy(partition)
      end
      if verbose
        # TRANSLATORS: error popup
        txt = _("Partitions cannot be created since other partitions on the disk are used.")
        Popup.Message(txt)
      end
      ret = false
    end
  end

  log.info("CanCreate device:#{disk["device"]} verbose:#{verbose} ret:#{ret}")

  return ret

end

- (Object) CanDelete(p, disk, verbose)



5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
# File '../../src/modules/Storage.rb', line 5234

def CanDelete(p, disk, verbose)
  p = deep_copy(p)
  disk = deep_copy(disk)
  txt = ""
  ret = CanEdit(p, false)
  if !ret && verbose && Ops.get_string(p, "mount", "") == "swap"
    ret = TryUnaccessSwap(Ops.get_string(p, "device", ""))
  end
  if !ret && verbose
    if Ops.get_string(p, "mount", "") == "swap"
      txt = Builtins.sformat(
        _(
          "\n" +
            "Device %1 cannot be removed because it contains activated swap\n" +
            "that is needed to run the installation.\n"
        ),
        Ops.get_string(p, "device", "")
      )
    else
      txt = Builtins.sformat(
        _(
          "\n" +
            "Device %1 cannot be removed because it contains the installation\n" +
            "data needed to perform the installation.\n"
        ),
        Ops.get_string(p, "device", "")
      )
    end
    Popup.Message(txt)
  end
  if ret &&
      (Ops.get_symbol(p, "type", :unknown) == :logical ||
        Ops.get_symbol(p, "type", :unknown) == :extended)
    num = Ops.get_symbol(p, "type", :unknown) == :extended ?
      4 :
      Ops.get_integer(p, "nr", 4)
    pl = Builtins.filter(Ops.get_list(disk, "partitions", [])) do |q|
      Ops.get_symbol(q, "type", :unknown) == :logical &&
        Ops.greater_than(Ops.get_integer(q, "nr", 0), num)
    end
    Builtins.y2milestone("CanDelete pl:%1", pl)
    pos = 0
    while ret && Ops.less_than(pos, Builtins.size(pl))
      ret = CanEdit(Ops.get(pl, pos, {}), false)
      pos = Ops.add(pos, 1) if ret
    end
    if !ret && verbose
      if Ops.get_string(p, "mount", "") == "swap"
        txt = Builtins.sformat(
          _(
            "\n" +
              "Device %1 cannot be removed because this would indirectly change\n" +
              "device %2, which contains activated swap that is needed to run \n" +
              "the installation.\n"
          ),
          Ops.get_string(p, "device", ""),
          Ops.get_string(pl, [pos, "device"], "")
        )
      else
        txt = Builtins.sformat(
          _(
            "\n" +
              "Device %1 cannot be removed because this would indirectly change\n" +
              "device %2, which contains data needed to perform the installation.\n"
          ),
          Ops.get_string(p, "device", ""),
          Ops.get_string(pl, [pos, "device"], "")
        )
      end
      Popup.Message(txt)
    end
  end

  # the check for verbose is needed for calls from StorageProposal (see bnc#871779)
  if ret && disk.fetch("label", "") == "dasd" && verbose
    if disk.fetch("partitions", []).any? do |partition|
        Ops.get_string(partition, "device", "") !=
          Ops.get_string(p, "device", "") &&
          !DeviceMounted(partition["device"]).empty? || IsUsedBy(partition)
      end
      if verbose
        txt = Builtins.sformat(
          _(
            "\n" +
              "Partition %1 cannot be removed since other partitions on the\n" +
              "disk %2 are used.\n"
            ),
          Ops.get_string(p, "device", ""),
          Ops.get_string(disk, "device", "")
        )
      Popup.Message(txt)
      end
      ret = false
    end
  end

  log.info("CanDelete device:#{p["device"]} verbose:#{verbose} ret:#{ret}")

  return ret
end

- (Object) CanEdit(p, verbose)



5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
# File '../../src/modules/Storage.rb', line 5190

def CanEdit(p, verbose)
  p = deep_copy(p)
  ret = true
  if Stage.initial
    if !Ops.get_boolean(p, "create", false) &&
        !Ops.get_boolean(p, "inactive", false) &&
        Ops.get_string(p, "mount", "") == "swap"
      ret = false
      ret = TryUnaccessSwap(Ops.get_string(p, "device", "")) if verbose
      Builtins.y2milestone("CanEdit ret:%1 p:%2", ret, p)
      if verbose && !ret
        txt = Builtins.sformat(
          _(
            "\n" +
              "Device %1 cannot be modified because it contains activated swap\n" +
              "that is needed to run the installation.\n"
          ),
          Ops.get_string(p, "device", "")
        )
        Popup.Message(txt)
      end
    end
    if IsInstallationSource(Ops.get_string(p, "device", ""))
      ret = false
      if verbose
        txt = Builtins.sformat(
          _(
            "\n" +
              "Device %1 cannot be modified because it contains the installation\n" +
              "data needed to perform the installation.\n"
          ),
          Ops.get_string(p, "device", "")
        )
        Popup.Message(txt)
      end
    end
  end

  log.info("CanEdit device:#{p["device"]} verbose:#{verbose} ret:#{ret}")

  return ret
end

- (Object) ChangeDescText(dev, txt)



2725
2726
2727
# File '../../src/modules/Storage.rb', line 2725

def ChangeDescText(dev, txt)
  ret = @sint.changeDescText(dev, txt)
end

- (Object) ChangeDmNamesFromCrypttab(crfile)



4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
# File '../../src/modules/Storage.rb', line 4279

def ChangeDmNamesFromCrypttab(crfile)
  st = Convert.to_map(SCR.Read(path(".target.stat"), crfile))
  Builtins.y2milestone(
    "ChangeDmNamesFromCrypttab crfile:%1 st:%2",
    crfile,
    st
  )
  if Ops.greater_than(Ops.get_integer(st, "size", 0), 0)
    Yast.import "AsciiFile"
    cr = {}
    cr_ref = arg_ref(cr)
    AsciiFile.SetDelimiter(cr_ref, " \t")
    cr = cr_ref.value
    cr_ref = arg_ref(cr)
    AsciiFile.ReadFile(cr_ref, crfile)
    cr = cr_ref.value
    i = 1
    r = 0
    while Ops.less_or_equal(i, AsciiFile.NumLines(cr))
      l = (
        cr_ref = arg_ref(cr);
        _GetLine_result = AsciiFile.GetLine(cr_ref, i);
        cr = cr_ref.value;
        _GetLine_result
      )
      Builtins.y2milestone("ChangeDmNamesFromCrypttab line:%1 is:%2", i, l)
      dev = Ops.get_string(l, ["fields", 1], "")
      nm = Ops.get_string(l, ["fields", 0], "")
      if !Builtins.isempty(dev) && !Builtins.isempty(nm)
        r = @sint.renameCryptDm(dev, nm)
        Builtins.y2milestone(
          "ChangeDmNamesFromCrypttab rename dm of %1 to %2 ret:%3",
          dev, nm, r)
      end
      i = Ops.add(i, 1)
    end
    @sint.dumpObjectList()
  end

  nil
end

- (Object) ChangeLvStripeCount(vgname, lvname, stripes)



3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
# File '../../src/modules/Storage.rb', line 3135

def ChangeLvStripeCount(vgname, lvname, stripes)
  Builtins.y2milestone(
    "ChangeLvStripeCount vg:%1 name:%2 stripes:%3",
    vgname,
    lvname,
    stripes
  )
  ret = @sint.changeLvStripeCount(vgname, lvname, stripes)
  if ret<0
    Builtins.y2error("ChangeLvStripeCount sint ret:%1", ret)
  end
  UpdateTargetMapDisk(Ops.add("/dev/", vgname))
  ret == 0
end

- (Object) ChangeLvStripeSize(vgname, lvname, stripeSize)



3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
# File '../../src/modules/Storage.rb', line 3119

def ChangeLvStripeSize(vgname, lvname, stripeSize)
  Builtins.y2milestone(
    "ChangeLvStripeSize vg:%1 name:%2 stripeSize:%3",
    vgname,
    lvname,
    stripeSize
  )
  ret = @sint.changeLvStripeSize(vgname, lvname, stripeSize)
  if ret<0
    Builtins.y2error("ChangeLvStripeSize sint ret:%1", ret)
  end
  UpdateTargetMapDisk(Ops.add("/dev/", vgname))
  ret == 0
end

- (Object) ChangeMdChunk(nr, chunk)



3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
# File '../../src/modules/Storage.rb', line 3386

def ChangeMdChunk(nr, chunk)
  Builtins.y2milestone("ChangeMdChunk nr:%1 chunk:%2", nr, chunk)
  rd = MdToDev(nr)
  ret = @sint.changeMdChunk(rd, chunk)
  if ret<0
    Builtins.y2error("ChangeMdChunk sint ret:%1", ret)
  end
  UpdateTargetMapDev(rd)
  ret == 0
end

- (Object) ChangeMdParity(nr, ptype)



3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
# File '../../src/modules/Storage.rb', line 3360

def ChangeMdParity(nr, ptype)
  Builtins.y2milestone("ChangeMdParity nr:%1 parity:%2", nr, ptype)
  rd = MdToDev(nr)
  tmp = Ops.get(@conv_parstring, ptype, 0)
  ret = @sint.changeMdParity(rd, tmp)
  if ret<0
    Builtins.y2error("ChangeMdParity sint ret:%1", ret)
  end
  UpdateTargetMapDev(rd)
  ret == 0
end

- (Object) ChangeMdParitySymbol(nr, ptype)



3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
# File '../../src/modules/Storage.rb', line 3373

def ChangeMdParitySymbol(nr, ptype)
  Builtins.y2milestone("ChangeMdParitySymbol nr:%1 parity:%2", nr, ptype)
  rd = MdToDev(nr)
  tmp = fromSymbol(@conv_mdparity, ptype)
  ret = @sint.changeMdParity(rd, tmp)
  if ret<0
    Builtins.y2error("ChangeMdParitySymbol sint ret:%1", ret)
  end
  UpdateTargetMapDev(rd)
  ret == 0
end

- (Object) ChangeMdType(nr, mdtype)



3349
3350
3351
3352
3353
3354
3355
3356
3357
# File '../../src/modules/Storage.rb', line 3349

def ChangeMdType(nr, mdtype)
  Builtins.y2milestone("ChangeMdType nr:%1 mdtype:%2", nr, mdtype)
  rd = MdToDev(nr)
  tmp = Ops.get(@conv_mdstring, mdtype, 0)
  ret = @sint.changeMdType(rd, tmp)
  Builtins.y2error("ChangeMdType sint ret:%1", ret) if ret<0
  UpdateTargetMapDev(rd)
  ret == 0
end

- (Object) ChangeText



5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
# File '../../src/modules/Storage.rb', line 5392

def ChangeText
  texts = Builtins.maplist(GetCommitInfos()) do |info|
    text = String.EscapeTags(Ops.get_string(info, :text, ""))
    if Ops.get_boolean(info, :destructive, false)
      text = HTML.Colorize(text, "red")
    end
    text
  end

  ret = Builtins.isempty(texts) ? "" : HTML.List(texts)

  if Stage.initial && Builtins.isempty(GetEntryForMountpoint("/"))
    wroot = Ops.add(
      Ops.add(_("Nothing assigned as root filesystem!"), HTML.Newline),
      _("Installation will most certainly fail fatally!")
    )
    ret = Ops.add(ret, HTML.Para(HTML.Colorize(wroot, "red")))
  end

  if ret != @save_chtxt
    @sint.dumpObjectList()
    @sint.dumpCommitInfos()
  end

  ret
end

- (Object) ChangeVolumeProperties(part)



2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
# File '../../src/modules/Storage.rb', line 2730

def ChangeVolumeProperties(part)
  part = deep_copy(part)
  ret = 0
  tmp = 0
  changed = false
  ts = ""
  dev = Ops.get_string(part, "device", "")
  vinfo = ::Storage::VolumeInfo.new()
  ret = @sint.getVolume(dev, vinfo)
  if ret != 0
    Builtins.y2error("ChangeVolumeProperties device:%1 not found", dev)
  end
  curr = {}
  curr = volumeMap(vinfo, curr) if ret == 0
  if ret == 0 &&
      Ops.get_string(part, "mount", "") != Ops.get_string(curr, "mount", "")
    changed = true
    ts = Ops.get_string(part, "mount", "")
    ret = @sint.changeMountPoint(dev, ts)
    if ret<0
      Builtins.y2error("ChangeVolumeProperties sint ret:%1", ret)
    else
      Builtins.y2milestone("ChangeVolumeProperties sint ret:%1", ret)
    end
  end
  if ret == 0 && Ops.get_symbol(part, "type", :unknown) != :extended &&
      (Ops.get_boolean(part, "format", false) !=
        Ops.get_boolean(curr, "format", false) ||
        Ops.get_symbol(part, "used_fs", :none) !=
          Ops.get_symbol(curr, "used_fs", :none))
    changed = true
    tmp = fromSymbol(
      FileSystems.conv_fs,
      Ops.get_symbol(part, "used_fs", :none)
    )
    Builtins.y2milestone(
      "ChangeVolumeProperties fs:%1 symbol:%2",
      tmp,
      Ops.get_symbol(part, "used_fs", :none)
    )
    ret = @sint.changeFormatVolume(dev,
        Ops.get_boolean(part, "format", false),
        tmp
      );
    if ret<0
      Builtins.y2error("ChangeVolumeProperties sint ret:%1", ret)
    else
      Builtins.y2milestone("ChangeVolumeProperties sint ret:%1", ret)
    end
  end
  if ret == 0 &&
      Ops.greater_than(Builtins.size(Ops.get_string(part, "mount", "")), 0) &&
      Ops.get_string(part, "fstopt", "") !=
        Ops.get_string(curr, "fstopt", "")
    changed = true
    ts = Ops.get_string(part, "fstopt", "")
    ret = @sint.changeFstabOptions(dev, ts)
    if ret<0
      Builtins.y2error("ChangeVolumeProperties sint ret:%1", ret)
    else
      Builtins.y2milestone("ChangeVolumeProperties sint ret:%1", ret)
    end
  end
  defmb = GetMountBy(dev)
  if ret == 0 &&
      Ops.greater_than(Builtins.size(Ops.get_string(part, "mount", "")), 0) &&
      Ops.get_symbol(part, "mountby", defmb) !=
        Ops.get_symbol(curr, "mountby", defmb)
    changed = true
    tmp = fromSymbol(
      @conv_mountby,
      Ops.get_symbol(part, "mountby", :device)
    )
    Builtins.y2milestone("ChangeVolumeProperties mby:%1", tmp)
    ret = @sint.changeMountBy(dev, tmp)
    if ret<0
      Builtins.y2error("ChangeVolumeProperties sint ret:%1", ret)
    else
      Builtins.y2milestone("ChangeVolumeProperties sint ret:%1", ret)
    end
  end
  if ret == 0 &&
      Ops.get_string(part, "label", "") != Ops.get_string(curr, "label", "")
    changed = true
    ts = Ops.get_string(part, "label", "")
    ret = @sint.changeLabelVolume(dev, ts)
    if ret<0
      Builtins.y2error("ChangeVolumeProperties sint ret:%1", ret)
    else
      Builtins.y2milestone("ChangeVolumeProperties sint ret:%1", ret)
    end
  end
  if ret == 0 && Ops.get_boolean(part, "format", false) &&
      convertFsOptionMapToString(Ops.get_map(part, "fs_options", {}), :mkfs) !=
        Ops.get_string(curr, "mkfs_opt", "")
    changed = true
    ts = convertFsOptionMapToString(
      Ops.get_map(part, "fs_options", {}),
      :mkfs
    )
    Builtins.y2milestone("FsOption ts:%1", ts)
    ret = @sint.changeMkfsOptVolume(dev, ts)
    if ret<0
      Builtins.y2error("ChangeVolumeProperties sint ret:%1", ret)
    else
      Builtins.y2milestone("ChangeVolumeProperties sint ret:%1", ret)
    end
  end
  if ret == 0 && Ops.get_boolean(part, "format", false) &&
      !Builtins.isempty(Ops.get_string(part, "mkfs_options", "")) &&
      Ops.get_string(part, "mkfs_options", "") !=
        Ops.get_string(curr, "mkfs_opt", "")
    changed = true
    ts = Ops.get_string(part, "mkfs_options", "")
    Builtins.y2milestone("FsOption ts:%1", ts)
    ret = @sint.changeMkfsOptVolume(dev, ts)
    if ret<0
      Builtins.y2error("ChangeVolumeProperties sint ret:%1", ret)
    else
      Builtins.y2milestone("ChangeVolumeProperties sint ret:%1", ret)
    end
  end
  if ret == 0 && Ops.get_boolean(part, "format", false) &&
      convertFsOptionMapToString(
        Ops.get_map(part, "fs_options", {}),
        :tunefs
      ) !=
        Ops.get_string(curr, "tunefs_opt", "")
    changed = true
    ts = convertFsOptionMapToString(
      Ops.get_map(part, "fs_options", {}),
      :tunefs
    )
    Builtins.y2milestone("FsOption ts:%1", ts)
    ret = @sint.changeTunefsOptVolume(dev, ts)
    if ret<0
      Builtins.y2error("ChangeVolumeProperties sint ret:%1", ret)
    else
      Builtins.y2milestone("ChangeVolumeProperties sint ret:%1", ret)
    end
  end
  if ret == 0 &&
      Ops.get_symbol(part, "enc_type", :none) !=
        Ops.get_symbol(curr, "enc_type", :none)
    changed = true
    SetCrypt(
      dev,
      Ops.get_symbol(part, "enc_type", :none) != :none,
      Ops.get_boolean(part, "format", false)
    )
  end
  if ret == 0 &&
      Ops.get_string(part, "dtxt", "") != Ops.get_string(curr, "dtxt", "")
    changed = true
    ret = ChangeDescText(dev, Ops.get_string(part, "dtxt", ""))
  end
  if ret == 0 &&
      (Ops.get_boolean(part, "resize", false) &&
        Ops.get_integer(part, ["region", 1], 0) !=
          Ops.get_integer(curr, ["region", 1], 0) ||
        Ops.get_boolean(part, "resize", false) !=
          Ops.get_boolean(curr, "resize", false))
    changed = true
    d = Ops.get_string(part, "device", "")
    i = Ops.get_integer(part, ["region", 1], 0)
    if Ops.get_boolean(part, "resize", false)
      Builtins.y2milestone("ChangeVolumeProperties resize to %1 cyl", i)
      if Ops.get_boolean(part, "ignore_fs", false)
        ret = @sint.resizePartitionNoFs(d, i)
      else
        ret = @sint.resizePartition(d, i)
      end
    else
      ret = @sint.forgetResizeVolume(d)
    end
    if ret<0
      Builtins.y2error("ChangeVolumeProperties sint ret:%1", ret)
    else
      Builtins.y2milestone("ChangeVolumeProperties sint ret:%1", ret)
    end
  end
  if ret == 0 && Ops.get_boolean(part, "change_fsid", false) &&
      Ops.get_integer(part, "fsid", 0) != Ops.get_integer(curr, "fsid", 0)
    changed = true
    d = Ops.get_string(part, "device", "")
    i = Ops.get_integer(part, "fsid", 0)
    Builtins.y2milestone("ChangeVolumeProperties fsid to %1", i)
    ret = @sint.changePartitionId(d, i)
    if ret<0
      Builtins.y2error("ChangeVolumeProperties sint ret:%1", ret)
    else
      Builtins.y2milestone("ChangeVolumeProperties sint ret:%1", ret)
    end
  end
  if ret == 0 && !part.fetch("subvol",[]).empty?
    d = part.fetch("device","")
    fmt = part.fetch("format",false)
    rem = part["subvol"].select { |p| p.fetch("delete",false) }
    cre = part["subvol"].select { |p| !p.fetch("delete",false)&&(p.fetch("create",false)||fmt) }
    Builtins.y2milestone("ChangeVolumeProperties rem:%1", rem)
    Builtins.y2milestone("ChangeVolumeProperties cre:%1", cre)
    while ret == 0 && !rem.empty?
      pth = rem.first.fetch("name","")
      if @sint.existSubvolume(d, pth)
        changed = true
        ret = @sint.removeSubvolume(d, pth)
        if ret<0
          Builtins.y2error("ChangeVolumeProperties sint ret:%1", ret)
        else
          Builtins.y2milestone("ChangeVolumeProperties sint ret:%1", ret)
        end
      end
      rem = rem.drop(1)
    end
    while ret == 0 && !cre.empty?
      pth = cre.first.fetch("name","")
      if ! @sint.existSubvolume(d, pth)
        changed = true
        ret = @sint.createSubvolume(d, pth)
        if ret<0
          Builtins.y2error("ChangeVolumeProperties sint ret:%1", ret)
        else
          Builtins.y2milestone("ChangeVolumeProperties sint ret:%1", ret)
        end
      end
      cre = cre.drop(1)
    end
  end

  if ret == 0 && part.fetch("userdata", {}) != curr.fetch("userdata", {})
    changed = true
    d = part.fetch("device", "")
    userdata = ::Storage::MapStringString.new()
    part.fetch("userdata", {}).each do |a, b|
      userdata[a]= b
    end
    Builtins.y2milestone("ChangeVolumeProperties userdata to %1", userdata.to_s)
    ret = @sint.setUserdata(d, userdata)
    if ret < 0
      Builtins.y2error("ChangeVolumeProperties sint ret:%1", ret)
    else
      Builtins.y2milestone("ChangeVolumeProperties sint ret:%1", ret)
    end
  end

  UpdateTargetMapDev(dev) if changed
  if ret != 0
    Builtins.y2milestone("ChangeVolumeProperties ret:%1", ret)
    Builtins.y2milestone("ChangeVolumeProperties part:%1", part)
    Builtins.y2milestone("ChangeVolumeProperties curr:%1", curr)
  end
  ret == 0
end

- (Object) CheckBackupState(who)



1246
1247
1248
1249
1250
1251
1252
# File '../../src/modules/Storage.rb', line 1246

def CheckBackupState(who)
  Builtins.y2milestone("CheckBackupStates who:%1", who)
  return nil if !InitLibstorage(false)
  ret = @sint.checkBackupState(who)
  Builtins.y2milestone("CheckBackupStates ret:%1", ret)
  ret
end

- (Object) CheckCryptOk(dev, fs_passwd, silent, erase)



3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
# File '../../src/modules/Storage.rb', line 3906

def CheckCryptOk(dev, fs_passwd, silent, erase)
  i = @sint.verifyCryptPassword(dev, fs_passwd, erase)
  if i != 0 && !silent
    Popup.Error(
      Builtins.sformat(
        _(
          "Could not set encryption.\n" +
            "System error code is %1.\n" +
            "\n" +
            "The encryption password provided could be incorrect.\n"
        ),
        i
      )
    )
  end
  Builtins.y2milestone(
    "CheckCryptOk dev:%1 pwlen:%2 ret:%3",
    dev,
    Builtins.size(fs_passwd),
    i == 0
  )
  i == 0
end

- (Object) CheckEncryptionPasswords(pw1, pw2, min_length, empty_allowed)



3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
# File '../../src/modules/Storage.rb', line 3938

def CheckEncryptionPasswords(pw1, pw2, min_length, empty_allowed)
  if pw1 != pw2
    # popup text
    Popup.Message(
      _(
        "The first and the second version\n" +
          "of the password do not match.\n" +
          "Try again."
      )
    )
    return false
  end

  if Builtins.isempty(pw1)
    if !empty_allowed
      # popup text
      Popup.Message(_("You did not enter a password.\nTry again.\n"))
      return false
    end
  else
    if Ops.less_than(Builtins.size(pw1), min_length)
      # popup text
      Popup.Message(
        Builtins.sformat(
          _("The password must have at least %1 characters.\nTry again.\n"),
          min_length
        )
      )
      return false
    end

    allowed_chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#* ,.;:._-+=!$%&/|?{[()]}@^\\<>"
    if Builtins.findfirstnotof(pw1, allowed_chars) != nil
      # popup text
      Popup.Message(
        _(
          "The password may only contain the following characters:\n" +
            "0..9, a..z, A..Z, and any of \"@#* ,.;:._-+=!$%&/|?{[()]}^\\<>\".\n" +
            "Try again."
        )
      )
      return false
    end
  end

  true
end

- (Object) CheckForLvmRootFs



6656
6657
6658
6659
6660
6661
# File '../../src/modules/Storage.rb', line 6656

def CheckForLvmRootFs
  part = GetEntryForMountpoint("/")
  ret = Ops.get_symbol(part, "type", :primary) == :lvm
  Builtins.y2milestone("CheckForLvmRootFs root:%1 ret:%2", part, ret)
  ret
end

- (Object) CheckForMdRootFs



6664
6665
6666
6667
6668
6669
# File '../../src/modules/Storage.rb', line 6664

def CheckForMdRootFs
  part = GetEntryForMountpoint("/")
  ret = Ops.get_symbol(part, "type", :primary) == :sw_raid
  Builtins.y2milestone("CheckForMdRootFs root:%1 ret:%2", part, ret)
  ret
end

- (Object) CheckMd(nr)



3398
3399
3400
3401
3402
3403
3404
3405
# File '../../src/modules/Storage.rb', line 3398

def CheckMd(nr)
  Builtins.y2milestone("CheckMd nr:%1", nr)
  ret = 0
  rd = MdToDev(nr)
  ret = @sint.checkMd(rd)
  Builtins.y2milestone("CheckMd sint ret:%1", ret) if ret != 0
  ret
end

- (Object) CheckNfsVolume(nfsdev, opts, nfs4)



3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
# File '../../src/modules/Storage.rb', line 3216

def CheckNfsVolume(nfsdev, opts, nfs4)
  Builtins.y2milestone(
    "CheckNfsVolume dev:%1 opts:%2 nfs4:%3",
    nfsdev,
    opts,
    nfs4
  )
  ret, sz = @sint.checkNfsDevice(nfsdev, opts, nfs4)
  sz = 0 if ret<0
  if ret<0
    Builtins.y2error("CheckNfsVolume sint ret:%1", ret)
  else
    ret = sz
  end
  Builtins.y2milestone("CheckNfsVolume ret:%1", ret)
  ret
end

- (Object) CheckSwapable(dev)



3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
# File '../../src/modules/Storage.rb', line 3847

def CheckSwapable(dev)
  return true if Mode.test

  cmd = Ops.add("/sbin/swapon --fixpgsz ", dev)
  ok = Convert.to_integer(SCR.Execute(path(".target.bash"), cmd)) == 0
  if ok
    cmd = Ops.add("/sbin/swapoff ", dev)
    SCR.Execute(path(".target.bash"), cmd)
  end
  Builtins.y2milestone("CheckSwapable dev:%1 ret:%2", dev, ok)
  ok
end

- (Boolean) CheckSwapOn(disk)

Check if swap paritition is availbe on a disk

Parameters:

  • disk (String)

    Disk to be checked

Returns:

  • (Boolean)

    true if swap available.



5732
5733
5734
5735
5736
5737
# File '../../src/modules/Storage.rb', line 5732

def CheckSwapOn(disk)
  swaps = SwappingPartitions()
  ret = Builtins.contains(SwappingPartitions(), disk)
  Builtins.y2milestone("CheckSwapOn disk:%1 ret:%2", disk, ret)
  ret
end

- (Object) ClassicStringToByte(str)



370
371
372
373
374
375
376
377
378
379
380
381
# File '../../src/modules/Storage.rb', line 370

def ClassicStringToByte(str)
  ret, bytes = ::Storage::humanStringToByte(str,true)
  if( !ret )
    ts = Ops.add(str, "b")
	ret, bytes = ::Storage::humanStringToByte(ts,true)
	if( !ret )
	  bytes = 0 
      Builtins.y2error("cannot parse %1 or %2", str, ts)
    end
  end
  bytes
end

- (Fixnum) CommitChanges

Apply storage changes

Returns:

  • (Fixnum)


4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
# File '../../src/modules/Storage.rb', line 4840

def CommitChanges
  Builtins.y2milestone("CommitChanges")
  ret = @sint.commit()
  if ret<0
    Builtins.y2error("CommitChanges sint ret:%1", ret)
  end
  UpdateTargetMap()

  env = ENV["YAST2_STORAGE_SLEEP_AFTER_COMMIT"]
  SCR.Execute(path(".target.bash"), "sleep " + env) if env != nil

  ret
end

- (Object) ComputeMdSize(md_type, devices, sizeK)



3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
# File '../../src/modules/Storage.rb', line 3408

def ComputeMdSize(md_type, devices, sizeK)
  tmp = ::Storage::RAID_UNK
  Builtins.foreach(Ops.get_map(@conv_mdtype, "m", {})) do |k, v|
    tmp = k if v == md_type
  end
  Builtins.y2milestone("ComputeMdSize devices:%1", devices)
  empty = ::Storage::ListString.new()
  devs = StringListFromList(devices);
  ret, s = @sint.computeMdSize(tmp, devs, empty)
  sizeK.value=s if ret==0
  Builtins.y2milestone("ComputeMdSize sint ret:%1", ret) if ret != 0
  Builtins.y2milestone("ComputeMdSize sizeK:%1", sizeK)
  ret
end

- (Object) convertFsOptionMapToString(fsopt, cmd)



1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
# File '../../src/modules/Storage.rb', line 1100

def convertFsOptionMapToString(fsopt, cmd)
  fsopt = deep_copy(fsopt)
  ret = ""

  # do nothing
  if fsopt != nil || fsopt != {}
    ignore = ["auto", "default", "none", ""]

    Builtins.foreach(fsopt) do |option_key, option|
      option_str = Ops.get_string(option, "option_str", "")
      option_value = Ops.get(option, "option_value", "")
      option_blank = Ops.get_boolean(option, "option_blank", false)
      option_cmd = Ops.get_symbol(option, "option_cmd", :mkfs)
      Builtins.y2milestone(
        "convertFsOptionMapToString k:%1 opt:%2 val:%3 cmd:%4",
        option_key,
        option,
        option_value,
        option_cmd
      )
      if cmd == option_cmd
        if Ops.is_string?(option_value) && option_value != nil
          if !Builtins.contains(ignore, option_value)
            if Ops.greater_than(Builtins.size(ret), 0)
              ret = Ops.add(ret, " ")
            end
            ret = Ops.add(ret, option_str)
            ret = Ops.add(ret, " ") if option_blank
            ret = Ops.add(ret, Convert.to_string(option_value))
          end
        elsif Ops.is_boolean?(option_value) && option_value != nil
          if Ops.greater_than(Builtins.size(option_str), 0)
            if Ops.greater_than(Builtins.size(ret), 0)
              ret = Ops.add(ret, " ")
            end
            ret = Ops.add(ret, option_str)
          end
        elsif Ops.is_integer?(option_value) && option_value != nil
          ret = Ops.add(ret, " ") if Ops.greater_than(Builtins.size(ret), 0)
          ret = Ops.add(ret, option_str)
          ret = Ops.add(ret, " ") if option_blank
          ret = Ops.add(ret, Builtins.sformat("%1", option_value))
        end
      end
    end
  end
  if Ops.greater_than(Builtins.size(fsopt), 0) ||
      Ops.greater_than(Builtins.size(ret), 0)
    Builtins.y2milestone(
      "convertFsOptionMapToString fsopt:%1 ret:%2",
      fsopt,
      ret
    )
  end
  ret
end

- (Object) convertStringToFsOptionMap(opts, fs, cmd)



1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
# File '../../src/modules/Storage.rb', line 1158

def convertStringToFsOptionMap(opts, fs, cmd)
  ret = {}
  Builtins.y2milestone(
    "convertStringToFsOptionMap opts:\"%1\" fs:%2 cmd:%3",
    opts,
    fs,
    cmd
  )
  pos = Builtins.findfirstnotof(opts, " \t")
  opts = Builtins.substring(opts, pos) if Ops.greater_than(pos, 0)

  op = Convert.convert(
    FileSystems.GetOptions(fs),
    :from => "list",
    :to   => "list <map>"
  )
  op = Builtins.filter(op) do |o|
    Ops.get_symbol(o, :option_cmd, :mkfs) == cmd
  end

  while Ops.greater_than(Builtins.size(opts), 0)
    found = false
    Builtins.foreach(op) do |o|
      m = {}
      os = Ops.get_string(o, :option_str, "")
      nos = Ops.get_string(o, :option_false, "")
      se_ok = false
      found_os = false
      if Ops.greater_than(Builtins.size(os), 0) &&
          Builtins.search(opts, os) == 0
        found_os = true
        se_ok = true
      elsif Ops.greater_than(Builtins.size(nos), 0) &&
          Builtins.search(opts, nos) == 0
        found_os = false
        se_ok = true
      end
      if !found && se_ok
        found = true
        Ops.set(m, "option_str", found_os ? os : nos)
        Ops.set(m, "option_cmd", Ops.get_symbol(o, :option_cmd, :mkfs))
        if Ops.get_symbol(o, :type, :text) == :boolean
          Ops.set(m, "option_value", found_os)
          Ops.set(ret, Ops.get_string(o, :query_key, ""), m)
        end
        opts = Builtins.substring(
          opts,
          found_os ? Builtins.size(os) : Builtins.size(nos)
        )
        pos = Builtins.findfirstnotof(opts, " \t")
        opts = Builtins.substring(opts, pos) if Ops.greater_than(pos, 0)
        if Ops.get_symbol(o, :type, :text) != :boolean &&
            Ops.greater_than(Builtins.size(opts), 0) &&
            Builtins.search(opts, "-") != 0
          Ops.set(m, "option_blank", true) if Ops.greater_than(pos, 0)
          pos = Builtins.findfirstof(opts, " \t")
          if pos == nil
            Ops.set(m, "option_value", opts)
            opts = ""
          else
            Ops.set(m, "option_value", Builtins.substring(opts, 0, pos))
            opts = Builtins.substring(opts, pos)
          end
          Ops.set(ret, Ops.get_string(o, :query_key, ""), m)
        end
        pos = Builtins.findfirstnotof(opts, " \t")
        opts = Builtins.substring(opts, pos) if Ops.greater_than(pos, 0)
      end
    end
    if !found
      pos = Builtins.findfirstnotof(opts, " \t")
      if Ops.greater_than(pos, 0)
        opts = Builtins.substring(opts, pos)
      else
        opts = ""
      end
    end
    Builtins.y2milestone(
      "convertStringToFsOptionMap opts:%1 ret:%2",
      opts,
      ret
    )
  end
  Builtins.y2milestone("convertStringToFsOptionMap ret:%1", ret)
  deep_copy(ret)
end

- (Object) CreateAny(ctype, d, p)



3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
# File '../../src/modules/Storage.rb', line 3615

def CreateAny(ctype, d, p)
  ret = true
  if IsPartType(ctype)
    mby = GetMountBy(Ops.get_string(p.value, "device", ""))
    mby = :uuid if Ops.get_symbol(p.value, "used_fs", :unknown) == :btrfs
    ret = CreatePartition(
      Ops.get_string(d, "device", ""),
      Ops.get_string(p.value, "device", ""),
      Ops.get_symbol(p.value, "type", :primary),
      Ops.get_integer(p.value, "fsid", Partitions.fsid_native),
      Ops.get_integer(p.value, ["region", 0], 0),
      Ops.get_integer(p.value, ["region", 1], 0),
      Ops.get_symbol(p.value, "mountby", mby)
    )
    if !Builtins.haskey(p.value, "mountby") && mby != :device
      Ops.set(p.value, "mountby", mby)
    end
  elsif ctype == :CT_MD
    ret = CreateMd( p.value["device"], p.value.fetch("raid_type","raid1") )
    if ret && p.value.has_key?("chunk_size")
      ChangeMdChunk( p.value["device"], p.value.fetch("chunk_size",4) )
    end
    if ret && HasRaidParity(p.value.fetch("raid_type","")) &&
        p.value.has_key?("parity_algorithm")
      ChangeMdParity( p.value["device"], p.value.fetch("parity_algorithm",""))
    end
    if ret
      ret = ExtendMd( p.value["device"], p.value.fetch("devices",[]))
    end
  elsif ctype == :CT_LOOP
    Builtins.y2milestone("CreateAny Loop p:%1", p.value)
    dev = CreateLoop(
      Ops.get_string(p.value, "fpath", ""),
      Ops.get_boolean(p.value, "create_file", false),
      Ops.get_integer(p.value, "size_k", 0),
      Ops.get_string(p.value, "mount", "")
    )
    ret = Ops.greater_than(Builtins.size(dev), 0)
    Ops.set(p.value, "device", dev) if ret
  elsif ctype == :CT_LVM
    if Ops.get_boolean(p.value, "pool", false)
      ret = CreateLvmPool(
        Ops.get_string(d, "name", ""),
        Ops.get_string(p.value, "name", ""),
        Ops.get_integer(p.value, "size_k", 0),
        Ops.get_integer(p.value, "stripes", 1)
      )
    elsif !Builtins.isempty(Ops.get_string(p.value, "used_pool", ""))
      ret = CreateLvmThin(
        Ops.get_string(d, "name", ""),
        Ops.get_string(p.value, "name", ""),
        Ops.get_string(p.value, "used_pool", ""),
        Ops.get_integer(p.value, "size_k", 0)
      )
    else
      ret = CreateLvmLv(
        Ops.get_string(d, "name", ""),
        Ops.get_string(p.value, "name", ""),
        Ops.get_integer(p.value, "size_k", 0),
        Ops.get_integer(p.value, "stripes", 1)
      )
    end
    if ret && Ops.greater_than(Ops.get_integer(p.value, "stripes", 1), 1) &&
        Ops.greater_than(Ops.get_integer(p.value, "stripesize", 0), 0)
      ChangeLvStripeSize(
        Ops.get_string(d, "name", ""),
        Ops.get_string(p.value, "name", ""),
        Ops.get_integer(p.value, "stripesize", 0)
      )
    end
  elsif ctype == :CT_NFS
    ret = AddNfsVolume(
      Ops.get_string(p.value, "device", ""),
      Ops.get_string(p.value, "fstopt", ""),
      Ops.get_integer(p.value, "size_k", 0),
      Ops.get_string(p.value, "mount", ""),
      Ops.get_symbol(p.value, "used_fs", :nfs) == :nfs4
    )
  end
  Builtins.y2milestone("CreateAny ret:%1", ret)
  ret
end

- (Object) CreateLoop(file, create, sizeK, mp)



3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
# File '../../src/modules/Storage.rb', line 3498

def CreateLoop(file, create, sizeK, mp)
  Builtins.y2milestone(
    "CreateLoop file:%1 create:%2 sizeK:%3 mp:%4",
    file,
    create,
    sizeK,
    mp
  )
  pwd = GetCryptPwd(file)
  ret, dev = @sint.createFileLoop(file, !create, sizeK, mp, pwd)
  dev = "" if ret<0
  Builtins.y2error("CreateLoop sint ret:%1", ret) if ret<0
  @sint.forgetCryptPassword(file)
  UpdateTargetMapDisk("/dev/loop")
  Builtins.y2milestone("CreateLoop dev:%1", dev)
  dev
end

- (Object) CreateLvmLv(vgname, lvname, sizeK, stripes)



3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
# File '../../src/modules/Storage.rb', line 3087

def CreateLvmLv(vgname, lvname, sizeK, stripes)
  Builtins.y2milestone(
    "CreateLvmLv vg:%1 name:%2 sizeK:%3 stripes:%4",
    vgname,
    lvname,
    sizeK,
    stripes
  )
  ret, dummy = @sint.createLvmLv(vgname, lvname, sizeK, stripes)
  dummy = "" if ret<0
  Builtins.y2error("CreateLvmLv sint ret:%1", ret) if ret<0
  UpdateTargetMapDisk(Ops.add("/dev/", vgname))
  ret == 0
end

- (Object) CreateLvmPool(vgname, lvname, sizeK, stripes)



3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
# File '../../src/modules/Storage.rb', line 3151

def CreateLvmPool(vgname, lvname, sizeK, stripes)
  Builtins.y2milestone(
    "CreateLvmPool vg:%1 name:%2 sizeK:%3 stripes:%4",
    vgname,
    lvname,
    sizeK,
    stripes
  )
  ret, dummy = @sint.createLvmLvPool(vgname, lvname, sizeK)
  dummy = "" if ret<0
  if ret<0
    Builtins.y2error("CreateLvmPool sint ret:%1", ret)
  elsif Ops.greater_than(stripes, 1) &&
      !ChangeLvStripeCount(vgname, lvname, stripes)
    ret = -1
  end
  UpdateTargetMapDisk(Ops.add("/dev/", vgname))
  ret == 0
end

- (Object) CreateLvmThin(vgname, lvname, pool, sizeK)



3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
# File '../../src/modules/Storage.rb', line 3103

def CreateLvmThin(vgname, lvname, pool, sizeK)
  Builtins.y2milestone(
    "CreateLvmThin vg:%1 name:%2 pool:%3 sizeK:%4",
    vgname,
    lvname,
    pool,
    sizeK
  )
  ret, dummy = @sint.createLvmLvThin(vgname, lvname, pool, sizeK)
  dummy = "" if ret<0
  Builtins.y2error("CreateLvmLv sint ret:%1", ret) if ret<0
  UpdateTargetMapDisk(Ops.add("/dev/", vgname))
  ret == 0
end

- (Object) CreateLvmVg(name, pesize, lvm2)



3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
# File '../../src/modules/Storage.rb', line 3023

def CreateLvmVg(name, pesize, lvm2)
  Builtins.y2milestone(
    "CreateLvmVg name:%1 pesize:%2 lvm2:%3",
    name,
    pesize,
    lvm2
  )
  devs = ::Storage::DequeString.new()
  ret = @sint.createLvmVg(name, pesize.div(1024), !lvm2, devs)
  Builtins.y2error("CreateLvmVg sint ret:%1", ret) if ret<0
  UpdateTargetMap()
  ret == 0
end

- (Object) CreateLvmVgWithDevs(name, pesize, lvm2, devs)



3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
# File '../../src/modules/Storage.rb', line 3047

def CreateLvmVgWithDevs(name, pesize, lvm2, devs)
  devd = StringDequeFromList(devs)
  Builtins.y2milestone(
    "CreateLvmVgWithDevs name:%1 pesize:%2 lvm2:%3 devs:%4",
    name,
    pesize,
    lvm2,
    devs
  )
  ret = @sint.createLvmVg(name, pesize.div(1024), !lvm2, devd)
  if ret<0
    Builtins.y2error("CreateLvmVgWithDevs sint ret:%1", ret)
  end
  UpdateTargetMap()
  ret == 0
end

- (Object) CreateMd(nr, type)



3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
# File '../../src/modules/Storage.rb', line 3269

def CreateMd(nr, type)
  Builtins.y2milestone("CreateMd nr:%1 type:%2", nr, type)
  tmp = Ops.get(@conv_mdstring, type, 0)
  empty = ::Storage::ListString.new()
  rd = MdToDev(nr)
  ret = @sint.createMd(rd, tmp, empty, empty)
  Builtins.y2error("CreateMd sint ret:%1", ret) if ret<0
  UpdateTargetMapDisk("/dev/md")
  ret == 0
end

- (Object) CreateMdWithDevs(nr, type, devices)



3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
# File '../../src/modules/Storage.rb', line 3290

def CreateMdWithDevs(nr, type, devices)
  Builtins.y2milestone(
    "CreateMdWithDevs nr:%1 type:%2 devices:%3",
    nr,
    type,
    devices
  )
  tmp = ::Storage::RAID_UNK
  Builtins.foreach(Ops.get_map(@conv_mdtype, "m", {})) do |k, v|
    tmp = k if v == type
  end
  empty = ::Storage::ListString.new()
  devs = StringListFromList(devices);
  rd = MdToDev(nr)
  ret = @sint.createMd(rd, tmp, devs, empty)
  if ret<0
    Builtins.y2error("CreateMdWithDevs sint ret:%1", ret)
  end
  UpdateTargetMap()
  ret == 0
end

- (Boolean) CreatePartition(disk, device, ptype, id, start, len, mby)

Creates a new partition

Parameters:

  • disk (String)
  • device (String)
  • ptype (Symbol)

    (types?)

  • id (Fixnum)
  • start (Fixnum)
  • len (Fixnum)

    (bytes|cyls?)

  • mby (Symbol)

    (one of?)

Returns:

  • (Boolean)

    if successful



2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
# File '../../src/modules/Storage.rb', line 2537

def CreatePartition(disk, device, ptype, id, start, len, mby)
  log.info("CreatePartition disk:#{disk} device:#{device} ptype:#{ptype} id:#{id} " +
           "start:#{start} len:#{len} mby:#{mby}")
  pt = fromSymbol(@conv_ptype, ptype)
  log.info("CreatePartition ptype:#{ptype} pt:#{pt}")
  region = ::Storage::RegionInfo.new(start, len)
  ret, cdev = @sint.createPartition(disk, pt, region)
  cdev = "" if ret<0
  if device != cdev
    log.error("CreatePartition device:#{device} cdev:#{cdev}")
  end
  log.error("CreatePartition ret #{ret}") if ret<0
  ret = @sint.changePartitionId(device, id)
  log.error("CreatePartition ret #{ret}") if ret<0
  tmp = fromSymbol(@conv_mountby, mby)
  @sint.changeMountBy(device, tmp)
  log.info("CreatePartition sint ret:#{ret}")
  UpdateTargetMap()
  ret == 0
end

- (Object) CreatePartitionTable(disk, label)



3568
3569
3570
3571
3572
3573
3574
3575
3576
# File '../../src/modules/Storage.rb', line 3568

def CreatePartitionTable(disk, label)
  Builtins.y2milestone("CreatePartitionTable %1 label:%2", disk, label)
  ret = @sint.destroyPartitionTable(disk, label)
  if ret<0
    Builtins.y2error("CreatePartitionTable sint ret:%1", ret)
  end
  UpdateTargetMap()
  ret == 0
end

- (Object) CreateTargetBackup(who)



2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
# File '../../src/modules/Storage.rb', line 2248

def CreateTargetBackup(who)
  t = Ops.add(
    Ops.add(Ops.add("targetMap_s_", who), "_"),
    Builtins.sformat("%1", @count)
  )
  @count = Ops.add(@count, 1)
  SCR.Write(path(".target.ycp"), SaveDumpPath(t), GetTargetMap())
  Builtins.y2milestone("CreateTargetBackup who:%1", who)
  ret = @sint.createBackupState(who)
  if ret<0
    Builtins.y2error("CreateTargetBackup sint ret:%1", ret)
  end

  nil
end

- (Object) CryptVolPopup(dev1, dev2)



4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
# File '../../src/modules/Storage.rb', line 4082

def CryptVolPopup(dev1, dev2)
  dev1 = deep_copy(dev1)
  dev2 = deep_copy(dev2)
  button_box = ButtonBox(
    PushButton(Id(:yes), Opt(:okButton), _("Provide Password")),
    PushButton(
      Id(:no_button),
      Opt(:default, :cancelButton),
      Label.CancelButton
    )
  )

  display_info = UI.GetDisplayInfo
  has_image_support = Ops.get_boolean(
    display_info,
    "HasImageSupport",
    false
  )

  ad = Empty()
  if Ops.greater_than(Builtins.size(dev2), 0)
    ad = VBox(
      Left(
        Label(_("The following encrypted volumes are already available."))
      ),
      Left(RichText(HTML.List(Builtins.sort(dev2)))),
      VSpacing(0.2)
    )
  end

  icon = has_image_support ? Top(Image(Icon.IconPath("question"))) : Empty()

  layout = VBox(
    VSpacing(0.4),
    HBox(
      icon,
      HSpacing(1),
      VBox(
        Left(Heading(_("Encrypted Volume Activation"))),
        VSpacing(0.2),
        Left(
          Label(
            _(
              "The following volumes contain an encryption signature but the \n" +
                "passwords are not yet known.\n" +
                "The passwords need to be known if the volumes are needed either \n" +
                "during an update or if they contain an encrypted LVM physical volume."
            )
          )
        ),
        VSpacing(0.2),
        Left(RichText(HTML.List(Builtins.sort(dev1)))),
        VSpacing(0.2),
        ad,
        Left(Label(_("Do you want to provide encryption passwords?"))),
        button_box
      )
    )
  )

  UI.OpenDialog(layout)
  ret = Convert.to_symbol(UI.UserInput)
  UI.CloseDialog
  Builtins.y2milestone("symbol:%1", ret)
  ret == :yes
end

- (Object) DefaultDiskLabel(disk)



3546
3547
3548
3549
3550
# File '../../src/modules/Storage.rb', line 3546

def DefaultDiskLabel(disk)
  label = @sint.defaultDiskLabel(disk)
  Builtins.y2milestone("DefaultDiskLabel disk:%1 label:%2", disk, label)
  label
end

- (Object) DeleteDevice(device)



2985
2986
2987
2988
2989
2990
2991
# File '../../src/modules/Storage.rb', line 2985

def DeleteDevice(device)
  Builtins.y2milestone("DeleteDevice device:%1", device)
  ret = @sint.removeVolume(device)
  Builtins.y2error("DeleteDevice sint ret:%1", ret) if ret<0
  UpdateTargetMap()
  ret == 0
end

- (Object) DeleteDmraid(name)



3003
3004
3005
3006
3007
3008
3009
# File '../../src/modules/Storage.rb', line 3003

def DeleteDmraid(name)
  Builtins.y2milestone("DeleteDmraid name:%1", name)
  ret = @sint.removeDmraid(name)
  Builtins.y2error("DeleteDmraid sint ret:%1", ret) if ret<0
  UpdateTargetMap()
  ret == 0
end

- (Object) DeleteLoop(disk, file, remove_file)



3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
# File '../../src/modules/Storage.rb', line 3532

def DeleteLoop(disk, file, remove_file)
  Builtins.y2milestone(
    "DeleteLoop disk:%1 file:%2 remove_file:%3",
    disk,
    file,
    remove_file
  )
  ret = @sint.removeFileLoop(file, remove_file)
  Builtins.y2error("DeleteLoop sint ret:%1", ret) if ret<0
  UpdateTargetMapDisk(disk)
  ret == 0
end

- (Object) DeleteLvmVg(name)



2994
2995
2996
2997
2998
2999
3000
# File '../../src/modules/Storage.rb', line 2994

def DeleteLvmVg(name)
  Builtins.y2milestone("DeleteLvmVg name:%1", name)
  ret = @sint.removeLvmVg(name)
  Builtins.y2error("DeleteLvmVg sint ret:%1", ret) if ret<0
  UpdateTargetMap()
  ret == 0
end

- (Object) DeleteMdPartCo(name)



3012
3013
3014
3015
3016
3017
3018
3019
3020
# File '../../src/modules/Storage.rb', line 3012

def DeleteMdPartCo(name)
  Builtins.y2milestone("DeleteMdPartCo name:%1", name)
  ret = @sint.removeMdPartCo(name, true)
  if ret<0
    Builtins.y2error("DeleteMdPartCo sint ret:%1", ret)
  end
  UpdateTargetMap()
  ret == 0
end

- (Boolean) DeletePartitionTable(disk, label)

Delete the partition table and disk label of device

Parameters:

  • string

    the disk to deleted the partition table from

Returns:

  • (Boolean)


3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
# File '../../src/modules/Storage.rb', line 3556

def DeletePartitionTable(disk, label)
  Builtins.y2milestone("DeletePartitionTable disk:%1 label:%2", disk, label)
  label = DefaultDiskLabel(disk) if Builtins.isempty(label)
  ret = @sint.destroyPartitionTable(disk, label)
  if ret<0
    Builtins.y2error("DeletePartitionTable sint ret:%1", ret)
  end
  UpdateTargetMap()
  ret == 0
end

- (Object) DelPartitionData(tg, device, key)

remove <key> in partition <device> and return changed map <tg>



5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
# File '../../src/modules/Storage.rb', line 5573

def DelPartitionData(tg, device, key)
  tg = deep_copy(tg)
  Builtins.y2debug("device=%1, key=%2", device, key)
  tmp = Ops.get(GetDiskPartitionTg(device, tg), 0, {})
  disk = Ops.get_string(tmp, "disk", "")
  dev = GetDeviceName(
    Ops.get_string(tmp, "disk", ""),
    Ops.get(tmp, "nr", 0)
  )
  Ops.set(
    tg,
    [disk, "partitions"],
    Builtins.maplist(Ops.get_list(tg, [disk, "partitions"], [])) do |p|
      if Ops.get_string(p, "device", "") == dev
        p = Builtins.filter(
          Convert.convert(p, :from => "map", :to => "map <string, any>")
        ) { |k, e| k != key }
      end
      deep_copy(p)
    end
  )
  deep_copy(tg)
end

- (Object) DelTmpfsVolume(mount)



3246
3247
3248
3249
3250
3251
3252
3253
3254
# File '../../src/modules/Storage.rb', line 3246

def DelTmpfsVolume(mount)
  Builtins.y2milestone("DelTmpfsVolume mount:%1", mount)
  ret = @sint.removeTmpfsMount(mount)
  if ret<0
    Builtins.y2error("DelTmpfsVolume sint ret:%1", ret)
  end
  UpdateTargetMapDisk("/dev/tmpfs")
  ret == 0
end

- (Symbol) DetectFs(device)

Detects a filesystem on a device

Parameters:

  • device (String)

    name

Returns:

  • (Symbol)

    filesystem



6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
# File '../../src/modules/Storage.rb', line 6264

def DetectFs(device)
  ret = :unknown
  Builtins.y2milestone("DetectFs:%1", device)
  vinfo = ::Storage::VolumeInfo.new()
  r = @sint.getVolume(device, vinfo)
  if r != 0
    Builtins.y2error("DetectFs device:%1 not found (ret:%2)", device, r)
  else
    curr = {}
    curr = volumeMap(vinfo, curr)
    ret = Ops.get_symbol(curr, "detected_fs", :unknown)
  end
  Builtins.y2milestone("DetectFs ret %1", ret)
  ret
end

- (Object) DetectHomeFs(p)



4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
# File '../../src/modules/Storage.rb', line 4915

def DetectHomeFs(p)
  p = deep_copy(p)
  Builtins.y2milestone("DetectHomeFs p:%1", p)
  ret = false
  poss_fs = [:ext2, :ext3, :ext4, :btrfs, :reiser, :xfs, :jfs]
  device = Ops.get_string(p, "device", "")
  if !Ops.get_boolean(p, "create", false) &&
      Builtins.contains(poss_fs, Ops.get_symbol(p, "detected_fs", :unknown)) &&
      !Builtins.isempty(device)
    resize_info = {}
     = {}

    if (
        resize_info_ref = arg_ref(resize_info);
         = arg_ref();
        _GetFreeInfo_result = GetFreeInfo(
          device,
          false,
          resize_info_ref,
          true,
          ,
          true
        );
        resize_info = resize_info_ref.value;
         = .value;
        _GetFreeInfo_result
      ) &&
        Ops.greater_than(Ops.get_integer(, :homes, 0), 0)
      ret = true
    end
  end
  Builtins.y2milestone("DetectHomeFs device:%1 ret:%2", device, ret)
  ret
end

- (Object) deviceMap(info)



1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
# File '../../src/modules/Storage.rb', line 1304

def deviceMap(info)

  ret = {
    "device" => info.device,
    "name" => info.name
  }

  tmp = []
  info.usedBy.each do |used_by|
    tmp.push({ "type" => toSymbol(@conv_usedby, used_by.type), "device" => used_by.device })
  end

  if tmp.empty?
    ret["used_by_type"] = :UB_NONE
    ret["used_by_device"] = ""
  else
    ret["used_by"] = tmp
    ret["used_by_type"] = tmp[0]["type"]
    ret["used_by_device"] = tmp[0]["device"]
  end

  ret["udev_path"] = info.udevPath if !info.udevPath.empty?
  ret["udev_id"] = info.udevId.to_a if !info.udevId.empty?

  if !info.userdata.empty?
    # there's no to_h for the swig stl map object
    tmp = {}
    info.userdata.each do |a, b|
      tmp[a] = b
    end
    ret["userdata"] = tmp
  end

  return ret

end

- (Object) DeviceMatchFstab(device, fstab_spec)



6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
# File '../../src/modules/Storage.rb', line 6923

def DeviceMatchFstab(device, fstab_spec)
  ret = false
  tg = GetTargetMap()
  ts = fstab_spec
  if DeviceNameMightNeedAdaption(fstab_spec)
    # translate fstab_spec from old to new kernel device name
    ts = Ops.get(GetTranslatedDevices({}, {}, [fstab_spec]), 0, "")
    if ts != fstab_spec
      Builtins.y2milestone(
        "DeviceMatchFstab translate %1 --> %2",
        fstab_spec,
        ts
      )
    end
  end
  pl = GetPartitionLst(tg, ts)
  ret = Builtins.find(pl) { |p| Ops.get_string(p, "device", "") == device } != nil
  Builtins.y2milestone(
    "DeviceMatchFstab device:%1 fstab:%2 ret:%3",
    device,
    fstab_spec,
    ret
  )
  ret
end

- (Object) DeviceMounted(dev)



4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
# File '../../src/modules/Storage.rb', line 4855

def DeviceMounted(dev)
  ret = ::Storage::ListString.new()
  @sint.checkDeviceMounted(dev, ret)
  if !ret.empty?
    Builtins.y2milestone("DeviceMounted %1 at %2", dev, ret.front())
  end
  if !ret.empty?
     ret.front()
  else
	 ""
  end
end

- (Object) DeviceNameMightNeedAdaption(device)



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File '../../src/modules/Storage.rb', line 305

def DeviceNameMightNeedAdaption(device)

  if IsKernelDeviceName(device)
    return true
  end

  if device.start_with?("/dev/disk/by-id/raid-") ||
      device.start_with?("/dev/disk/by-id/dm-name-") ||
      device.start_with?("/dev/disk/by-id/dm-uuid-DMRAID-")
    return true
  end

  return false

end

- (Object) DeviceRealDisk(device)



5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
# File '../../src/modules/Storage.rb', line 5638

def DeviceRealDisk(device)
  ret = false

  if Builtins.search(device, "LABEL") != 0 &&
      Builtins.search(device, "UUID") != 0
    dev = {}
    dev = GetDiskPartition(device)
    ret = Ops.get_string(dev, "disk", "") != "/dev/md" &&
      Ops.get_string(dev, "disk", "") != "/dev/loop" &&
      Builtins.search(Ops.get_string(dev, "disk", ""), "/dev/evms") != 0 &&
      Ops.is_integer?(Ops.get(dev, "nr", 0))
    if !ret && Ops.get_string(dev, "disk", "") != "/dev/md"
      st = Convert.to_map(
        SCR.Read(path(".target.stat"), Ops.get_string(dev, "disk", ""))
      )
      ret = !Ops.get_boolean(st, "isdir", false)
    end
  end
  Builtins.y2milestone("DeviceRealDisk %1 ret %2", device, ret)
  ret
end

- (Object) diskMap(dinfo, d)



1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
# File '../../src/modules/Storage.rb', line 1255

def diskMap(dinfo, d)
  d = deep_copy(d)
  Ops.set(d, "size_k", dinfo.sizeK)
  Ops.set(d, "cyl_size", dinfo.cylSize)
  Ops.set(d, "cyl_count", dinfo.cyl)
  Ops.set(d, "sector_size", dinfo.sectorSize)
  Ops.set(d, "label", dinfo.disklabel)
  tmp = dinfo.orig_disklabel
  Ops.set(d, "orig_label", tmp) if Ops.greater_than(Builtins.size(tmp), 0)
  Ops.set(d, "max_logical", dinfo.maxLogical)
  Ops.set(d, "max_primary", dinfo.maxPrimary)

  t = dinfo.transport
  Ops.set(d, "transport", toSymbol(@conv_transport, t))
  if t == ::Storage::ISCSI
    Ops.set(d, "iscsi", true)
  elsif Builtins.haskey(d, "iscsi")
    d = Builtins.remove(d, "iscsi")
  end

  bt = dinfo.has_fake_partition
  if bt
    Ops.set(d, "has_fake_partition", true)
  elsif Builtins.haskey(d, "has_fake_partition")
    d = Builtins.remove(d, "has_fake_partition")
  end

  bt = dinfo.initDisk
  if bt
    Ops.set(d, "dasdfmt", true)
  elsif Builtins.haskey(d, "dasdfmt")
    d = Builtins.remove(d, "dasdfmt")
  end
  Builtins.y2milestone("diskMap ret:%1", d)
  deep_copy(d)
end

- (Object) DisposeTargetBackup(who)



2265
2266
2267
2268
2269
2270
2271
2272
2273
# File '../../src/modules/Storage.rb', line 2265

def DisposeTargetBackup(who)
  Builtins.y2milestone("DisposeTargetBackup who:%1", who)
  ret = @sint.removeBackupState(who)
  if ret<0
    Builtins.y2error("DisposeTargetBackup sint ret:%1", ret)
  end

  nil
end

- (Object) dmPartCoMap(infos, d)



1293
1294
1295
1296
1297
1298
1299
1300
1301
# File '../../src/modules/Storage.rb', line 1293

def dmPartCoMap(infos, d)
  d = deep_copy(d)
  dinfo = infos.d
  d = diskMap(dinfo, d)
  d["devices"] = infos.devices.to_a
  Ops.set(d, "minor", infos.minor)
  Builtins.y2milestone("dmPartCoMap ret:%1", d)
  deep_copy(d)
end

- (Object) dmPartMap(info, p)



1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
# File '../../src/modules/Storage.rb', line 1440

def dmPartMap(info, p)
  p = deep_copy(p)
  vinfo = info.v
  p = volumeMap(vinfo, p)
  Ops.set(p, "nr", 0)
  part = info.part
  if part
    pinfo = info.p
    p = partAddMap(pinfo, p)
  end
  Builtins.y2milestone("dmPartMap ret:%1", p)
  deep_copy(p)
end

- (Object) DumpObjectList



6879
6880
6881
6882
6883
# File '../../src/modules/Storage.rb', line 6879

def DumpObjectList
  return if !InitLibstorage(false)
  @sint.dumpObjectList()
  nil
end

- (Object) EqualBackupStates(s1, s2, vb)



2276
2277
2278
2279
2280
2281
2282
2283
# File '../../src/modules/Storage.rb', line 2276

def EqualBackupStates(s1, s2, vb)
  Builtins.y2milestone(
    "EqualBackupStates s1:\"%1\" s2:\"%2\" verbose:%3",
    s1, s2, vb)
  ret = @sint.equalBackupStates(s1, s2, vb)
  Builtins.y2milestone("EqualBackupStates ret:%1", ret)
  ret
end

- (Object) ExtendBtrfsVolume(uuid, device)



3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
# File '../../src/modules/Storage.rb', line 3172

def ExtendBtrfsVolume(uuid, device)
  Builtins.y2milestone("ExtendBtrfsVolume uuid:%1 device:%2", uuid, device)
  ret = 0
  devd = ::Storage::DequeString.new()
  devd.push(device)
  ret = @sint.extendBtrfsVolume(uuid, devd)
  if ret<0
    Builtins.y2error("ExtendBtrfsVolume sint ret:%1", ret)
  end
  UpdateTargetMap()
  ret == 0
end

- (Object) ExtendedErrorMsg



5425
5426
5427
# File '../../src/modules/Storage.rb', line 5425

def ExtendedErrorMsg
  return @sint.getExtendedErrorMessage().force_encoding("UTF-8")
end

- (Object) ExtendLvmVg(name, device)



3065
3066
3067
3068
3069
3070
3071
3072
3073
# File '../../src/modules/Storage.rb', line 3065

def ExtendLvmVg(name, device)
  Builtins.y2milestone("ExtendLvmVg name:%1 device:%2", name, device)
  devd = ::Storage::DequeString.new()
  devd.push(device)
  ret = @sint.extendLvmVg(name, devd)
  Builtins.y2error("ExtendLvmVg sint ret:%1", ret) if ret<0
  UpdateTargetMap()
  ret == 0
end

- (Object) ExtendMd(nr, devs)



3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
# File '../../src/modules/Storage.rb', line 3325

def ExtendMd(nr, devs)
  Builtins.y2milestone("ExtendMd nr:%1 devs:%2", nr, devs)
  empty = ::Storage::ListString.new()
  devices = StringListFromList(devs);
  rd = MdToDev(nr)
  ret = @sint.extendMd(rd, devices, empty)
  Builtins.y2error("ExtendMd sint ret:%1", ret) if ret<0
  UpdateTargetMap()
  ret == 0
end

- (Object) FindBtrfsUuid(uuid)



5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
# File '../../src/modules/Storage.rb', line 5112

def FindBtrfsUuid(uuid)
  btrfs = Ops.get(GetTargetMap(), "/dev/btrfs", {})
  ret = Ops.get(
    Builtins.filter(Ops.get_list(btrfs, "partitions", [])) do |p|
      Ops.get_string(p, "uuid", "") == uuid
    end,
    0,
    {}
  )
  Builtins.y2milestone("FindBtrfsUuid uuid:%1 ret:%2", uuid, ret)
  deep_copy(ret)
end

- (Object) FinishInstall



6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
# File '../../src/modules/Storage.rb', line 6498

def FinishInstall
  Builtins.y2milestone("FinishInstall initial:%1", Stage.initial)

  target_map = GetTargetMap()

  need_crypt = false
  need_md = false
  need_lvm = false
  need_dmraid = false
  need_dmmultipath = false

  Builtins.foreach(target_map) do |k, e|
    if Builtins.find(Ops.get_list(e, "partitions", [])) do |part|
        Ops.get_symbol(part, "enc_type", :none) != :none
      end != nil
      need_crypt = true
    end
    if Ops.get_symbol(e, "type", :CT_UNKNOWN) == :CT_MD &&
        !Builtins.isempty(Ops.get_list(e, "partitions", []))
      need_md = true
    end
    need_md = true if Ops.get_symbol(e, "type", :CT_UNKNOWN) == :CT_MDPART
    need_lvm = true if Ops.get_symbol(e, "type", :CT_UNKNOWN) == :CT_LVM
    if Ops.get_symbol(e, "type", :CT_UNKNOWN) == :CT_DMRAID
      need_dmraid = true
    end
    if Ops.get_symbol(e, "type", :CT_UNKNOWN) == :CT_DMMULTIPATH
      need_dmmultipath = true
    end
  end

  Builtins.y2milestone(
    "FinishInstall need crypto:%1 md:%2 lvm:%3 dmraid:%4 dmmultipath:%5",
    need_crypt,
    need_md,
    need_lvm,
    need_dmraid,
    need_dmmultipath
  )

  CallInsserv(need_md, "boot.md")
  CallInsserv(need_dmraid, "boot.dmraid")
  Service.Enable("multipathd") if need_dmmultipath

  Builtins.y2milestone("FinishInstall done")

  nil
end

- (Object) FinishLibstorage



359
360
361
362
363
364
365
366
367
# File '../../src/modules/Storage.rb', line 359

def FinishLibstorage
  return if @sint == nil

  log.info("FinishLibstorage")
  ::Storage::destroyStorageInterface(@sint)
  @sint = nil

  nil
end

- (Object) FreeCylindersAroundPartition(device, free_before, free_after)



6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
# File '../../src/modules/Storage.rb', line 6068

def FreeCylindersAroundPartition(device, free_before, free_after)
  r, free_before.value, free_after.value = 
	@sint.freeCylindersAroundPartition(device)
  ret = r==0
  Builtins.y2milestone(
    "FreeCylindersAfterPartition ret:%1 free_before:%2 free_after:%3",
    ret,
    free_before.value,
    free_after.value
  )
  ret
end

- (Object) fromSymbol(conv, val)



502
503
504
505
506
507
# File '../../src/modules/Storage.rb', line 502

def fromSymbol(conv, val)
  conv = deep_copy(conv)
  ret = Ops.get_integer(conv, "def_int", -1)
  Builtins.foreach(Ops.get_map(conv, "m", {})) { |i, s| ret = i if s == val }
  ret
end

- (Object) GetAffectedDevices(dev)



4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
# File '../../src/modules/Storage.rb', line 4560

def GetAffectedDevices(dev)
  devs = ::Storage::ListString.new();
  devs.push(dev)
  r = ::Storage::ListString.new();
  res = @sint.getRecursiveUsing(devs, false, r);
  Builtins.y2milestone("GetAffectedDevices dev:%1 ret:%2", dev, res)
  ret = r.to_a
  Builtins.y2milestone("GetAffectedDevices ret:%1", ret)
  ret
end

- (Object) GetBootPartition(disk)



6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
# File '../../src/modules/Storage.rb', line 6281

def GetBootPartition(disk)
  ret = {}
  tg = GetTargetMap()
  ret = Ops.get(
    Builtins.filter(Ops.get_list(tg, [disk, "partitions"], [])) do |p|
      Ops.get_boolean(p, "boot", false)
    end,
    0,
    {}
  )
  Builtins.y2milestone("disk:%1 ret:%2", disk, ret)
  deep_copy(ret)
end

- (Object) GetCommitInfos

FIXME: please, add description of the list that is returned by this function.



5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
# File '../../src/modules/Storage.rb', line 5377

def GetCommitInfos
  infos = ::Storage::ListCommitInfo.new()
  @sint.getCommitInfos(infos)
  ret = []
  infos.each do |info|
    m = {
      :destructive => info.destructive,
      :text => info.text.force_encoding("UTF-8")
    }
	ret.push(m)
  end
  ret
end

- (Object) getContainerInfo(c)



1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
# File '../../src/modules/Storage.rb', line 1475

def getContainerInfo(c)
  Builtins.y2milestone("getContainerInfo %1", c)
  ret = 0
  t = 0
  vinfo = ::Storage::VolumeInfo.new()
  if Ops.get_symbol(c, "type", :CT_UNKNOWN) == :CT_DISK
    pinfos = ::Storage::DequePartitionInfo.new()
    infos = ::Storage::DiskInfo.new()
    d = Ops.get_string(c, "device", "")
    ret = @sint.getDiskInfo( d, infos)
    if ret == 0
      c = diskMap(infos, c)
    else
      Builtins.y2warning(
        "disk \"%1\" ret:%2",
        Ops.get_string(c, "device", ""),
        ret
      )
    end
    Ops.set(c, "partitions", [])
    ret = @sint.getPartitionInfo(d, pinfos)
    pinfos.each do |info|
      tmp = ""
      p = {}
      vinfo = info.v
      p = volumeMap(vinfo, p)
      Ops.set(p, "nr", info.nr)
      Ops.set(p, "fsid", info.id)
      Ops.set(
        p,
        "fstype",
        Partitions.FsIdToString(Ops.get_integer(p, "fsid", 0))
      )
      p["region"] = [ info.cylRegion.start, info.cylRegion.len ]
      t = info.partitionType
      Ops.set(p, "type", toSymbol(@conv_ptype, t))
      boot = info.boot
      Ops.set(p, "boot", true) if boot
      Ops.set(
        c,
        "partitions",
        Builtins.add(Ops.get_list(c, "partitions", []), p)
      )
    end
  elsif Ops.get_symbol(c, "type", :CT_UNKNOWN) == :CT_DMRAID
    pinfos = ::Storage::DequeDmraidInfo.new()
    infos = ::Storage::DmraidCoInfo.new()
    d = Ops.get_string(c, "device", "")
    ret = @sint.getDmraidCoInfo(d,infos)
    if ret == 0
      pinfo = infos.p
      c = dmPartCoMap(pinfo, c)
    else
      Builtins.y2warning(
        "disk \"%1\" ret:%2",
        Ops.get_string(c, "device", ""),
        ret)
    end
    Ops.set(c, "partitions", [])
    ret = @sint.getDmraidInfo( d, pinfos)
    pinfos.each do |info|
      pinfo = info.p
      p = {}
      p = dmPartMap(pinfo, p)
      Ops.set(p, "fstype", Partitions.dmraid_name)
      if Ops.get_integer(p, "nr", -1) != 0
        Ops.set(
          c,
          "partitions",
          Builtins.add(Ops.get_list(c, "partitions", []), p)
        )
      end
    end
  elsif Ops.get_symbol(c, "type", :CT_UNKNOWN) == :CT_DMMULTIPATH
    pinfos = ::Storage::DequeDmmultipathInfo.new()
    infos = ::Storage::DmmultipathCoInfo.new()
    d = Ops.get_string(c, "device", "")
    ret = @sint.getDmmultipathCoInfo(d, infos)
    if ret == 0
      pinfo = infos.p
      c = dmPartCoMap(pinfo, c)
    else
      Builtins.y2warning(
        "disk \"%1\" ret:%2",
        Ops.get_string(c, "device", ""),
        ret
      )
    end
    Ops.set(c, "partitions", [])
    ret = @sint.getDmmultipathInfo( d, pinfos )
    pinfos.each do |info|
      pinfo = info.p
      p = {}
      p = dmPartMap(pinfo, p)
      Ops.set(p, "fstype", Partitions.dmmultipath_name)
      if Ops.get_integer(p, "nr", -1) != 0
        Ops.set(
          c,
          "partitions",
          Builtins.add(Ops.get_list(c, "partitions", []), p)
        )
      end
    end
  elsif Ops.get_symbol(c, "type", :CT_UNKNOWN) == :CT_MDPART
    pinfos = ::Storage::DequeMdPartInfo.new()
    infos = ::Storage::MdPartCoInfo.new()
    d = Ops.get_string(c, "device", "")
    ret = @sint.getMdPartCoInfo( d, infos)
    if ret == 0
      dinfo = infos.d
      c = diskMap(dinfo, c)
    else
      Builtins.y2warning(
        "disk \"%1\" ret:%2",
        Ops.get_string(c, "device", ""),
        ret
      )
    end

    c["devices"] = infos.devices.to_a
    c["spares" ] = infos.spares.to_a if !infos.spares.empty?

    t2 = infos.type
    Ops.set(
      c,
      "raid_type",
      Builtins.substring(
        Builtins.sformat("%1", toSymbol(@conv_mdtype, t2)),
        1
      )
    )
    if HasRaidParity(Ops.get_string(c, "raid_type", ""))
      t2 = infos.parity
      pt = toSymbol(@conv_mdparity, t2)
      if pt != :par_default
        Ops.set(c, "parity_algorithm", Ops.get(@rev_conv_parstring, t2, ""))
      end
    end
    t2 = infos.chunkSizeK
    Ops.set(c, "chunk_size", t2) if t2>0
    Ops.set(c, "sb_ver", infos.sb_ver)

    Ops.set(c, "partitions", [])
    ret = @sint.getMdPartInfo(d, pinfos)
    pinfos.each do |info|
      p = {}
      p = mdPartMap(info, p)
      Ops.set(p, "fstype", Partitions.raid_name)
      if Ops.get_integer(p, "nr", -1) != 0
        Ops.set(
          c,
          "partitions",
          Builtins.add(Ops.get_list(c, "partitions", []), p)
        )
      end
    end
  elsif Ops.get_symbol(c, "type", :CT_UNKNOWN) == :CT_LVM
    pinfos = ::Storage::DequeLvmLvInfo.new()
    infos = ::Storage::LvmVgInfo.new()
    n = Ops.get_string(c, "name", "")
    ret = @sint.getLvmVgInfo(n, infos)
    if ret == 0
      Ops.set(c, "create", infos.create)
      Ops.set(c, "size_k", infos.sizeK)
      Ops.set(c, "cyl_size", 1024*infos.peSizeK)
      Ops.set(c, "pesize", 1024*infos.peSizeK)
      Ops.set(c, "cyl_count", infos.peCount)
      Ops.set(c, "pe_free", infos.peFree)
      Ops.set(c, "lvm2", infos.lvm2)

      c["devices"] = infos.devices.to_a
      c["devices_add"] = infos.devices_add.to_a if !infos.devices_add.empty?
      c["devices_rem"] = infos.devices_rem.to_a if !infos.devices_rem.empty?
    else
      Builtins.y2warning(
        "LVM Vg \"%1\" ret:%2",
        Ops.get_string(c, "name", ""),
        ret
      )
    end
    ret = @sint.getLvmLvInfo(n, pinfos)
    pinfos.each do |info|
      p = {}
      vinfo = info.v
      p = volumeMap(vinfo, p)
      Ops.set(p, "stripes", info.stripes)
      t = info.stripeSizeK
      Ops.set(p, "stripesize", t) if t>0
      s = info.origin
      Ops.set(p, "origin", s) if !Builtins.isempty(s)
      s = info.used_pool
      Ops.set(p, "used_pool", s) if !Builtins.isempty(s)
      Ops.set(p, "pool", true) if info.pool
      Ops.set(p, "type", :lvm)
      Ops.set(p, "fstype", Partitions.lv_name)
      Ops.set(
        c,
        "partitions",
        Builtins.add(Ops.get_list(c, "partitions", []), p)
      )
    end
  elsif Ops.get_symbol(c, "type", :CT_UNKNOWN) == :CT_MD
    pinfos = ::Storage::DequeMdInfo.new()
    ret = @sint.getMdInfo(pinfos)
    Builtins.y2warning("getMdInfo ret:%1", ret) if ret<0
    pinfos.each do |info|
      p = {}
      vinfo = info.v
      p = volumeMap(vinfo, p)
      Ops.set(p, "nr", info.nr)
      t2 = info.type
      Ops.set(
        p,
        "raid_type",
        Builtins.substring(
          Builtins.sformat("%1", toSymbol(@conv_mdtype, t2)),
          1
        )
      )
      if HasRaidParity(Ops.get_string(p, "raid_type", ""))
        pt = toSymbol(@conv_mdparity, info.parity)
        if pt != :par_default
          Ops.set(
            p,
            "parity_algorithm",
            Ops.get(@rev_conv_parstring, info.parity, "")
          )
        end
      end
      Ops.set(p, "type", :sw_raid)
      Ops.set(p, "fstype", Partitions.raid_name)
      t2 = info.chunkSizeK
      Ops.set(p, "chunk_size", t2) if t2>0
      Ops.set(p, "sb_ver", info.sb_ver)
      Ops.set(p, "raid_inactive", true) if info.inactive

      p["devices"] = info.devices.to_a
      p["spares"] = info.spares.to_a if !info.spares.empty?

      Ops.set(
        c,
        "partitions",
        Builtins.add(Ops.get_list(c, "partitions", []), p)
      )
    end
  elsif Ops.get_symbol(c, "type", :CT_UNKNOWN) == :CT_LOOP
    pinfos = ::Storage::DequeLoopInfo.new()
    ret = @sint.getLoopInfo(pinfos)
    Builtins.y2warning("getLoopInfo ret:%1", ret) if ret<0
    pinfos.each do |info|
      p = {}
      vinfo = info.v
      p = volumeMap(vinfo, p)
      Ops.set(p, "nr", info.nr)
      Ops.set(p, "type", :loop)
      Ops.set(p, "fstype", Partitions.loop_name)
      Ops.set(p, "fpath", info.file)
      Ops.set(p, "create_file", !info.reuseFile)
      if Ops.get_symbol(p, "enc_type", :unknown) != :luks &&
          !Builtins.isempty(Ops.get_string(p, "loop", ""))
        Ops.set(p, "device", Ops.get_string(p, "loop", ""))
      end
      Ops.set(
        c,
        "partitions",
        Builtins.add(Ops.get_list(c, "partitions", []), p)
      )
    end
  elsif Ops.get_symbol(c, "type", :CT_UNKNOWN) == :CT_DM
    pinfos = ::Storage::DequeDmInfo.new()
    ret = @sint.getDmInfo(pinfos)
    Builtins.y2warning("getDmInfo ret:%1", ret) if ret<0
    pinfos.each do |info|
      p = {}
      vinfo = info.v
      p = volumeMap(vinfo, p)
      Ops.set(p, "nr", info.nr)
      Ops.set(p, "type", :dm)
      Ops.set(p, "fstype", Partitions.dm_name)
      Ops.set(
        c,
        "partitions",
        Builtins.add(Ops.get_list(c, "partitions", []), p)
      )
    end
  elsif Ops.get_symbol(c, "type", :CT_UNKNOWN) == :CT_NFS
    pinfos = ::Storage::DequeNfsInfo.new()
    Builtins.y2milestone("before getNfsInfo")
    ret = @sint.getNfsInfo(pinfos)
    Builtins.y2milestone("after getNfsInfo")
    Builtins.y2warning("getNfsInfo ret:%1", ret) if ret<0
    pinfos.each do |info|
      p = {}
      vinfo = info.v
      p = volumeMap(vinfo, p)
      Ops.set(p, "type", :nfs)
      Ops.set(p, "fstype", Partitions.nfs_name)
      Ops.set(
        c,
        "partitions",
        Builtins.add(Ops.get_list(c, "partitions", []), p)
      )
    end
  elsif Ops.get_symbol(c, "type", :CT_UNKNOWN) == :CT_BTRFS
    pinfos = ::Storage::DequeBtrfsInfo.new()
    Builtins.y2milestone("before getBtrfsInfo")
    ret = @sint.getBtrfsInfo(pinfos)
    Builtins.y2milestone("after getBtrfsInfo")
    Builtins.y2warning("getBtrfsInfo ret:%1", ret) if ret<0
    pinfos.each do |info|
      p = {}
      vinfo = info.v
      p = volumeMap(vinfo, p)
      Ops.set(p, "type", :btrfs)
      Ops.set(p, "fstype", Partitions.btrfs_name)

      p["devices"] = info.devices.to_a
      p["devices_add"] = info.devices_add.to_a if !info.devices_add.empty?
      p["devices_rem"] = info.devices_rem.to_a if !info.devices_rem.empty?

      li = []
      Ops.set(p, "subvol", li)
      ls = []
      info.subvol.each { |subvol| ls.push(subvol) }
      if !Builtins.isempty(ls)
        li = Builtins.maplist(ls) do |s|
          m = { "name" => s }
          deep_copy(m)
        end
        Ops.set(p, "subvol", li)
        Builtins.y2milestone("subvol:%1", Ops.get_list(p, "subvol", []))
      end
      ls = []
      info.subvol_add.each { |subvol_add| ls.push(subvol_add) }
      if !Builtins.isempty(ls)
        li = Builtins.maplist(ls) do |s|
          m = { "create" => true, "name" => s }
          deep_copy(m)
        end
        Ops.set(
          p,
          "subvol",
          Builtins.union(Ops.get_list(p, "subvol", []), li)
        )
        Builtins.y2milestone("subvol:%1", Ops.get_list(p, "subvol", []))
      end
      ls = []
      info.subvol_rem.each { |subvol_rem| ls.push(subvol_rem) }
      if !Builtins.isempty(ls)
        li = Builtins.maplist(ls) do |s|
          m = { "delete" => true, "name" => s }
          deep_copy(m)
        end
        Ops.set(
          p,
          "subvol",
          Builtins.union(Ops.get_list(p, "subvol", []), li)
        )
        Builtins.y2milestone("subvol:%1", Ops.get_list(p, "subvol", []))
      end
	  vols = 0;
	  vols += p["devices"].size if( p.has_key?("devices") )
	  vols += p["devices_add"].size if( p.has_key?("devices_add") )
      if vols>1 
         !Builtins.isempty(Ops.get_list(p, "devices_add", []))
        Ops.set(
          p,
          "device",
          Ops.add("UUID=", Ops.get_string(p, "uuid", ""))
        )
      end
      Ops.set(
        c,
        "partitions",
        Builtins.add(Ops.get_list(c, "partitions", []), p)
      )
    end
  elsif Ops.get_symbol(c, "type", :CT_UNKNOWN) == :CT_TMPFS
    pinfos = ::Storage::DequeTmpfsInfo.new()
    Builtins.y2milestone("before getTmpfsInfo")
    ret = @sint.getTmpfsInfo(pinfos)
    Builtins.y2milestone("after getTmpfsInfo")
    Builtins.y2warning("getTmpfsInfo ret:%1", ret) if ret<0
    pinfos.each do |info|
      p = {}
      vinfo = info.v
      p = volumeMap(vinfo, p)
      Ops.set(p, "type", :tmpfs)
      Ops.set(p, "fstype", Partitions.tmpfs_name)
      Ops.set(p, "device", "tmpfs")
      Ops.set(
        c,
        "partitions",
        Builtins.add(Ops.get_list(c, "partitions", []), p)
      )
    end
  end
  #y2milestone ("getContainerInfo container %1", remove( c, "partitions" ) );
  Builtins.y2milestone("getContainerInfo container %1", c)
  deep_copy(c)
end

- (Object) getContainers



1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
# File '../../src/modules/Storage.rb', line 1917

def getContainers
  ret = []
  cinfos = ::Storage::DequeContainerInfo.new()
  @sint.getContainers(cinfos)
  cinfos.each do |info|
    c = deviceMap(info)
    c["type"] = toSymbol(@conv_ctype, info.type)
	Builtins.y2milestone("c:%1",c)
    c["readonly"] = true if info.readonly
    ret = Builtins.add(ret, c)
  end
  Builtins.y2milestone("getContainers ret:%1", ret)
  deep_copy(ret)
end

- (Object) GetContVolInfo(device, info)



510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
# File '../../src/modules/Storage.rb', line 510

def GetContVolInfo(device, info)
  tmp = ::Storage::ContVolInfo.new()
  if @sint.getContVolInfo(device, tmp) != 0
    return false
  end

  info.value = {
    "ctype"   => toSymbol(@conv_ctype, tmp.ctype),
    "cname"   => tmp.cname,
    "cdevice" => tmp.cdevice,
    "vname"   => tmp.vname,
    "vdevice" => tmp.vdevice,
    "num"     => tmp.num
  }

  Builtins.y2milestone(
    "GetContVolInfo device:%1 info:%2",
    device,
    info.value
  )
  true
end

- (Object) GetCreatedSwaps



7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
# File '../../src/modules/Storage.rb', line 7096

def GetCreatedSwaps
  tg = GetTargetMap()
  ret = []
  Builtins.foreach(tg) do |k, d|
    ret = Builtins.union(
      ret,
      Builtins.filter(Ops.get_list(d, "partitions", [])) do |p|
        Ops.get_boolean(p, "create", false) &&
          Ops.get_string(p, "mount", "") == "swap"
      end
    )
  end
  deep_copy(ret)
end

- (Object) GetCryptLists(target)



4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
# File '../../src/modules/Storage.rb', line 4150

def GetCryptLists(target)
  target = deep_copy(target)
  ac_cr = []
  in_cr = []
  Builtins.foreach(target) do |k, m|
    tmp = Builtins.filter(Ops.get_list(m, "partitions", [])) do |p|
      Ops.get_symbol(p, "enc_type", :none) == :luks
    end
    in_cr = Convert.convert(
      Builtins.merge(in_cr, Builtins.filter(tmp) do |p|
        Builtins.isempty(Ops.get_string(p, "crypt_device", ""))
      end),
      :from => "list",
      :to   => "list <map>"
    )
    ac_cr = Convert.convert(
      Builtins.merge(ac_cr, Builtins.filter(tmp) do |p|
        !Builtins.isempty(Ops.get_string(p, "crypt_device", ""))
      end),
      :from => "list",
      :to   => "list <map>"
    )
  end
  Builtins.y2milestone("GetCryptLists inactive:%1", in_cr)
  Builtins.y2milestone("GetCryptLists active:%1", ac_cr)
  ret = {}
  Ops.set(ret, "active", Builtins.maplist(ac_cr) do |p|
    Ops.get_string(p, "device", "")
  end)
  Ops.set(ret, "inactive", Builtins.maplist(in_cr) do |p|
    Ops.get_string(p, "device", "")
  end)
  Builtins.y2milestone("ret:%1", ret)
  deep_copy(ret)
end

- (Object) GetCryptPwd(device)



3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
# File '../../src/modules/Storage.rb', line 3424

def GetCryptPwd(device)
  Builtins.y2milestone("GetCryptPwd device:%1", device)
  ret, pwd = @sint.getCryptPassword(device)
  pwd = "" if ret<0
  if ret<0
    Builtins.y2error("GetCryptPwd sint ret:%1", ret)
  else
    Builtins.y2milestone("GetCryptPwd empty:%1", Builtins.size(pwd) == 0)
  end
  pwd
end

- (Object) GetCustomDisplay



2341
2342
2343
# File '../../src/modules/Storage.rb', line 2341

def GetCustomDisplay
  Ops.get_boolean(@StorageMap, @custom_display_key, false)
end

- (Object) GetDefaultMountBy



6894
6895
6896
6897
6898
# File '../../src/modules/Storage.rb', line 6894

def GetDefaultMountBy
  val = @sint.getDefaultMountBy()
  ret = toSymbol(@conv_mountby, val)
  ret
end

- (Object) GetDetectedDiskPaths



7112
7113
7114
7115
7116
7117
# File '../../src/modules/Storage.rb', line 7112

def GetDetectedDiskPaths
  disks = ::Storage::getPresentDisks
  ret = disks.to_a
  Builtins.y2milestone("disks:%1", ret)
  ret
end

- (String) GetDeviceName(disk, partition)

Returns Device Name

Examples:

Storage::GetDeviceName(“/dev/md”, 1)

Storage::GetDeviceName(“/dev/system”, “root”)

Parameters:

  • string

    Disk

  • partition (Object)

Returns:

  • (String)

    device name



471
472
473
474
475
476
477
478
479
# File '../../src/modules/Storage.rb', line 471

def GetDeviceName(disk, partition)
  ret = disk
  if Ops.is_integer?(partition)
    ret = @sint.getPartitionName(disk, Convert.to_integer(partition));
  elsif !Builtins.isempty(Convert.to_string(partition))
    ret = Ops.add(Ops.add(ret, "/"), Convert.to_string(partition))
  end
  ret
end

- (Object) GetDisk(tg, device)

Returns disk identified by 'device' taken from the 'tg' (target) map

Parameters:

  • tg (Hash{String => map})

    (target map)

  • device (String)


852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
# File '../../src/modules/Storage.rb', line 852

def GetDisk(tg, device)
  tg = deep_copy(tg)
  ret = {}
  tmp = Ops.get(GetDiskPartitionTg(device, tg), 0, {})
  disk = Ops.get_string(tmp, "disk", "")
  if Builtins.search(device, "/dev/evms") == 0 && !Builtins.haskey(tg, disk)
    disk = "/dev/evms"
  end
  Builtins.y2debug("GetDisk disk=%1", disk)
  Convert.convert(
    Ops.get(tg, disk, {}),
    :from => "map",
    :to   => "map <string, any>"
  )
end

- (Hash) getDiskInfo(device, disk)

Returns map with disk info

Parameters:

  • device (String)
  • disk (Hash)

Returns:

  • (Hash)

    disk info



2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
# File '../../src/modules/Storage.rb', line 2182

def getDiskInfo(device, disk)
  disk = deep_copy(disk)
  c = {}
  c = Builtins.find(@conts) { |p| Ops.get_string(p, "device", "") == device }
  if c == nil
    tmp = GetDiskPartition(device)
    Builtins.y2milestone("getDiskInfo map %1", tmp)
    c = Builtins.find(@conts) do |p|
      Ops.get_string(p, "device", "") == Ops.get_string(tmp, "disk", "")
    end if Ops.get_string(
      tmp,
      "disk",
      ""
    ) != device
  end
  Builtins.y2milestone("getDiskInfo c:%1", c)
  if c != nil
    disk = toDiskMap(disk, getContainerInfo(c))
    Builtins.y2milestone(
      "getDiskInfo ret:%1",
      Builtins.haskey(disk, "partitions") ?
        Builtins.remove(disk, "partitions") :
        disk
    )
  end
  deep_copy(disk)
end

- (Hash) GetDiskPartition(device)

Returns map describing the disk partition

Examples: “/dev/sda” -> $[ “disk” : “/dev/sda”, “nr” : “” ] “/dev/sda2” -> $[ “disk” : “/dev/sda”, “nr” : 2 ] “/dev/system” -> $[ “disk” : “/dev/system”, “nr” : “” ] “/dev/system/abuild” -> $[ “disk” : “/dev/system”, “nr” : “abuild” ]

Parameters:

  • device (String)

Returns:

  • (Hash)

    DiskPartition



769
770
771
# File '../../src/modules/Storage.rb', line 769

def GetDiskPartition(device)
  Ops.get(GetDiskPartitionTg(device, GetTargetMap()), 0, {})
end

- (Object) GetDiskPartitionTg(inpdev, tg)



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
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
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
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
# File '../../src/modules/Storage.rb', line 534

def GetDiskPartitionTg(inpdev, tg)
  tg = deep_copy(tg)
  device = inpdev
  ret = []
  dlen = 0
  as_string = false
  ls = Builtins.filter(Builtins.splitstring(device, "/")) do |s|
    !Builtins.isempty(s)
  end
  if Builtins.search(device, "LABEL=") == 0 ||
      Builtins.search(device, "UUID=") == 0
    tl = Builtins.splitstring(device, "=")
    ls = ["dev", "disk", "", Ops.get(tl, 1, "")]
    Ops.set(
      ls,
      2,
      Builtins.search(device, "LABEL=") == 0 ? "by-label" : "by-uuid"
    )
    Builtins.y2milestone("GetDiskPartitionTg ls:%1", ls)
  end
  Builtins.y2debug(
    "GetDiskPartitionTg size:%1 ls:%2",
    Builtins.size(ls),
    ls
  )
  if Ops.greater_or_equal(Builtins.size(ls), 4) &&
      Ops.get(ls, 1, "") == "disk" &&
      Builtins.contains(
        ["by-id", "by-path", "by-uuid", "by-label"],
        Ops.get(ls, 2, "")
      )
    part = {}
    regex = "-part[0-9]+$"
    if Ops.get(ls, 2, "") == "by-label"
      Builtins.foreach(tg) do |dev, disk|
        part = Builtins.find(Ops.get_list(disk, "partitions", [])) do |p|
          Ops.get_string(p, "label", "") == Ops.get(ls, 3, "")
        end
        if part != nil
          tmp = {}
          Ops.set(tmp, "disk", dev)
          if Builtins.haskey(part, "nr")
            Ops.set(tmp, "nr", Ops.get(part, "nr", 0))
          else
            Ops.set(tmp, "nr", Ops.get_string(part, "name", ""))
          end
          ret = Builtins.add(ret, tmp)
        end
      end
    elsif Ops.get(ls, 2, "") == "by-uuid"
      Builtins.foreach(tg) do |dev, disk|
        part = Builtins.find(Ops.get_list(disk, "partitions", [])) do |p|
          Ops.get_string(p, "uuid", "") == Ops.get(ls, 3, "")
        end
        if part != nil
          tmp = {}
          Ops.set(tmp, "disk", dev)
          if Builtins.haskey(part, "nr")
            Ops.set(tmp, "nr", Ops.get(part, "nr", 0))
          else
            Ops.set(tmp, "nr", Ops.get_string(part, "name", ""))
          end
          ret = Builtins.add(ret, tmp)
        end
      end
    elsif Ops.get(ls, 2, "") == "by-id"
      id = Ops.get(ls, 3, "")
      num = 0
      l = Builtins.regexppos(id, regex)
      if Ops.greater_than(Builtins.size(l), 0)
        num = Builtins.tointeger(
          Builtins.substring(id, Ops.add(Ops.get_integer(l, 0, 0), 5))
        )
        id = Builtins.substring(id, 0, Ops.get_integer(l, 0, 0))
        Builtins.y2debug("GetDiskPartitionTg id:%1 num:%2", id, num)
      end
      Builtins.foreach(tg) do |dev, disk|
        if Builtins.size(ret) == 0 &&
            Builtins.find(Ops.get_list(disk, "udev_id", [])) { |s| s == id } != nil
          part = Builtins.find(Ops.get_list(disk, "partitions", [])) do |p|
            Ops.get_integer(p, "nr", 0) == num
          end
          if num == 0 || part != nil
            tmp = {}
            Ops.set(tmp, "disk", dev)
            if Ops.greater_than(num, 0)
              Ops.set(tmp, "nr", num)
            else
              Ops.set(tmp, "nr", "")
            end
            ret = [tmp]
          end
        end
      end
    elsif Ops.get(ls, 2, "") == "by-path"
      id = Ops.get(ls, 3, "")
      num = 0
      l = Builtins.regexppos(id, regex)
      if Ops.greater_than(Builtins.size(l), 0)
        num = Builtins.tointeger(
          Builtins.substring(id, Ops.add(Ops.get_integer(l, 0, 0), 5))
        )
        id = Builtins.substring(id, 0, Ops.get_integer(l, 0, 0))
        Builtins.y2debug("GetDiskPartitionTg id:%1 num:%2", id, num)
      end
      Builtins.foreach(tg) do |dev, disk|
        if Builtins.size(ret) == 0 &&
            Ops.get_string(disk, "udev_path", "") == id
          part = Builtins.find(Ops.get_list(disk, "partitions", [])) do |p|
            Ops.get_integer(p, "nr", 0) == num
          end
          if num == 0 || part != nil
            tmp = {}
            Ops.set(tmp, "disk", dev)
            if Ops.greater_than(num, 0)
              Ops.set(tmp, "nr", num)
            else
              Ops.set(tmp, "nr", "")
            end
            ret = [tmp]
          end
        end
      end
    end
  elsif Builtins.search(device, "/") == 0
    if Builtins.search(device, "/dev/hd") == 0 ||
        Builtins.search(device, "/dev/sd") == 0 ||
        Builtins.search(device, "/dev/ed") == 0 ||
        Builtins.search(device, "/dev/iseries/vd") == 0
      dlen = Builtins.findfirstof(device, "0123456789")
      dlen = Builtins.size(device) if dlen == nil
    elsif Builtins.search(device, "/dev/md") == 0 && Builtins.size(ls) == 2
      pos = Builtins.search(device, "p")
      if pos != nil
        dlen = pos
      else
        dlen = 7
      end
    elsif Builtins.search(device, "/dev/loop") == 0
      dlen = 9
    elsif Builtins.search(device, "/dev/i2o/hd") == 0
      dlen = 12
    elsif @sint.getPartitionPrefix(device)=="p"
      pos = Builtins.findlastof(device, "p")
      dlen = Builtins.size(device)
      dlen = pos if pos != nil
    elsif Builtins.search(device, "/dev/dasd") == 0
      dlen = Builtins.size(device)
      if Builtins.findfirstof(device, "0123456789") != nil
        dlen = Ops.subtract(dlen, 1)
      end
    elsif Builtins.search(device, "/dev/mapper/") == 0
      regex = "[_-]part[0-9]+$"
      l = Builtins.regexppos(device, regex)
      if Ops.greater_than(Builtins.size(l), 0)
        dlen = Ops.get_integer(l, 0, 0)
      else
        dlen = Builtins.size(device)
      end
    else
      as_string = true
      if Ops.greater_or_equal(Builtins.size(ls), 3)
        pos = Builtins.findlastof(device, "/")
        dlen = pos if pos != nil
      else
        dlen = Builtins.size(device)
        nonzero = Builtins.findlastnotof(device, "0123456789")
        if nonzero != nil && Ops.less_than(nonzero, Ops.subtract(dlen, 1))
          dlen = Ops.add(nonzero, 1)
          as_string = false
        end
      end
    end
    tmp = {}
    Ops.set(tmp, "disk", Builtins.substring(device, 0, dlen))
    device = Builtins.substring(device, dlen)
    if Builtins.search(device, "-part") == 0
      device = Builtins.substring(device, 5)
    end
    if Ops.greater_than(Builtins.size(device), 0) &&
        Builtins.findfirstof(device, "/p") == 0
      device = Builtins.substring(device, 1)
    end
    Ops.set(tmp, "nr", -1)
    if as_string
      Ops.set(tmp, "nr", device)
    else
      if Ops.greater_than(Builtins.size(device), 0)
        Ops.set(tmp, "nr", Builtins.tointeger(device))
      end
    end
    if Ops.greater_than(Builtins.size(Ops.get_string(tmp, "disk", "")), 0) &&
        Ops.get(tmp, "nr", 1) == -1
      Ops.set(tmp, "nr", "")
    end
    if Ops.greater_than(Builtins.size(tg), 0) &&
        !Builtins.haskey(tg, Ops.get_string(tmp, "disk", ""))
      Builtins.y2milestone("GetDiskPartitionTg tmp:%1", tmp)
      r = {}
      if (
          r_ref = arg_ref(r);
          _GetContVolInfo_result = GetContVolInfo(inpdev, r_ref);
          r = r_ref.value;
          _GetContVolInfo_result
        )
        Builtins.y2milestone("GetDiskPartitionTg rtmp:%1", r)
        if Builtins.haskey(tg, Ops.get_string(r, "cdevice", ""))
          Ops.set(tmp, "disk", Ops.get_string(r, "cdevice", ""))
          if Ops.get_integer(r, "num", -1) != -1
            Ops.set(tmp, "nr", Ops.get_integer(r, "num", -1))
          else
            Ops.set(tmp, "nr", Ops.get_string(r, "vname", ""))
          end
        end
      end
    end
    ret = [tmp]
  else
    ret = [{ "disk" => "/dev/nfs", "nr" => device }]
  end
  Builtins.y2debug("GetDiskPartitionTg device:%1 ret:%2", device, ret)
  deep_copy(ret)
end

- (Object) GetDmraidToMdadm



7120
7121
7122
7123
7124
7125
7126
7127
7128
# File '../../src/modules/Storage.rb', line 7120

def GetDmraidToMdadm()
  mapping = {}
  tmp = ::Storage::DmraidToMdadm()
  tmp.each do |a, b|
    mapping[a] = b
  end
  Builtins.y2milestone("dmraid to mdadm mapping %1", mapping)
  return mapping
end

- (Object) GetDoResize



2377
2378
2379
# File '../../src/modules/Storage.rb', line 2377

def GetDoResize
  Ops.get_string(@StorageMap, @do_resize_key, "NO")
end

- (Object) GetEntryForMountpoint(mp)



6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
# File '../../src/modules/Storage.rb', line 6548

def GetEntryForMountpoint(mp)
  partitions = []

  Builtins.foreach(GetTargetMap()) do |dev, disk|
    tmp = Builtins.filter(Ops.get_list(disk, "partitions", [])) do |part|
      Ops.get_string(part, "mount", "") == mp
    end
    partitions = Convert.convert(
      Builtins.union(partitions, tmp),
      :from => "list",
      :to   => "list <map>"
    )
  end

  Ops.get(partitions, 0, {})
end

- (Object) GetExitKey



2221
2222
2223
# File '../../src/modules/Storage.rb', line 2221

def GetExitKey
  @exit_key
end

- (Object) GetForeignPrimary



6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
# File '../../src/modules/Storage.rb', line 6021

def GetForeignPrimary
  ret = []
  if Arch.i386 || Arch.ia64 || Arch.x86_64
    Builtins.foreach(GetPrimPartitions(GetTargetMap(), false)) do |e|
      ret = Builtins.add(
        ret,
        Builtins.sformat(
          "%1 %2",
          Ops.get_string(e, "device", ""),
          Ops.get_string(e, "string", "")
        )
      )
    end
  end
  Builtins.y2milestone("ret=%1", ret)
  deep_copy(ret)
end

- (Object) GetFreeInfo(device, get_resize, resize_info, get_content, content_info, use_cache)



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
# File '../../src/modules/Storage.rb', line 897

def GetFreeInfo(device, get_resize, resize_info, get_content, , use_cache)
  resize_info.value = {}
  .value = {}

  tmp1 = ::Storage::ResizeInfo.new()
  tmp2 = ::Storage::ContentInfo.new()

  ret = @sint.getFreeInfo(device, get_resize, tmp1, get_content,
      tmp2, use_cache)

  if ret
    if get_resize
      resize_info.value = {
        :df_free_k     => tmp1.df_freeK,
        :resize_free_k => tmp1.resize_freeK,
        :used_k        => tmp1.usedK,
        :resize_ok     => tmp1.resize_ok
      }
    end

    if get_content
      .value = {
        :windows => tmp2.windows,
        :efi     => tmp2.efi,
        :homes   => tmp2.homes
      }
    end
  end

  Builtins.y2milestone("GetFreeInfo device:%1 ret:%2", device, ret)
  ret
end

- (Object) GetFreeSpace(device, used_fs, verbose)

Returns map of free space per partition

Parameters:

  • device (String)
  • integer

    testsize

  • used_fs (Symbol)
  • verbose (Boolean)


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
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
# File '../../src/modules/Storage.rb', line 937

def GetFreeSpace(device, used_fs, verbose)
  resize_info = {}
   = {}

  r = (
    resize_info_ref = arg_ref(resize_info);
     = arg_ref();
    _GetFreeInfo_result = GetFreeInfo(
      device,
      true,
      resize_info_ref,
      true,
      ,
      used_fs == :ntfs
    );
    resize_info = resize_info_ref.value;
     = .value;
    _GetFreeInfo_result
  )

  used = 1024*Ops.get_integer(resize_info, :used_k, 0)
  resize_free = 1024*Ops.get_integer(resize_info, :resize_free_k, 0)
  df_free = 1024*Ops.get_integer(resize_info, :df_free_k, 0)
  resize_ok = Ops.get_boolean(resize_info, :resize_ok, false)

  win_disk = Ops.get_boolean(, :windows, false)
  efi = Ops.get_boolean(, :efi, false)

  if used_fs == :ntfs && (!r || !resize_ok) && verbose
    cmd = Builtins.sformat("/usr/sbin/ntfsresize -f -i '%1'", device)
    Builtins.y2milestone("GetFreeSpace Executing cmd:%1", cmd)
    bcall = Convert.to_map(
      SCR.Execute(
        path(".target.bash_output"),
        cmd,
        { "LC_MESSAGES" => "POSIX" }
      )
    )
    Builtins.y2milestone("GetFreeSpace Executing ret:%1", bcall)
    tmp = _("Resize Not Possible:") + "\n\n"
    tmp = Ops.add(
      Ops.add(tmp, Ops.get_string(bcall, "stdout", "")),
      Ops.get_string(bcall, "stderr", "")
    )
    Popup.Error(tmp)
    return {}
  end

  linux_size = 0
  min_linux_size = 0
  add_free = Ops.subtract(df_free, resize_free)

  Builtins.y2milestone(
    "GetFreeSpace resize_free %1 add_free %2",
    resize_free,
    add_free
  )

  if Ops.less_than(resize_free, 300 * 1024 * 1024) || !r
    linux_size = 0
    min_linux_size = 0
  elsif Ops.less_than(resize_free, 600 * 1024 * 1024)
    linux_size = resize_free
    if Ops.less_than(add_free, 75 * 1024 * 1024)
      linux_size = Ops.add(
        Ops.subtract(linux_size, 75 * 1024 * 1024),
        add_free
      )
    end
    min_linux_size = linux_size
  elsif Ops.less_than(resize_free, 1024 * 1024 * 1024)
    linux_size = resize_free
    if Ops.less_than(add_free, 200 * 1024 * 1024)
      linux_size = Ops.add(
        Ops.subtract(linux_size, 200 * 1024 * 1024),
        add_free
      )
    end
    min_linux_size = 300 * 1024 * 1024
  elsif Ops.less_than(resize_free, 2 * 1024 * 1024 * 1024)
    linux_size = resize_free
    if Ops.less_than(add_free, 300 * 1024 * 1024)
      linux_size = Ops.add(
        Ops.subtract(linux_size, 300 * 1024 * 1024),
        add_free
      )
    end
    min_linux_size = 500 * 1024 * 1024
  elsif Ops.less_than(resize_free, 3 * 1024 * 1024 * 1024)
    linux_size = resize_free
    if Ops.less_than(add_free, 800 * 1024 * 1024)
      linux_size = Ops.add(
        Ops.subtract(linux_size, 800 * 1024 * 1024),
        add_free
      )
    end
    min_linux_size = 500 * 1024 * 1024
  else
    linux_size = resize_free
    if Ops.less_than(add_free, Ops.divide(resize_free, 3))
      linux_size = Ops.add(
        Ops.subtract(linux_size, Ops.divide(resize_free, 3)),
        add_free
      )
    end
    min_linux_size = 500 * 1024 * 1024
  end

  new_size = Ops.subtract(
    Ops.add(Ops.add(used, add_free), resize_free),
    linux_size
  )

  ret = {
    "ok"           => r,
    "resize_ok"    => resize_ok,
    "free"         => (resize_free>0) ? resize_free : 0,
    "df_free"      => df_free,
    "used"         => used,
    "win_disk"     => win_disk,
    "efi"          => efi,
    "linux_size"   => linux_size,
    "max_win_size" => Ops.subtract(
      Ops.add(Ops.add(used, resize_free), add_free),
      min_linux_size
    ),
    "ntfs"         => used_fs == :ntfs,
    "new_size"     => new_size
  }

  Builtins.y2milestone("GetFreeSpace %1 ret %2", device, ret)
  ret
end

- (Object) GetIgnoreFstab(device, val)



487
488
489
490
# File '../../src/modules/Storage.rb', line 487

def GetIgnoreFstab(device, val)
  ret, val.value = @sint.getIgnoreFstab(device);
  ret == 0
end

- (Object) GetMountBy(device)



6901
6902
6903
6904
6905
6906
# File '../../src/modules/Storage.rb', line 6901

def GetMountBy(device)
  r, val = @sint.getMountBy(device)
  val = 0 if r<0
  ret = toSymbol(@conv_mountby, val)
  ret
end

- (Hash) GetMountPoints

GetMountPoints() collect mountpoint:device as map to get a sorted list

For directory mount points (key starting with /) the value is a list [partitionName, fsid, targetdevice, raid_type] For swap mount points, the value is a list of lists: [[partitionName, fsid, targetdevice, raid_type], …]

FIXME: please, add more detailed description of the 'map of lists' with examples if possible.

Structure:

Returns:

  • (Hash)

    of lists, the map key is the mount point, usually starting with a “/”. Exception is “swap”



5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
# File '../../src/modules/Storage.rb', line 5472

def GetMountPoints
  mountPoints = {}
  swapPoints = []
  tg = GetTargetMap()
  Builtins.foreach(tg) do |targetdevice, target|
    partitions = Ops.get_list(target, "partitions", [])
    Builtins.foreach(partitions) do |partition|
      partitionName = Ops.get_string(partition, "device", "")
      mountPoint = Ops.get_string(partition, "mount", "")
      fsid = Ops.get_integer(partition, "fsid", 0)
      if mountPoint != ""
        raid_type = ""
        if Ops.get_symbol(partition, "type", :undefined) == :sw_raid
          raid_type = Ops.get_string(partition, "raid_type", "")
        end
        # partition has a mount point
        if mountPoint == "swap"
          swapPoints = Builtins.add(
            swapPoints,
            [partitionName, fsid, targetdevice, raid_type]
          )
        else
          mountPoints = Builtins.add(
            mountPoints,
            mountPoint,
            [partitionName, fsid, targetdevice, raid_type]
          )
        end
      end
    end
  end
  if Ops.greater_than(Builtins.size(swapPoints), 0)
    mountPoints = Builtins.add(mountPoints, "swap", swapPoints)
  end
  if !Stage.initial
    cm = Builtins.filter(Partitions.CurMounted) do |e|
      Builtins.search(Ops.get_string(e, "spec", ""), "/dev/") == 0
    end
    Builtins.foreach(cm) do |e|
      if !Builtins.haskey(mountPoints, Ops.get_string(e, "file", ""))
        p = GetPartition(tg, Ops.get_string(e, "spec", ""))
        if Ops.greater_than(Builtins.size(p), 0)
          raid_type = ""
          if Ops.get_symbol(p, "type", :undefined) == :sw_raid
            raid_type = Ops.get_string(p, "raid_type", "")
          end
          d = GetDiskPartition(Ops.get_string(e, "spec", ""))
          Ops.set(
            mountPoints,
            Ops.get_string(e, "file", ""),
            [
              Ops.get_string(p, "device", ""),
              Ops.get_integer(p, "fsid", 0),
              Ops.get_string(d, "disk", ""),
              raid_type
            ]
          )
        end
      end
    end
  end
  Builtins.y2milestone("ret %1", mountPoints)
  deep_copy(mountPoints)
end

- (Hash{String => map}) GetOndiskTarget

Returns map describing the disk target

Returns:

  • (Hash{String => map})


2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
# File '../../src/modules/Storage.rb', line 2229

def GetOndiskTarget
  keys = ["mount", "enc_type", "mountby", "fstopt", "used_fs", "format"]
  ret = GetTargetMap()
  Builtins.foreach(ret) do |d, disk|
    pl = Builtins.maplist(Ops.get_list(disk, "partitions", [])) do |p|
      Builtins.filter(p) { |k, e| !Builtins.contains(keys, k) }
    end
    pl = Builtins.maplist(pl) do |p|
      if Ops.get_symbol(p, "detected_fs", :unknown) != :unknown
        Ops.set(p, "used_fs", Ops.get_symbol(p, "detected_fs", :unknown))
      end
      deep_copy(p)
    end
    Ops.set(ret, [d, "partitions"], pl)
  end
  deep_copy(ret)
end

- (Array) GetOtherLinuxPartitions

Get list of all Linux Partitions on all real disks

Returns:

  • (Array)

    Partition list



5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
# File '../../src/modules/Storage.rb', line 5704

def GetOtherLinuxPartitions
  ret = []
  Builtins.foreach(GetTargetMap()) do |dev, disk|
    if IsPartitionable(disk)
      l = Builtins.filter(Ops.get_list(disk, "partitions", [])) do |p|
        !Ops.get_boolean(p, "format", false) &&
          Partitions.IsLinuxPartition(Ops.get_integer(p, "fsid", 0))
      end
      l = Builtins.filter(l) do |p|
        Builtins.contains(
          [:xfs, :ext2, :ext3, :ext4, :btrfs, :jfs, :reiser],
          Ops.get_symbol(p, "used_fs", :unknown)
        )
      end
      l = Builtins.filter(l) do |p|
        !FileSystems.IsSystemMp(Ops.get_string(p, "mount", ""), false)
      end
      ret = Builtins.union(ret, l) if Ops.greater_than(Builtins.size(l), 0)
    end
  end
  Builtins.y2milestone("GetOtherLinuxPartitions ret=%1", ret)
  deep_copy(ret)
end

- (Object) GetPartDisk



2353
2354
2355
# File '../../src/modules/Storage.rb', line 2353

def GetPartDisk
  Ops.get_string(@StorageMap, @part_disk_key, "")
end

- (Object) GetPartition(tg, device)



838
839
840
841
842
843
844
845
# File '../../src/modules/Storage.rb', line 838

def GetPartition(tg, device)
  tg = deep_copy(tg)
  Convert.convert(
    Ops.get(GetPartitionLst(tg, device), 0, {}),
    :from => "map",
    :to   => "map <string, any>"
  )
end

- (Object) GetPartitionAlignment



5447
5448
5449
5450
5451
5452
# File '../../src/modules/Storage.rb', line 5447

def GetPartitionAlignment
  val = @sint.getPartitionAlignment()
  pal = toSymbol(@conv_partalign, val)
  Builtins.y2milestone("GetPartitionAlignment val:%1", pal)
  pal
end

- (Object) GetPartitionLst(tg, device)

return list of partitions of map <tg>



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
# File '../../src/modules/Storage.rb', line 784

def GetPartitionLst(tg, device)
  tg = deep_copy(tg)
  ret = []
  tmp = GetDiskPartitionTg(device, tg)
  Builtins.y2milestone("GetPartitionLst tmp:%1", tmp)
  Builtins.foreach(tmp) do |m|
    disk = Ops.get_string(m, "disk", "")
    if Builtins.search(device, "/dev/evms") == 0 &&
        !Builtins.haskey(tg, disk)
      disk = "/dev/evms"
    end
    Builtins.y2debug("GetPartitionLst device=%1 disk=%2", device, disk)
    part = Builtins.filter(Ops.get_list(tg, [disk, "partitions"], [])) do |p|
      Ops.get_string(p, "device", "") == device
    end
    part = Builtins.filter(part) { |p| !Ops.get_boolean(p, "delete", false) }
    if Builtins.size(part) == 0 && Ops.is_integer?(Ops.get(m, "nr", 0))
      part = Builtins.filter(Ops.get_list(tg, [disk, "partitions"], [])) do |p|
        Ops.get_integer(p, "nr", -1) == Ops.get_integer(m, "nr", 0)
      end
      part = Builtins.filter(part) do |p|
        !Ops.get_boolean(p, "delete", false)
      end
    end
    if Builtins.size(part) == 0
      part = Builtins.filter(Ops.get_list(tg, [disk, "partitions"], [])) do |p|
        Ops.get_string(p, "name", "") == Ops.get_string(m, "nr", "")
      end
      part = Builtins.filter(part) do |p|
        !Ops.get_boolean(p, "delete", false)
      end
    end
    pa = Ops.get(part, 0, {})
    if Builtins.size(pa) == 0 &&
        Builtins.search(device, "/dev/mapper/") == 0
      part = Builtins.filter(
        Ops.get_list(tg, ["/dev/mapper", "partitions"], [])
      ) { |p| Ops.get_string(p, "device", "") == device }
      pa = Ops.get(part, 0, {})
    end
    if Builtins.size(pa) == 0 &&
        Builtins.search(device, "/dev/mapper/") == 0
      part = Builtins.filter(
        Ops.get_list(tg, ["/dev/loop", "partitions"], [])
      ) { |p| Ops.get_string(p, "device", "") == device }
      pa = Ops.get(part, 0, {})
    end
    ret = Builtins.add(ret, pa) if Ops.greater_than(Builtins.size(pa), 0)
  end
  Builtins.y2debug("GetPartitionLst ret=%1", ret)
  deep_copy(ret)
end

- (Object) GetPartMode



2324
2325
2326
2327
2328
2329
2330
# File '../../src/modules/Storage.rb', line 2324

def GetPartMode
  Builtins.y2milestone(
    "GetPartMode %1",
    Ops.get_string(@StorageMap, @part_mode_key, "")
  )
  Ops.get_string(@StorageMap, @part_mode_key, "")
end

- (Object) GetPartProposalActive



2312
2313
2314
# File '../../src/modules/Storage.rb', line 2312

def GetPartProposalActive
  Ops.get_boolean(@StorageMap, @part_proposal_active_key, true)
end

- (Object) GetPartProposalFirst



2401
2402
2403
# File '../../src/modules/Storage.rb', line 2401

def GetPartProposalFirst
  Ops.get_boolean(@StorageMap, @part_proposal_first_key, true)
end

- (Object) GetPartProposalMode



2389
2390
2391
# File '../../src/modules/Storage.rb', line 2389

def GetPartProposalMode
  Ops.get_string(@StorageMap, @part_proposal_mode_key, "accept")
end

- (Array) GetPrimPartitions(targets, foreign_os)

Returns list of primary partitions found

Parameters:

  • targets (Hash{String => map})
  • foreign_os (Boolean)

Returns:

  • (Array)

    of primary partitions



5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
# File '../../src/modules/Storage.rb', line 5745

def GetPrimPartitions(targets, foreign_os)
  targets = deep_copy(targets)
  ret = []
  num_dos = 0
  num_win = 0
  num_os2 = 0
  num_linux = 0
  linux_text = "Linux other"
  dos_text = "dos"
  win_text = "windows"
  os2_text = "OS/2 Boot Manager"

  Builtins.foreach(targets) do |disk, data|
    Builtins.foreach(Ops.get_list(data, "partitions", [])) do |part|
      device = Ops.get_string(part, "device", "")
      if Ops.get_symbol(part, "type", :unknown) == :primary &&
          !Ops.get_boolean(part, "create", false) &&
          SCR.Execute(
            path(".target.bash"),
            Ops.add("/usr/lib/YaST2/bin/check.boot ", device)
          ) == 0
        text = ""
        if Partitions.IsDosWinNtPartition(Ops.get_integer(part, "fsid", 0)) &&
            !IsUsedBy(data)
          resize_info = {}
           = {}

          if (
              resize_info_ref = arg_ref(resize_info);
               = arg_ref();
              _GetFreeInfo_result = GetFreeInfo(
                device,
                false,
                resize_info_ref,
                true,
                ,
                true
              );
              resize_info = resize_info_ref.value;
               = .value;
              _GetFreeInfo_result
            ) &&
              Ops.get_boolean(, :windows, false)
            if Builtins.contains(
                Partitions.fsid_dostypes,
                Ops.get_integer(part, "fsid", 0)
              )
              num_dos = Ops.add(num_dos, 1)
              text = dos_text
            else
              num_win = Ops.add(num_win, 1)
              text = win_text
            end
          end
        elsif Ops.get_integer(part, "fsid", 0) == 18 && !foreign_os
          text = "Vendor diagnostic"
        elsif Ops.get_integer(part, "fsid", 0) == 10
          text = os2_text
          num_os2 = Ops.add(num_os2, 1)
        elsif Ops.get_integer(part, "fsid", 0) == Partitions.fsid_native &&
            Builtins.size(Ops.get_string(part, "mount", "")) == 0 &&
            !foreign_os
          text = linux_text
          num_linux = Ops.add(num_linux, 1)
        end
        if !Builtins.isempty(text)
          entry = { "device" => device, "string" => text }
          Builtins.y2milestone("new entry %1", entry)
          ret = Builtins.add(ret, entry)
        end
      end
    end
  end
  Builtins.y2milestone(
    "GetPrimPartitions foreign_os:%5 num_linux %1 num_win %2 num_dos %3 num_os2 %4",
    num_linux,
    num_win,
    num_dos,
    num_os2,
    foreign_os
  )

  num = 1
  ret = Builtins.maplist(ret) do |entry|
    if Ops.get_string(entry, "string", "") == linux_text
      Ops.set(
        entry,
        "string",
        Ops.add(linux_text, Builtins.sformat(" %1", num))
      )
      num = Ops.add(num, 1)
    end
    deep_copy(entry)
  end if Ops.greater_than(
    num_linux,
    1
  )
  num = 1
  ret = Builtins.maplist(ret) do |entry|
    if Ops.get_string(entry, "string", "") == dos_text
      Ops.set(
        entry,
        "string",
        Ops.add(dos_text, Builtins.sformat(" %1", num))
      )
      num = Ops.add(num, 1)
    end
    deep_copy(entry)
  end if Ops.greater_than(
    num_dos,
    1
  )
  num = 1
  ret = Builtins.maplist(ret) do |entry|
    if Ops.get_string(entry, "string", "") == win_text
      Ops.set(
        entry,
        "string",
        Ops.add(win_text, Builtins.sformat(" %1", num))
      )
      num = Ops.add(num, 1)
    end
    deep_copy(entry)
  end if Ops.greater_than(
    num_win,
    1
  )
  num = 1
  ret = Builtins.maplist(ret) do |entry|
    if Ops.get_string(entry, "string", "") == os2_text
      Ops.set(
        entry,
        "string",
        Ops.add(os2_text, Builtins.sformat(" %1", num))
      )
      num = Ops.add(num, 1)
    end
    deep_copy(entry)
  end if Ops.greater_than(
    num_os2,
    1
  )
  Builtins.y2milestone("GetPrimPartitions ret %1", ret)
  deep_copy(ret)
end

- (Object) GetRecursiveRemoval



4579
4580
4581
# File '../../src/modules/Storage.rb', line 4579

def GetRecursiveRemoval
  @sint.getRecursiveRemoval()
end

- (Object) GetRootInitrdModules



6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
# File '../../src/modules/Storage.rb', line 6566

def GetRootInitrdModules
  partition = GetEntryForMountpoint("/")
  Builtins.y2milestone("GetRootInitrdModules root partition %1", partition)

  tg = GetTargetMap()
  disk = {}
  Builtins.foreach(tg) do |k, d|
    if Builtins.size(disk) == 0 &&
        Builtins.find(Ops.get_list(d, "partitions", [])) do |p|
          !Ops.get_boolean(p, "delete", false) &&
            Ops.get_string(p, "device", "") ==
              Ops.get_string(partition, "device", "")
        end != nil
      disk = deep_copy(d)
    end
  end
  Builtins.y2milestone(
    "GetRootInitrdModules disk %1",
    Builtins.haskey(disk, "partitions") ?
      Builtins.remove(disk, "partitions") :
      disk
  )

  initrdmodules = FileSystems.GetNeededModules(
    Ops.get_symbol(partition, "used_fs", :ext2)
  )

  if Ops.get_symbol(partition, "type", :unknown) == :sw_raid
    t = Ops.get_string(partition, "raid_type", "")
    if !Builtins.contains(initrdmodules, t)
      initrdmodules = Builtins.add(initrdmodules, t)
    end
  end
  if Ops.get_symbol(partition, "type", :unknown) == :lvm
    vgdevice = Builtins.substring(
      Ops.get_string(partition, "device", ""),
      5
    )
    vgdevice = Ops.add(
      "/dev/",
      Builtins.substring(vgdevice, 0, Builtins.findfirstof(vgdevice, "/"))
    )
    mod = Builtins.maplist(
      Builtins.filter(Ops.get_list(tg, ["/dev/md", "partitions"], [])) do |e|
        Ops.get_string(e, "used_by_device", "") == vgdevice
      end
    ) { |k| Ops.get_string(k, "raid_type", "") }
    Builtins.y2milestone("GetRootInitrdModules mod %1", mod)
    Builtins.foreach(mod) do |e|
      if Ops.greater_than(Builtins.size(e), 0) &&
          !Builtins.contains(initrdmodules, e)
        initrdmodules = Builtins.add(initrdmodules, e)
      end
    end
    if !Builtins.contains(initrdmodules, "dm_mod")
      initrdmodules = Builtins.add(initrdmodules, "dm_mod")
    end
  end
  if Ops.greater_than(Builtins.size(Ops.get_list(disk, "modules", [])), 0)
    Builtins.y2milestone(
      "adding disk modules %1",
      Ops.get_list(disk, "modules", [])
    )
    Builtins.foreach(Ops.get_list(disk, "modules", [])) do |m|
      if !Builtins.contains(initrdmodules, m)
        initrdmodules = Builtins.add(initrdmodules, m)
      end
    end
  end
  if Ops.greater_than(
      Builtins.size(Ops.get_string(disk, "driver_module", "")),
      0
    )
    m = Ops.get_string(disk, "driver_module", "")
    Builtins.y2milestone("adding driver modules %1", m)
    if !Builtins.contains(initrdmodules, m)
      initrdmodules = Builtins.add(initrdmodules, m)
    end
  end
  SCR.UnmountAgent(path(".proc.modules"))
  lmod = Convert.to_map(SCR.Read(path(".proc.modules")))
  Builtins.y2milestone("GetRootInitrdModules lmod:%1", lmod)
  if Ops.greater_than(Builtins.size(Ops.get_map(lmod, "edd", {})), 0)
    initrdmodules = Builtins.add(initrdmodules, "edd")
  end
  Builtins.y2milestone("GetRootInitrdModules ret %1", initrdmodules)
  deep_copy(initrdmodules)
end

- (Object) GetTargetChangeTime



2307
2308
2309
# File '../../src/modules/Storage.rb', line 2307

def GetTargetChangeTime
  Ops.get_integer(@StorageMap, "targets_time", 0)
end

- (Hash{String => map}) GetTargetMap

Returns a system target map.

Structure:

 

Returns:

  • (Hash{String => map})

    target map



4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
# File '../../src/modules/Storage.rb', line 4420

def GetTargetMap
  return nil if !InitLibstorage(false)

  tmp = {}
  changed = false

  if Mode.test
    Builtins.foreach(@conts) do |c|
      Ops.set(tmp, Ops.get_string(c, "device", ""), getContainerInfo(c))
    end
    Ops.set(@StorageMap, @targets_key, tmp)
    if !@probe_done
      @probe_done = true
      changed = true
    end
  elsif !@probe_done && !Mode.config
    bios_id_raid = {}
    Builtins.y2milestone("probing StorageDevices")
    rename = {}
    tmp = StorageDevices.Probe(true)
    Builtins.foreach(tmp) do |dev, disk|
      dtmp = Ops.get(GetDiskPartitionTg(dev, {}), 0, {})
      Builtins.y2milestone("probing dev %1 disk %2", dev, dtmp)
      if Builtins.search(dev, "/dev/dm-") == 0 ||
          Builtins.search(dev, "/dev/md") == 0
        if Ops.greater_than(
            Builtins.size(Ops.get_string(disk, "bios_id", "")),
            0
          )
          Ops.set(bios_id_raid, dev, Ops.get_string(disk, "bios_id", ""))
        end
      elsif Ops.greater_than(
          Builtins.size(Ops.get_string(dtmp, "disk", "")),
          0
        ) &&
          dev != Ops.get_string(dtmp, "disk", "")
        Ops.set(rename, dev, Ops.get_string(dtmp, "disk", ""))
        Builtins.y2milestone("probing rename %1", rename)
      end
    end
    tmp = Builtins.filter(tmp) do |dev, disk|
      Builtins.search(dev, "/dev/dm-") != 0
    end
    tmp = Builtins.filter(tmp) do |dev, disk|
      Builtins.search(dev, "/dev/md") != 0
    end
    Builtins.foreach(rename) do |old, new|
      if Builtins.haskey(tmp, old)
        Ops.set(tmp, new, Ops.get(tmp, old, {}))
        tmp = Builtins.remove(tmp, old)
        Ops.set(tmp, [new, "device"], new)
        Builtins.y2milestone(
          "probing old:%1 new:%2",
          old,
          Ops.get(tmp, new, {})
        )
      end
    end if Ops.greater_than(
      Builtins.size(rename),
      0
    )

    # remove all devices unknown to libstorage, otherwise the target-map
    # has containers without container-type
    tmp.select! do |dev, disk|
      @conts.any? { |c| c["device"] == dev }
    end

    Builtins.y2milestone("probing done")
    @probe_done = true
    changed = true
    Builtins.foreach(tmp) do |dev, disk|
      Ops.set(tmp, dev, getDiskInfo(dev, disk))
      InitializeDisk(dev, true) if Ops.get_boolean(disk, "dasdfmt", false)
    end
    Builtins.foreach(@conts) do |c|
      if Ops.get_symbol(c, "type", :CT_UNKNOWN) != :CT_DISK
        Ops.set(tmp, Ops.get_string(c, "device", ""), getContainerInfo(c))
      end
    end
    tmp = HandleBtrfsSimpleVolumes(tmp)
    if !Builtins.isempty(bios_id_raid)
      Builtins.y2milestone("bios_id_raid:%1", bios_id_raid)
      Builtins.foreach(bios_id_raid) do |dm, bios|
        pos = Builtins.findfirstof(dm, "0123456789")
        minor = Builtins.tointeger(Builtins.substring(dm, pos))
        Builtins.y2milestone("pos:%1 minor:%2", pos, minor)
        Builtins.foreach(tmp) do |dev, c|
          if Ops.get_symbol(c, "type", :CT_UNKNOWN) == :CT_DMRAID &&
              Ops.get_integer(c, "minor", 0) == minor
            Builtins.y2milestone("adding bios_id %1 to %2", bios, dev)
            Ops.set(tmp, [dev, "bios_id"], bios)
          end
          if Ops.get_symbol(c, "type", :CT_UNKNOWN) == :CT_MDPART &&
              Ops.get_string(c, "device", "") == dm
            Builtins.y2milestone("adding bios_id %1 to %2", bios, dev)
            Ops.set(tmp, [dev, "bios_id"], bios)
          end
        end
      end
    end
    if Stage.initial
      tmp = AddProposalName(tmp)
      tmp = AskCryptPasswords(tmp) if !Mode.autoinst
    end
    Ops.set(@StorageMap, @targets_key, tmp)
  end
  if changed
    tmp = Ops.get_map(@StorageMap, @targets_key, {})
    SCR.Write(path(".target.ycp"), SaveDumpPath("targetMap_i"), tmp)
    if !Mode.autoinst
      Builtins.y2milestone("AddSwapMp")
      tmp = AddSwapMp(tmp)
    end
    CreateTargetBackup("initial")
    if (Stage.initial || Mode.repair) && !Mode.autoinst
      AddMountPointsForWin(tmp)
    end
    Ops.set(@StorageMap, @targets_key, GetTargetMap())
    SCR.Write(path(".target.ycp"), SaveDumpPath("targetMap_ii"), tmp)
    Builtins.y2milestone("changed done")
  end

  ret = Ops.get_map(@StorageMap, @targets_key, {})
  if changed
    Builtins.y2milestone("GetTargetMap changed:%1", changed)
  else
    Builtins.y2debug("GetTargetMap changed:%1", changed)
  end
  Builtins.foreach(ret) do |k, m|
    if changed
      Builtins.y2milestone("GetTargetMap %1:%2", k, m)
    else
      Builtins.y2debug("GetTargetMap %1:%2", k, m)
    end
  end
  deep_copy(ret)
end

- (Object) GetTestsuite



2365
2366
2367
# File '../../src/modules/Storage.rb', line 2365

def GetTestsuite
  Ops.get_boolean(@StorageMap, @testsuite_key, false)
end

- (Object) GetTranslatedDevices(oldv, newv, names)



6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
# File '../../src/modules/Storage.rb', line 6447

def GetTranslatedDevices(oldv, newv, names)
  oldv = deep_copy(oldv)
  newv = deep_copy(newv)
  names = deep_copy(names)
  Builtins.y2milestone("GetTranslatedDevices old:%1 new:%2", oldv, newv)
  Builtins.y2milestone("GetTranslatedDevices names %1", names)
  ret = deep_copy(names)
  dm = BuildDiskmap(oldv)
  ret = Builtins.maplist(ret) { |n| HdDiskMap(n, dm) } if Ops.greater_than(
    Builtins.size(dm),
    0
  )
  if (Ops.less_than(Ops.get_integer(oldv, "major", 0), 9) ||
      Ops.get_integer(oldv, "major", 0) == 9 &&
        Ops.get_integer(oldv, "minor", 0) == 0) &&
      Arch.board_iseries
    ret = Builtins.maplist(ret) { |n| HdToIseries(n) }
  end
  ret = Builtins.maplist(ret) { |n| SLES9PersistentDevNames(n) } if Ops.get_integer(
    oldv,
    "major",
    0
  ) == 9

  # convert dmraid names to mdadm names
  mapping = GetDmraidToMdadm()
  if !mapping.empty?
    ret.map! { |name| TranslateDeviceDmraidToMdadm(name, mapping) }
  end

  Builtins.y2milestone("GetTranslatedDevices ret %1", ret)
  deep_copy(ret)
end

- (Object) GetUnusedPartitionSlots(device, slots)



1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
# File '../../src/modules/Storage.rb', line 1072

def GetUnusedPartitionSlots(device, slots)
  swig_slots = ::Storage::ListPartitionSlotInfo.new()
  ret = @sint.getUnusedPartitionSlots(device, swig_slots)
  slots.value = []
  swig_slots.each do |swig_slot|
    m = {
      :region => [ swig_slot.cylRegion.start, swig_slot.cylRegion.len ],
      :nr => swig_slot.nr,
      :device => swig_slot.device,
      :primary_slot => swig_slot.primarySlot,
      :primary_possible => swig_slot.primaryPossible,
      :extended_slot => swig_slot.extendedSlot,
      :extended_possible => swig_slot.extendedPossible,
      :logical_slot => swig_slot.logicalSlot,
      :logical_possible => swig_slot.logicalPossible
    }
	slots.value.push( m )
  end
  ret
end

- (Object) GetUsedDisks(device)



6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
# File '../../src/modules/Storage.rb', line 6988

def GetUsedDisks(device)
  Builtins.y2milestone("GetUsedDisks device:%1", device)
  ret = []
  tg = GetTargetMap()
  info = {}
  if ( info_ref = arg_ref(info);
      _GetContVolInfo_result = GetContVolInfo(device, info_ref);
      info = info_ref.value;
      _GetContVolInfo_result
    )
    Builtins.y2milestone("GetUsedDisks info:%1", info)
    to_visit = [device]
    visited_devs = []
    begin
      visited_devs = Builtins.add(visited_devs, Ops.get(to_visit, 0, ""))
      to_visit = Builtins.remove(to_visit, 0)
      add_list = []
      if Ops.get_symbol(info, "ctype", :CT_UNKNOWN) == :CT_DISK
        if !Builtins.contains(ret, Ops.get_string(info, "cdevice", ""))
          ret = Builtins.add(ret, Ops.get_string(info, "cdevice", ""))
        end
      elsif Ops.get_symbol(info, "ctype", :CT_UNKNOWN) == :CT_NFS
        ret = Builtins.add(ret, "/dev/nfs")
      elsif Ops.get_symbol(info, "ctype", :CT_UNKNOWN) == :CT_BTRFS
        bt = Builtins.find(
          Ops.get_list(tg, ["/dev/btrfs", "partitions"], [])
        ) do |p|
          Builtins.contains(
            Ops.get_list(p, "devices", []),
            Ops.get_string(info, "vdevice", "")
          )
        end
        Builtins.y2milestone("GetUsedDisks bt:%1", bt)
        add_list = Ops.get_list(bt, "devices", []) if bt != nil
      else
        add_list = Ops.get_list(
          tg,
          [Ops.get_string(info, "cdevice", ""), "devices"],
          []
        )
      end
      if Ops.greater_than(Builtins.size(add_list), 0)
        Builtins.y2milestone("GetUsedDisks add_list:%1", add_list)
      end
      Builtins.foreach(add_list) do |s|
        if !Builtins.contains(visited_devs, s) &&
            !Builtins.contains(to_visit, s) &&
            !Builtins.contains(ret, s)
          to_visit = Builtins.add(to_visit, s)
        end
      end
      Builtins.y2milestone("GetUsedDisks to_visit:%1", to_visit)
      while Ops.greater_than(Builtins.size(to_visit), 0) &&
          !(
            info_ref = arg_ref(info);
            _GetContVolInfo_result = GetContVolInfo(
              Ops.get(to_visit, 0, ""),
              info_ref
            );
            info = info_ref.value;
            _GetContVolInfo_result
          )
        visited_devs = Builtins.add(visited_devs, Ops.get(to_visit, 0, ""))
        to_visit = Builtins.remove(to_visit, 0)
      end
      if Ops.greater_than(Builtins.size(to_visit), 0)
        Builtins.y2milestone("GetUsedDisks info:%1", info)
      end
    end while Ops.greater_than(Builtins.size(to_visit), 0)
    ret = Builtins.sort(ret) if Ops.greater_than(Builtins.size(ret), 1)
  elsif Builtins.substring(device, 0, 1) != "/" &&
      Ops.greater_than(Builtins.search(device, ":"), 0)
    ret = ["/dev/nfs"]
  end
  Builtins.y2milestone("GetUsedDisks ret:%1", ret)
  deep_copy(ret)
end

- (Object) GetUsedFs



5900
5901
5902
5903
5904
5905
5906
5907
# File '../../src/modules/Storage.rb', line 5900

def GetUsedFs
  return nil if !InitLibstorage(false)

  r = @sint.getAllUsedFs()
  ret = r.to_a
  Builtins.y2milestone( "GetUsedFs ret:%1", ret )
  ret
end

- (Object) GetWinDevice



2413
2414
2415
# File '../../src/modules/Storage.rb', line 2413

def GetWinDevice
  Ops.get_boolean(@StorageMap, @win_device_key, false)
end

- (Object) GetWinPrimPartitions(targets)



5892
5893
5894
5895
5896
5897
# File '../../src/modules/Storage.rb', line 5892

def GetWinPrimPartitions(targets)
  targets = deep_copy(targets)
  ret = GetPrimPartitions(targets, true)
  Builtins.y2milestone("GetWinPrimPartitions ret %1", ret)
  deep_copy(ret)
end

- (Object) HandleBtrfsSimpleVolumes(tg)



1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
# File '../../src/modules/Storage.rb', line 1938

def HandleBtrfsSimpleVolumes(tg)
  tg = deep_copy(tg)
  if Builtins.haskey(tg, "/dev/btrfs")
    simple = Builtins.filter(
      Ops.get_list(tg, ["/dev/btrfs", "partitions"], [])
    ) do |p|
      Ops.less_or_equal(Builtins.size(Ops.get_list(p, "devices", [])), 1)
    end
    Ops.set(
      tg,
      ["/dev/btrfs", "partitions"],
      Builtins.filter(Ops.get_list(tg, ["/dev/btrfs", "partitions"], [])) do |p|
        Ops.greater_than(Builtins.size(Ops.get_list(p, "devices", [])), 1)
      end
    )
    Builtins.y2milestone("HandleBtrfsSimpleVolumes simple %1", simple)
    keys = [
      "subvol",
      "uuid",
      "label",
      "format",
      "inactive",
      "mount",
      "mountby",
      "used_fs",
      "userdata"
    ]
    Builtins.foreach(simple) do |p|
      mp = GetPartition(tg, Ops.get_string(p, "device", ""))
      Builtins.y2milestone("HandleBtrfsSimpleVolumes before %1", mp)
      Builtins.foreach(keys) do |k|
        if Ops.get(p, k) != nil
          Builtins.y2milestone("HandleBtrfsSimpleVolumes set key %1", k)
          tg = SetPartitionData(
            tg,
            Ops.get_string(p, "device", ""),
            k,
            Ops.get(p, k)
          )
        else
          if Builtins.haskey(mp, k)
            Builtins.y2milestone(
              "HandleBtrfsSimpleVolumes remove key %1",
              k
            )
            tg = DelPartitionData(tg, Ops.get_string(p, "device", ""), k)
          end
        end
      end
      Builtins.y2milestone(
        "HandleBtrfsSimpleVolumes after  %1",
        GetPartition(tg, Ops.get_string(p, "device", ""))
      )
    end
  end
  deep_copy(tg)
end

- (Object) HandleProposalPackages

Takes care of selecting packages needed by storage in installation (replacement for HandlePackages in *_proposal clients)



5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
# File '../../src/modules/Storage.rb', line 5990

def HandleProposalPackages
  #Use PackagesProposal to ensure that package selection
  #does not get reset by this module (#433001)
  Yast.import "PackagesProposal"

  proposal_ID = "storage_proposal"
  pkgs = AddPackageList()

  #Set rather than Add, there might be some packs left over
  #from previous 'MakeProposal' we don't need now
  #This also covers the case when AddPackagesList returns [] or nil
  if !PackagesProposal.SetResolvables(proposal_ID, :package, pkgs)
    Builtins.y2error(
      "PackagesProposal::SetResolvables() for %1 failed",
      pkgs
    )
    Report.Error(
      Builtins.sformat(
        _("Adding the following resolvables failed: %1"),
        pkgs
      )
    )
  end

  SaveUsedFs() if Stage.initial
  Pkg.PkgSolve(true)

  nil
end

- (Object) HasRaidParity(rt)



1470
1471
1472
# File '../../src/modules/Storage.rb', line 1470

def HasRaidParity(rt)
  Builtins.contains(["raid5", "raid6", "raid10"], rt)
end

- (Object) HaveLinuxPartitions

** Determine if there is any Linux partition on this system.

If there is none, we don't need to ask if the user wants to update or boot an installed system - he can only do a new installation anyway. No time-consuming or dangerous operations should be performed here, only simple checks for existence of a Linux (type 83) partition.

Returns:

  • boolean true if there is anything that might be a Linux partition



5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
# File '../../src/modules/Storage.rb', line 5671

def HaveLinuxPartitions
  ret = false
  Builtins.foreach(GetTargetMap()) do |dev, disk|
    if !ret
      Builtins.y2milestone(
        "HaveLinuxPartitions %1 typ:%2 pbl:%3 ro:%4 driver:%5",
        dev,
        Ops.get_symbol(disk, "type", :CT_UNKNOWN),
        IsPartitionable(disk),
        Ops.get_boolean(disk, "readonly", false),
        Ops.get_string(disk, "driver", "")
      )
      if IsPartitionable(disk)
        Builtins.foreach(Ops.get_list(disk, "partitions", [])) do |e|
          ret = ret ||
            Partitions.IsLinuxPartition(
              Ops.get_integer(e, "fsid", Partitions.fsid_native)
            )
        end
      elsif Ops.get_symbol(disk, "type", :CT_UNKNOWN) == :CT_DISK &&
          Ops.get_boolean(disk, "readonly", false) &&
          Ops.get_string(disk, "driver", "") == "vbd"
        ret = true
      end
    end
  end
  Builtins.y2milestone("HaveLinuxPartitions ret=%1", ret)
  ret
end

- (Object) HdDiskMap(input, diskmap)



6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
# File '../../src/modules/Storage.rb', line 6355

def HdDiskMap(input, diskmap)
  diskmap = deep_copy(diskmap)
  ret = input
  if IsKernelDeviceName(input)
    d = GetDiskPartition(input)
    if Builtins.haskey(diskmap, Ops.get_string(d, "disk", ""))
      ret = GetDeviceName(
        Ops.get_string(diskmap, Ops.get_string(d, "disk", ""), ""),
        Ops.get(d, "nr", 0)
      )
    end
  end
  Builtins.y2milestone("HdDiskMap input:%1 ret:%2", input, ret)
  ret
end

- (Object) HdToIseries(input)



6296
6297
6298
6299
6300
6301
6302
6303
6304
# File '../../src/modules/Storage.rb', line 6296

def HdToIseries(input)
  ret = input
  regex = "/dev/hd[a-z][0-9]*"
  if Builtins.regexpmatch(input, regex)
    ret = Ops.add("/dev/iseries/vd", Builtins.substring(ret, 7))
  end
  Builtins.y2milestone("HdToIseries input:%1 ret:%2", input, ret)
  ret
end

- (Object) HumanStringToByte(str, bytes)



404
405
406
407
408
409
410
411
412
413
414
415
# File '../../src/modules/Storage.rb', line 404

def HumanStringToByte(str, bytes)
  i = 0
  bytes.value = i # bnc #408829 and #408891
  ret, bytes.value = ::Storage::humanStringToByte( str, false )
  Builtins.y2milestone(
    "HumanStringToByte ret:%1 str:%2 bytes:%3",
    ret,
    str,
    bytes.value
  )
  ret
end

- (Object) HumanStringToKByte(str, bytes_k)



418
419
420
421
422
423
424
425
426
427
428
429
# File '../../src/modules/Storage.rb', line 418

def HumanStringToKByte(str, bytes_k)
  ret, bytes = ::Storage::humanStringToByte( str, false )
  bytes = 0 if !ret  # bnc #408829
  bytes_k.value = bytes.div(1024)
  Builtins.y2milestone(
    "HumanStringToKByte ret:%1 str:%2 bytes_k:%3",
    ret,
    str,
    bytes_k.value
  )
  ret
end

- (Object) HumanStringToKByteWithRangeCheck(str, bytes_k, min_k, max_k)

Converts a string into a integer and checks the allowed range for the integer. The range check is a bit sloppy to compensate rounding issues but it's guaranteed that the result lies within the allowed range.



435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# File '../../src/modules/Storage.rb', line 435

def HumanStringToKByteWithRangeCheck(str, bytes_k, min_k, max_k)
  if !(
      bytes_k_ref = arg_ref(bytes_k.value);
      _HumanStringToKByte_result = HumanStringToKByte(str, bytes_k_ref);
      bytes_k.value = bytes_k_ref.value;
      _HumanStringToKByte_result
    )
    return false
  end

  if min_k != nil && Ops.less_than(bytes_k.value, min_k)
    if KByteToHumanString(bytes_k.value) != KByteToHumanString(min_k)
      return false
    end
    bytes_k.value = min_k
  end

  if max_k != nil && Ops.greater_than(bytes_k.value, max_k)
    if KByteToHumanString(bytes_k.value) != KByteToHumanString(max_k)
      return false
    end
    bytes_k.value = max_k
  end

  true
end

- (Boolean) InitializeDisk(disk, value)

Set the flag if a disk needs to be initialized

Parameters:

  • string

    the disk to be changed

Returns:

  • (Boolean)


3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
# File '../../src/modules/Storage.rb', line 3582

def InitializeDisk(disk, value)
  rbool = true
  Builtins.y2milestone("InitializeDisk %1 value %2", disk, value)
  ret = @sint.initializeDisk(disk, value)
  if ret<0
    Builtins.y2error("InitializeDisk sint ret:%1", ret)
    rbool = false
  end
  if rbool && value
    d = GetDisk(GetTargetMap(), disk)
    Builtins.y2milestone("d:%1", d)
    rbool = CreatePartition(
      disk,
      Ops.add(disk, "1"),
      :primary,
      Partitions.fsid_native,
      0,
      Ops.get_integer(d, "cyl_count", 1),
      GetMountBy(Ops.add(disk, "1"))
    )
    Builtins.y2error("InitializeDisk create failed") if !rbool
  end
  UpdateTargetMapDisk(disk)
  rbool
end

- (Object) InitLibstorage(readonly)



322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File '../../src/modules/Storage.rb', line 322

def InitLibstorage(readonly)
  return true if @sint != nil

  log.info("InitLibstorage")

  @sint = StorageInit.CreateInterface(readonly)
  if @sint == nil
    log.error("StorageInit::CreateInterface failed")
    return false
  end

  StorageClients.InstallCallbacks(@sint)

  btrfs_default_subvolume = ProductFeatures.GetStringFeature("partitioning",
                                                             "btrfs_default_subvolume")
  @sint.setDefaultSubvolName(btrfs_default_subvolume) if btrfs_default_subvolume

  if Stage.initial
    @sint.setDetectMountedVolumes(false)
    @sint.setRootPrefix(Installation.destdir)

    if Mode.autoinst || Mode.autoupgrade
	  val = @default_multipathing ? ::Storage::MPAS_ON : ::Storage::MPAS_OFF
      @sint.setMultipathAutostart(val)
    end
  end

  @conts = getContainers
  log.info("InitLibstorage conts:#{@conts}")

  FileSystems.InitSlib(@sint)
  Partitions.InitSlib(@sint)

  true
end

- (Object) IsDeviceOnNetwork(device)



7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
# File '../../src/modules/Storage.rb', line 7067

def IsDeviceOnNetwork(device)
  ret = :no
  tg = GetTargetMap()

  disks = GetUsedDisks(device)
  if Ops.get(disks, 0, "") == "/dev/nfs"
    ret = :nfs
  else
    Builtins.foreach(disks) do |s|
      if ret == :no
        Builtins.y2milestone(
          "disk:%1 tarnsport:%2",
          s,
          Ops.get_symbol(tg, [s, "transport"], :unknown)
        )
        if Builtins.contains(
            [:fcoe, :iscsi],
            Ops.get_symbol(tg, [s, "transport"], :unknown)
          )
          ret = Ops.get_symbol(tg, [s, "transport"], :unknown)
        end
      end
    end
  end
  Builtins.y2milestone("IsDeviceOnNetwork device:%1 ret:%2", device, ret)
  ret
end

- (Object) IsDiskType(t)



1933
1934
1935
# File '../../src/modules/Storage.rb', line 1933

def IsDiskType(t)
  Builtins.contains([:CT_DISK, :CT_DMRAID, :CT_DMMULTIPATH, :CT_MDPART], t)
end

- (Object) IsEfiPartition(p)



3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
# File '../../src/modules/Storage.rb', line 3699

def IsEfiPartition(p)
  p = deep_copy(p)
  ret = false

  resize_info = {}
   = {}
  if (
      resize_info_ref = arg_ref(resize_info);
       = arg_ref();
      _GetFreeInfo_result = GetFreeInfo(
        Ops.get_string(p, "device", ""),
        false,
        resize_info_ref,
        true,
        ,
        true
      );
      resize_info = resize_info_ref.value;
       = .value;
      _GetFreeInfo_result
    ) &&
      Ops.get_boolean(, :efi, false)
    ret = true
  end

  Builtins.y2milestone("IsEfiPartition ret:%1", ret)
  ret
end

- (Object) IsInstallationSource(device)



2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
# File '../../src/modules/Storage.rb', line 2440

def IsInstallationSource(device)
  if @part_insts == nil
    @part_insts = ""

    if Stage.initial
      tmp = Convert.to_string(SCR.Read(path(".etc.install_inf.Partition")))
      if tmp != nil && !Builtins.isempty(tmp)
        Builtins.y2milestone(
          "IsInstallationSource .etc.install_inf.Partition:\"%1\"",
          tmp
        )

        info = {}
        if (
            info_ref = arg_ref(info);
            _GetContVolInfo_result = GetContVolInfo(
              Ops.add("/dev/", tmp),
              info_ref
            );
            info = info_ref.value;
            _GetContVolInfo_result
          )
          @part_insts = Ops.get_string(info, "vdevice", "")
        end
      end
    end

    Builtins.y2milestone(
      "IsInstallationSource part_insts:\"%1\"",
      @part_insts
    )
  end

  !Builtins.isempty(@part_insts) && device == @part_insts
end

- (Object) IsKernelDeviceName(device)



298
299
300
301
302
# File '../../src/modules/Storage.rb', line 298

def IsKernelDeviceName(device)
  Builtins.substring(device, 0, 6) != "LABEL=" &&
    Builtins.substring(device, 0, 5) != "UUID=" &&
    Builtins.substring(device, 0, 13) != "/dev/disk/by-"
end

- (Boolean) IsPartitionable(entry)

Checks if a container is partitionable

Structure:

entry ~ $[ "type" : ... ? ]

Parameters:

  • entry (Hash)

Returns:

  • (Boolean)

    true if partitionable



5629
5630
5631
5632
5633
5634
5635
# File '../../src/modules/Storage.rb', line 5629

def IsPartitionable(entry)
  entry = deep_copy(entry)
  Ops.get_symbol(entry, "type", :CT_UNKNOWN) == :CT_DMRAID ||
    Ops.get_symbol(entry, "type", :CT_UNKNOWN) == :CT_DMMULTIPATH ||
    Ops.get_symbol(entry, "type", :CT_UNKNOWN) == :CT_MDPART ||
    IsRealDisk(entry)
end

- (Object) IsPartType(t)



3609
3610
3611
3612
# File '../../src/modules/Storage.rb', line 3609

def IsPartType(t)
  t == :CT_DMRAID || t == :CT_DMMULTIPATH || t == :CT_DISK ||
    t == :CT_MDPART
end

- (Object) IsPersistent(p)



6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
# File '../../src/modules/Storage.rb', line 6950

def IsPersistent(p)
  p = deep_copy(p)
  ret = Builtins.contains(
    [:lvm, :sw_raid, :dm],
    Ops.get_symbol(p, "type", :unknown)
  )
  if !ret &&
      Builtins.contains(
        [:primary, :logical, :extended],
        Ops.get_symbol(p, "type", :unknown)
      )
    d = GetDisk(GetTargetMap(), Ops.get_string(p, "device", ""))
    ret = Ops.get_symbol(d, "type", :CT_UNKNONW) == :CT_DMRAID ||
      Ops.get_symbol(d, "type", :CT_UNKNONW) == :CT_DMMULTIPATH ||
      Ops.greater_than(Builtins.size(Ops.get_list(d, "udev_id", [])), 0)
  end
  Builtins.y2milestone(
    "IsPersistent device:%1 ret:%2",
    Ops.get_string(p, "device", ""),
    ret
  )
  ret
end

- (Boolean) IsRealDisk(entry)

Check if a disk is a real disk and not RAID or LVM

Structure:

entry ~ $[
   "type":`CT_DISK,
   "driver" : "?",
   "readonly" : false / true,
 ]

Parameters:

  • entry (Hash)

    (disk)

Returns:

  • (Boolean)

    true if real disk



5611
5612
5613
5614
5615
5616
5617
# File '../../src/modules/Storage.rb', line 5611

def IsRealDisk(entry)
  entry = deep_copy(entry)
  Ops.get_symbol(entry, "type", :CT_UNKNOWN) == :CT_DISK &&
    !(Ops.get_symbol(entry, "type", :CT_UNKNOWN) == :CT_DISK &&
      Ops.get_boolean(entry, "readonly", false) &&
      Ops.get_string(entry, "driver", "") == "vbd")
end

- (Hash) IsResizable(part)

Returns whether a partition is resizable

Parameters:

  • map

    partition

Returns:

  • (Hash)

    resizable ?



6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
# File '../../src/modules/Storage.rb', line 6044

def IsResizable(part)
  part = deep_copy(part)
  ret = FileSystems.IsResizable(:unknown)
  if !Arch.s390 && Partitions.IsResizable(Ops.get_integer(part, "fsid", 0)) ||
      Ops.get_symbol(part, "type", :none) == :lvm
    if Ops.get_integer(part, "fsid", 0) == Partitions.fsid_swap
      ret = FileSystems.IsResizable(:swap)
    else
      if !(Ops.get_symbol(part, "type", :none) == :lvm &&
          Ops.get_symbol(part, "used_fs", :unknown) == :vfat)
        ret = FileSystems.IsResizable(
          Ops.get_symbol(part, "used_fs", :unknown)
        )
      end
    end
  end
  ret["device"] = (Partitions.IsResizable(part.fetch("fsid",0)) &&
                   !part.fetch("device","").start_with?("/dev/dasd")) ||
    part.fetch("type",:none)==:lvm
  Builtins.y2milestone("IsResizable part:%1 ret:%2", part, ret)
  deep_copy(ret)
end

- (Object) IsUsedBy(p)



5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
# File '../../src/modules/Storage.rb', line 5126

def IsUsedBy(p)
  p = deep_copy(p)
  ret = !Builtins.isempty(Ops.get_list(p, "used_by", []))
  if ret && Ops.get_symbol(p, ["used_by", 0, "type"], :UB_NONE) == :UB_BTRFS
    b = FindBtrfsUuid(Ops.get_string(p, ["used_by", 0, "device"], ""))
    if Ops.less_or_equal(Builtins.size(Ops.get_list(b, "devices", [])), 1)
      ret = false
    end
  end
  Builtins.y2milestone(
    "IsUsedBy %1 by %2 ret:%3",
    Ops.get_string(p, "device", ""),
    Ops.get_list(p, "used_by", []),
    ret
  )
  ret
end

- (Object) IsVgEncrypted(tg, vg_key)



3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
# File '../../src/modules/Storage.rb', line 3468

def IsVgEncrypted(tg, vg_key)
  ret = false
  devs = Ops.get_list(tg, [vg_key, "devices"], [])
  Builtins.foreach(devs) do |s|
    p = GetPartition(tg, s)
    ret = Ops.get_symbol(p, "enc_type", :none) == :luks if !ret
    Builtins.y2milestone("IsVgEncrypted ret:%1 p:%2", ret, p)
  end
  Builtins.y2milestone("IsVgEncrypted key:%1 ret:%2", vg_key, ret)
  ret
end

- (Object) KByteToHumanString(bytes_k)



389
390
391
# File '../../src/modules/Storage.rb', line 389

def KByteToHumanString(bytes_k)
  return ::Storage::byteToHumanString(bytes_k*1024, false, 2, false).force_encoding("UTF-8")
end

- (Object) KByteToHumanStringOmitZeroes(bytes_k)



399
400
401
# File '../../src/modules/Storage.rb', line 399

def KByteToHumanStringOmitZeroes(bytes_k)
  return ::Storage::byteToHumanString(bytes_k*1024, false, 2, true).force_encoding("UTF-8")
end

- (Object) LastAction



5420
5421
5422
# File '../../src/modules/Storage.rb', line 5420

def LastAction
  return @sint.getLastAction().force_encoding("UTF-8")
end

- (Object) main



33
34
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File '../../src/modules/Storage.rb', line 33

def main
  Yast.import "Pkg"
  Yast.import "UI"

  textdomain "storage"

  Yast.import "Arch"
  Yast.import "Directory"
  Yast.import "FileSystems"
  Yast.import "FileUtils"
  Yast.import "Installation"
  Yast.import "Label"
  Yast.import "Icon"
  Yast.import "Mode"
  Yast.import "Partitions"
  Yast.import "Popup"
  Yast.import "Report"
  Yast.import "Misc"
  Yast.import "HTML"
  Yast.import "StorageInit"
  Yast.import "StorageDevices"
  Yast.import "StorageClients"
  Yast.import "Stage"
  Yast.import "String"
  Yast.import "Hotplug"
  Yast.import "ProductFeatures"
  Yast.import "Service"

  # simple resize functionality - dialog to set size of Linux and Windows before proposal

  @resize_partition = nil

  @resize_partition_data = nil

  @resize_cyl_size = nil

  @default_multipathing = false

  # end of resizing functions


  @conv_ctype = {
    "def_sym" => :CT_UNKNOWN,
    "def_int" => ::Storage::CUNKNOWN,
    "m"       => {
      ::Storage::DISK        => :CT_DISK,
      ::Storage::MD          => :CT_MD,
      ::Storage::LOOP        => :CT_LOOP,
      ::Storage::LVM         => :CT_LVM,
      ::Storage::DMRAID      => :CT_DMRAID,
      ::Storage::DMMULTIPATH => :CT_DMMULTIPATH,
      ::Storage::DM          => :CT_DM,
      ::Storage::MDPART      => :CT_MDPART,
      ::Storage::NFSC        => :CT_NFS,
      ::Storage::BTRFSC      => :CT_BTRFS,
      ::Storage::TMPFSC      => :CT_TMPFS
    }
  }

  @conv_usedby = {
    "def_sym" => :UB_NONE,
    "def_int" => ::Storage::UB_NONE,
    "m"       => {
      ::Storage::UB_LVM         => :UB_LVM,
      ::Storage::UB_MD          => :UB_MD,
      ::Storage::UB_DMRAID      => :UB_DMRAID,
      ::Storage::UB_DMMULTIPATH => :UB_DMMULTIPATH,
      ::Storage::UB_MDPART      => :UB_MDPART,
      ::Storage::UB_DM          => :UB_DM,
      ::Storage::UB_BTRFS       => :UB_BTRFS
    }
  }

  @conv_ptype = {
    "def_sym" => :primary,
    "def_int" => ::Storage::PRIMARY,
    "m"       => {
      ::Storage::LOGICAL  => :logical,
      ::Storage::EXTENDED => :extended
    }
  }

  @conv_mountby = {
    "def_sym" => :device,
    "def_int" => ::Storage::MOUNTBY_DEVICE,
    "m"       => {
      ::Storage::MOUNTBY_UUID  => :uuid,
      ::Storage::MOUNTBY_LABEL => :label,
      ::Storage::MOUNTBY_ID    => :id,
      ::Storage::MOUNTBY_PATH  => :path
    }
  }

  @conv_encryption = {
    "def_sym" => :none,
    "def_int" => ::Storage::ENC_NONE,
    "m"       => {
      ::Storage::ENC_TWOFISH        => :twofish,
      ::Storage::ENC_TWOFISH_OLD    => :twofish_old,
      ::Storage::ENC_TWOFISH256_OLD => :twofish_256_old,
      ::Storage::ENC_LUKS           => :luks,
      ::Storage::ENC_UNKNOWN        => :unknown
    }
  }

  @conv_mdtype = {
    "def_sym" => :raid_unknown,
    "def_int" => ::Storage::RAID_UNK,
    "m"       => {
      ::Storage::RAID0     => :raid0,
      ::Storage::RAID1     => :raid1,
      ::Storage::RAID5     => :raid5,
      ::Storage::RAID6     => :raid6,
      ::Storage::RAID10    => :raid10,
      ::Storage::MULTIPATH => :multipath
    }
  }

  @conv_mdstring = {
    "raid0"     => ::Storage::RAID0,
    "raid1"     => ::Storage::RAID1,
    "raid5"     => ::Storage::RAID5,
    "raid6"     => ::Storage::RAID6,
    "raid10"    => ::Storage::RAID10,
    "multipath" => ::Storage::MULTIPATH
  }

  @conv_mdparity = {
    "def_sym" => :par_default,
    "def_int" => ::Storage::PAR_DEFAULT,
    "m"       => {
      ::Storage::LEFT_ASYMMETRIC    => :left_asymmetric,
      ::Storage::LEFT_SYMMETRIC     => :left_symmetric,
      ::Storage::RIGHT_ASYMMETRIC   => :right_asymmetric,
      ::Storage::RIGHT_SYMMETRIC    => :right_symmetric,
      ::Storage::PAR_FIRST          => :par_first,
      ::Storage::PAR_LAST           => :par_last,
      ::Storage::LEFT_ASYMMETRIC_6  => :left_asymmetric_6,
      ::Storage::LEFT_SYMMETRIC_6   => :left_symmetric_6,
      ::Storage::RIGHT_ASYMMETRIC_6 => :right_asymmetric_6,
      ::Storage::RIGHT_SYMMETRIC_6  => :right_symmetric_6,
      ::Storage::PAR_FIRST_6        => :par_first_6,
      ::Storage::PAR_NEAR_2         => :par_near_2,
      ::Storage::PAR_OFFSET_2       => :par_offset_2,
      ::Storage::PAR_FAR_2          => :par_far_2,
      ::Storage::PAR_NEAR_3         => :par_near_3,
      ::Storage::PAR_OFFSET_3       => :par_offset_3,
      ::Storage::PAR_FAR_3          => :par_far_3
    }
  }

  @conv_parstring = {
    "default"            => ::Storage::PAR_DEFAULT,
    "left_asymmetric"    => ::Storage::LEFT_ASYMMETRIC,
    "left_symmetric"     => ::Storage::LEFT_SYMMETRIC,
    "right_asymmetric"   => ::Storage::RIGHT_ASYMMETRIC,
    "right_symmetric"    => ::Storage::RIGHT_SYMMETRIC,
    "parity_first"       => ::Storage::PAR_FIRST,
    "parity_last"        => ::Storage::PAR_LAST,
    "left_asymmetric_6"  => ::Storage::LEFT_ASYMMETRIC_6,
    "left_symmetric_6"   => ::Storage::LEFT_SYMMETRIC_6,
    "right_asymmetric_6" => ::Storage::RIGHT_ASYMMETRIC_6,
    "right_symmetric_6"  => ::Storage::RIGHT_SYMMETRIC_6,
    "parity_first_6"     => ::Storage::PAR_FIRST_6,
    "n2"                 => ::Storage::PAR_NEAR_2,
    "o2"                 => ::Storage::PAR_OFFSET_2,
    "f2"                 => ::Storage::PAR_FAR_2,
    "n3"                 => ::Storage::PAR_NEAR_3,
    "o3"                 => ::Storage::PAR_OFFSET_3,
    "f3"                 => ::Storage::PAR_FAR_3
  }

  @rev_conv_parstring = Builtins.mapmap(@conv_parstring) do |s, i|
    { i => s }
  end

  @conv_partalign = {
    "def_sym" => :align_optimal,
    "def_int" => ::Storage::ALIGN_OPTIMAL,
    "m"       => {
      ::Storage::ALIGN_OPTIMAL  => :align_optimal,
      ::Storage::ALIGN_CYLINDER => :align_cylinder
    }
  }

  @conv_transport = {
    "def_sym" => :unknown,
    "def_int" => ::Storage::TUNKNOWN,
    "m"       => {
      ::Storage::SBP   => :sbp,
      ::Storage::ATA   => :ata,
      ::Storage::FC    => :fc,
      ::Storage::ISCSI => :iscsi,
      ::Storage::SAS   => :sas,
      ::Storage::SATA  => :sata,
      ::Storage::SPI   => :spi,
      ::Storage::USB   => :usb,
      ::Storage::FCOE  => :fcoe
    }
  }


  @DiskMapVersion = {}
  @DiskMap = {}

  @type_order = {
    :CT_DISK        => 0,
    :CT_DMRAID      => 1,
    :CT_DMMULTIPATH => 2,
    :CT_MDPART      => 3,
    :CT_MD          => 4,
    :CT_DM          => 5,
    :CT_LVM         => 6,
    :CT_LOOP        => 7,
    :CT_NFS         => 8,
    :CT_BTRFS       => 9,
    :CT_TMPFS       => 10
  }

  @hw_packages = []

  @part_insts = nil


  # Storage = TargetMap
  # /* Storage = $[ "targets" 			: $[],
  # 		    "must_reread_partitions"   	: false,
  # 		    "win_device"   		: false,
  # 		    "testsuite"   		: false,
  # 		    "do_resize"    		: "",
  # 		    "part_proposal_mode"        : "",
  # 		    "part_proposal_first"       : true,
  # 		    "focus"		       	: key
  # 		    ]


  @StorageMap = {}

  # stringkeys for access  to the Storage map
  @targets_key = "targets"
  @part_mode_key = "part_mode"
  @part_disk_key = "part_disk"
  @testsuite_key = "testsuite"
  @do_resize_key = "do_resize"
  @win_device_key = "win_device"
  @custom_display_key = "custom_display"
  @part_proposal_mode_key = "part_proposal_mode"
  @part_proposal_first_key = "part_proposal_first"
  @part_proposal_active_key = "part_proposal_active"

  @probe_done = false
  @exit_key = :next
  @sint = nil
  @conts = []

  @count = 0

  @save_chtxt = ""


  @dbus_cookie = nil
  Storage()
end

- (Object) MaxCylLabel(disk, start_cyl)



2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
# File '../../src/modules/Storage.rb', line 2503

def MaxCylLabel(disk, start_cyl)
  disk = deep_copy(disk)
  ret = Ops.divide(
    Ops.multiply(
      Partitions.MaxSectors(Ops.get_string(disk, "label", "")),
      Ops.get_integer(disk, "sector_size", 512)
    ),
    1024
  )
  Builtins.y2milestone(
    "MaxCylLabel val_k:%1 cyl_size:%2",
    ret,
    Ops.get_integer(disk, "cyl_size", 1)
  )
  cylk2 = Ops.divide(Ops.get_integer(disk, "cyl_size", 1), 512)
  cylk2 = 2 if Ops.less_than(cylk2, 2)
  Builtins.y2milestone("MaxCylLabel val_k:%1 cylk2:%2", ret, cylk2)
  ret = Ops.subtract(Ops.divide(Ops.multiply(ret, 2), cylk2), 1)
  ret = Ops.add(ret, start_cyl)
  Builtins.y2milestone("MaxCylLabel ret:%1", ret)
  ret
end

- (Object) mdPartMap(info, p)



1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
# File '../../src/modules/Storage.rb', line 1455

def mdPartMap(info, p)
  p = deep_copy(p)
  vinfo = info.v
  p = volumeMap(vinfo, p)
  Ops.set(p, "nr", 0)
  part = info.part
  if part
    pinfo = info.p
    p = partAddMap(pinfo, p)
  end
  Builtins.y2milestone("mdPartMap ret:%1", p)
  deep_copy(p)
end

- (Object) MdToDev(nr_or_string)



3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
# File '../../src/modules/Storage.rb', line 3257

def MdToDev(nr_or_string)
  Builtins.y2milestone("MdToDev nr_or:%1", nr_or_string)
  if Ops.is_string?(nr_or_string)
     ret = nr_or_string
  else 
     ret = "/dev/md"+nr_or_string.to_s
  end
  Builtins.y2milestone("MdToDev ret:%1", ret)
  ret
end

- (Boolean) Mount(dev, mp)

Mounts a device

Parameters:

  • string

    device name

  • string

    mount point

Returns:

  • (Boolean)

    if successful

See Also:

  • #Umount()


4910
4911
4912
# File '../../src/modules/Storage.rb', line 4910

def Mount(dev, mp)
  MountOpt(dev, mp, "")
end

- (Object) mountedPartitionsOnDisk(disk)



5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
# File '../../src/modules/Storage.rb', line 5364

def mountedPartitionsOnDisk(disk)
  d = GetDisk(GetTargetMap(), disk)
  ret = Builtins.filter(Ops.get_list(d, "partitions", [])) do |p|
    Ops.greater_than(
      Builtins.size(DeviceMounted(Ops.get_string(p, "device", ""))),
      0
    )
  end
  deep_copy(ret)
end

- (Boolean) MountOpt(dev, mp, fstopt)

Mounts a device

Parameters:

  • string

    device name

  • string

    mount point

  • fstopt (String)

    mount options

Returns:

  • (Boolean)

    if successful

See Also:

  • #Umount()


4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
# File '../../src/modules/Storage.rb', line 4890

def MountOpt(dev, mp, fstopt)
  ret = @sint.mountDeviceRo(dev, mp, fstopt)
  Builtins.y2milestone(
    "MountOpt %1 to %2 with %3 ret %4",
    dev,
    mp,
    fstopt,
    ret
  )
  ret
end

- (Object) NeedCryptPwd(device)



3461
3462
3463
3464
3465
# File '../../src/modules/Storage.rb', line 3461

def NeedCryptPwd(device)
  ret = @sint.needCryptPassword(device)
  Builtins.y2milestone("NeedCryptPwd device:%1 ret:%2", device, ret)
  ret
end

- (Object) NeedVgPassword(tg, vg_key)



3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
# File '../../src/modules/Storage.rb', line 3481

def NeedVgPassword(tg, vg_key)
  ret = IsVgEncrypted(tg, vg_key)
  Builtins.y2milestone("NeedVgPassword vg:%1", Ops.get(tg, vg_key, {}))
  if ret
    devs = Ops.get_list(tg, [vg_key, "devices"], [])
    Builtins.foreach(devs) do |s|
      ret = ret && NeedCryptPwd(s)
      Builtins.y2milestone("NeedVgPassword ret:%1 s:%2", ret, s)
    end
  else
    ret = !Builtins.haskey(tg, vg_key)
  end
  Builtins.y2milestone("NeedVgPassword key:%1 ret:%2", vg_key, ret)
  ret
end

- (Object) NextMd



2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
# File '../../src/modules/Storage.rb', line 2491

def NextMd
  Builtins.y2milestone("NextMd")
  r, num, dev = @sint.nextFreeMd()
  Builtins.y2error("NextMd ret %1", r) if r<0
  num = 0 if r<0
  dev = "" if r<0
  ret = { "device" => dev, "nr" => num }
  Builtins.y2milestone("NextMd sint ret:%1 map:%2", r, ret)
  deep_copy(ret)
end

- (Object) NextPartition(disk, ptype)



2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
# File '../../src/modules/Storage.rb', line 2477

def NextPartition(disk, ptype)
  Builtins.y2milestone("NextPartition disk:%1 ptype:%2", disk, ptype)
  pt = fromSymbol(@conv_ptype, ptype)
  Builtins.y2milestone("NextPartition type:%1 pt:%2", ptype, pt)
  r, num, dev = @sint.nextFreePartition(disk, pt)
  Builtins.y2error("NextPartition ret %1", r) if r<0
  num = 0 if r<0
  dev = "" if r<0
  ret = { "device" => dev, "nr" => num }
  Builtins.y2milestone("NextPartition sint ret:%1 map:%2", r, ret)
  deep_copy(ret)
end

- (Object) NumLoopDevices



6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
# File '../../src/modules/Storage.rb', line 6672

def NumLoopDevices
  bo = Convert.to_map(WFM.Execute(path(".local.bash_output"), "losetup -a"))
  sl = Builtins.splitstring(Ops.get_string(bo, "stdout", ""), "\n")
  sl = Builtins.filter(sl) { |s| Builtins.search(s, "/dev/loop") == 0 }
  sl = Builtins.maplist(sl) do |s|
    Builtins.substring(s, 0, Builtins.search(s, ":"))
  end
  sl = Builtins.maplist(sl) { |s| Builtins.substring(s, 9) }
  il = Builtins.sort(Builtins.maplist(sl) { |s| Builtins.tointeger(s) })
  ret = Ops.add(Ops.get(il, Ops.subtract(Builtins.size(sl), 1), -1), 1)
  Builtins.y2milestone("NumLoopDevices ret:%1", ret)
  ret
end

- (Object) onepartition2fstab(part, other_nr)

—————————————————– convert partitions to fstab entries return map (might be empty)



6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
# File '../../src/modules/Storage.rb', line 6690

def onepartition2fstab(part, other_nr)
  part = deep_copy(part)
  Builtins.y2milestone("onepartition2fstab part=%1", part)
  if Ops.get_boolean(part, "delete", false) ||
      Ops.get_symbol(part, "type", :unknown) == :extended ||
      Builtins.contains(
        [:lvm, :sw_raid, :evms],
        Ops.get_symbol(part, "type", :unknown)
      ) &&
        Builtins.size(Ops.get_string(part, "mount", "")) == 0 ||
      Ops.get_symbol(part, "enc_type", :none) != :none &&
        !Ops.get_boolean(part, "noauto", false) ||
      !IsUsedBy(part) ||
      Builtins.contains(
        [
          Partitions.fsid_prep_chrp_boot,
          Partitions.fsid_gpt_prep,
          Partitions.fsid_lvm,
          Partitions.fsid_raid
        ],
        Ops.get_integer(part, "fsid", 0)
      ) &&
        Builtins.size(Ops.get_string(part, "mount", "")) == 0
    return {}
  end

  spec = Ops.get_string(part, "device", "")
  if Ops.get_symbol(part, "mountby", :device) == :label &&
      Ops.greater_than(Builtins.size(Ops.get_string(part, "label", "")), 0)
    spec = Builtins.sformat("LABEL=%1", Ops.get_string(part, "label", ""))
  elsif Ops.get_symbol(part, "mountby", :device) == :uuid &&
      Ops.greater_than(Builtins.size(Ops.get_string(part, "uuid", "")), 0)
    spec = Builtins.sformat("UUID=%1", Ops.get_string(part, "uuid", ""))
  end
  Builtins.y2debug("onepartition2fstab spec=%1", spec)
  mount_point = Ops.get_string(part, "mount", "")
  fsid = Ops.get_integer(part, "fsid", 0)

  used_fs = Ops.get_symbol(part, "used_fs", :ext2)
  format = Ops.get_boolean(part, "format", false)

  vfstype = "unknown" # keep "unknown", used again below
  freq = 0
  passno = 0
  mntops = Ops.get_string(part, "fstopt", "")

  if mount_point == "swap"
    vfstype = "swap"
    if Builtins.isempty(mntops)
      mntops = Ops.get_string(
        FileSystems.GetFstabDefaultMap("swap"),
        "mntops",
        ""
      )
    end
    passno = 0
  elsif fsid == Partitions.fsid_native || fsid == Partitions.fsid_lvm ||
      Ops.get_symbol(part, "type", :unknown) == :evms &&
        Ops.get_symbol(part, "detected_fs", :none) != :unknown
    vfstype = FileSystems.GetMountString(used_fs, format ? "ext2" : "auto")

    freq = 1
    if mount_point == "/"
      passno = 1
    elsif mount_point != ""
      passno = 2
    elsif Stage.initial && !Arch.s390
      mount_point = Ops.add("/data", other_nr.value)
      # Don't mount and fsck this filesystem during boot, its
      # state is unknown.
      mntops = "noauto,user"
      vfstype = "auto"
      freq = 0
      passno = 0
      other_nr.value = Ops.add(other_nr.value, 1)
      Builtins.y2milestone("TT add MountPoint %1", mount_point)
    end
  elsif (Arch.i386 || Arch.ia64 || Arch.x86_64) &&
      Ops.greater_than(Builtins.size(mount_point), 0) &&
      (used_fs == :vfat || used_fs == :ntfs) &&
      (Builtins.contains(
        Builtins.union(
          Builtins.union(
            Partitions.fsid_dostypes,
            Partitions.fsid_ntfstypes
          ),
          Partitions.fsid_wintypes
        ),
        fsid
      ) ||
        fsid == Partitions.fsid_gpt_boot)
    freq = 0
    passno = 0
    lower_point = Builtins.tolower(mount_point)
    if lower_point != "" && mount_point != lower_point
      lower_point = PathToDestdir(lower_point)
      Builtins.y2milestone(
        "symlink %1 -> %2",
        Builtins.substring(
          mount_point,
          Ops.add(Builtins.findlastof(mount_point, "/"), 1)
        ),
        lower_point
      )
      SCR.Execute(
        path(".target.symlink"),
        Builtins.substring(
          mount_point,
          Ops.add(Builtins.findlastof(mount_point, "/"), 1)
        ),
        lower_point
      )
    end
    vfstype = FileSystems.GetMountString(used_fs, "auto")
  elsif (Arch.sparc || Arch.alpha) &&
      Builtins.contains(Partitions.fsid_skipped, fsid)
    return {} # skip "whole disk" partition
  else
    return {} # unknown type
  end
  if Ops.get_symbol(part, "detected_fs", :unknown) == :unknown ||
      Ops.get_boolean(part, "noauto", false)
    passno = 0
  end

  ret = {
    "spec"    => spec,
    "mount"   => mount_point,
    "vfstype" => vfstype,
    "mntops"  => mntops,
    "freq"    => freq,
    "device"  => Ops.get_string(part, "device", ""),
    "passno"  => passno
  }

  if Builtins.size(Ops.get_string(ret, "mntops", "")) == 0
    Ops.set(ret, "mntops", "defaults")
  end

  Builtins.y2milestone("onepartition2fstab ret=%1", ret)
  deep_copy(ret)
end

- (Object) partAddMap(info, p)



1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
# File '../../src/modules/Storage.rb', line 1423

def partAddMap(info, p)
  p = deep_copy(p)
  Ops.set(p, "nr", info.nr)
  Ops.set(p, "fsid", info.id)
  Ops.set(
    p,
    "fstype",
    Partitions.FsIdToString(Ops.get_integer(p, "fsid", 0))
  )
  p["region"] = [ info.cylRegion.start, info.cylRegion.len ]
  Ops.set(p, "type", toSymbol(@conv_ptype, info.partitionType))
  Ops.set(p, "boot", true) if info.boot
  Builtins.y2milestone("partAddMap ret:%1", p)
  deep_copy(p)
end

- (Object) PasswdPopup(helptxt, header, label, pw2, minpwlen, tmpcrypt)



3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
# File '../../src/modules/Storage.rb', line 3987

def PasswdPopup(helptxt, header, label, pw2, minpwlen, tmpcrypt)
  ad = Empty()
  if pw2
    ad = VBox(
      VSpacing(0.5),
      HBox(
        Password(
          Id(:pw2),
          Opt(:hstretch),
          # Label: get same password again for verification
          # Please use newline if label is longer than 40 characters
          _("Reenter the Password for &Verification:"),
          ""
        ),
        HSpacing(13)
      )
    )
  end
  UI.OpenDialog(
    Opt(:decorated),
    HBox(
      HWeight(3, RichText(helptxt)),
      HWeight(
        6,
        VBox(
          VSpacing(0.3),
          HBox(HSpacing(1), Heading(header), HSpacing(1)),
          VSpacing(1),
          HBox(
            HSpacing(4),
            VBox(
              # label text
              Label(label),
              VSpacing(),
              HBox(
                Password(
                  Id(:pw1),
                  Opt(:hstretch),
                  # Label: get password for encrypted volume
                  # Please use newline if label is longer than 40 characters
                  _("&Enter Encryption Password:"),
                  ""
                ),
                HSpacing(13)
              ),
              ad
            ),
            HSpacing(4)
          ),
          VSpacing(2),
          ButtonBox(
            PushButton(Id(:ok), Opt(:default), Label.OKButton),
            PushButton(Id(:cancel), Label.CancelButton)
          ),
          VSpacing(0.5)
        )
      )
    )
  )

  ret = ""
  password = ""
  widget = nil
  begin
    # Clear password fields on every round.
    UI.ChangeWidget(Id(:pw1), :Value, "")
    UI.ChangeWidget(Id(:pw2), :Value, "") if pw2

    UI.SetFocus(Id(:pw1))

    widget = Convert.to_symbol(UI.UserInput)

    case widget
      when :ok
        password = Convert.to_string(UI.QueryWidget(Id(:pw1), :Value))

        if pw2
          tmp = Convert.to_string(UI.QueryWidget(Id(:pw2), :Value))
          if !CheckEncryptionPasswords(password, tmp, minpwlen, tmpcrypt)
            widget = :again
          else
            ret = password
          end
        else
          ret = password
        end
    end
  end until widget == :cancel || widget == :ok

  UI.CloseDialog
  ret = password if widget == :ok
  ret
end

- (Object) PathToDestdir(p)



6082
6083
6084
6085
6086
6087
# File '../../src/modules/Storage.rb', line 6082

def PathToDestdir(p)
  if Installation.scr_destdir != "/"
    p = Ops.add(Installation.scr_destdir, p)
  end
  p
end

- (Object) PerformLosetup(loop, format)



6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
# File '../../src/modules/Storage.rb', line 6211

def PerformLosetup(loop, format)
  crypt_ok = false
  pwd = Ops.get_string(loop.value, "passwd", "")
  device = Ops.get_string(loop.value, "partitionName", "")
  mdir = SaveDumpPath("tmp_mp")
  Builtins.y2milestone("PerformLosetup mdir:%1", mdir)
  if Ops.greater_or_equal(
      Convert.to_integer(SCR.Read(path(".target.size"), mdir)),
      0
    )
    SCR.Execute(path(".target.bash"), Ops.add("rm -f ", mdir))
  end
  SCR.Execute(path(".target.mkdir"), mdir)
  crypt_ok = SetCryptPwd(device, pwd) && SetCrypt(device, true, false) &&
    Mount(device, mdir)
  if crypt_ok
    vinfo = ::Storage::VolumeInfo.new()
    ret = @sint.getVolume(device, vinfo)
    if ret != 0
      Builtins.y2error(
        "PerformLosetup device:%1 not found (ret:%2)",
        device,
        ret
      )
      crypt_ok = false
    else
      Ops.set(
        loop.value,
        "loop_dev",
        Ops.add(
          "/dev/mapper/cr_",
          Builtins.substring(
            device,
            Ops.add(Builtins.findlastof(device, "/"), 1)
          )
        )
      )
      Builtins.y2milestone(
        "PerformLosetup crdev:%1",
        Ops.get_string(loop.value, "loop_dev", "")
      )
    end
    SCR.Execute(path(".target.bash"), Ops.add("umount ", mdir))
  end
  Builtins.y2milestone("PerformLosetup ret %1", crypt_ok)
  crypt_ok
end

- (Array) ReadFstab(dir)

Reads and returns fstab from directory

FIXME: please, add description of the list that is returned by this function.

Structure:

[...unknown...]

Parameters:

  • string

    directory

Returns:

  • (Array)

    fstab?



5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
# File '../../src/modules/Storage.rb', line 5347

def ReadFstab(dir)
  ret = []
  vinfos = ::Storage::DequeVolumeInfo.new()
  r = @sint.readFstab(dir, vinfos)
  if !r
    Builtins.y2error("ReadFstab sint dir %1 ret %2", dir, r)
  else
    vinfos.each do |info|
      p = {}
      p = volumeMap(info, p)
      ret = Builtins.add(ret, p)
    end
  end
  Builtins.y2milestone("ReadFstab from %1 ret %2", dir, ret)
  ret
end

- (Object) ReduceBtrfsVolume(uuid, device)



3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
# File '../../src/modules/Storage.rb', line 3186

def ReduceBtrfsVolume(uuid, device)
  Builtins.y2milestone("ReduceBtrfsVolume uuid:%1 device:%2", uuid, device)
  ret = 0
  devd = ::Storage::DequeString.new()
  devd.push(device)
  ret = @sint.shrinkBtrfsVolume(uuid, devd)
  if ret<0
    Builtins.y2error("ReduceBtrfsVolume sint ret:%1", ret)
  end
  UpdateTargetMap()
  ret == 0
end

- (Object) ReduceLvmVg(name, device)



3076
3077
3078
3079
3080
3081
3082
3083
3084
# File '../../src/modules/Storage.rb', line 3076

def ReduceLvmVg(name, device)
  Builtins.y2milestone("ReduceLvmVg name:%1 device:%2", name, device)
  devd = ::Storage::DequeString.new()
  devd.push(device)
  ret = @sint.shrinkLvmVg(name, devd)
  Builtins.y2error("ReduceLvmVg sint ret:%1", ret) if ret<0
  UpdateTargetMap()
  ret == 0
end

- (Object) RemoveDmMapsTo(device)

Removes … maps to …

Parameters:

  • device (String)

    name



3839
3840
3841
3842
3843
3844
# File '../../src/modules/Storage.rb', line 3839

def RemoveDmMapsTo(device)
  Builtins.y2milestone("RemoveDmMapsTo device:%1", device)
  return if !InitLibstorage(false)
  @sint.removeDmTableTo(device)
  nil
end

- (Object) ReplaceMd(nr, devs)



3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
# File '../../src/modules/Storage.rb', line 3313

def ReplaceMd(nr, devs)
  Builtins.y2milestone("ReplaceMd nr:%1 devs:%2", nr, devs)
  empty = ::Storage::ListString.new()
  devices = StringListFromList(devs);
  rd = MdToDev(nr)
  ret = @sint.updateMd(rd, devices, empty)
  Builtins.y2error("ReplaceMd sint ret:%1", ret) if ret<0
  UpdateTargetMap()
  ret == 0
end

- (Hash{String => map}) ReReadTargetMap

Rereads the system target map and returns it

Returns:

  • (Hash{String => map})

    target map

See Also:

  • #GetTargetMap();


4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
# File '../../src/modules/Storage.rb', line 4824

def ReReadTargetMap
  need_reread = @sint != nil

  return nil if !InitLibstorage(false)

  Builtins.y2milestone("start reread need_reread:%1", need_reread)
  @probe_done = false
  @sint.rescanEverything() if need_reread
  @conts = getContainers
  GetTargetMap()
end

- (Object) RescanCrypted



3931
3932
3933
3934
3935
# File '../../src/modules/Storage.rb', line 3931

def RescanCrypted
  ret = @sint.rescanCryptedObjects()
  Builtins.y2milestone("RescanCrypted ret:%1", ret)
  ret
end

- (Object) ResetOndiskTarget



2300
2301
2302
2303
2304
# File '../../src/modules/Storage.rb', line 2300

def ResetOndiskTarget
  RestoreTargetBackup("initial")

  nil
end

- (Boolean) ResizePartition(device, disk, new_cyls)

Sets a new size for volume

Parameters:

  • device (String)

    name

  • disk (String)
  • new_cyls (Fixnum)

    (in cylinders)

Returns:

  • (Boolean)

    if successful



2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
# File '../../src/modules/Storage.rb', line 2652

def ResizePartition(device, disk, new_cyls)
  Builtins.y2milestone(
    "ResizePartition device:%1 disk:%2 new_cyls:%3",
    device,
    disk,
    new_cyls
  )
  ret = @sint.resizePartition(device, new_cyls)
  if ret<0
    Builtins.y2error("ResizePartition sint ret:%1", ret)
  end
  UpdateTargetMapDisk(disk)
  ret == 0
end

- (Boolean) ResizeVolume(device, disk, new_size_k)

Sets a new size for volume

Parameters:

  • device (String)

    name

  • disk (String)
  • integer

    new_size (in kBytes)

Returns:

  • (Boolean)

    if successful



2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
# File '../../src/modules/Storage.rb', line 2674

def ResizeVolume(device, disk, new_size_k)
  Builtins.y2milestone(
    "ResizeVolume device:%1 disk:%2 new_size_k:%3",
    device,
    disk,
    new_size_k
  )
  ret = @sint.resizeVolume(device, new_size_k)
  Builtins.y2error("ResizeVolume sint ret:%1", ret) if ret<0
  UpdateTargetMapDisk(disk)
  ret == 0
end

- (Object) RestoreTargetBackup(who)



2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
# File '../../src/modules/Storage.rb', line 2286

def RestoreTargetBackup(who)
  Builtins.y2milestone("RestoreTargetBackup who:%1", who)
  ret = @sint.restoreBackupState(who)
  if ret<0
    Builtins.y2error("RestoreTargetBackup sint ret:%1", ret)
  end
  UpdateTargetMap()
  t = Ops.add("targetMap_r_", who)
  SCR.Write(path(".target.ycp"), SaveDumpPath(t), GetTargetMap())

  nil
end

- (Object) SaveDeviceGraph(filename)



6909
6910
6911
6912
6913
# File '../../src/modules/Storage.rb', line 6909

def SaveDeviceGraph(filename)
  ret = ::Storage::saveDeviceGraph(@sint, filename)
  Builtins.y2milestone("SaveDeviceGraph filename:%1 ret:%2", filename, ret)
  ret
end

- (Object) SaveDumpPath(name)



1094
1095
1096
1097
# File '../../src/modules/Storage.rb', line 1094

def SaveDumpPath(name)
  ret = Ops.add(Ops.add(Directory.tmpdir, "/"), name)
  ret
end

- (Object) SaveExitKey(key)



2211
2212
2213
2214
2215
2216
2217
2218
# File '../../src/modules/Storage.rb', line 2211

def SaveExitKey(key)
  if key == :next || key == :back
    @exit_key = key
    Builtins.y2milestone("Exit Key %1", @exit_key)
  end

  nil
end

- (Object) SaveMountGraph(filename)



6916
6917
6918
6919
6920
# File '../../src/modules/Storage.rb', line 6916

def SaveMountGraph(filename)
  ret = ::Storage::saveMountGraph(@sint, filename);
  Builtins.y2milestone("SaveMountGraph filename:%1 ret:%2", filename, ret)
  ret
end

- (Object) SaveUsedFs



5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
# File '../../src/modules/Storage.rb', line 5910

def SaveUsedFs
  Builtins.y2milestone("SaveUsedFs")
  SCR.Write(
    path(".sysconfig.storage.USED_FS_LIST"),
    Builtins.mergestring(GetUsedFs(), " ")
  )
  SCR.Write(path(".sysconfig.storage"), nil)

  nil
end

- (Object) SetCrypt(device, crpt, format)



2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
# File '../../src/modules/Storage.rb', line 2688

def SetCrypt(device, crpt, format)
  Builtins.y2milestone(
    "SetCrypt device:%1 val:%2 format:%3",
    device,
    crpt,
    format
  )
  ret, is_crypt = @sint.getCrypt(device)
  is_crypt = false if ret<0
  if ret == 0 && !format && is_crypt == crpt
    Builtins.y2milestone("SetCrypt crypt already set")
  else
    ret = @sint.setCrypt(device, crpt)
    if ret<0
      Builtins.y2error("SetCrypt sint ret:%1", ret)
      if !format && crpt
        Popup.Error(
          Builtins.sformat(
            _(
              "Could not set encryption.\n" +
                "System error code is %1.\n" +
                "\n" +
                "The encryption password provided could be incorrect.\n"
            ),
            ret
          )
        )
      end
      @sint.forgetCryptPassword(device)
    else
      Builtins.y2milestone("SetCrypt sint ret:%1", ret)
    end
  end
  ret == 0
end

- (Object) SetCryptPwd(device, pwd)



3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
# File '../../src/modules/Storage.rb', line 3437

def SetCryptPwd(device, pwd)
  Builtins.y2milestone("SetCryptPwd device:%1", device)
  ret = @sint.setCryptPassword(device, pwd)
  if ret<0
    Builtins.y2error("SetCryptPwd sint ret:%1", ret)
  else
    Builtins.y2milestone("SetCryptPwd sint ret:%1", ret)
  end
  ret == 0
end

- (Object) SetCustomDisplay(value)



2346
2347
2348
2349
2350
# File '../../src/modules/Storage.rb', line 2346

def SetCustomDisplay(value)
  Ops.set(@StorageMap, @custom_display_key, value)

  nil
end

- (Object) SetDefaultMountBy(mby)



6886
6887
6888
6889
6890
6891
# File '../../src/modules/Storage.rb', line 6886

def SetDefaultMountBy(mby)
  val = fromSymbol(@conv_mountby, mby)
  @sint.setDefaultMountBy(val)

  nil
end

- (Object) SetDoResize(value)



2382
2383
2384
2385
2386
# File '../../src/modules/Storage.rb', line 2382

def SetDoResize(value)
  @StorageMap = Builtins.add(@StorageMap, @do_resize_key, value)

  nil
end

- (Object) SetIgnoreFstab(device, val)



482
483
484
# File '../../src/modules/Storage.rb', line 482

def SetIgnoreFstab(device, val)
  @sint.setIgnoreFstab(device, val)==0
end

- (Object) SetMultipathStartup(val)



6126
6127
6128
6129
6130
6131
6132
6133
# File '../../src/modules/Storage.rb', line 6126

def SetMultipathStartup(val)
  Builtins.y2milestone("SetMultipathStartup val:%1", val)
  if( @default_multipathing != val )
	  @default_multipathing = val
	  ActivateMultipath(val) if @sint
  end
  nil
end

- (Object) SetPartDisk(value)



2358
2359
2360
2361
2362
# File '../../src/modules/Storage.rb', line 2358

def SetPartDisk(value)
  Ops.set(@StorageMap, @part_disk_key, value)

  nil
end

- (Object) SetPartitionAlignment(pal)



5438
5439
5440
5441
5442
5443
5444
# File '../../src/modules/Storage.rb', line 5438

def SetPartitionAlignment(pal)
  Builtins.y2milestone("SetPartitionAlignment val:%1", pal)
  val = fromSymbol(@conv_partalign, pal)
  @sint.setPartitionAlignment(val)

  nil
end

- (Hash{String => map}) SetPartitionData(tg, device, key, value)

Set <key> in partition <device> to the given <value> and return changed map <tg>

Parameters:

  • tg (Hash{String => map})
  • device (String)

    name

Returns:

  • (Hash{String => map})

    changed target map



5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
# File '../../src/modules/Storage.rb', line 5545

def SetPartitionData(tg, device, key, value)
  tg = deep_copy(tg)
  value = deep_copy(value)
  Builtins.y2milestone(
    "SetPartitionData device=%1 key=%2 value=%3",
    device,
    key,
    value
  )
  tmp = Ops.get(GetDiskPartitionTg(device, tg), 0, {})
  disk = Ops.get_string(tmp, "disk", "")
  dev = GetDeviceName(
    Ops.get_string(tmp, "disk", ""),
    Ops.get(tmp, "nr", 0)
  )
  Ops.set(
    tg,
    [disk, "partitions"],
    Builtins.maplist(Ops.get_list(tg, [disk, "partitions"], [])) do |p|
      Ops.set(p, key, value) if Ops.get_string(p, "device", "") == dev
      deep_copy(p)
    end
  )
  deep_copy(tg)
end

- (Boolean) SetPartitionFormat(device, format, fs)

Sets whether a partition should be formatted

Parameters:

  • device (String)

    name

  • format (Boolean)

    (yes,no)

  • symbol

    filesystem

Returns:

  • (Boolean)

    if successful



2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
# File '../../src/modules/Storage.rb', line 2593

def SetPartitionFormat(device, format, fs)
  Builtins.y2milestone(
    "SetPartitionFormat device:%1 format:%2 fs:%3",
    device,
    format,
    fs
  )
  tmp = fromSymbol(FileSystems.conv_fs, fs)
  Builtins.y2milestone("SetPartitionFormat fs:%1", tmp)
  ret = @sint.changeFormatVolume(device, format, tmp)
  if ret<0
    Builtins.y2error("SetPartitionFormat sint ret:%1", ret)
  end
  UpdateTargetMapDev(device)
  ret == 0
end

- (Boolean) SetPartitionId(device, id)

Sets partition ID

Parameters:

  • device (String)

    name

  • integer

    ID

Returns:

  • (Boolean)

    if successful

See Also:

  • #UnchangePartitionId()


2618
2619
2620
2621
2622
2623
2624
2625
2626
# File '../../src/modules/Storage.rb', line 2618

def SetPartitionId(device, id)
  Builtins.y2milestone("SetPartitionId device:%1 id:%2", device, id)
  ret = @sint.changePartitionId(device, id)
  if ret<0
    Builtins.y2error("SetPartitionId sint ret:%1", ret)
  end
  UpdateTargetMapDev(device)
  ret == 0
end

- (Boolean) SetPartitionMount(device, mp)

Sets a mountpoint for partition

Parameters:

  • device (String)

    name

  • string

    mount point

Returns:

  • (Boolean)

    if successful



2576
2577
2578
2579
2580
2581
2582
2583
2584
# File '../../src/modules/Storage.rb', line 2576

def SetPartitionMount(device, mp)
  Builtins.y2milestone("SetPartitionMount device:%1 mp:%2", device, mp)
  ret = @sint.changeMountPoint(device, mp)
  if ret<0
    Builtins.y2error("SetPartitionMount sint ret:%1", ret)
  end
  UpdateTargetMapDev(device)
  ret == 0
end

- (Object) SetPartMode(value)



2333
2334
2335
2336
2337
2338
# File '../../src/modules/Storage.rb', line 2333

def SetPartMode(value)
  Builtins.y2milestone("SetPartMode %1", value)
  Ops.set(@StorageMap, @part_mode_key, value)

  nil
end

- (Object) SetPartProposalActive(value)



2317
2318
2319
2320
2321
# File '../../src/modules/Storage.rb', line 2317

def SetPartProposalActive(value)
  Ops.set(@StorageMap, @part_proposal_active_key, value)

  nil
end

- (Object) SetPartProposalFirst(value)



2406
2407
2408
2409
2410
# File '../../src/modules/Storage.rb', line 2406

def SetPartProposalFirst(value)
  @StorageMap = Builtins.add(@StorageMap, @part_proposal_first_key, value)

  nil
end

- (Object) SetPartProposalMode(value)



2394
2395
2396
2397
2398
# File '../../src/modules/Storage.rb', line 2394

def SetPartProposalMode(value)
  @StorageMap = Builtins.add(@StorageMap, @part_proposal_mode_key, value)

  nil
end

- (Object) SetRecursiveRemoval(val)



4572
4573
4574
4575
4576
# File '../../src/modules/Storage.rb', line 4572

def SetRecursiveRemoval(val)
  Builtins.y2milestone("SetRecursiveRemoval val:%1", val)
  @sint.setRecursiveRemoval(val)
  nil
end

- (Object) SetTargetMap(target)



4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
# File '../../src/modules/Storage.rb', line 4584

def SetTargetMap(target)
  target = deep_copy(target)
  save_crypt = {}
  Builtins.y2milestone("SetTargetMap")
  SetRecursiveRemoval(true) if !GetRecursiveRemoval()
  #SCR::Write(.target.ycp, Storage::SaveDumpPath("targetMap_set_"+sformat("%1",count)), target );
  #count = count+1;
  CreateTargetBackup("tmp_set")
  tg = GetTargetMap()
  keys = Builtins.maplist(target) { |k, e| k }
  Builtins.foreach(keys) do |k|
    if Ops.get_boolean(target, [k, "delete"], false) &&
        Builtins.haskey(tg, k)
      if Ops.get_symbol(target, [k, "type"], :CT_UNKNOWN) == :CT_LVM
        DeleteLvmVg(Ops.get_string(target, [k, "name"], ""))
        Ops.set(target, [k, "delete"], false)
      elsif Ops.get_symbol(target, [k, "type"], :CT_UNKNOWN) == :CT_DMRAID
        DeleteDmraid(k)
        Ops.set(target, [k, "delete"], false)
      end
    end
  end
  keys = Builtins.maplist(target) { |k, e| k }
  Builtins.y2milestone("SetTargetMap keys %1", keys)
  t1 = Builtins.filter(keys) do |k|
    !Ops.get_boolean(target, [k, "delete"], false) &&
      !Ops.get_boolean(target, [k, "create"], false)
  end
  Builtins.foreach(t1) do |k|
    dps = Builtins.filter(Ops.get_list(target, [k, "partitions"], [])) do |p|
      !Ops.get_boolean(p, "create", false) &&
        !Ops.get_boolean(p, "delete", false)
    end
    Builtins.foreach(dps) do |p|
      if Ops.get_symbol(p, "type", :primary) != :extended ||
          Ops.get_boolean(p, "resize", false)
        ChangeVolumeProperties(p)
      end
    end if Ops.greater_than(
      Builtins.size(dps),
      0
    )
  end
  keys = Builtins.maplist(tg) { |k, e| k }
  keys = Builtins.sort(keys) do |a, b|
    Ops.greater_than(
      Ops.get(@type_order, Ops.get_symbol(tg, [a, "type"], :CT_UNKNOWN), 9),
      Ops.get(@type_order, Ops.get_symbol(tg, [b, "type"], :CT_UNKNOWN), 9)
    )
  end
  Builtins.y2milestone("SetTargetMap keys %1", keys)
  Builtins.foreach(keys) do |k|
    dps = Builtins.filter(Ops.get_list(tg, [k, "partitions"], [])) do |p|
      Ops.get_boolean(p, "create", false)
    end
    if Ops.greater_than(Builtins.size(dps), 1) &&
        Builtins.haskey(Ops.get(dps, 0, {}), "nr")
      dps = Builtins.sort(dps) do |a, b|
        Ops.greater_than(
          Ops.get_integer(a, "nr", 0),
          Ops.get_integer(b, "nr", 0)
        )
      end
      Builtins.y2milestone("SetTargetMap dps:%1", dps)
    end
    Builtins.foreach(dps) do |p|
      tdev = Ops.get_string(p, "device", "")
      if Ops.get_symbol(p, "enc_type", :none) != :none
        Ops.set(save_crypt, tdev, GetCryptPwd(tdev))
      end
      DeleteDevice(tdev)
    end
    if Ops.get_boolean(tg, [k, "create"], false)
      if Ops.get_symbol(tg, [k, "type"], :CT_UNKNOWN) == :CT_LVM
        DeleteLvmVg(Ops.get_string(tg, [k, "name"], ""))
      end
    elsif !Ops.get_boolean(tg, [k, "delete"], false)
      if Ops.get_symbol(tg, [k, "type"], :CT_UNKNOWN) == :CT_LVM &&
          Ops.greater_than(
            Builtins.size(Ops.get_list(target, [k, "devices_add"], [])),
            0
          )
        ls = Ops.get_list(target, [k, "devices_add"], [])
        Builtins.foreach(ls) do |d|
          ReduceLvmVg(Ops.get_string(target, [k, "name"], ""), d)
        end
      end
    end
  end
  keys = Builtins.maplist(target) { |k, e| k }
  keys = Builtins.sort(keys) do |a, b|
    Ops.greater_than(
      Ops.get(
        @type_order,
        Ops.get_symbol(target, [a, "type"], :CT_UNKNOWN),
        9
      ),
      Ops.get(
        @type_order,
        Ops.get_symbol(target, [b, "type"], :CT_UNKNOWN),
        9
      )
    )
  end
  Builtins.y2milestone("SetTargetMap keys %1", keys)
  Builtins.foreach(keys) do |k|
    dps = Builtins.filter(Ops.get_list(target, [k, "partitions"], [])) do |p|
      Ops.get_boolean(p, "delete", false)
    end
    if Ops.greater_than(Builtins.size(dps), 1) &&
        Builtins.haskey(Ops.get(dps, 0, {}), "nr")
      dps = Builtins.sort(dps) do |a, b|
        Ops.greater_than(
          Ops.get_integer(a, "nr", 0),
          Ops.get_integer(b, "nr", 0)
        )
      end
    end
    Builtins.foreach(dps) do |p|
      if Ops.greater_than(Builtins.size(Ops.get_string(p, "dtxt", "")), 0)
        ChangeDescText(
          Ops.get_string(p, "device", ""),
          Ops.get_string(p, "dtxt", "")
        )
      end
      DeleteDevice(Ops.get_string(p, "device", ""))
    end
    if Ops.get_boolean(target, [k, "delete"], false)
      if Ops.get_symbol(target, [k, "type"], :CT_UNKNOWN) == :CT_LVM
        DeleteLvmVg(Ops.get_string(target, [k, "name"], ""))
      elsif Ops.get_symbol(target, [k, "type"], :CT_UNKNOWN) == :CT_DISK
        DeletePartitionTable(
          k,
          Ops.get_string(target, [k, "disklabel"], "")
        )
      elsif Ops.get_symbol(target, [k, "type"], :CT_UNKNOWN) == :CT_DMRAID
        DeleteDmraid(k)
      end
    end
    if Ops.get_boolean(target, [k, "del_ptable"], false) &&
        IsPartType(Ops.get_symbol(target, [k, "type"], :CT_UNKNOWN))
      DeletePartitionTable(k, Ops.get_string(target, [k, "disklabel"], ""))
    end
  end
  keys = Builtins.maplist(target) { |k, e| k }
  keys = Builtins.sort(keys) do |a, b|
    Ops.less_than(
      Ops.get(
        @type_order,
        Ops.get_symbol(target, [a, "type"], :CT_UNKNOWN),
        9
      ),
      Ops.get(
        @type_order,
        Ops.get_symbol(target, [b, "type"], :CT_UNKNOWN),
        9
      )
    )
  end
  Builtins.y2milestone("SetTargetMap keys %1", keys)
  Builtins.foreach(keys) do |k|
    if Ops.get_boolean(target, [k, "create"], false)
      if Ops.get_symbol(target, [k, "type"], :CT_UNKNOWN) == :CT_LVM
        CreateLvmVg(
          Ops.get_string(target, [k, "name"], ""),
          Ops.get_integer(target, [k, "pesize"], 0),
          Ops.get_boolean(target, [k, "lvm2"], true)
        )
        ls = Convert.convert(
          Builtins.union(
            Ops.get_list(target, [k, "devices"], []),
            Ops.get_list(target, [k, "devices_add"], [])
          ),
          :from => "list",
          :to   => "list <string>"
        )
        Builtins.foreach(ls) do |d|
          ExtendLvmVg(Ops.get_string(target, [k, "name"], ""), d)
        end
      end
    end
    if !Ops.get_boolean(target, [k, "delete"], false) &&
        !Ops.get_boolean(target, [k, "create"], false)
      if Ops.get_symbol(target, [k, "type"], :CT_UNKNOWN) == :CT_LVM &&
          Ops.greater_than(
            Builtins.size(Ops.get_list(target, [k, "devices_add"], [])),
            0
          )
        ls = Ops.get_list(target, [k, "devices_add"], [])
        Builtins.foreach(ls) do |d|
          ExtendLvmVg(Ops.get_string(target, [k, "name"], ""), d)
        end
      end
    end
    dps = Builtins.filter(Ops.get_list(target, [k, "partitions"], [])) do |p|
      !Ops.get_boolean(p, "delete", false) &&
        Ops.get_boolean(p, "create", false)
    end
    if dps.size>1
	  Builtins.y2milestone("SetTargetMap dps:%1",dps)
	  if dps.fetch(0,{}).has_key?("nr")
 dps.sort! { |a, b| a.fetch("nr",0)<=>b.fetch("nr",0) }
	  elsif dps.fetch(0,{}).fetch("type",:none)==:lvm
 dps = dps.partition { |a| a.fetch("pool",false) }
      end
	  Builtins.y2milestone("SetTargetMap dps:%1",dps)
    end
    Builtins.foreach(dps) do |p|
      p_ref = arg_ref(p)
      CreateAny(
        Ops.get_symbol(target, [k, "type"], :CT_UNKNOWN),
        Ops.get(target, k, {}),
        p_ref
      )
      p = p_ref.value
      tdev = Ops.get_string(p, "device", "")
      if Ops.get_symbol(p, "enc_type", :none) != :none &&
          !Builtins.isempty(Ops.get(save_crypt, tdev, "")) &&
          Builtins.isempty(GetCryptPwd(tdev))
        SetCryptPwd(tdev, Ops.get(save_crypt, tdev, ""))
      end
      if Ops.get_symbol(p, "type", :primary) != :extended
        ChangeVolumeProperties(p)
      end
    end
  end
  changed = !EqualBackupStates("tmp_set", "", true)
  Builtins.y2milestone("SetTargetMap changed:%1", changed)
  UpdateChangeTime() if changed
  DisposeTargetBackup("tmp_set")
  Builtins.y2milestone("SetTargetMap ChangeTime %1", GetTargetChangeTime())

  nil
end

- (Object) SetTestsuite(value)



2370
2371
2372
2373
2374
# File '../../src/modules/Storage.rb', line 2370

def SetTestsuite(value)
  @StorageMap = Builtins.add(@StorageMap, @testsuite_key, value)

  nil
end

- (Object) SetVolOptions(p, mnt, fs, fs_opts, fstab_opts, label)



5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
# File '../../src/modules/Storage.rb', line 5014

def SetVolOptions(p, mnt, fs, fs_opts, fstab_opts, label)
  p = deep_copy(p)
  Builtins.y2milestone("SetVolOptions p:%1", p)
  Builtins.y2milestone(
    "SetVolOptions mount:%1 fs:%2 fs_opt:%3 fst_opt:%4 label:%5",
    mnt,
    fs,
    fs_opts,
    fstab_opts,
    label
  )
  ret = deep_copy(p)
  Ops.set(ret, "mount", mnt) if Ops.greater_than(Builtins.size(mnt), 0)
  if fs != nil && fs != :unknown
    Ops.set(ret, "used_fs", fs)
  else
    if mnt == Partitions.BootMount
      Ops.set(ret, "used_fs", Partitions.DefaultBootFs)
    else
      Ops.set(ret, "used_fs", Partitions.DefaultFs)
    end
  end
  if Ops.get_symbol(ret, "used_fs", :unknown) == :unknown ||
      Ops.get_symbol(ret, "used_fs", :unknown) == :none ||
      Ops.get_symbol(ret, "used_fs", :unknown) == :hfs ||
      Ops.get_symbol(ret, "used_fs", :unknown) == :hfsplus
    Ops.set(ret, "format", false)
  else
    Ops.set(ret, "format", true)
  end
  if Ops.get_boolean(ret, "format", false) &&
      !Ops.get_boolean(ret, "create", false) &&
      Ops.get_symbol(ret, "detected_fs", :unknown) != :unknown &&
      mnt == "/home"
    lvm = Ops.get_symbol(p, "type", :primary) == :lvm
    if lvm && Ops.get_string(ret, "name", "") == "home" ||
        !lvm && DetectHomeFs(ret)
      Ops.set(ret, "format", false)
      if Ops.get_symbol(ret, "used_fs", :unknown) !=
          Ops.get_symbol(ret, "detected_fs", :unknown)
        Ops.set(
          ret,
          "used_fs",
          Ops.get_symbol(ret, "detected_fs", :unknown)
        )
        fstab_opts = FileSystems.DefaultFstabOptions(ret)
      end
    end
  end
  if Ops.get_boolean(ret, "format", false) &&
      !Ops.get_boolean(ret, "create", false) &&
      Ops.get_symbol(ret, "detected_fs", :unknown) == :vfat &&
      Ops.get_integer(ret, "fsid", 0) == Partitions.fsid_gpt_boot &&
      mnt == Partitions.BootMount
    Ops.set(ret, "format", false)
  end
  if Ops.get_boolean(ret, "format", false) &&
      !Ops.get_boolean(ret, "create", false) &&
      Ops.get_symbol(ret, "detected_fs", :unknown) == :swap &&
      mnt == "swap"
    Ops.set(ret, "format", false)
    Ops.set(ret, "used_fs", :swap)
  end
  if Ops.get_symbol(ret, "used_fs", :unknown) == :btrfs && mnt == "/"
    ret = AddSubvolRoot(ret)
  end
  if Ops.greater_than(Builtins.size(fstab_opts), 0)
    Ops.set(ret, "fstopt", fstab_opts)
  else
    Ops.set(ret, "fstopt", FileSystems.DefaultFstabOptions(ret))
  end

  if Ops.greater_than(Builtins.size(fs_opts), 0)
    Ops.set(
      ret,
      "fs_options",
      convertStringToFsOptionMap(
        fs_opts,
        Ops.get_symbol(ret, "used_fs", :unknown),
        :mkfs
      )
    )
  else
    Ops.set(ret, "fs_options", FileSystems.DefaultFormatOptions(ret))
  end

  if Ops.greater_than(Builtins.size(label), 0)
    Ops.set(ret, "label", label)
  elsif Ops.greater_than(Builtins.size(Ops.get_string(ret, "label", "")), 0) &&
      Ops.get_boolean(ret, "format", false)
    Ops.set(ret, "label", "")
  end

  Builtins.y2milestone("SetVolOptions ret:%1", ret)
  deep_copy(ret)
end

- (Object) SetWinDevice(value)



2418
2419
2420
2421
2422
# File '../../src/modules/Storage.rb', line 2418

def SetWinDevice(value)
  @StorageMap = Builtins.add(@StorageMap, @win_device_key, value)

  nil
end

- (Object) SetZeroNewPartitions(val)



5430
5431
5432
5433
5434
5435
# File '../../src/modules/Storage.rb', line 5430

def SetZeroNewPartitions(val)
  Builtins.y2milestone("SetZeroNewPartitions val:%1", val)
  @sint.setZeroNewPartitions(val)

  nil
end

- (Object) ShrinkMd(nr, devs)



3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
# File '../../src/modules/Storage.rb', line 3337

def ShrinkMd(nr, devs)
  Builtins.y2milestone("ShrinkMd nr:%1 devs:%2", nr, devs)
  empty = ::Storage::ListString.new()
  devices = StringListFromList(devs);
  rd = MdToDev(nr)
  ret = @sint.shrinkMd(rd, devices, empty)
  Builtins.y2error("ShrinkMd sint ret:%1", ret) if ret<0
  UpdateTargetMap()
  ret == 0
end

- (Object) SLES9PersistentDevNames(input)



6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
# File '../../src/modules/Storage.rb', line 6307

def SLES9PersistentDevNames(input)
  ret = input
  regex1 = "/dev/disk/by-id/.*"
  regex2 = "/dev/disk/by-path/.*"
  prefix = "scsi-"
  tmpdev = ""

  return input if Builtins.regexpmatch(input, ".*-part[0-9]*$")

  if Builtins.regexpmatch(input, ".*/by-id/(scsi|ccw|usb|ata)-.*$")
    return input
  end

  if Builtins.regexpmatch(input, regex1)
    if Builtins.regexpmatch(input, ".*/by-id/0X.{4}p?[0-9]?$")
      prefix = "ccw-"
    end
    tmpdev = Ops.add(
      Ops.add("/dev/disk/by-id/", prefix),
      Builtins.substring(input, Ops.add(Builtins.findlastof(input, "/"), 1))
    )
    Builtins.y2milestone("by id tmp %1", tmpdev)
    ret = tmpdev
  elsif Builtins.regexpmatch(input, regex2)
    tmpdev = input
    Builtins.y2milestone("by path tmp %1", tmpdev)
  end

  if Ops.greater_than(Builtins.size(tmpdev), 0)
    if Builtins.regexpmatch(tmpdev, ".*p[0-9]*$")
      ret = Builtins.regexpsub(tmpdev, "(.*)p([0-9]*)$", "\\1-part\\2")
    else
      ret = Builtins.regexpsub(
        tmpdev,
        "(.*[[:alpha:][:punct:]])([0-9]*)$",
        "\\1-part\\2"
      )
    end
  end
  Builtins.y2milestone(
    "SLES9PersistentDevNames input:%1 ret:%2",
    input,
    ret
  )
  ret
end

- (Object) SpecialBootHandling(tg)



6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
# File '../../src/modules/Storage.rb', line 6136

def SpecialBootHandling(tg)
  tg = deep_copy(tg)
  have_ppc_boot = false
  Builtins.foreach(tg) do |dev, disk|
    dlabel = disk.fetch("label", "")
    disk.fetch("partitions",[]).each do |part|
      if !have_ppc_boot &&
         part.fetch("fsid", 0) == Partitions.FsidBoot(dlabel) &&
         part.fetch("mount","").empty? &&
         part.fetch("create",false)
        have_ppc_boot = true
      end
    end
  end
  Builtins.y2milestone( "SpecialBootHandling: ppc_boot:%1", have_ppc_boot)
  Builtins.foreach(tg) do |dev, disk|
    new_part = []
    dlabel = disk.fetch("label", "")
    disk.fetch("partitions",[]).each do |part|
      # convert a mount point of /boot to a 41 PReP boot partition
      if Partitions.PrepBoot &&
         part.fetch("mount","") == Partitions.BootMount &&
         !have_ppc_boot
        id = Partitions.FsidBoot(dlabel)
        part["format"]=false
        part["mount"]=""
        part["fstype"]=Partitions.FsIdToString(id)
        part["prep_install"]=true
        if !part.fetch("create",false) &&
           part.fetch("fsid",0) != id
          part["ori_fsid"] = part.fetch("fsid",0)
          part["change_fsid"] = true
        end
        part["fsid"] = id
        Builtins.y2milestone( "SpecialBootHandling modified Prep part=%1", part)
      end
      if Arch.board_mac &&
         part.fetch("mount","") == Partitions.BootMount
        id = Partitions.fsid_mac_hfs
        part["mount"] = ""
        part["fstype"] = Partitions.FsIdToString(id)
        part["fsid"] = id
        part["used_fs"] = :hfs
        part["detected_fs"] = :hfs
        Builtins.y2milestone( "SpecialBootHandling modified hfs part=%1", part)
      end
      if Arch.ia64 &&
         part.fetch("mount","") == Partitions.BootMount
        id = Partitions.fsid_gpt_boot
        part["fsid"] = id
        part["fstype"] = Partitions.FsIdToString(id)
        if !part.fetch("create",false) &&
           part.fetch("detected_fs",:none)==:vfat
          part["format"] = false
        end
        Builtins.y2milestone( "SpecialBootHandling modified GPT boot part=%1", part)
      end
      if !Partitions.EfiBoot && (Arch.i386||Arch.x86_64) &&
        dlabel == "gpt" &&
         part.fetch("mount","") == Partitions.BootMount
        id = Partitions.fsid_bios_grub
        part["fsid"] = id
        part["fstype"] = Partitions.FsIdToString(id)
 part["format"] = false
 part["mount"] = ""
        Builtins.y2milestone( "SpecialBootHandling modified BIOS grub part=%1", part)
      end
      new_part.push(part)
    end
    Ops.set(tg, [dev, "partitions"], new_part)
  end
  deep_copy(tg)
end

- (Object) Storage

Storage Constructor



2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
# File '../../src/modules/Storage.rb', line 2426

def Storage
  if Mode.normal
    SetPartMode("CUSTOM")
    SetPartProposalActive(false)
  end
  if Stage.initial
    SetPartMode("CUSTOM")
    SetPartProposalActive(false)
  end

  nil
end

- (Object) StringDequeFromList(devs)



3038
3039
3040
3041
3042
3043
3044
# File '../../src/modules/Storage.rb', line 3038

def StringDequeFromList(devs)
  devd = ::Storage::DequeString.new()
  Builtins.foreach(devs) do |s|
    devd.push(s)
  end
  devd
end

- (Object) StringListFromList(devs)



3281
3282
3283
3284
3285
3286
3287
# File '../../src/modules/Storage.rb', line 3281

def StringListFromList(devs)
  ret = ::Storage::ListString.new()
  Builtins.foreach(devs) do |s|
    ret.push(s)
  end
  ret
end

- (Array) SwappingPartitions

Get List of swap partitions

Returns:

  • (Array)

    List of swap partitions



871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
# File '../../src/modules/Storage.rb', line 871

def SwappingPartitions
  SCR.UnmountAgent(path(".proc.swaps"))
  swaps = Convert.convert(
    SCR.Read(path(".proc.swaps")),
    :from => "any",
    :to   => "list <map>"
  )
  if swaps == nil
    Builtins.y2error("SCR::Read(.proc.swaps) returned nil")
    Builtins.y2milestone(
      "/proc/swaps is %1",
      SCR.Execute(path(".target.bash_output"), "cat /proc/swaps")
    )
    swaps = []
  end
  swaps = Builtins.filter(swaps) do |e|
    Ops.get_string(e, "type", "") == "partition"
  end
  ret = Builtins.maplist(swaps) do |e|
    Partitions.TranslateMapperName(Ops.get_string(e, "file", ""))
  end
  Builtins.y2milestone("SwappingPartitions %1", ret)
  deep_copy(ret)
end

- (Object) SwitchUiAutomounter(on)



6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
# File '../../src/modules/Storage.rb', line 6852

def SwitchUiAutomounter(on)
  Builtins.y2milestone("SwitchUiAutomounter on:%1", on)

  begin

    system_bus = DBus::SystemBus.instance
    service = system_bus.service("org.freedesktop.UDisks")
    dbus_object = service.object("/org/freedesktop/UDisks")
    dbus_object.default_iface = "org.freedesktop.UDisks"
    dbus_object.introspect

    if !on
      @dbus_cookie = dbus_object.Inhibit().first
    else
      dbus_object.Uninhibit(@dbus_cookie)
      @dbus_cookie = nil
    end

  rescue Exception => e
    Builtins.y2error("SwitchUiAutomounter failed %1", e.message)

  end

  nil
end

- (Object) toDiskMap(disk, cinfo)



1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
# File '../../src/modules/Storage.rb', line 1878

def toDiskMap(disk, cinfo)
  disk = deep_copy(disk)
  cinfo = deep_copy(cinfo)
  l = [
    "size_k",
    "cyl_size",
    "cyl_count",
    "sector_size",
    "label",
    "orig_label",
    "name",
    "device",
    "max_logical",
    "max_primary",
    "type",
    "readonly",
    "transport",
    "iscsi",
    "used_by",
    "used_by_type",
    "used_by_device",
    "partitions",
    "dasdfmt",
    "udev_id",
    "udev_path",
    "has_fake_partition",
    "userdata"
  ]
  Builtins.foreach(l) do |s|
    if Builtins.haskey(cinfo, s)
      Ops.set(disk, s, Ops.get(cinfo, s, 0))
    elsif Builtins.haskey(disk, s)
      disk = Builtins.remove(disk, s)
    end
  end
  deep_copy(disk)
end

- (Object) toSymbol(conv, val)



492
493
494
495
496
497
498
499
# File '../../src/modules/Storage.rb', line 492

def toSymbol(conv, val)
  conv = deep_copy(conv)
  Ops.get_symbol(
    conv,
    ["m", val],
    Ops.get_symbol(conv, "def_sym", :invalid_conv_map)
  )
end

- (Object) TranslateDeviceDmraidToMdadm(device, mapping)



6436
6437
6438
6439
6440
6441
6442
6443
6444
# File '../../src/modules/Storage.rb', line 6436

def TranslateDeviceDmraidToMdadm(device, mapping)
  ret = device
  mapping.each do |name, uuid|
    ret = ret.sub("/dev/disk/by-id/raid-" + name, "/dev/disk/by-id/md-uuid-" + uuid)
    ret = ret.sub("/dev/disk/by-id/dm-name-" + name, "/dev/disk/by-id/md-uuid-" + uuid)
    ret = ret.sub("/dev/disk/by-id/dm-uuid-DMRAID-" + name, "/dev/disk/by-id/md-uuid-" + uuid)
  end
  return ret
end

- (Boolean) TryUnaccessSwap(device)

Tries to umount given device if mounted

Parameters:

  • device (String)

    to umount

Returns:

  • (Boolean)

    if successful



5149
5150
5151
5152
5153
5154
# File '../../src/modules/Storage.rb', line 5149

def TryUnaccessSwap(device)
  ret = Builtins.isempty(DeviceMounted(device))
  ret = Umount(device, true) if !ret && Mode.live_installation
  Builtins.y2milestone("TryUnaccessSwap device %1 ret:%2", device, ret)
  ret
end

- (Boolean) Umount(dev, unsetup)

Umounts a device

Parameters:

  • string

    device name

Returns:

  • (Boolean)

    if successful

See Also:

  • #Mount()


4875
4876
4877
4878
4879
# File '../../src/modules/Storage.rb', line 4875

def Umount(dev, unsetup)
  ret = @sint.umountDeviceUns(dev, unsetup)
  Builtins.y2milestone("Umount %1 unsetup %2 ret %3", dev, unsetup, ret)
  ret
end

- (Boolean) UnchangePartitionId(device)

Restores the original partition ID

Parameters:

  • device (String)

    name

Returns:

  • (Boolean)

    if succesful

See Also:

  • #SetPartitionId()


2635
2636
2637
2638
2639
2640
2641
2642
2643
# File '../../src/modules/Storage.rb', line 2635

def UnchangePartitionId(device)
  Builtins.y2milestone("UnchangePartitionId device:%1", device)
  ret = @sint.forgetChangePartitionId(device)
  if ret<0
    Builtins.y2error("UnchangePartitionId sint ret:%1", ret)
  end
  UpdateTargetMapDev(device)
  ret == 0
end

- (Object) UpdateChangeTime



774
775
776
777
778
779
780
# File '../../src/modules/Storage.rb', line 774

def UpdateChangeTime
  change_time = Builtins.time
  Builtins.y2milestone("UpdateChangeTime time %1", change_time)
  Ops.set(@StorageMap, "targets_time", change_time)

  nil
end

- (Object) UpdateLoop(dev, file, create, sizeK)



3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
# File '../../src/modules/Storage.rb', line 3517

def UpdateLoop(dev, file, create, sizeK)
  Builtins.y2milestone(
    "UpdateLoop device:%1 file:%2 create:%3 sizeK:%4",
    dev,
    file,
    create,
    sizeK
  )
  ret = @sint.modifyFileLoop(dev, file, !create, sizeK)
  Builtins.y2error("UpdateLoop sint ret:%1", ret) if ret<0
  UpdateTargetMapDisk("/dev/loop")
  ret == 0
end

- (Object) UpdatePartition(device, start, len)



2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
# File '../../src/modules/Storage.rb', line 2559

def UpdatePartition(device, start, len)
  log.info("UpdatePartition device:#{device} start:#{start} len:#{len}")
  region = ::Storage::RegionInfo.new(start, len)
  ret = @sint.updatePartitionArea(device, region)
  if ret<0
    log.error("UpdatePartition sint ret:#{ret}")
  end
  UpdateTargetMapDev(device)
  ret == 0
end

- (Object) UpdateTargetMap

Updates target map

See Also:

  • #GetTargetMap()


2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
# File '../../src/modules/Storage.rb', line 2000

def UpdateTargetMap
  @conts = getContainers
  rem_keys = []
  tg = Ops.get_map(@StorageMap, @targets_key, {})
  #SCR::Write(.target.ycp, "/tmp/upd_all_bef_"+sformat("%1",count), StorageMap[targets_key]:$[] );
  Builtins.foreach(tg) do |dev, disk|
    c = {}
    c = Builtins.find(@conts) do |c2|
      Ops.get_string(c2, "device", "") == dev
    end
    if c == nil
      rem_keys = Builtins.add(rem_keys, dev)
    elsif IsDiskType(Ops.get_symbol(c, "type", :CT_UNKNOWN))
      Ops.set(tg, dev, toDiskMap(Ops.get(tg, dev, {}), getContainerInfo(c)))
    else
      Ops.set(tg, dev, getContainerInfo(c))
    end
    Builtins.y2milestone(
      "UpdateTargetMap dev:%1 is:%2",
      dev,
      Ops.get(tg, dev, {})
    )
  end
  tg = HandleBtrfsSimpleVolumes(tg)
  if Builtins.haskey(tg, "/dev/btrfs")
    simple = Builtins.filter(
      Ops.get_list(tg, ["/dev/btrfs", "partitions"], [])
    ) do |p|
      Ops.less_or_equal(Builtins.size(Ops.get_list(p, "devices", [])), 1)
    end
    Ops.set(
      tg,
      ["/dev/btrfs", "partitions"],
      Builtins.filter(Ops.get_list(tg, ["/dev/btrfs", "partitions"], [])) do |p|
        Ops.greater_than(Builtins.size(Ops.get_list(p, "devices", [])), 1)
      end
    )
    Builtins.y2milestone("simple %1", simple)
    Builtins.foreach(simple) do |p|
      tg = SetPartitionData(
        tg,
        Ops.get_string(p, "device", ""),
        "subvol",
        Ops.get_list(p, "subvol", [])
      )
      tg = SetPartitionData(
        tg,
        Ops.get_string(p, "device", ""),
        "userdata",
        Ops.get_map(p, "userdata", {})
      )
    end
  end
  Builtins.y2milestone("UpdateTargetMap rem_keys:%1", rem_keys)
  Builtins.foreach(rem_keys) { |dev| tg = Builtins.remove(tg, dev) }
  Builtins.foreach(@conts) do |c|
    if Ops.get_symbol(c, "type", :CT_UNKNOWN) != :CT_DISK &&
        !Builtins.haskey(tg, Ops.get_string(c, "device", ""))
      Ops.set(tg, Ops.get_string(c, "device", ""), getContainerInfo(c))
      Builtins.y2milestone(
        "UpdateTargetMap dev:%1 is:%2",
        Ops.get_string(c, "device", ""),
        Ops.get(tg, Ops.get_string(c, "device", ""), {})
      )
    end
  end
  Ops.set(@StorageMap, @targets_key, tg) 
  #SCR::Write(.target.ycp, "/tmp/upd_all_aft_"+sformat("%1",count), StorageMap[targets_key]:$[] );
  #count = count+1;

  nil
end

- (Object) UpdateTargetMapDev(dev)



2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
# File '../../src/modules/Storage.rb', line 2110

def UpdateTargetMapDev(dev)
  Builtins.y2milestone("UpdateTargetMapDev %1", dev)
  tg = Ops.get_map(@StorageMap, @targets_key, {})
  #SCR::Write(.target.ycp, "/tmp/upd_dev_bef_"+sformat("%1",count), tg );
  cdev = ""
  mdev = GetPartition(tg, dev)
  Builtins.y2milestone("UpdateTargetMapDev mdev %1", mdev)
  btrfs = Ops.get_symbol(mdev, "used_fs", :unknown) == :btrfs
  Builtins.y2milestone("UpdateTargetMapDev btrfs %1", btrfs)
  Builtins.foreach(tg) do |key, d|
    if Builtins.size(cdev) == 0 &&
        Builtins.find(Ops.get_list(d, "partitions", [])) do |p|
          Ops.get_string(p, "device", "") == dev
        end != nil
      cdev = Ops.get_string(d, "device", "")
    end
  end
  Builtins.y2milestone("UpdateTargetMapDev cdev %1", cdev)
  c = {}
  c = Builtins.find(@conts) { |c2| Ops.get_string(c2, "device", "") == cdev }
  disk = {}
  disk = getContainerInfo(c) if c != nil
  if c != nil && Builtins.haskey(tg, cdev)
    partitions = Ops.get_list(tg, [cdev, "partitions"], [])
    found = false
    partitions = Builtins.maplist(partitions) do |p|
      if Ops.get_string(p, "device", "") == dev
        pp = Builtins.find(Ops.get_list(disk, "partitions", [])) do |q|
          Ops.get_string(q, "device", "") == dev
        end
        if pp != nil
          found = true
          p = deep_copy(pp)
          mdev = deep_copy(pp)
        end
      end
      deep_copy(p)
    end
    Ops.set(
      tg,
      [Ops.get_string(disk, "device", ""), "partitions"],
      partitions
    )
    Builtins.y2error("UpdateTargetMapDev not found %1", dev) if !found
  else
    Builtins.y2error(
      "UpdateTargetMapDev key %1 not found in target",
      Ops.get_string(disk, "device", "")
    )
  end
  Builtins.y2milestone("UpdateTargetMapDev mdev %1", mdev)
  btrfs = btrfs || Ops.get_symbol(mdev, "used_fs", :unknown) == :btrfs
  Builtins.y2milestone("UpdateTargetMapDev btrfs %1", btrfs)
  if btrfs
    bt = Ops.get(tg, "/dev/btrfs", {})
    Ops.set(bt, "type", :CT_BTRFS) if Builtins.size(bt) == 0
    Ops.set(tg, "/dev/btrfs", getContainerInfo(bt))
    tg = HandleBtrfsSimpleVolumes(tg)
  end
  Ops.set(@StorageMap, @targets_key, tg) 
  #SCR::Write(.target.ycp, "/tmp/upd_dev_aft_"+sformat("%1",count), StorageMap[targets_key]:$[] );
  #count = count+1;

  nil
end

- (Object) UpdateTargetMapDisk(dev)



2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
# File '../../src/modules/Storage.rb', line 2074

def UpdateTargetMapDisk(dev)
  Builtins.y2milestone("UpdateTargetMapDisk")
  @conts = getContainers
  c = {}
  c = Builtins.find(@conts) { |c2| Ops.get_string(c2, "device", "") == dev }
  tg = Ops.get_map(@StorageMap, @targets_key, {})
  #SCR::Write(.target.ycp, "/tmp/upd_disk_bef_"+sformat("%1",count), StorageMap[targets_key]:$[] );
  if c == nil
    tg = Builtins.remove(tg, dev) if Builtins.haskey(tg, dev)
  elsif IsDiskType(Ops.get_symbol(c, "type", :CT_UNKNOWN))
    Ops.set(tg, dev, toDiskMap(Ops.get(tg, dev, {}), getContainerInfo(c)))
  else
    Ops.set(tg, dev, getContainerInfo(c))
  end
  numbt = Builtins.size(
    Builtins.filter(Ops.get_list(tg, [dev, "partitions"], [])) do |p|
      Ops.get_symbol(p, "used_fs", :unknown) == :btrfs
    end
  )
  Builtins.y2milestone("UpdateTargetMapDisk btrfs:%1", numbt)
  if Ops.greater_than(numbt, 0) && dev != "/dev/btrfs"
    bt = Ops.get(tg, "/dev/btrfs", {})
    Ops.set(bt, "type", :CT_BTRFS) if Builtins.size(bt) == 0
    Ops.set(tg, "/dev/btrfs", getContainerInfo(bt))
  end
  if Ops.greater_than(numbt, 0) || dev == "/dev/btrfs"
    tg = HandleBtrfsSimpleVolumes(tg)
  end
  Ops.set(@StorageMap, @targets_key, tg) 
  #SCR::Write(.target.ycp, "/tmp/upd_disk_aft_"+sformat("%1",count), StorageMap[targets_key]:$[] );
  #count = count+1;

  nil
end

- (Object) volumeMap(vinfo, p)



1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
# File '../../src/modules/Storage.rb', line 1342

def volumeMap(vinfo, p)
  p = deep_copy(p)
  p.merge!(deviceMap(vinfo))
  tmp = vinfo.crypt_device
  Ops.set(p, "crypt_device", tmp) if !Builtins.isempty(tmp)
  Ops.set(p, "size_k", vinfo.sizeK)
  fs = toSymbol(FileSystems.conv_fs, vinfo.fs)
  Ops.set(p, "used_fs", fs) if fs != :unknown
  fs = toSymbol(FileSystems.conv_fs, vinfo.detected_fs)
  Ops.set(p, "detected_fs", fs)
  Ops.set(p, "format", true) if vinfo.format
  Ops.set(p, "create", true) if vinfo.create
  tmp = vinfo.mount
  if !Builtins.isempty(tmp)
    Ops.set(p, "mount", tmp)
    Ops.set(p, "inactive", true) if !vinfo.is_mounted
    Ops.set(p, "mountby", toSymbol(@conv_mountby, vinfo.mount_by))
  end

  tmp = vinfo.fstab_options
  if !Builtins.isempty(tmp)
    Ops.set(p, "fstopt", tmp)
    if Builtins.find(Builtins.splitstring(tmp, ",")) { |s| s == "noauto" } != nil
      Ops.set(p, "noauto", true)
    end
  end
  tmp = vinfo.mkfs_options
  if !Builtins.isempty(tmp)
    Ops.set(p, "mkfs_opt", tmp)
    Ops.set(
      p,
      "fs_options",
      convertStringToFsOptionMap(
        tmp,
        Ops.get_symbol(p, "used_fs", :unknown),
        :mkfs
      )
    )
  else
    p = Builtins.remove(p, "fs_options") if Builtins.haskey(p, "fs_options")
  end
  tmp = vinfo.tunefs_options
  if !Builtins.isempty(tmp)
    Ops.set(p, "tunefs_opt", tmp)
    Ops.set(
      p,
      "fs_options",
      Builtins.union(
        Ops.get_map(p, "fs_options", {}),
        convertStringToFsOptionMap(
          tmp,
          Ops.get_symbol(p, "used_fs", :unknown),
          :tunefs
        )
      )
    )
  end
  tmp = vinfo.dtxt
  Ops.set(p, "dtxt", tmp) if !Builtins.isempty(tmp)
  tmp = vinfo.uuid
  Ops.set(p, "uuid", tmp) if !Builtins.isempty(tmp)
  tmp = vinfo.label
  Ops.set(p, "label", tmp) if !Builtins.isempty(tmp)
  t = vinfo.encryption
  if t != ::Storage::ENC_NONE
    Ops.set(p, "enc_type", toSymbol(@conv_encryption, t))
  end
  tbool = vinfo.resize
  if tbool
    Ops.set(p, "resize", true)
    Ops.set(p, "orig_size_k", vinfo.origSizeK)
  end
  Ops.set(p, "ignore_fs", true) if vinfo.ignore_fs
  Ops.set(p, "ignore_fstab", true) if vinfo.ignore_fstab
  tmp = vinfo.loop
  Ops.set(p, "loop", tmp) if !Builtins.isempty(tmp)

  deep_copy(p)
end