Class: Bootloader::UdevMapping

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton, Yast::I18n, Yast::Logger
Defined in:
src/lib/bootloader/udev_mapping.rb

Overview

Class manages mapping between udev names of disks and partitions.

Instance Method Summary collapse

Instance Method Details

#to_kernel_device(dev) ⇒ String?

Converts full udev name to kernel device ( disk or partition )

Parameters:

  • dev (String)

    device udev, mdadm or kernel name like /dev/disk/by-id/blabla

Returns:

  • (String, nil)

    kernel device or nil when running AutoYaST configuration.

Raises:

  • when device have udev format but do not exists


31
32
33
34
35
36
37
38
# File 'src/lib/bootloader/udev_mapping.rb', line 31

def to_kernel_device(dev)
  textdomain "bootloader"
  log.info "call to_kernel_device for #{dev}"
  raise "invalid device nil" unless dev

  # method udev_to_kernel works also for alternative raid names (bnc#944041)
  udev_to_kernel(dev)
end

#to_mountby_device(dev) ⇒ String

Converts udev or kernel device (disk or partition) to udev name that fits best.

The strategy to discover the best udev name is delegated to storage-ng, see Y2Storage::Filesystems::BlkFilesystem#preferred_name

Parameters:

  • dev (String)

    device udev or kernel one like /dev/disk/by-id/blabla

Returns:

  • (String)

    udev name


47
48
49
50
51
52
53
# File 'src/lib/bootloader/udev_mapping.rb', line 47

def to_mountby_device(dev)
  kernel_dev = to_kernel_device(dev)

  log.info "#{dev} looked as kernel device name: #{kernel_dev}"

  kernel_to_udev(kernel_dev)
end