Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/SLE-15-SP4' into huha-vol-labe…
Browse files Browse the repository at this point in the history
…l-sp5
  • Loading branch information
shundhammer committed Jun 7, 2023
2 parents 7746bc1 + efa638a commit 0eaf97c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
7 changes: 7 additions & 0 deletions package/yast2-storage-ng.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Jun 7 08:03:52 UTC 2023 - Stefan Hundhammer <shundhammer@suse.com>

- Prevent setting the volume label for a mounted btrfs or swap
(bsc#1211337)
- 4.5.23

-------------------------------------------------------------------
Mon Apr 24 14:47:33 UTC 2023 - Ancor Gonzalez Sosa <ancor@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-storage-ng.spec
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-storage-ng
Version: 4.5.22
Version: 4.5.23
Release: 0
Summary: YaST2 - Storage Configuration
License: GPL-2.0-only OR GPL-3.0-only
Expand Down
8 changes: 8 additions & 0 deletions src/lib/y2partitioner/actions/controllers/filesystem.rb
Expand Up @@ -175,6 +175,14 @@ def mount_path
mount_point.path
end

# Check if the filesystem is currently mounted in the system device graph.
#
# @return [Boolean]
def mounted_in_system_graph?
sys_fs = system_device(filesystem)
sys_fs&.active_mount_point?
end

# Partition id of the block device if it is a partition
#
# @return [Y2Storage::PartitionId, nil] nil if there is no block device or the
Expand Down
22 changes: 22 additions & 0 deletions src/lib/y2partitioner/widgets/fstab_options.rb
Expand Up @@ -263,6 +263,7 @@ def init
self.value = filesystem.label
Yast::UI.ChangeWidget(Id(widget_id), :ValidChars, valid_chars)
Yast::UI.ChangeWidget(Id(widget_id), :InputMaxLength, input_max_length)
disable unless can_set_volume_label?
end

# Validates uniqueness of the given label. The presence of the label is also
Expand All @@ -280,6 +281,27 @@ def validate
# @return [Widgets::FstabOptions]
attr_reader :parent_widget

# Check if the volume label can be set.
#
# @return [Boolean]
def can_set_volume_label?
return true unless @controller.mounted_in_system_graph?

blk_dev = @controller.blk_device_name
fs_type = @controller.filesystem_type
log.info("#{blk_dev} type #{fs_type} is mounted")
# Can't change the volume label for a mounted Btrfs or swap (bsc#1211337)
!btrfs? && !swap?
end

def btrfs?
@controller.filesystem_type.is?(:btrfs)
end

def swap?
@controller.filesystem_type.is?(:swap)
end

# Checks whether a label is given when the filesystem is mounted by label
#
# @note An error popup is presented when the filesystem is mounted by label
Expand Down

0 comments on commit 0eaf97c

Please sign in to comment.