Skip to content

Commit

Permalink
Merge pull request #593 from ancorgs/udev_fallbacks
Browse files Browse the repository at this point in the history
Fix calculation of udev mapping (bsc#1166096)
  • Loading branch information
ancorgs committed Mar 25, 2020
2 parents 1d30f4e + b46a487 commit 0d9e1a5
Show file tree
Hide file tree
Showing 5 changed files with 426 additions and 46 deletions.
7 changes: 7 additions & 0 deletions package/yast2-bootloader.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Mar 25 07:57:13 UTC 2020 - Ancor Gonzalez Sosa <ancor@suse.com>

- Fixed the calculation of the udev name used to reference devices
that are not formatted, like PReP partitions (bsc#1166096).
- 4.2.19

-------------------------------------------------------------------
Tue Mar 24 08:10:33 UTC 2020 - Steffen Winterfeldt <snwint@suse.com>

Expand Down
10 changes: 5 additions & 5 deletions package/yast2-bootloader.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-bootloader
Version: 4.2.18
Version: 4.2.19
Release: 0
Summary: YaST2 - Bootloader Configuration
License: GPL-2.0-or-later
Expand All @@ -29,8 +29,8 @@ Source0: %{name}-%{version}.tar.bz2
BuildRequires: yast2 >= 3.1.176
BuildRequires: yast2-devtools >= 4.2.2
BuildRequires: yast2-ruby-bindings >= 1.0.0
# Y2Storage::Mountable#preferred_mount_by
BuildRequires: yast2-storage-ng >= 4.2.90
# Y2Storage::BlkDevice#preferred_name
BuildRequires: yast2-storage-ng >= 4.2.102
# lenses needed also for tests
BuildRequires: augeas-lenses
BuildRequires: rubygem(%rb_default_ruby_abi:cfa_grub2) >= 1.0.1
Expand All @@ -46,8 +46,8 @@ Requires: yast2 >= 3.1.176
Requires: yast2-core >= 2.18.7
Requires: yast2-packager >= 2.17.24
Requires: yast2-pkg-bindings >= 2.17.25
# Y2Storage::Mountable#preferred_mount_by
Requires: yast2-storage-ng >= 4.2.90
# Y2Storage::BlkDevice#preferred_name
Requires: yast2-storage-ng >= 4.2.102
# Support for multiple values in GRUB_TERMINAL
Requires: rubygem(%rb_default_ruby_abi:cfa_grub2) >= 1.0.1
# lenses are needed as cfa_grub2 depends only on augeas bindings, but also
Expand Down
33 changes: 24 additions & 9 deletions src/lib/bootloader/udev_mapping.rb
Expand Up @@ -91,22 +91,37 @@ def kernel_to_udev(dev)
return dev
end

udev = mount_by_udev(device) || device.name
udev = udev_path(device)
log.info "udev device for #{dev.inspect} is #{udev.inspect}"

udev
end

# @return [String, nil] nil if the udev name cannot be found
def mount_by_udev(device)
# Most convenient udev name of the device
#
# If possible, the udev path is chosen based on the mount_by attribute of
# the filesystem. If the device is not mounted or there is no path for
# the specified mount_by, a preferred (and available) name is calculated.
#
# @param device [Y2Storage::BlkDevice]
# @return [String]
def udev_path(device)
filesystem = device.filesystem
return nil unless filesystem

# If the device is not mounted, a preferred mount by option is calculated.
mount_by = filesystem.mount_by || filesystem.preferred_mount_by
return nil unless mount_by

device.path_for_mount_by(mount_by)
if filesystem
mount_by_name = filesystem.mount_by_name

if mount_by_name
log.info "udev_path: using the udev name of the configured mount_by"
mount_by_name
else
log.info "udev_path: using the preferred udev name for the filesystem"
filesystem.preferred_name
end
else
log.info "udev_path: not formatted, using preferred udev name for the block device"
device.preferred_name
end
end
end
end

0 comments on commit 0d9e1a5

Please sign in to comment.