Class: Yast::NfsOptionsClass
- Inherits:
-
Module
- Object
- Module
- Yast::NfsOptionsClass
- Defined in:
- ../../src/modules/NfsOptions.rb
Overview
Handle NFS mount options
Constant Summary
- NEGATABLE_OPTIONS =
these can be negated by “no”
[ "ac", "acl", "atime", "auto", "bg", "cto", "dev", "diratime", "exec", "fg", "fsc", "group", "hard", "intr", "iversion", "lock", "mand", "owner", "posix", "rdirplus", "relatime", "soft", "strictatime", "suid", "tcp", "udp", "user", "users" ]
- NEGATED_OPTIONS =
NEGATABLE_OPTIONS.map { |o| "no#{o}" }
- SIMPLE_OPTIONS =
these cannot be negated they are not nfs specific BTW
[ "_netdev", "async", "bind", "defaults", "dirsync", "loud", "nofail", "owner", "rbind", "remount", "ro", "rw", "silent", "sync" ]
- OPTIONS_WITH_VALUE =
[ "acdirmax", "acdirmin", "acdirmin", "acregmax", "acregmin", "actimeo", "bsize", "clientaddr", "context", "defcontext", "fscontext", "minorversion", "mounthost", "mountport", "mountprog", "mountvers", "namlen", "nfsprog", "nfsvers", "port", "proto", "retrans", "retry", "rootcontext", "rsize", "sec", "timeo", "vers", "wsize" ]
Instance Method Summary (collapse)
-
- (Array<String>) from_string(options)
Parse to an internal representation: Simply split by commas, but “defaults” is represented by the empty list.
-
- (Boolean) get_nfs41(options)
FIXME: factor out get_nfs4(vfstype, options) (depending on n::o)!.
- - (Object) main
- - (Boolean) non_value_option?(option)
-
- (String) set_nfs41(options, nfs41)
Add or remove minorversion=1 according to nfs41.
-
- (String) to_string(option_list)
Convert list of individual options to a fstab option string.
-
- (String) validate(options)
Checks the nfs options for /etc/fstab: nonempty, comma separated list of foo,nofoo,bar=baz (see nfs(5)).
Instance Method Details
- (Array<String>) from_string(options)
Parse to an internal representation: Simply split by commas, but “defaults” is represented by the empty list
115 116 117 118 119 |
# File '../../src/modules/NfsOptions.rb', line 115 def from_string() return [] if == "defaults" .split(",") end |
- (Boolean) get_nfs41(options)
FIXME: factor out get_nfs4(vfstype, options) (depending on n::o)!
175 176 177 178 179 180 |
# File '../../src/modules/NfsOptions.rb', line 175 def get_nfs41() option_list = from_string() enabled = "minorversion=1" Builtins.contains(option_list, enabled) end |
- (Object) main
107 108 109 |
# File '../../src/modules/NfsOptions.rb', line 107 def main textdomain "nfs" end |
- (Boolean) non_value_option?(option)
130 131 132 |
# File '../../src/modules/NfsOptions.rb', line 130 def non_value_option?(option) NEGATABLE_OPTIONS.include?(option) || NEGATED_OPTIONS.include?(option) || SIMPLE_OPTIONS.include?(option) end |
- (String) set_nfs41(options, nfs41)
Add or remove minorversion=1 according to nfs41. FIXME: vfstype=nfs4 is deprecated in favor of nfsvers=4 (aka vers=4)
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File '../../src/modules/NfsOptions.rb', line 187 def set_nfs41(, nfs41) # don't mutate the string unnecessarily return if get_nfs41() == nfs41 enabled = "minorversion=1" disabled = "minorversion=0" option_list = from_string() option_list = Builtins.filter(option_list) { |opt| opt != enabled } option_list = Builtins.filter(option_list) { |opt| opt != disabled } option_list = Builtins.add(option_list, enabled) if nfs41 to_string(option_list) end |
- (String) to_string(option_list)
Convert list of individual options to a fstab option string
124 125 126 127 128 |
# File '../../src/modules/NfsOptions.rb', line 124 def to_string(option_list) return "defaults" if option_list.empty? option_list.join(",") end |
- (String) validate(options)
Checks the nfs options for /etc/fstab: nonempty, comma separated list of foo,nofoo,bar=baz (see nfs(5))
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File '../../src/modules/NfsOptions.rb', line 138 def validate() # To translators: error popup return _("Empty option strings are not allowed.") if .empty? = "" from_string().each do |opt| key, value, *rest = opt.split("=") # Known options without any expected value if non_value_option?(key) next if value.nil? # To translators: error popup = _("Unexpected value '%{value}' for option '%{key}'") % { :value => value, :key => key } # All unknown options elsif !OPTIONS_WITH_VALUE.include?(key) # To translators: error popup = _("Unknown option: '%{key}'") % { :key => key } # All known ones with badly specified values elsif !rest.empty? # To translators: error popup = _("Invalid option: '%{opt}'") % { :opt => opt } # All options missing a value elsif value.nil? # To translators: error popup = _("Empty value for option: '%{key}'") % { :key => key } end break unless .empty? end end |