Class: Bootloader::UdevMapping
- Inherits:
-
Object
- Object
- Bootloader::UdevMapping
- Extended by:
- Forwardable
- Includes:
- Singleton, Yast::Logger
- Defined in:
- src/lib/bootloader/udev_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/udev_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 44 45 46 47 48 49 50 51 52 53 54 |
# File 'src/lib/bootloader/udev_mapping.rb', line 39 def to_kernel_device(dev) # for non-udev devices try to see specific raid names (bnc#944041) if dev =~ /^\/dev\/disk\/by-/ all_devices[dev] or raise "Unknown udev device #{dev}" else param = Yast::ArgRef.new({}) result = Yast::Storage.GetContVolInfo(dev, param) return dev unless result # not raid with funny name info = param.value return info["vdevice"] unless info["vdevice"].empty? return info["cdevice"] unless info["cdevice"].empty? raise "unknown value for raid device '#{info.inspect}'" end 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
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 |
# File 'src/lib/bootloader/udev_mapping.rb', line 60 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 do |p| [p["device"], p["crypt_device"]].include?(kernel_dev) end 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 udev_pair.first end |