rfusefs 1.0.2.RC1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- #No hidden files (except for .gitignore)
2
- .*
3
- !.gitignore
4
- !.travis.yml
5
- #Files generated by rake
6
- doc
7
- pkg
8
- #Jedit stupid default backup settings
9
- *'`'
@@ -1,8 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - "1.8.7"
4
- - "1.9.3"
5
- - "2.0.0"
6
- before_install:
7
- - sudo apt-get update -qq
8
- - sudo apt-get install -qq libfuse-dev
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in rfusefs.gemspec
4
- gemspec
@@ -1,28 +0,0 @@
1
- === 1.0.1 / 2013-12-19
2
-
3
- * Add FuseFS.main to create pretty usage messages
4
-
5
- * Support extended attributes in filesystems
6
-
7
- * Updates and cleanup of PathMapperFS
8
-
9
- * Provide SqliteMapperFS
10
-
11
- === 1.0.0 / 2012-08-07
12
-
13
- * Depend on new rfuse 1.0.0, Ruby 1.9
14
-
15
- * API breaking changes
16
-
17
- * order of arguments to {FuseFS.mount}, {FuseFS.start} changed
18
- to account for better option handling in RFuse
19
-
20
- === 0.8.0 / 2011-02-19
21
-
22
- * Initial port from fusefs
23
-
24
- * Improved raw methods
25
- * new "times" api for including atime,mtime,ctime in stat results
26
- * metadir allow mv directories
27
- * includes PathMapperFS
28
-
@@ -1,106 +0,0 @@
1
- = rfusefs
2
-
3
- * https://rubygems.org/gems/rfusefs
4
- * https://github.com/lwoggardner/rfusefs
5
-
6
- == DESCRIPTION
7
-
8
- RFuseFS is a port of the FuseFS[http://rubygems.org/gems/fusefs/]
9
- library aimed at allowing Ruby programmers to quickly and easily create
10
- virtual filesystems with little more than a few lines of code.
11
-
12
- RFuseFS is api compatible with FuseFS (0.7.0)
13
-
14
- == SYNOPSIS
15
-
16
- FuseFS provides a layer of abstraction to a programmer who wants to create a
17
- virtual filesystem via FUSE.
18
-
19
- First define a virtual directory by subclassing {FuseFS::FuseDir}
20
-
21
- See samples under /samples and also the following starter classes
22
-
23
- * {FuseFS::FuseDir}
24
- * {FuseFS::MetaDir}
25
- * {FuseFS::DirLink}
26
- * {FuseFS::PathMapperFS}
27
- * {FuseFS::SqliteMapperFS}
28
-
29
- Then start your filesystem with
30
-
31
- * {FuseFS.start}
32
- * {FuseFS.main}
33
-
34
- Finally to use the filesystem open up your favourite file browser/terminal and
35
- explore the contents under <mountpoint>
36
-
37
- Happy Filesystem Hacking!
38
-
39
- === the hello world filesystem in 14 LOC
40
-
41
- require 'rfusefs'
42
-
43
- class HelloDir
44
-
45
- def contents(path)
46
- ['hello.txt']
47
- end
48
-
49
- def file?(path)
50
- path == '/hello.txt'
51
- end
52
-
53
- def read_file(path)
54
- "Hello, World!\n"
55
- end
56
-
57
- end
58
-
59
- # Usage: #{$0} mountpoint [mount_options]
60
- FuseFS.main() { |options| HelloDir.new }
61
-
62
- == REQUIREMENTS:
63
-
64
- * FUSE (http://fuse.sourceforge.org)
65
- * Ruby (>=1.9)
66
- * rfuse (~> 1.0)
67
-
68
- == INSTALL:
69
-
70
- * gem install rfusefs
71
-
72
- == DEVELOPERS:
73
-
74
- After checking out the source, run:
75
-
76
- $ bundle install # install dependencies
77
- $ rake spec # run tests
78
- $ rake yard # generate docs
79
-
80
-
81
- == LICENSE:
82
-
83
- (The MIT License)
84
-
85
- * Copyright (c) 2005 Greg Millam. (FuseFS)
86
- * Copyright (c) 2009 Kyle Maxwell. (FuseFS)
87
- * Copyright (c) 2012 Grant Gardner. (RFuseFS)
88
-
89
- Permission is hereby granted, free of charge, to any person obtaining
90
- a copy of this software and associated documentation files (the
91
- 'Software'), to deal in the Software without restriction, including
92
- without limitation the rights to use, copy, modify, merge, publish,
93
- distribute, sublicense, and/or sell copies of the Software, and to
94
- permit persons to whom the Software is furnished to do so, subject to
95
- the following conditions:
96
-
97
- The above copyright notice and this permission notice shall be
98
- included in all copies or substantial portions of the Software.
99
-
100
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
101
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
102
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
103
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
104
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
105
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
106
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile DELETED
@@ -1,22 +0,0 @@
1
- # -*- ruby -*-
2
- require "bundler/gem_tasks"
3
- require 'yard'
4
- require 'rspec/core/rake_task'
5
- require 'rake/clean'
6
-
7
- CLOBBER.include [ "pkg/","doc/" ]
8
-
9
- YARD::Rake::YardocTask.new do |t|
10
- # Need this because YardocTask does not read the gemspec
11
- t.files = ['lib/**/*.rb', '-','History.rdoc'] # optional
12
- end
13
-
14
- RSpec::Core::RakeTask.new(:spec)
15
-
16
- desc "FuseFS compatibility specs"
17
- RSpec::Core::RakeTask.new("spec:fusefs") do |t|
18
- t.pattern = 'spec-fusefs/**/*_spec.rb'
19
- end
20
-
21
- task :default => ["spec","spec:fusefs"]
22
- # vim: syntax=ruby
data/TODO.txt DELETED
@@ -1,6 +0,0 @@
1
-
2
- = TODO
3
-
4
- Fix (or remove) samples
5
-
6
-
@@ -1,313 +0,0 @@
1
- module FuseFS
2
-
3
- # Helper for filesystem accounting
4
- class StatsHelper
5
-
6
- # @return [Integer] size of filesystem in bytes
7
- attr_accessor :max_space
8
- # @return [Integer] maximum number of (virtual) inodes
9
- attr_accessor :max_nodes
10
-
11
- # If set true, adjustments that cause space/nodes to exceed
12
- # the maximums will raise ENOSPC (no space left on device)
13
- # @return [Boolean]
14
- attr_accessor :strict
15
-
16
- # @return [Integer] used space in bytes
17
- attr_reader :space
18
-
19
- # @return [Integer] used inodes (typically count of files and directories)
20
- attr_reader :nodes
21
-
22
- #
23
- # @param [Integer] max_space
24
- # @param [Integer] max_nodes
25
- # @param [Booleanr] strict
26
- def initialize(max_space=nil,max_nodes=nil,strict=false)
27
- @nodes = 0
28
- @space = 0
29
- @max_space = max_space
30
- @max_nodes = max_nodes
31
- @strict = strict
32
- end
33
-
34
- # Adjust accumlated statistics
35
- # @param [Integer] delta_space change in {#space} usage
36
- # @param [Integer] delta_nodes change in {#nodes} usage
37
- #
38
- # @return [void]
39
- # @raise [Errno::ENOSPC] if {#strict} and adjusted {#space}/{#nodes} would exceed {#max_space} or {#max_nodes}
40
- def adjust(delta_space,delta_nodes=0)
41
- @nodes += delta_nodes
42
- @space += delta_space
43
- raise Errno::ENOSPC if @strict && ( @nodes > @max_nodes || @space > @max_space )
44
- end
45
-
46
- # @overload to_statistics()
47
- # @return [Array<Integer>] in format expected by {FuseDir#statistics}
48
- # @overload to_statistics(free_space,free_nodes)
49
- # Calculate total space so that free space remains fixed
50
- # @param [Integer] free_space available space in bytes
51
- # @param [Integer] free_nodes available (virtual) inodes
52
- # @return [Array<Integer>] in format expected by {FuseDir#statistics}
53
- def to_statistics(free_space=nil,free_nodes=nil)
54
- total_space = free_space ? space + free_space : max_space
55
- total_nodes = free_nodes ? nodes + free_nodes : max_nodes
56
- [ @space, @nodes, total_space, total_nodes ]
57
- end
58
- end
59
-
60
- # This class is equivalent to using Object.new() as the virtual directory
61
- # for target for {FuseFS.start}. It exists primarily to document the API
62
- # but can also be used as a superclass for your filesystem providing sensible defaults
63
- #
64
- # == Method call sequences
65
- #
66
- # === Stat (getattr)
67
- #
68
- # FUSE itself will generally stat referenced files and validate the results
69
- # before performing any file/directory operations so this sequence is called
70
- # very often
71
- #
72
- # 1. {#directory?} is checked first
73
- # * {#can_write?} OR {#can_mkdir?} with .\_rfusefs_check\_ to determine write permissions
74
- # * {#times} is called to determine atime,mtime,ctime info for the directory
75
- #
76
- # 2. {#file?} is checked next
77
- # * {#can_write?}, {#executable?}, {#size}, {#times} are called to fill out the details
78
- #
79
- # 3. otherwise we tell FUSE that the path does not exist
80
- #
81
- # === List directory
82
- #
83
- # FUSE confirms the path is a directory (via stat above) before we call {#contents}
84
- #
85
- # FUSE will generally go on to stat each directory entry in the results
86
- #
87
- # === Reading files
88
- #
89
- # FUSE confirms path is a file before we call {#read_file}
90
- #
91
- # For fine control of file access see {#raw_open}, {#raw_read}, {#raw_close}
92
- #
93
- # === Writing files
94
- #
95
- # FUSE confirms path for the new file is a directory
96
- #
97
- # * {#can_write?} is checked at file open
98
- # * {#write_to} is called when the file is synced, flushed or closed
99
- #
100
- # See also {#raw_open}, {#raw_truncate}, {#raw_write}, {#raw_sync}, {#raw_close}
101
- #
102
- # === Deleting files
103
- #
104
- # FUSE confirms path is a file before we call {#can_delete?} then {#delete}
105
- #
106
- # === Creating directories
107
- #
108
- # FUSE confirms parent is a directory before we call {#can_mkdir?} then {#mkdir}
109
- #
110
- # === Deleting directories
111
- #
112
- # FUSE confirms path is a directory before we call {#can_rmdir?} then {#rmdir}
113
- #
114
- # === Renaming files and directories
115
- #
116
- # FUSE confirms the rename is valid (eg. not renaming a directory to a file)
117
- #
118
- # * Try {#rename} to see if the virtual directory wants to handle this itself
119
- # * If rename returns false/nil then we try to copy/delete (files only) ie.
120
- # * {#file?}(from), {#can_write?}(to), {#can_delete?}(from) and if all true
121
- # * {#read_file}(from), {#write_to}(to), {#delete}(from)
122
- # * otherwise reject the rename
123
- class FuseDir
124
- INIT_TIMES = Array.new(3,0)
125
-
126
- # base,rest = split_path(path)
127
- # @return [Array<String,String>] base,rest. base is the first directory in
128
- # path, and rest is nil> or the remaining path.
129
- # Typically if rest is not nil? you should
130
- # recurse the paths
131
- def split_path(path)
132
- cur, *rest = path.scan(/[^\/]+/)
133
- if rest.empty?
134
- [ cur, nil ]
135
- else
136
- [ cur, File::SEPARATOR + File.join(rest) ]
137
- end
138
- end
139
-
140
- # base,*rest = scan_path(path)
141
- # @return [Array<String>] all directory and file elements in path. Useful
142
- # when encapsulating an entire fs into one object
143
- def scan_path(path)
144
- path.scan(/[^\/]+/)
145
- end
146
-
147
- # @abstract FuseFS api
148
- # @return [Boolean] true if path is a directory
149
- def directory?(path);return false;end
150
-
151
- # @abstract FuseFS api
152
- # @return [Boolean] true if path is a file
153
- def file?(path);end
154
-
155
- # @abstract FuseFS api
156
- # @return [Array<String>] array of file and directory names within path
157
- def contents(path);return [];end
158
-
159
- # @abstract FuseFS api
160
- # @return [Boolean] true if path is an executable file
161
- def executable?(path);return false;end
162
-
163
- # File size
164
- # @abstract FuseFS api
165
- # @return [Integer] the size in byte of a file (lots of applications rely on this being accurate )
166
- def size(path); read_file(path).length ;end
167
-
168
- # File time information. RFuseFS extension.
169
- # @abstract FuseFS api
170
- # @return [Array<Integer, Time>] a 3 element array [ atime, mtime. ctime ] (good for rsync etc)
171
- def times(path);return INIT_TIMES;end
172
-
173
- # @abstract FuseFS api
174
- # @return [String] the contents of the file at path
175
- def read_file(path);return "";end
176
-
177
- # @abstract FuseFS api
178
- # @return [Boolean] true if the user can write to file at path
179
- def can_write?(path);return false;end
180
-
181
- # Write the contents of str to file at path
182
- # @abstract FuseFS api
183
- # @return [void]
184
- def write_to(path,str);end
185
-
186
- # @abstract FuseFS api
187
- # @return [Boolean] true if the user can delete the file at path
188
- def can_delete?(path);return false;end
189
-
190
- # Delete the file at path
191
- # @abstract FuseFS api
192
- # @return [void]
193
- def delete(path);end
194
-
195
- # @abstract FuseFS api
196
- # @return [Boolean] true if user can make a directory at path
197
- def can_mkdir?(path);return false;end
198
-
199
- # Make a directory at path
200
- # @abstract FuseFS api
201
- # @return [void]
202
- def mkdir(path);end
203
-
204
- # @abstract FuseFS api
205
- # @return [Boolean] true if user can remove a directory at path
206
- def can_rmdir?(path);return false;end
207
-
208
- # Remove the directory at path
209
- # @abstract FuseFS api
210
- # @return [void]
211
- def rmdir(path);end
212
-
213
- # Neat toy. Called when a file is touched or has its timestamp explicitly modified
214
- # @abstract FuseFS api
215
- # @return [void]
216
- def touch(path,modtime);end
217
-
218
- # Move a file or directory.
219
- # @abstract FuseFS api
220
- # @return [Boolean] true to indicate the rename has been handled,
221
- # otherwise will fallback to copy/delete
222
- def rename(from_path,to_path);end
223
-
224
- # Raw file access
225
- # @abstract FuseFS api
226
- # @param mode [String] "r","w" or "rw", with "a" if file is opened for append
227
- # @param rfusefs [Boolean] will be "true" if RFuseFS extensions are available
228
- # @return [nil] to indicate raw operations are not implemented
229
- # @return [Object] a filehandle
230
- # Under RFuseFS this object will be passed back in to the other raw
231
- # methods as the optional parameter _raw_
232
- #
233
- def raw_open(path,mode,rfusefs = nil);end
234
-
235
- # RFuseFS extension.
236
- # @abstract FuseFS api
237
- #
238
- # @overload raw_truncate(path,offset,raw)
239
- # Truncate an open file to offset bytes
240
- # @param [String] path
241
- # @param [Integer] offset
242
- # @param [Object] raw the filehandle returned from {#raw_open}
243
- # @return [void]
244
- #
245
- # @overload raw_truncate(path,offset)
246
- # Optionally truncate a file to offset bytes directly
247
- # @param [String] path
248
- # @param [Integer] offset
249
- # @return [Boolean]
250
- # if truncate has been performed, otherwise the truncation will be performed with {#read_file} and {#write_to}
251
- #
252
- def raw_truncate(path,offset,raw=nil);end
253
-
254
- # Read _sz_ bytes from file at path (or filehandle raw) starting at offset off
255
- #
256
- # @param [String] path
257
- # @param [Integer] offset
258
- # @param [Integer] size
259
- # @param [Object] raw the filehandle returned by {#raw_open}
260
- # @abstract FuseFS api
261
- # @return [void]
262
- def raw_read(path,offset,size,raw=nil);end
263
-
264
- # Write _sz_ bytes from file at path (or filehandle raw) starting at offset off
265
- # @abstract FuseFS api
266
- # @return [void]
267
- def raw_write(path,off,sz,buf,raw=nil);end
268
-
269
-
270
- # Sync buffered data to your filesystem
271
- # @param [String] path
272
- # @param [Boolena] datasync only sync user data, not metadata
273
- # @param [Object] raw the filehandle return by {#raw_open}
274
- def raw_sync(path,datasync,raw=nil);end
275
-
276
- # Close the file previously opened at path (or filehandle raw)
277
- # @abstract FuseFS api
278
- # @return [void]
279
- def raw_close(path,raw=nil);end
280
-
281
- # RFuseFS extension.
282
- # Extended attributes.
283
- # @param [String] path
284
- # @return [Hash] extended attributes for this path.
285
- # The returned object will be manipulated directly using :[] :[]=,, :keys and :delete
286
- # so the default (a new empty hash on every call) will not retain attributes that are set
287
- # @abstract FuseFS api
288
- def xattr(path); {} ; end
289
-
290
- # RFuseFS extensions.
291
- # File system statistics
292
- # @param [String] path
293
- # @return [Array<Integer>] the statistics
294
- # used_space (in bytes), used_files, max_space, max_files
295
- # See {StatsHelper}
296
- # @return [RFuse::StatVfs] or raw statistics
297
- # @abstract FuseFS api
298
- def statistics(path); [0,0,0,0]; end
299
-
300
- # RFuseFS extension.
301
- # Called when the filesystem is mounted
302
- # @return [void]
303
- def mounted();end
304
-
305
- # RFuseFS extension.
306
- # Called when the filesystem is unmounted
307
- # @return [void]
308
- def unmounted();end
309
-
310
- end
311
-
312
- DEFAULT_FS = FuseDir.new()
313
- end