rfusefs 1.0.2.RC2 → 1.1.1.rc20201114.37

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  module FuseFS
2
2
 
3
3
  # A full in-memory filesystem defined with hashes. It is writable to the
4
- # user that mounted it
4
+ # user that mounted it
5
5
  # may create and edit files within it, as well as the programmer
6
6
  # === Usage
7
7
  # root = Metadir.new()
@@ -14,10 +14,10 @@ module FuseFS
14
14
  # Because Metadir is fully recursive, you can mount your own or other defined
15
15
  # directory structures under it. For example, to mount a dictionary filesystem
16
16
  # (see samples/dictfs.rb), use:
17
- #
17
+ #
18
18
  # root.mkdir("/dict",DictFS.new())
19
- #
20
- class MetaDir
19
+ #
20
+ class MetaDir
21
21
 
22
22
  DEFAULT_FS = FuseDir.new()
23
23
 
@@ -66,7 +66,7 @@ module FuseFS
66
66
  # Extended attributes
67
67
  def xattr(path)
68
68
  pathmethod(:xattr,path) do | path |
69
- @xattr[path]
69
+ @xattr[path]
70
70
  end
71
71
  end
72
72
 
@@ -1,13 +1,19 @@
1
- require 'ffi-xattr'
2
1
 
3
2
  module FuseFS
3
+ begin
4
+ require 'ffi-xattr'
5
+ HAS_FFI_XATTR = true
6
+ rescue LoadError
7
+ warn "ffi-xattr not available, extended attributes will not be mapped"
8
+ HAS_FFI_XATTR = false
9
+ end
4
10
 
5
11
  # A FuseFS that maps files from their original location into a new path
6
12
  # eg tagged audio files can be mapped by title etc...
7
13
  #
8
14
  class PathMapperFS < FuseDir
9
15
 
10
- # Represents a mappted file or directory
16
+ # Represents a mapped file or directory
11
17
  class MNode
12
18
 
13
19
  # Merge extended attributes with the ones from the underlying file
@@ -17,7 +23,7 @@ module FuseFS
17
23
 
18
24
  def initialize(node)
19
25
  @node = node
20
- @file_xattr = ::Xattr.new(node.real_path.to_s) if node.file?
26
+ @file_xattr = ::Xattr.new(node.real_path.to_s) if node.file? && HAS_FFI_XATTR
21
27
  end
22
28
 
23
29
  def [](key)
@@ -26,12 +32,12 @@ module FuseFS
26
32
 
27
33
  def []=(key,value)
28
34
  raise Errno::EACCES if additional.has_key?(key) || node.directory?
29
- file_xattr[key] = value
35
+ file_xattr[key] = value if file_xattr
30
36
  end
31
37
 
32
38
  def delete(key)
33
39
  raise Errno::EACCES if additional.has_key?(key) || node.directory?
34
- file_xattr.remove(key)
40
+ file_xattr.remove(key) if file_xattr
35
41
  end
36
42
 
37
43
  def keys
@@ -106,10 +112,10 @@ module FuseFS
106
112
  end
107
113
 
108
114
  # Compatibility and convenience method
109
- # @param [:pm_real_path,String,Symbol] key
110
- # @return [String] {#real_path} if key == :pm_real_path
115
+ # @param [:pm_real_path,String,Symbol] key
116
+ # @return [String] {#real_path} if key == :pm_real_path
111
117
  # @return [MNode] the node representing the file named key
112
- # @return [Object] shortcut for {#options}[key]
118
+ # @return [Object] shortcut for {#options}[key]
113
119
  def[](key)
114
120
  case key
115
121
  when :pm_real_path
@@ -173,12 +179,12 @@ module FuseFS
173
179
  #
174
180
  # @return [StatsHelper] accumulated filesystem statistics
175
181
  attr_reader :stats
176
-
182
+
177
183
  # Creates a new Path Mapper filesystem over an existing directory
178
184
  # @param [String] dir
179
185
  # @param [Hash] options
180
186
  # @yieldparam [String] file path to map
