Skip to content

Commit

Permalink
Add a method to change Btrfs default subvolume
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Nov 3, 2016
1 parent de6cd79 commit 00aa17f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/modules/FileSystems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

module Yast
class FileSystemsClass < Module
SUPPORTED_DEFAULT_SUBVOLUME_NAMES = ["", "@"].freeze

def main

textdomain "storage"
Expand Down Expand Up @@ -2030,14 +2032,37 @@ def AddQuotaOpts(part, fst_opts)
ret
end

# Set the default subvolume name
#
# @param [String] Default subvolume name. Only "" and "@" are supported.
# @return [Boolean] True if subvolume was changed; false otherwise.
def default_subvol=(name)
if SUPPORTED_DEFAULT_SUBVOLUME_NAMES.include?(name)
@default_subvol = name
Storage.default_subvolume_name = name
true
else
log.warn "Unsupported default subvolume name='#{name}'. Ignoring."
false
end
end

# Default subvolume name
#
# @return [String] Default subvolume name.
def default_subvol
@default_subvol
end

publish :variable => :conv_fs, :type => "map <string, any>"
publish :variable => :possible_root_fs, :type => "const list <symbol>"
publish :function => :system_m_points, :type => "list <string> ()"
publish :function => :crypt_m_points, :type => "list <string> ()"
publish :variable => :swap_m_points, :type => "const list <string>"
publish :variable => :tmp_m_points, :type => "const list <string>"
publish :variable => :default_subvol, :type => "string"
publish :variable => :nchars, :type => "string"
publish :function => :default_subvol, :type => "string ()"
publish :function => :default_subvol=, :type => "string (string)"
publish :function => :SuggestMPoints, :type => "list <string> ()"
publish :function => :SuggestTmpfsMPoints, :type => "list <string> ()"
publish :function => :GetGeneralFstabOptions, :type => "list <map <symbol, any>> ()"
Expand Down
5 changes: 5 additions & 0 deletions src/modules/Storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,11 @@ def FinishLibstorage
nil
end

def default_subvolume_name=(name)
return if @sint.nil?
@sint.setDefaultSubvolName(name)
end


def default_subvolume_name()
return @sint.getDefaultSubvolName()
Expand Down

0 comments on commit 00aa17f

Please sign in to comment.