Skip to content

Commit

Permalink
Merge pull request #179 from yast/norecovery_mount_SP3
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Aug 4, 2022
2 parents 4814c0e + c016294 commit 9750991
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
7 changes: 7 additions & 0 deletions package/yast2-update.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Feb 14 17:20:32 UTC 2022 - Ladislav Slezák <lslezak@suse.cz>

- Use the "norecovery" mount option when searching the root
partitions (bsc#1195894)
- 4.3.4

-------------------------------------------------------------------
Fri Jul 23 08:56:04 UTC 2021 - José Iván López González <jlopez@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-update.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-update
Version: 4.3.3
Version: 4.3.4
Release: 0
Summary: YaST2 - Update
Group: System/YaST
Expand Down
10 changes: 8 additions & 2 deletions src/modules/RootPart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class RootPartClass < Module
include Logger
NON_MODULAR_FS = ["devtmpfs", "none", "proc", "sysfs"].freeze

# filesystems which support the "norecovery" mount options
NORECOVERY_FS = [:btrfs, :ext3, :ext4, :xfs].freeze

def main
Yast.import "UI"

Expand Down Expand Up @@ -1526,13 +1529,16 @@ def CheckPartition(filesystem)
SCR.Execute(path(".target.modprobe"), mount_type, "")
end

mount_options = ["ro"]
mount_options << "norecovery" if NORECOVERY_FS.include?(freshman[:fs])

# mount (read-only) partition to Installation::destdir
log.debug("Mounting #{[p_dev, Installation.destdir, Installation.mountlog].inspect}")
log.info "Mounting #{p_dev} with options #{mount_options}"
mount =
SCR.Execute(
path(".target.mount"),
[p_dev, Installation.destdir, Installation.mountlog],
"-o ro"
"-o #{mount_options.join(",")}"
)

if Convert.to_boolean(mount)
Expand Down
31 changes: 31 additions & 0 deletions test/root_part_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,35 @@
end
end
end

describe "#CheckPartition" do
before do
stub_storage(scenario)
allow(Yast::SCR).to receive(:Execute)
end

let(:scenario) { "two-disks-two-btrfs.xml" }

it "uses 'norecovery' mount option for Btrfs" do
# return failure to avoid scanning for /etc/fstab
expect(Yast::SCR).to receive(:Execute)
.with(Yast.path(".target.mount"), Array, "-o ro,norecovery")
.and_return(false)

fs = Y2Storage::StorageManager.instance.probed.blk_filesystems.first
subject.CheckPartition(fs)
end

it "does not use 'norecovery` mount option for Ext2" do
# return failure to avoid scanning for /etc/fstab
expect(Yast::SCR).to receive(:Execute)
.with(Yast.path(".target.mount"), Array, "-o ro")
.and_return(false)

fs = Y2Storage::StorageManager.instance.probed.blk_filesystems.first
allow(fs).to receive(:type).and_return(Y2Storage::Filesystems::Type::EXT2)

subject.CheckPartition(fs)
end
end
end

0 comments on commit 9750991

Please sign in to comment.