Skip to content

Commit

Permalink
Make code climate happy
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Mar 12, 2018
1 parent 10591b4 commit 71668ba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
15 changes: 12 additions & 3 deletions src/lib/y2partitioner/actions/controllers/filesystem.rb
Expand Up @@ -481,9 +481,7 @@ def apply_mount_point_options(options)

# Special handling for some mount paths ("/", "/boot/*")
opt = options[:mount_options] || []
opt = filesystem.type.special_path_fstab_options(opt, mount_point.path)
opt.push("ro") if read_only?(mount_point.path)
mount_point.mount_options = opt
mount_point.mount_options = add_special_mount_options_for(mount_point.path, opt)
end

def current_value_for(attribute)
Expand Down Expand Up @@ -688,6 +686,17 @@ def read_only?(path)
spec = Y2Storage::VolumeSpecification.for(path)
spec && spec.btrfs_read_only
end

# Adds special mount options for a given path
#
# @param path [String] Mount point path
# @param mount_options [Array<String>] Original set of options
# @return [Array<String>] Mount options including special ones
def add_special_mount_options_for(path, mount_options)
opt = filesystem.type.special_path_fstab_options(mount_options, path)
opt.push("ro") if read_only?(path)
opt
end
end
end
end
Expand Down
13 changes: 10 additions & 3 deletions src/lib/y2storage/planned/can_be_formatted.rb
Expand Up @@ -27,6 +27,7 @@ module Y2Storage
module Planned
# Mixin for planned devices that can have an associated block filesystem.
# @see Planned::Device
# rubocop:disable Metrics/ModuleLength
module CanBeFormatted
# @return [Filesystems::Type] the type of filesystem this device should
# get, like Filesystems::Type::BTRFS or Filesystems::Type::SWAP. A value of
Expand Down Expand Up @@ -186,7 +187,14 @@ def setup_mount_point(filesystem)
# @param mount_point [MountPoint]
def setup_fstab_options(mount_point)
return unless mount_point
options = fstab_options_for(mount_point)
mount_point.mount_options = options unless options.empty?
end

# Returns fstab options for the given mount point
#
# @param mount_point [MountPoint]
def fstab_options_for(mount_point)
options =
if fstab_options
fstab_options
Expand All @@ -195,9 +203,8 @@ def setup_fstab_options(mount_point)
else
[]
end

options.unshift("ro") if read_only # allow 'ro' to be overriden with 'rw'
mount_point.mount_options = options unless options.empty?
options.unshift("ro") if read_only
options
end

# Creates subvolumes in the previously created filesystem that is placed
Expand Down

0 comments on commit 71668ba

Please sign in to comment.