rfusefs 1.0.2 → 1.1.3
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.
- checksums.yaml +5 -13
- data/.yardopts +2 -0
- data/CHANGES.md +43 -0
- data/LICENSE +24 -0
- data/README.md +83 -0
- data/TODO.md +7 -0
- data/lib/fuse/fusedir.rb +17 -2
- data/lib/fuse/rfusefs-fuse.rb +446 -414
- data/lib/fusefs/metadir.rb +5 -5
- data/lib/fusefs/pathmapper.rb +7 -7
- data/lib/fusefs/sqlitemapper.rb +7 -2
- data/lib/rfusefs.rb +20 -48
- data/lib/rfusefs/version.rb +1 -1
- metadata +35 -53
- data/.gitignore +0 -9
- data/.travis.yml +0 -8
- data/Gemfile +0 -4
- data/History.rdoc +0 -28
- data/README.rdoc +0 -107
- data/Rakefile +0 -22
- data/TODO.txt +0 -6
- data/rfusefs.gemspec +0 -31
- data/samples/demo.rb +0 -57
- data/samples/dictfs.rb +0 -74
- data/samples/hello.rb +0 -20
- data/samples/openurifs.rb +0 -53
- data/samples/railsfs.rb +0 -77
- data/samples/sqlfs.rb +0 -134
- data/samples/yamlfs.rb +0 -168
- data/spec-fusefs/fusefs_spec.rb +0 -12
- data/spec/metadir_spec.rb +0 -364
- data/spec/mount_unmount_spec.rb +0 -21
- data/spec/pathmapper_spec.rb +0 -417
- data/spec/rfusefs_spec.rb +0 -497
- data/spec/sample_spec.rb +0 -30
- data/spec/spec_helper.rb +0 -42
- data/spec/sqlitemapper_spec.rb +0 -135
data/spec/sample_spec.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rfusefs'
|
3
|
-
require 'tmpdir'
|
4
|
-
require 'pathname'
|
5
|
-
require 'hello'
|
6
|
-
|
7
|
-
describe "Access Hello World sample from Ruby file operations" do
|
8
|
-
let(:mountpoint) { Pathname.new(Dir.mktmpdir("rfusefs_sample")) }
|
9
|
-
|
10
|
-
before(:all) do
|
11
|
-
hello = HelloDir.new()
|
12
|
-
FuseFS.mount(hello,mountpoint)
|
13
|
-
#Give FUSE some time to get started
|
14
|
-
sleep(0.5)
|
15
|
-
end
|
16
|
-
|
17
|
-
after(:all) do
|
18
|
-
FuseFS.unmount(mountpoint)
|
19
|
-
sleep(0.5)
|
20
|
-
FileUtils.rmdir(mountpoint)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should list expected root directory contents" do
|
24
|
-
Dir.entries(mountpoint.to_s).should =~ [".","..","hello.txt"]
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should output the expected sample contents" do
|
28
|
-
(mountpoint + "hello.txt").read().should == "Hello, World!\n"
|
29
|
-
end
|
30
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
SPEC_DIR = File.dirname(__FILE__)
|
2
|
-
lib_path = File.expand_path("#{SPEC_DIR}/../samples")
|
3
|
-
puts lib_path
|
4
|
-
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
|
5
|
-
|
6
|
-
|
7
|
-
require 'rfusefs'
|
8
|
-
require 'fusefs/metadir'
|
9
|
-
require 'fcntl'
|
10
|
-
require 'tmpdir'
|
11
|
-
require 'pathname'
|
12
|
-
require 'fileutils'
|
13
|
-
|
14
|
-
module RFuseFSHelper
|
15
|
-
|
16
|
-
def pathnames(*args)
|
17
|
-
args.collect {|x| Pathname.new(x) }
|
18
|
-
end
|
19
|
-
|
20
|
-
def permissions(mode)
|
21
|
-
return (mode & 07777)
|
22
|
-
end
|
23
|
-
|
24
|
-
def filetype(mode)
|
25
|
-
return (mode & RFuse::Stat::S_IFMT)
|
26
|
-
end
|
27
|
-
|
28
|
-
FuseContext = Struct.new(:uid,:gid)
|
29
|
-
def fuse_context(uid=Process.uid,gid=Process.gid)
|
30
|
-
FuseContext.new(uid,gid)
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
def mktmpdir(name)
|
35
|
-
tmpdir = Pathname.new(Dir.tmpdir) + "rfusefs"
|
36
|
-
tmpdir = tmpdir + name
|
37
|
-
FileUtils.mkdir_p(tmpdir.to_s) unless tmpdir.directory?
|
38
|
-
tmpdir
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
include RFuseFSHelper
|
data/spec/sqlitemapper_spec.rb
DELETED
@@ -1,135 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'tmpdir'
|
3
|
-
require 'sqlite3'
|
4
|
-
require 'pathname'
|
5
|
-
require "fusefs/sqlitemapper"
|
6
|
-
|
7
|
-
class SQLFixture
|
8
|
-
|
9
|
-
SQL = "select * from files"
|
10
|
-
|
11
|
-
attr_reader :tmpdir
|
12
|
-
attr_reader :db
|
13
|
-
def initialize()
|
14
|
-
@tmpdir = Pathname.new(Dir.mktmpdir("rfusefs_sqlitemapper"))
|
15
|
-
@db_path = @tmpdir + "test.db"
|
16
|
-
@db = SQLite3::Database.new(@db_path.to_s)
|
17
|
-
@db.execute <<-SQL
|
18
|
-
create table files (
|
19
|
-
real_path varchar(120),
|
20
|
-
mapped_path varchar(120)
|
21
|
-
);
|
22
|
-
SQL
|
23
|
-
|
24
|
-
pathmap("hello.txt","/textfiles/hello")
|
25
|
-
pathmap("mysong.mp3","/artist/album/mysong.mp3")
|
26
|
-
pathmap("apicture.jpeg","/pictures/201103/apicture.jpg")
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
def pathmap(real_file,mapped_path)
|
31
|
-
real_path = (@tmpdir + real_file).to_s
|
32
|
-
File.open(real_path,"w") do |f|
|
33
|
-
f << mapped_path
|
34
|
-
end
|
35
|
-
@db.execute "insert into files values ( ?, ? )", real_path,mapped_path
|
36
|
-
end
|
37
|
-
|
38
|
-
def unpathmap(mapped_path)
|
39
|
-
@db.execute("delete from files where mapped_path = ?", mapped_path)
|
40
|
-
end
|
41
|
-
|
42
|
-
def db_force_write
|
43
|
-
@db.close unless @db.closed?
|
44
|
-
@db = SQLite3::Database.new(@db_path.to_s)
|
45
|
-
end
|
46
|
-
|
47
|
-
def fs
|
48
|
-
@fs ||= FuseFS::SqliteMapperFS.new(@db_path,SQL) do |row|
|
49
|
-
[ row['real_path'], row['mapped_path'] ]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def mount()
|
54
|
-
return @mountpoint if @mountpoint
|
55
|
-
@mountpoint = Pathname.new(Dir.mktmpdir("rfusefs_sqlitmapper_mnt"))
|
56
|
-
FuseFS.mount(fs,@mountpoint)
|
57
|
-
sleep 0.5
|
58
|
-
@mountpoint
|
59
|
-
end
|
60
|
-
|
61
|
-
def cleanup
|
62
|
-
@db.close
|
63
|
-
if @mountpoint
|
64
|
-
FuseFS.unmount(@mountpoint)
|
65
|
-
FileUtils.rmdir @mountpoint
|
66
|
-
end
|
67
|
-
FileUtils.rm_r(@tmpdir)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
describe "SqliteMapper" do
|
71
|
-
|
72
|
-
let(:fixture) { SQLFixture.new }
|
73
|
-
let(:fs) { fixture.fs }
|
74
|
-
|
75
|
-
after(:each) do
|
76
|
-
fixture.cleanup
|
77
|
-
end
|
78
|
-
|
79
|
-
context "filesystem outside FUSE" do
|
80
|
-
before(:each) do
|
81
|
-
fs.mounted()
|
82
|
-
sleep(0.5)
|
83
|
-
end
|
84
|
-
|
85
|
-
after(:each) do
|
86
|
-
fs.unmounted()
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should map files from a sqlite database" do
|
90
|
-
fs.directory?("/").should be_true
|
91
|
-
fs.directory?("/textfiles").should be_true
|
92
|
-
fs.directory?("/pictures/201103").should be_true
|
93
|
-
fs.file?("/textfiles/hello").should be_true
|
94
|
-
fs.directory?("/textfiles/hello").should be_false
|
95
|
-
fs.file?("/artist/album/mysong.mp3").should be_true
|
96
|
-
fs.directory?("/artist/album/mysong.mp3").should be_false
|
97
|
-
fs.file?("/some/unknown/path").should be_false
|
98
|
-
end
|
99
|
-
|
100
|
-
context "an updated database" do
|
101
|
-
|
102
|
-
it "should add new files" do
|
103
|
-
fixture.pathmap("added.txt","/textfiles/added.txt")
|
104
|
-
fixture.db_force_write()
|
105
|
-
fs.rescan; sleep(0.3)
|
106
|
-
fs.file?("/textfiles/added.txt").should be_true
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should remove files and directories no longer mapped" do
|
110
|
-
fixture.unpathmap("/textfiles/hello")
|
111
|
-
fixture.db_force_write()
|
112
|
-
fs.rescan; sleep(0.3)
|
113
|
-
fs.file?("/textfiles/hello").should be_false
|
114
|
-
fs.directory?("/textfiles").should be_false
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
context "a real Fuse filesystem" do
|
119
|
-
before(:each) do
|
120
|
-
fs.use_raw_file_access = true
|
121
|
-
fs.allow_write = true
|
122
|
-
@mountpoint = fixture.mount
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should read files" do
|
126
|
-
|
127
|
-
hello_path = (@mountpoint + "textfiles/hello")
|
128
|
-
hello_path.open do |f|
|
129
|
-
f.read.should == "/textfiles/hello"
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|