Class: Mount::Context
- Inherits:
-
Object
- Object
- Mount::Context
- Defined in:
- lib/rbmount/context.rb
Instance Method Summary collapse
- #append_options(optstr) ⇒ Object
- #apply_fstab ⇒ Object
- #cache ⇒ Object
- #cache=(cache) ⇒ Object
- #canonicalize=(ok) ⇒ Object
- #do_mount ⇒ Object
- #do_umount ⇒ Object
- #each_mount ⇒ Object
- #fake=(ok) ⇒ Object
- #fake? ⇒ Boolean
- #finalize ⇒ Object
- #finalize_mount ⇒ Object
- #finalize_umount ⇒ Object
- #force=(ok) ⇒ Object
- #force? ⇒ Boolean
- #fs ⇒ Object
- #fs=(fs) ⇒ Object
- #fs_mounted?(fs) ⇒ Boolean
- #fstab ⇒ Object
- #fstab=(tb) ⇒ Object
- #fstype ⇒ Object
- #fstype=(fstype) ⇒ Object
- #fstype_pattern=(pattern) ⇒ Object
- #helper_setopt(c, arg) ⇒ Object
- #helpers=(ok) ⇒ Object
- #init_helper(action, flags = 0) ⇒ Object
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #lazy=(ok) ⇒ Object
- #lazy? ⇒ Boolean
- #lock ⇒ Object
- #loopdel=(ok) ⇒ Object
- #mflags ⇒ Object
- #mflags=(flags) ⇒ Object
- #mount ⇒ Object
- #mountdata=(data) ⇒ Object
- #mtab ⇒ Object
- #mtab=(ok) ⇒ Object
- #mtab? ⇒ Boolean
- #next_mount(direction = :forward) ⇒ Object
- #on_error(&blk) ⇒ Object
- #options=(optstr) ⇒ Object
- #options_pattern=(pattern) ⇒ Object
- #optsmode ⇒ Object
- #optsmode=(mode) ⇒ Object
- #prepare_mount ⇒ Object
- #prepare_umount ⇒ Object
- #rdonly_umount=(ok) ⇒ Object
- #rdonly_umount? ⇒ Boolean
- #reset! ⇒ Object
- #restricted? ⇒ Boolean
- #sloppy=(ok) ⇒ Object
- #sloppy? ⇒ Boolean
- #source ⇒ Object
- #source=(src) ⇒ Object
- #status ⇒ Object
- #strerror ⇒ Object
- #syscall_status=(status) ⇒ Object
- #table(filename) ⇒ Object
- #target ⇒ Object
- #target=(target) ⇒ Object
- #umount ⇒ Object
- #user_mflags(flags) ⇒ Object
- #verbose=(ok) ⇒ Object
- #verbose? ⇒ Boolean
Constructor Details
Instance Method Details
#append_options(optstr) ⇒ Object
44 45 46 |
# File 'lib/rbmount/context.rb', line 44 def (optstr) Mount::C.(@pointer, optstr) end |
#apply_fstab ⇒ Object
48 49 50 |
# File 'lib/rbmount/context.rb', line 48 def apply_fstab Mount::C.mnt_context_apply_fstab(@pointer) end |
#cache ⇒ Object
92 93 94 |
# File 'lib/rbmount/context.rb', line 92 def cache Mount::Cache.new(Mount::C.mnt_context_get_cache(@pointer)) end |
#cache=(cache) ⇒ Object
215 216 217 |
# File 'lib/rbmount/context.rb', line 215 def cache= (cache) Mount::C.mnt_context_set_cache(@pointer, cache.to_c) end |
#canonicalize=(ok) ⇒ Object
52 53 54 |
# File 'lib/rbmount/context.rb', line 52 def canonicalize= (ok) Mount::C.mnt_context_disable_canonicalize(@pointer, !ok) end |
#do_mount ⇒ Object
284 285 286 |
# File 'lib/rbmount/context.rb', line 284 def do_mount Mount::C.mnt_context_do_mount(@pointer) end |
#do_umount ⇒ Object
327 328 329 |
# File 'lib/rbmount/context.rb', line 327 def do_umount Mount::C.mnt_context_do_umount(@pointer) end |
#each_mount ⇒ Object
311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/rbmount/context.rb', line 311 def each_mount Enumerator.new {|y| loop { res = next_mount break unless res y << res }.each {|args| yield *args if block_given? } } end |
#fake=(ok) ⇒ Object
64 65 66 |
# File 'lib/rbmount/context.rb', line 64 def fake= (ok) Mount::C.mnt_context_enable_fake(@pointer, !!ok) end |
#fake? ⇒ Boolean
176 177 178 |
# File 'lib/rbmount/context.rb', line 176 def fake? Mount::C.mnt_context_is_fake(@pointer) end |
#finalize ⇒ Object
28 29 30 |
# File 'lib/rbmount/context.rb', line 28 def finalize Mount::C.mnt_free_context(@pointer) end |
#finalize_mount ⇒ Object
288 289 290 |
# File 'lib/rbmount/context.rb', line 288 def finalize_mount Mount::C.mnt_context_finalize_mount(@pointer) end |
#finalize_umount ⇒ Object
331 332 333 |
# File 'lib/rbmount/context.rb', line 331 def finalize_umount Mount::C.mnt_context_finalize_umount(@pointer) end |
#force=(ok) ⇒ Object
68 69 70 |
# File 'lib/rbmount/context.rb', line 68 def force= (ok) Mount::C.mnt_context_enable_force(@pointer, !!ok) end |
#force? ⇒ Boolean
180 181 182 |
# File 'lib/rbmount/context.rb', line 180 def force? Mount::C.mnt_context_is_force(@pointer) end |
#fs ⇒ Object
96 97 98 |
# File 'lib/rbmount/context.rb', line 96 def fs Mount::FS.new(Mount::C.mnt_context_get_fs(@pointer)) end |
#fs=(fs) ⇒ Object
219 220 221 |
# File 'lib/rbmount/context.rb', line 219 def fs= (fs) Mount::C.mnt_context_set_fs(@pointer, fs.to_c) end |
#fs_mounted?(fs) ⇒ Boolean
184 185 186 187 188 189 |
# File 'lib/rbmount/context.rb', line 184 def fs_mounted? (fs) ptr = FFI::MemoryPointer.new(:int) Mount::C.mnt_context_is_fs_mounted(@pointer, fs.to_c, ptr) !ptr.read_int.zero? end |
#fstab ⇒ Object
100 101 102 103 104 105 |
# File 'lib/rbmount/context.rb', line 100 def fstab Mount::Table.new.tap {|tab| ptr = FFI::MemoryPointer.new(:pointer).write_pointer(tab.to_c) raise unless Mount::C.mnt_context_get_fstab(@pointer, ptr) } end |
#fstab=(tb) ⇒ Object
223 224 225 |
# File 'lib/rbmount/context.rb', line 223 def fstab= (tb) Mount::C.mnt_context_set_fstab(@pointer, tb.to_c) end |
#fstype ⇒ Object
107 108 109 |
# File 'lib/rbmount/context.rb', line 107 def fstype Mount::C.mnt_context_get_fstype(@pointer) end |
#fstype=(fstype) ⇒ Object
227 228 229 |
# File 'lib/rbmount/context.rb', line 227 def fstype= (fstype) Mount::C.mnt_context_set_fstype(@pointer, fstype) end |
#fstype_pattern=(pattern) ⇒ Object
231 232 233 |
# File 'lib/rbmount/context.rb', line 231 def fstype_pattern= (pattern) Mount::C.mnt_context_set_fstype_pattern(@pointer, pattern) end |
#helper_setopt(c, arg) ⇒ Object
168 169 170 |
# File 'lib/rbmount/context.rb', line 168 def helper_setopt (c, arg) Mount::C.mnt_context_helper_setopt(@pointer, c, arg) end |
#helpers=(ok) ⇒ Object
56 57 58 |
# File 'lib/rbmount/context.rb', line 56 def helpers= (ok) Mount::C.mnt_context_disable_helpers(@pointer, !ok) end |
#init_helper(action, flags = 0) ⇒ Object
172 173 174 |
# File 'lib/rbmount/context.rb', line 172 def init_helper (action, flags=0) Mount::C.mnt_context_init_helper(@pointer, action, flags) end |
#lazy=(ok) ⇒ Object
72 73 74 |
# File 'lib/rbmount/context.rb', line 72 def lazy= (ok) Mount::C.mnt_context_enable_lazy(@pointer, !!ok) end |
#lazy? ⇒ Boolean
191 192 193 |
# File 'lib/rbmount/context.rb', line 191 def lazy? Mount::C.mnt_context_is_lazy(@pointer) end |
#lock ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/rbmount/context.rb', line 111 def lock lk = Mount::C.mnt_context_get_lock(@pointer) raise if lk.null? Mount::Lock.allocate.tap {|lck| lck.instance_eval { @pointer = lk ObjectSpace.define_finalizer(self, self.method(:finalize)) } } end |
#loopdel=(ok) ⇒ Object
76 77 78 |
# File 'lib/rbmount/context.rb', line 76 def loopdel= (ok) Mount::C.mnt_context_enable_loopdel(@pointer, !!ok) end |
#mflags ⇒ Object
124 125 126 127 128 129 |
# File 'lib/rbmount/context.rb', line 124 def mflags ptr = FFI::MemoryPointer.new(:ulong) raise unless Mount::C.mnt_context_get_mflags(@pointer, ptr) ptr.read_ulong end |
#mflags=(flags) ⇒ Object
235 236 237 |
# File 'lib/rbmount/context.rb', line 235 def mflags= (flags) Mount::C.mnt_context_set_mflags(@pointer, flags) end |
#mount ⇒ Object
292 293 294 |
# File 'lib/rbmount/context.rb', line 292 def mount Mount::C.mnt_context_mount(@pointer) end |
#mountdata=(data) ⇒ Object
239 240 241 |
# File 'lib/rbmount/context.rb', line 239 def mountdata= (data) Mount::C.mnt_context_set_mountdata(@pointer, data) end |
#mtab ⇒ Object
131 132 133 134 135 136 |
# File 'lib/rbmount/context.rb', line 131 def mtab Mount::Table.new.tap {|tab| ptr = FFI::MemoryPointer.new(:pointer).write_pointer(tab.to_c) raise unless Mount::C.mnt_context_get_mtab(@pointer, ptr) } end |
#mtab=(ok) ⇒ Object
60 61 62 |
# File 'lib/rbmount/context.rb', line 60 def mtab= (ok) Mount::C.mnt_context_disable_mtab(@pointer, !ok) end |
#mtab? ⇒ Boolean
195 196 197 |
# File 'lib/rbmount/context.rb', line 195 def mtab? !Mount::C.mnt_context_is_nomtab(@pointer) end |
#next_mount(direction = :forward) ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/rbmount/context.rb', line 296 def next_mount (direction=:forward) fs = Mount::FS.new fsptr = FFI::MemoryPointer.new(:pointer).write_pointer(fs.to_c) rcptr = FFI::MemoryPointer.new(:int) iptr = FFI::MemoryPointer.new(:int) res = Mount::C.mnt_context_next_mount(@pointer, Mount::Iterator.new(Mount::Table::DIRECTION[direction]).to_c, fsptr, rcptr, iptr) return nil if res == 1 raise unless res [fs, rcptr.read_int, iptr.read_int] end |
#on_error(&blk) ⇒ Object
263 264 265 266 267 268 269 270 |
# File 'lib/rbmount/context.rb', line 263 def on_error (&blk) if blk.arity == 3 Mount::C.mnt_context_set_tables_errcb(@pointer, blk) true else false end end |
#options=(optstr) ⇒ Object
243 244 245 |
# File 'lib/rbmount/context.rb', line 243 def (optstr) Mount::C.(@pointer, optstr) end |
#options_pattern=(pattern) ⇒ Object
247 248 249 |
# File 'lib/rbmount/context.rb', line 247 def (pattern) Mount::C.(@pointer, pattern) end |
#optsmode ⇒ Object
138 139 140 |
# File 'lib/rbmount/context.rb', line 138 def optsmode Mount::C.mnt_context_get_optsmode(@pointer) end |
#optsmode=(mode) ⇒ Object
251 252 253 |
# File 'lib/rbmount/context.rb', line 251 def optsmode= (mode) Mount::C.mnt_context_set_optsmode(@pointer, mode) end |
#prepare_mount ⇒ Object
323 324 325 |
# File 'lib/rbmount/context.rb', line 323 def prepare_mount Mount::C.mnt_context_prepare_mount(@pointer) end |
#prepare_umount ⇒ Object
335 336 337 |
# File 'lib/rbmount/context.rb', line 335 def prepare_umount Mount::C.mnt_context_prepare_umount(@pointer) end |
#rdonly_umount=(ok) ⇒ Object
80 81 82 |
# File 'lib/rbmount/context.rb', line 80 def rdonly_umount= (ok) Mount::C.mnt_context_enable_rdonly_umount(@pointer, !!ok) end |
#rdonly_umount? ⇒ Boolean
199 200 201 |
# File 'lib/rbmount/context.rb', line 199 def rdonly_umount? Mount::C.mnt_context_is_rdonly_umount(@pointer) end |
#reset! ⇒ Object
39 40 41 42 |
# File 'lib/rbmount/context.rb', line 39 def reset! return false unless Mount::C.mnt_reset_context(@pointer) self end |
#restricted? ⇒ Boolean
203 204 205 |
# File 'lib/rbmount/context.rb', line 203 def restricted? Mount::C.mnt_context_is_restricted(@pointer) end |
#sloppy=(ok) ⇒ Object
84 85 86 |
# File 'lib/rbmount/context.rb', line 84 def sloppy= (ok) Mount::C.mnt_context_enable_sloppy(@pointer, !!ok) end |
#sloppy? ⇒ Boolean
207 208 209 |
# File 'lib/rbmount/context.rb', line 207 def sloppy? Mount::C.mnt_context_is_sloppy(@pointer) end |
#source ⇒ Object
142 143 144 |
# File 'lib/rbmount/context.rb', line 142 def source Mount::C.mnt_context_get_source(@pointer) end |
#source=(src) ⇒ Object
255 256 257 |
# File 'lib/rbmount/context.rb', line 255 def source= (src) Mount::C.mnt_context_set_source(@pointer, src) end |
#status ⇒ Object
146 147 148 |
# File 'lib/rbmount/context.rb', line 146 def status Mount::C.mnt_context_get_status(@pointer) end |
#strerror ⇒ Object
280 281 282 |
# File 'lib/rbmount/context.rb', line 280 def strerror '' end |
#syscall_status=(status) ⇒ Object
259 260 261 |
# File 'lib/rbmount/context.rb', line 259 def syscall_status= (status) Mount::C.mnt_context_set_syscall_status(@pointer, status) end |
#table(filename) ⇒ Object
150 151 152 153 154 155 |
# File 'lib/rbmount/context.rb', line 150 def table (filename) Mount::Table.new.tap {|tab| ptr = FFI::MemoryPointer.new(:pointer).write_pointer(tab.to_c) raise unless Mount::C.mnt_context_get_table(@pointer, filename, ptr) } end |
#target ⇒ Object
157 158 159 |
# File 'lib/rbmount/context.rb', line 157 def target Mount::C.mnt_context_get_target(@pointer) end |
#target=(target) ⇒ Object
272 273 274 |
# File 'lib/rbmount/context.rb', line 272 def target= (target) Mount::C.mnt_context_set_target(@pointer, target) end |
#umount ⇒ Object
339 340 341 |
# File 'lib/rbmount/context.rb', line 339 def umount Mount::C.mnt_context_umount(@pointer) end |
#user_mflags(flags) ⇒ Object
161 162 163 164 165 166 |
# File 'lib/rbmount/context.rb', line 161 def user_mflags ptr = FFI::MemoryPointer.new(:ulong) raise unless Mount::C.mnt_context_get_user_mflags(@pointer, ptr) ptr.read_ulong end |