ffi-libfuse 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +1 -0
  3. data/README.md +100 -0
  4. data/lib/ffi/accessors.rb +145 -0
  5. data/lib/ffi/devt.rb +30 -0
  6. data/lib/ffi/flock.rb +47 -0
  7. data/lib/ffi/gnu_extensions.rb +115 -0
  8. data/lib/ffi/libfuse/ackbar.rb +112 -0
  9. data/lib/ffi/libfuse/adapter/context.rb +37 -0
  10. data/lib/ffi/libfuse/adapter/debug.rb +89 -0
  11. data/lib/ffi/libfuse/adapter/fuse2_compat.rb +91 -0
  12. data/lib/ffi/libfuse/adapter/fuse3_support.rb +87 -0
  13. data/lib/ffi/libfuse/adapter/interrupt.rb +37 -0
  14. data/lib/ffi/libfuse/adapter/pathname.rb +23 -0
  15. data/lib/ffi/libfuse/adapter/ruby.rb +334 -0
  16. data/lib/ffi/libfuse/adapter/safe.rb +58 -0
  17. data/lib/ffi/libfuse/adapter/thread_local_context.rb +36 -0
  18. data/lib/ffi/libfuse/adapter.rb +79 -0
  19. data/lib/ffi/libfuse/callbacks.rb +61 -0
  20. data/lib/ffi/libfuse/fuse2.rb +159 -0
  21. data/lib/ffi/libfuse/fuse3.rb +162 -0
  22. data/lib/ffi/libfuse/fuse_args.rb +166 -0
  23. data/lib/ffi/libfuse/fuse_buffer.rb +155 -0
  24. data/lib/ffi/libfuse/fuse_callbacks.rb +48 -0
  25. data/lib/ffi/libfuse/fuse_cmdline_opts.rb +44 -0
  26. data/lib/ffi/libfuse/fuse_common.rb +249 -0
  27. data/lib/ffi/libfuse/fuse_config.rb +205 -0
  28. data/lib/ffi/libfuse/fuse_conn_info.rb +211 -0
  29. data/lib/ffi/libfuse/fuse_context.rb +79 -0
  30. data/lib/ffi/libfuse/fuse_file_info.rb +100 -0
  31. data/lib/ffi/libfuse/fuse_loop_config.rb +43 -0
  32. data/lib/ffi/libfuse/fuse_operations.rb +870 -0
  33. data/lib/ffi/libfuse/fuse_opt.rb +54 -0
  34. data/lib/ffi/libfuse/fuse_poll_handle.rb +59 -0
  35. data/lib/ffi/libfuse/fuse_version.rb +43 -0
  36. data/lib/ffi/libfuse/job_pool.rb +53 -0
  37. data/lib/ffi/libfuse/main.rb +200 -0
  38. data/lib/ffi/libfuse/test/operations.rb +56 -0
  39. data/lib/ffi/libfuse/test.rb +3 -0
  40. data/lib/ffi/libfuse/thread_pool.rb +147 -0
  41. data/lib/ffi/libfuse/version.rb +8 -0
  42. data/lib/ffi/libfuse.rb +24 -0
  43. data/lib/ffi/ruby_object.rb +95 -0
  44. data/lib/ffi/stat/constants.rb +29 -0
  45. data/lib/ffi/stat/native.rb +50 -0
  46. data/lib/ffi/stat/time_spec.rb +137 -0
  47. data/lib/ffi/stat.rb +96 -0
  48. data/lib/ffi/stat_vfs.rb +81 -0
  49. data/lib/ffi/struct_array.rb +39 -0
  50. data/lib/ffi/struct_wrapper.rb +100 -0
  51. data/sample/memory_fs.rb +189 -0
  52. data/sample/no_fs.rb +69 -0
  53. metadata +165 -0