181
- # @yieldreturn [String]
187
+ # @yieldreturn [String]
182
188
  # @see #initialize
183
189
  # @see #map_directory
184
190
  def PathMapperFS.create(dir,options={ },&block)
@@ -201,7 +207,7 @@ module FuseFS
201
207
  @use_raw_file_access = options[:use_raw_file_access]
202
208
  @allow_write = options[:allow_write]
203
209
  end
204
-
210
+
205
211
  # Recursively find all files and map according to the given block
206
212
  # @param [String...] dirs directories to list
207
213
  # @yieldparam [String] file path to map
@@ -250,17 +256,17 @@ module FuseFS
250
256
  node = node(path)
251
257
  (node && node.file?) ? node.real_path : nil
252
258
  end
253
-
259
+
254
260
  # Deletes files and directories.
255
261
  # Yields each {#node} in the filesystem and deletes it if the block returns true
256
262
  #
257
263
  # Useful if your filesystem is periodically remapping the entire contents and you need
258
264
  # to delete entries that have not been touched in the latest scan
259
265
  #
260
- # @yieldparam [Hash] filesystem node
266
+ # @yieldparam [Hash] filesystem node
261
267
  # @yieldreturn [true,false] should this node be deleted
262
268
  def cleanup(&block)
263
- recursive_cleanup(@root,&block)
269
+ recursive_cleanup(@root,&block)
264
270
  end
265
271
 
266
272
 
@@ -373,7 +379,7 @@ module FuseFS
373
379
  file.sysseek(offset)
374
380
  file.syswrite(buf[0,sz])
375
381
  end
376
-
382
+
377
383
  # @!visibility private
378
384
  def raw_sync(path,datasync,file=nil)
379
385
  file = @openfiles[path] unless file
@@ -387,7 +393,7 @@ module FuseFS
387
393
  # @!visibility private
388
394
  def raw_close(path,file=nil)
389
395
  file = @openfiles.delete(path) unless file
390
-
396
+
391
397
  if file && !file.closed?
392
398
  begin
393
399
  flags = file.fcntl(Fcntl::F_GETFL) & Fcntl::O_ACCMODE
@@ -15,7 +15,7 @@ module FuseFS
15
15
  # Maintains a count of the number of times through the scan loop
16
16
  attr_reader :scan_id
17
17
 
18
- #
18
+ #
19
19
  #
20
20
  # @param [String] db_path Path to Sqlite database
21
21
  # @param [String] sql query
@@ -55,7 +55,7 @@ module FuseFS
55
55
  end
56
56
 
57
57
  # FuseFS callback when filesystem is unmounted
58
- #
58
+ #
59
59
  # Stops the database watching threads
60
60
  # @api FuseFS
61
61
  def unmounted()
@@ -88,6 +88,11 @@ module FuseFS
88
88
  cleanup() { |file_node| file_node.options[:sqlite_scan_id] != @scan_id }
89
89
  end
90
90
 
91
+ # Rescan on HUP signal
92
+ def sighup
93
+ rescan()
94
+ end
95
+
91
96
  private
92
97
 
93
98
  def scan_loop()
@@ -45,28 +45,14 @@ module FuseFS
45
45
  # end
46
46
  #
47
47
  def FuseFS.main(argv=ARGV,options=[],option_usage="",device=nil,exec=File.basename($0))
48
- options = RFuse.parse_options(argv,*options)
49
-
50
- if options[:mountpoint]
51
- begin
52
- fs = yield options
53
- rescue StandardError => ex
54
- puts ex.message
55
- puts ex.backtrace.join("\n")
56
- end
57
-
58
- puts RFuse.usage(device,exec) if options[:help] || !fs
59
- puts "Options:\n" if options[:help]
60
-
61
- FuseFS.start(fs,*argv) if fs || options[:help]
62
-
63
- puts option_usage if options[:help]
64
- else
65
- puts "rfusefs: failed, no mountpoint provided",RFuse.usage(device,exec)
48
+ RFuse.main(argv,options,option_usage,device,exec) do |options,argv|
49
+ root = yield options
50
+ FuseFS.set_root(root)
51
+ FuseFS.mount_under(*argv)
66
52
  end
