Skip to content

Commit

Permalink
Merge pull request #180 from yast/norecovery_mount
Browse files Browse the repository at this point in the history
Use the "norecovery" mount option (bsc#1195894)
  • Loading branch information
lslezak committed Apr 28, 2022
2 parents d6bd482 + b50908b commit 617d014
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 @@
-------------------------------------------------------------------
Thu Apr 28 08:09:47 UTC 2022 - Ladislav Slezák <lslezak@suse.cz>

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

-------------------------------------------------------------------
Wed Apr 06 13:24:58 UTC 2022 - Ladislav Slezák <lslezak@suse.cz>

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.5.0
Version: 4.5.1
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 @@ -1303,13 +1306,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 @@ -400,4 +400,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 617d014

Please sign in to comment.