Class: Yast::NfsOptionsClass
- Inherits:
-
Module
- Object
- Module
- Yast::NfsOptionsClass
- Defined in:
- ../../src/modules/NfsOptions.rb
Constant Summary
- NEGATABLE_OPTIONS =
these can be negated by “no”
[ "ac", "acl", "atime", "auto", "bg", "cto", "dev", "diratime", "exec", "fg", "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", "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) from_string(options)
Parse to an internal representation: Simply split by commas, but “defaults” is represented by the empty list.
-
- (Object) get_nfs41(options)
FIXME: factor out get_nfs4(vfstype, options) (depending on n::o)! * @param options fstab option string * @return is version >= 4.1 enabled.
- - (Object) main
- - (Boolean) non_value_option?(option)
-
- (Object) set_nfs41(options, nfs41)
Add or remove minorversion=1 according to nfs41.
-
- (Object) to_string(option_list)
Convert list of individual options to a fstab option string.
-
- (Object) 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) from_string(options)
Parse to an internal representation: Simply split by commas, but "defaults" is represented by the empty list
111 112 113 114 115 |
# File '../../src/modules/NfsOptions.rb', line 111 def from_string() return [] if == "defaults" .split(",") end |
- (Object) get_nfs41(options)
FIXME: factor out get_nfs4(vfstype, options) (depending on n::o)! * @param options fstab option string * @return is version >= 4.1 enabled
173 174 175 176 177 178 |
# File '../../src/modules/NfsOptions.rb', line 173 def get_nfs41() option_list = from_string() _ENABLED = "minorversion=1" Builtins.contains(option_list, _ENABLED) end |
- (Object) main
103 104 105 |
# File '../../src/modules/NfsOptions.rb', line 103 def main textdomain "nfs" end |
- (Boolean) non_value_option?(option)
126 127 128 |
# File '../../src/modules/NfsOptions.rb', line 126 def non_value_option?(option) NEGATABLE_OPTIONS.include?(option) || NEGATED_OPTIONS.include?(option) || SIMPLE_OPTIONS.include?(option) end |
- (Object) 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)
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File '../../src/modules/NfsOptions.rb', line 185 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 |
- (Object) to_string(option_list)
Convert list of individual options to a fstab option string
120 121 122 123 124 |
# File '../../src/modules/NfsOptions.rb', line 120 def to_string(option_list) return "defaults" if option_list.empty? option_list.join(",") end |
- (Object) validate(options)
Checks the nfs options for /etc/fstab: nonempty, comma separated list of foo,nofoo,bar=baz (see nfs(5))
134 135 136 137 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 |
# File '../../src/modules/NfsOptions.rb', line 134 def validate() # To translators: error popup if .empty? return _("Empty option strings are not allowed.") end = "" 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 |