67
53
  end
68
54
 
69
- # Start the FuseFS root at mountpoint with opts.
55
+ # Start the FuseFS root at mountpoint with opts.
70
56
  #
71
57
  # If not previously set, Signal traps for "TERM" and "INT" are added
72
58
  # to exit the filesystem
@@ -77,7 +63,6 @@ module FuseFS
77
63
  # @note RFuseFS extension
78
64
  # @return [void]
79
65
  def FuseFS.start(root,mountpoint,*opts)
80
- set_default_traps("TERM","INT") { FuseFS.exit }
81
66
  FuseFS.set_root(root)
82
67
  begin
83
68
  FuseFS.mount_under(mountpoint,*opts)
@@ -88,7 +73,7 @@ module FuseFS
88
73
  end
89
74
 
90
75
  # Forks {FuseFS.start} so you can access your filesystem with ruby File
91
- # operations (eg for testing).
76
+ # operations (eg for testing).
92
77
  # @note This is an *RFuseFS* extension
93
78
  # @return [void]
94
79
  def FuseFS.mount(root,mountpoint,*opts)
@@ -126,43 +111,40 @@ module FuseFS
126
111
  end
127
112
  end
128
113
 
129
- # Set the root virtual directory
114
+ # Set the root virtual directory
130
115
  # @param root [Object] an object implementing a subset of {FuseFS::API}
131
116
  # @return [void]
132
117
  def FuseFS.set_root(root)
133
- @fs=RFuseFS.new(root)
118
+ @fs=Fuse::Root.new(root)
134
119
  end
135
120
 
136
121
  # This will cause FuseFS to virtually mount itself under the given path. {set_root} must have
137
122
  # been called previously.
138
123
  # @param [String] mountpoint an existing directory where the filesystem will be virtually mounted
139
124
  # @param [Array<String>] args
125
+ # @return [Fuse] the mounted fuse filesystem
140
126
  # These are as expected by the "mount" command. Note in particular that the first argument
141
127
  # is expected to be the mount point. For more information, see http://fuse.sourceforge.net
142
128
  # and the manual pages for "mount.fuse"
143
- def FuseFS.mount_under(mountpoint, *args)
144
- @fuse = RFuse::FuseDelegator.new(@fs,mountpoint,*args)
129
+ def FuseFS.mount_under(mountpoint, *args)
130
+ @fuse = Fuse.new(@fs,mountpoint,*args)
145
131
  end
146
132
 
147
- # This is the main loop waiting on then executing filesystem operations from the
148
- # kernel.
149
- #
133
+ # This is the main loop waiting on, then executing, filesystem operations from the
134
+ # kernel.
135
+ #
150
136
  # Note: Running in a separate thread is generally not useful. In particular
151
- # you cannot access your filesystem using ruby File operations.
137
+ # you cannot use Ruby File operations to access your filesystem from
138
+ # within the ruby process that calls run.
152
139
  # @note RFuseFS extension
153
140
  def FuseFS.run
154
- @fs.mounted()
155
- @fuse.loop if @fuse.mounted?
156
- ensure
157
- @fs.unmounted()
141
+ @fuse.run()
158
142
  end
159
143
 
160
- # Exit the run loop and teardown FUSE
161
- # Most useful from Signal.trap() or Kernel.at_exit()
144
+ # Exit the run loop and teardown FUSE
145
+ # Most useful from Signal.trap() or Kernel.at_exit()
162
146
  def FuseFS.exit
163
- if @fuse
164
- @fuse.exit
165
- end
147
+ @fuse.exit if @fuse
166
148
  end
167
149
 
168
150
  # @return [Fixnum] the calling process uid
@@ -188,15 +170,5 @@ module FuseFS
188
170
  #do nothing
189
171
  end
190
172
 
191
- private
192
-
193
- def self.set_default_traps(*signals,&block)
194
- signals.each do |sig|
195
- old_proc = Signal.trap(sig,block)
196
- unless "DEFAULT".eql?(old_proc)
197
- Signal.trap(sig,old_proc)
198
- end
199
- end
200
- end
201
173
  end
