Class: Bootloader::DeviceMapping
- Inherits:
-
Object
- Object
- Bootloader::DeviceMapping
- Extended by:
- Forwardable
- Includes:
- Singleton, Yast::Logger
- Defined in:
- src/lib/bootloader/device_mapping.rb
Overview
Class manages mapping between udev names of disks and partitions.
Constant Summary
Instance Method Summary (collapse)
-
- (Object) to_hash
Returns hash where keys are udev links for disks and partitions and value their kernel devices.
-
- (Object) to_kernel_device(dev)
Converts full udev name to kernel device ( disk or partition ).
-
- (Object) to_mountby_device(dev)
Converts udev or kernel device (disk or partition) to udev name according to mountby option or kernel device if such udev device do not exists.
Instance Method Details
- (Object) to_hash
Returns hash where keys are udev links for disks and partitions and value their kernel devices. TODO remove when remove pbl support
32 33 34 |
# File 'src/lib/bootloader/device_mapping.rb', line 32 def to_hash all_devices end |
- (Object) to_kernel_device(dev)
Converts full udev name to kernel device ( disk or partition )
39 40 41 42 43 |
# File 'src/lib/bootloader/device_mapping.rb', line 39 def to_kernel_device(dev) return dev if dev !~ /^\/dev\/disk\/by-/ all_devices[dev] or raise "Unknown udev device #{dev}" end |
- (Object) to_mountby_device(dev)
Converts udev or kernel device (disk or partition) to udev name according to mountby option or kernel device if such udev device do not exists
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 |
# File 'src/lib/bootloader/device_mapping.rb', line 49 def to_mountby_device(dev) kernel_dev = to_kernel_device(dev) log.info "#{dev} looked as kernel device name: #{kernel_dev}" # we do not know if it is partition or disk, but target map help us target_map = Yast::Storage.GetTargetMap storage_data = target_map[kernel_dev] if !storage_data #so partition disk = target_map[Yast::Storage.GetDiskPartition(kernel_dev)["disk"]] # if device is not disk, then it can be virtual device like tmpfs or # disk no longer exists return kernel_dev unless disk storage_data = disk["partitions"].find { |p| p["device"] == kernel_dev } end raise "Unknown device #{kernel_dev}" unless storage_data mount_by = storage_data["mountby"] mount_by ||= Yast::Arch.ppc ? :id : Yast::Storage.GetDefaultMountBy log.info "mount by: #{mount_by}" # explicit request to mount by kernel device return kernel_dev if mount_by == :device udev_data_key = MOUNT_BY_MAPPING_TO_UDEV[mount_by] raise "Internal error unknown mountby #{mount_by}" unless udev_data_key udev_pair = map_device_to_udev_devices(storage_data[udev_data_key], udev_data_key, kernel_dev).first if !udev_pair log.warn "Cannot find udev link to satisfy mount by for #{kernel_dev}" return kernel_dev end # udev pair contain as first udev device and as second coresponding kernel device return udev_pair.first end |