Skip to content

Commit

Permalink
Merge pull request #212 from ancorgs/crypt_device
Browse files Browse the repository at this point in the history
Fix detection for encrypted partitions (bnc#913540)
  • Loading branch information
ancorgs committed Feb 11, 2015
2 parents b7a7d1b + e6a5776 commit 7e739f2
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 2 deletions.
6 changes: 6 additions & 0 deletions package/yast2-bootloader.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Feb 10 15:24:53 UTC 2015 - ancor@suse.com

- Fixed detection for encrypted partitions (bnc#913540)
- 3.1.101.1

-------------------------------------------------------------------
Tue Oct 7 09:08:07 UTC 2014 - jreidinger@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-bootloader.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-bootloader
Version: 3.1.101
Version: 3.1.101.1
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
4 changes: 3 additions & 1 deletion src/lib/bootloader/device_mapping.rb
Expand Up @@ -59,7 +59,9 @@ def to_mountby_device(dev)
# disk no longer exists
return kernel_dev unless disk

storage_data = disk["partitions"].find { |p| p["device"] == kernel_dev }
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
Expand Down
81 changes: 81 additions & 0 deletions test/data/storage_encrypted.rb
@@ -0,0 +1,81 @@
{
"/dev/sda" => {
"bios_id" => "0x80",
"bus" => "IDE",
"cyl_count" => 2088,
"cyl_size" => 8225280,
"device" => "/dev/sda",
"driver" => "ahci",
"driver_module" => "ahci",
"label" => "msdos",
"max_logical" => 255,
"max_primary" => 4,
"model" => "HARDDISK",
"name" => "sda",
"partitions" => [
{
"crypt_device" => "/dev/mapper/cr_swap",
"detected_fs" => :swap,
"device" => "/dev/sda1",
"enc_type" => :luks,
"fsid" => 130,
"fstopt" => "defaults",
"fstype" => "Linux swap",
"mount" => "swap",
"mountby" => :device,
"name" => "sda1",
"nr" => 1,
"region" => [0, 261],
"size_k" => 2095104,
"type" => :primary,
"used_by_device" => "",
"used_by_type" => :UB_NONE,
"used_fs" => :swap,
"uuid" => "8a0f8519-7a40-4ccd-9b04-378f50c2f3dd",
"udev_id" => [
"ata-VBOX_HARDDISK_VBa974c669-b10eb72d-part1",
"scsi-0ATA_VBOX_HARDDISK_VBa974c669-b10eb72d-part1",
"scsi-1ATA_VBOX_HARDDISK_VBa974c669-b10eb72d-part1",
"scsi-SATA_VBOX_HARDDISK_VBa974c669-b10eb72d-part1"
],
"udev_path" => "pci-0000:00:0d.0-ata-1.0-part1"
},
{
"detected_fs" => :ext4,
"device" => "/dev/sda2",
"fsid" => 131,
"fstopt" => "acl,user_xattr",
"fstype" => "Linux native",
"mkfs_opt" => "-O dir_index -m5.0",
"mount" => "/",
"mountby" => :uuid,
"name" => "sda2",
"nr" => 2,
"region" => [260,1828],
"size_k" => 14681088,
"tunefs_opt" => "-c 0 -i 0",
"type" => :primary,
"used_by_device" => "",
"used_by_type" => :UB_NONE,
"used_fs" => :ext4,
"uuid" => "210f0de4-8d2b-4231-94db-8d7ba94254a9",
"udev_id" => [
"ata-VBOX_HARDDISK_VBa974c669-b10eb72d",
"scsi-0ATA_VBOX_HARDDISK_VBa974c669-b10eb72d",
"scsi-1ATA_VBOX_HARDDISK_VBa974c669-b10eb72d",
"scsi-SATA_VBOX_HARDDISK_VBa974c669-b10eb72d"
],
"udev_path" => "pci-0000:00:0d.0-ata-1.0"
}
],
"proposal_name" => "1. IDE Disk, 16.00 GiB, /dev/sda, VBOX-HARDDISK",
"sector_size" => 512,
"size_k" => 16777216,
"transport" => :sata,
"type" => :CT_DISK,
"unique" => "3OOL.nq7fqYbYIm7",
"used_by_device" => "",
"used_by_type" => :UB_NONE,
"vendor" => "VBOX"
}
}
9 changes: 9 additions & 0 deletions test/device_mapping_test.rb
Expand Up @@ -49,6 +49,9 @@
when "/dev/system/root"
disk = "/dev/system"
number = "system"
when "/dev/mapper/cr_swap"
disk = "/dev/sda"
number = "1"
when "tmpfs"
disk = "tmpfs"
number = ""
Expand Down Expand Up @@ -100,6 +103,12 @@
expect{subject.to_mountby_device("/dev/non-exists")}.to raise_error
expect{subject.to_mountby_device("/dev/disk-by-uuid/ffff-ffff-ffff-ffff")}.to raise_error
end

it "returns kernel device name if device is encrypted" do
target_map_stub("storage_encrypted.rb")

expect(subject.to_mountby_device("/dev/mapper/cr_swap")).to eq "/dev/mapper/cr_swap"
end
end
end

Expand Down

0 comments on commit 7e739f2

Please sign in to comment.