202
174
 
@@ -1,3 +1,3 @@
1
1
  module RFuseFS
2
- VERSION="1.0.2.RC2"
2
+ VERSION="1.1.1"
3
3
  end
metadata CHANGED
@@ -1,142 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfusefs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2.RC2
5
- prerelease: 6
4
+ version: 1.1.1.rc20201114.37
6
5
  platform: ruby
7
6
  authors:
8
7
  - Grant Gardner
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-18 00:00:00.000000000 Z
11
+ date: 2020-11-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rfuse
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 1.0.5RC0
19
+ version: '1.2'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 1.0.5RC0
26
+ version: '1.2'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: '3'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: '0'
54
+ version: '3'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: yard
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: redcarpet
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: sqlite3
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: sys-filesystem
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: ffi-xattr
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ">="
132
116
  - !ruby/object:Gem::Version
133
117
  version: 0.1.1
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - ">="
140
123
  - !ruby/object:Gem::Version
141
124
  version: 0.1.1
142
125
  description: A more Ruby like way to write FUSE filesystems - inspired by (compatible
@@ -145,15 +128,14 @@ email:
145
128
  - grant@lastweekend.com.au
146
129
  executables: []
147
130
  extensions: []
148
- extra_rdoc_files: []
131
+ extra_rdoc_files:
132
+ - CHANGES.md
149
133
  files:
150
- - .gitignore
151
- - .travis.yml
152
- - Gemfile
153
- - History.rdoc
154
- - README.rdoc
155
- - Rakefile
156
- - TODO.txt
134
+ - ".yardopts"
135
+ - CHANGES.md
136
+ - LICENSE
137
+ - README.md
138
+ - TODO.md
157
139
  - lib/fuse/fusedir.rb
158
140
  - lib/fuse/rfusefs-fuse.rb
159
141
  - lib/fusefs.rb
@@ -163,48 +145,27 @@ files:
163
145
  - lib/fusefs/sqlitemapper.rb
164
146
  - lib/rfusefs.rb
165
147
  - lib/rfusefs/version.rb
166
- - rfusefs.gemspec
167
- - samples/demo.rb
168
- - samples/dictfs.rb
169
- - samples/hello.rb
170
- - samples/openurifs.rb
171
- - samples/railsfs.rb
172
- - samples/sqlfs.rb
173
- - samples/yamlfs.rb
174
- - spec-fusefs/fusefs_spec.rb
175
- - spec/metadir_spec.rb
176
- - spec/mount_unmount_spec.rb
177
- - spec/pathmapper_spec.rb
178
- - spec/rfusefs_spec.rb
179
- - spec/sample_spec.rb
180
- - spec/spec_helper.rb
181
- - spec/sqlitemapper_spec.rb
182
148
  homepage: http://rubygems.org/gems/rfusefs
183
- licenses: []
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
184
152
  post_install_message:
185
153
  rdoc_options: []
186
154
  require_paths:
187
155
  - lib
188
156
  required_ruby_version: !ruby/object:Gem::Requirement
189
- none: false
190
157
  requirements:
191
- - - ! '>='
158
+ - - ">="
192
159
  - !ruby/object:Gem::Version
193
- version: '0'
194
- segments:
195
- - 0
196
- hash: -1145013380842573975
160
+ version: '2.5'
197
161
  required_rubygems_version: !ruby/object:Gem::Requirement
198
- none: false
199
162
  requirements:
200
- - - ! '>'
163
+ - - ">"
201
164
  - !ruby/object:Gem::Version
202
165
  version: 1.3.1
203
166
  requirements: []
204
- rubyforge_project:
205
- rubygems_version: 1.8.23
167
+ rubygems_version: 3.0.8
206
168
  signing_key:
207
- specification_version: 3
169
+ specification_version: 4
208
170
  summary: Filesystem in Ruby Userspace
209
171
  test_files: []
210
- has_rdoc: yard