Skip to content

Commit

Permalink
FileSystems is responsible for setting default_subvol
Browse files Browse the repository at this point in the history
* The responsability was somehow shared between Storage and FileSystems.
  • Loading branch information
imobachgs committed Nov 3, 2016
1 parent 130d95b commit f1b7098
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/modules/FileSystems.rb
Expand Up @@ -84,7 +84,8 @@ def main
@possible_root_fs = [:ext2, :ext3, :ext4, :btrfs, :reiser, :xfs]
@swap_m_points = ["swap"]
@tmp_m_points = ["/tmp", "/var/tmp"]
@default_subvol = "UNDEFINED"
self.default_subvol = ProductFeatures.GetStringFeature("partitioning", "btrfs_default_subvolume")


@suggest_m_points = []
@suggest_tmp_points = []
Expand Down Expand Up @@ -1449,7 +1450,7 @@ def FileSystems
def InitSlib(value)
@sint = value
if @sint != nil
@default_subvol = @sint.getDefaultSubvolName()
@sint.setDefaultSubvolName(@default_subvol)
Builtins.y2milestone(
"InitSlib used default_subvol:\"%1\"",
@default_subvol
Expand Down Expand Up @@ -2045,10 +2046,9 @@ def AddQuotaOpts(part, fst_opts)
# @param [String] Default subvolume name. Only "" and "@" are supported.
# @return [Boolean] True if subvolume was changed; false otherwise.
def default_subvol=(name)
return if @sint.nil?
if SUPPORTED_DEFAULT_SUBVOLUME_NAMES.include?(name)
@default_subvol = name
@sint.setDefaultSubvolName(name)
@sint.setDefaultSubvolName(name) unless @sint.nil?
true
else
log.warn "Unsupported default subvolume name='#{name}'. Ignoring."
Expand Down
6 changes: 1 addition & 5 deletions src/modules/Storage.rb
Expand Up @@ -339,10 +339,6 @@ def InitLibstorage(readonly)

StorageClients.InstallCallbacks(@sint)

btrfs_default_subvolume = ProductFeatures.GetStringFeature("partitioning",
"btrfs_default_subvolume")
@sint.setDefaultSubvolName(btrfs_default_subvolume) if btrfs_default_subvolume

if Stage.initial
@sint.setDetectMountedVolumes(false)
@sint.setRootPrefix(Installation.destdir)
Expand Down Expand Up @@ -375,7 +371,7 @@ def FinishLibstorage


def default_subvolume_name()
return @sint.getDefaultSubvolName()
FileSystems.default_subvol
end


Expand Down
13 changes: 11 additions & 2 deletions test/storage_test.rb
Expand Up @@ -8,14 +8,23 @@
Yast.import "StorageInit"

describe "Yast::Storage" do
subject { Yast::Storage }

before do
Yast::Storage.InitLibstorage(false)
subject.InitLibstorage(false)
end

describe "#SetUserdata" do
it "sets given user data for a given device" do
# non-zero error for device that does not exist
expect(Yast::Storage.SetUserdata("/dev/ice/does/not/exist", { "/" => "snapshots" })).not_to eq(0)
expect(subject.SetUserdata("/dev/ice/does/not/exist", { "/" => "snapshots" })).not_to eq(0)
end
end

describe "#default_subvolume_name" do
it "returns the default subvolume name according to FileSystems" do
expect(Yast::FileSystems).to receive(:default_subvol).and_return("SOME-VALUE")
expect(subject.default_subvolume_name).to eq("SOME-VALUE")
end
end
end

0 comments on commit f1b7098

Please sign in to comment.