data/sample/no_fs.rb ADDED
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'ffi/libfuse'
5
+
6
+ # An empty file system
7
+ class NoFS
8
+ include FFI::Libfuse::Adapter::Context
9
+ include FFI::Libfuse::Adapter::Fuse3Support
10
+ include FFI::Libfuse::Adapter::Ruby
11
+
12
+ OPTIONS = { 'log=' => :log }.freeze
13
+
14
+ def fuse_options
15
+ OPTIONS
16
+ end
17
+
18
+ def fuse_help
19
+ <<~END_HELP
20
+ NoFS options:
21
+ -o log=NAME the log file#{' '}
22
+
23
+ END_HELP
24
+ end
25
+
26
+ def fuse_version
27
+ 'NoFS: Version x.y.z'
28
+ end
29
+
30
+ def fuse_opt_proc(_data, arg, key, _outargs)
31
+ case key
32
+ when :log
33
+ @logfile = arg[4..]
34
+ return :handled
35
+ end
36
+ :keep
37
+ end
38
+
39
+ def getattr(_ctx, path, stat)
40
+ raise Errno::ENOENT unless path == '/'
41
+
42
+ stat.directory(mode: 0o555)
43
+ end
44
+
45
+ def readdir(_ctx, _path, _offset, _ffi)
46
+ %w[. ..].each { |d| yield(d, nil) }
47
+ end
48
+
49
+ def log
50
+ @log ||= File.open(@logfile || '/tmp/no_fs.out', 'a')
51
+ end
52
+
53
+ def init(ctx, conn, cfg = nil)
54
+ log.puts("NoFS init ctx- #{ctx.inspect}") if ctx
55
+ log.puts("NoFS init conn - #{conn.inspect}") if conn && !conn.null?
56
+ log.puts "NoFS init cfg #{cfg.inspect}" if cfg && !cfg.null?
57
+ warn 'NoFS: DEBUG enabled' if debug?
58
+ log.flush
59
+ 'INIT_DATA'
60
+ end
61
+
62
+ def destroy(obj, *_rest)
63
+ # If the fs is not cleanly unmounted the init data will have been GC'd by the time this is called
64
+ log.puts("NoFS destroy- #{obj.inspect}") if !obj.is_a?(WeakRef) || obj.weakref_alive?
65
+ log.puts "NoFS destroy- pid=#{Process.pid}"
66
+ end
67
+ end
68
+
69
+ exit(FFI::Libfuse.fuse_main($0, *ARGV, operations: NoFS.new, private_data: 'MAIN_DATA')) if __FILE__ == $0
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ffi-libfuse
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ platform: ruby
6
+ authors:
7
+ - Grant Gardner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-09-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sys-filesystem
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - grant@lastweekend.com.au
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".yardopts"
91
+ - README.md
92
+ - lib/ffi/accessors.rb
93
+ - lib/ffi/devt.rb
94
+ - lib/ffi/flock.rb
95
+ - lib/ffi/gnu_extensions.rb
96
+ - lib/ffi/libfuse.rb
97
+ - lib/ffi/libfuse/ackbar.rb
98
+ - lib/ffi/libfuse/adapter.rb
99
+ - lib/ffi/libfuse/adapter/context.rb
100
+ - lib/ffi/libfuse/adapter/debug.rb
101
+ - lib/ffi/libfuse/adapter/fuse2_compat.rb
102
+ - lib/ffi/libfuse/adapter/fuse3_support.rb
103
+ - lib/ffi/libfuse/adapter/interrupt.rb
104
+ - lib/ffi/libfuse/adapter/pathname.rb
105
+ - lib/ffi/libfuse/adapter/ruby.rb
106
+ - lib/ffi/libfuse/adapter/safe.rb
107
+ - lib/ffi/libfuse/adapter/thread_local_context.rb
108
+ - lib/ffi/libfuse/callbacks.rb
109
+ - lib/ffi/libfuse/fuse2.rb
110
+ - lib/ffi/libfuse/fuse3.rb
111
+ - lib/ffi/libfuse/fuse_args.rb
112
+ - lib/ffi/libfuse/fuse_buffer.rb
113
+ - lib/ffi/libfuse/fuse_callbacks.rb
114
+ - lib/ffi/libfuse/fuse_cmdline_opts.rb
115
+ - lib/ffi/libfuse/fuse_common.rb
116
+ - lib/ffi/libfuse/fuse_config.rb
117
+ - lib/ffi/libfuse/fuse_conn_info.rb
118
+ - lib/ffi/libfuse/fuse_context.rb
119
+ - lib/ffi/libfuse/fuse_file_info.rb
120
+ - lib/ffi/libfuse/fuse_loop_config.rb
121
+ - lib/ffi/libfuse/fuse_operations.rb
122
+ - lib/ffi/libfuse/fuse_opt.rb
123
+ - lib/ffi/libfuse/fuse_poll_handle.rb
124
+ - lib/ffi/libfuse/fuse_version.rb
125
+ - lib/ffi/libfuse/job_pool.rb
126
+ - lib/ffi/libfuse/main.rb
127
+ - lib/ffi/libfuse/test.rb
128
+ - lib/ffi/libfuse/test/operations.rb
129
+ - lib/ffi/libfuse/thread_pool.rb
130
+ - lib/ffi/libfuse/version.rb
131
+ - lib/ffi/ruby_object.rb
132
+ - lib/ffi/stat.rb
133
+ - lib/ffi/stat/constants.rb
134
+ - lib/ffi/stat/native.rb
135
+ - lib/ffi/stat/time_spec.rb
136
+ - lib/ffi/stat_vfs.rb
137
+ - lib/ffi/struct_array.rb
138
+ - lib/ffi/struct_wrapper.rb
139
+ - sample/memory_fs.rb
140
+ - sample/no_fs.rb
141
+ homepage:
142
+ licenses:
143
+ - MIT
144
+ metadata:
145
+ source_code_uri: http://github.com/lwoggardner/ffi-libfuse
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: 2.6.0
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">"
158
+ - !ruby/object:Gem::Version
159
+ version: 1.3.1
160
+ requirements: []
161
+ rubygems_version: 3.0.9
162
+ signing_key:
163
+ specification_version: 4
164
+ summary: FFI Bindings for Libfuse
165
+ test_files: []