ffi-libfuse 0.0.1.rctest12 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +3 -1
  3. data/CHANGELOG.md +60 -0
  4. data/LICENSE +21 -0
  5. data/README.md +127 -44
  6. data/lib/ffi/accessors.rb +6 -6
  7. data/lib/ffi/boolean_int.rb +27 -0
  8. data/lib/ffi/devt.rb +23 -0
  9. data/lib/ffi/encoding.rb +38 -0
  10. data/lib/ffi/flock.rb +7 -5
  11. data/lib/ffi/gnu_extensions.rb +1 -1
  12. data/lib/ffi/libfuse/ackbar.rb +3 -3
  13. data/lib/ffi/libfuse/adapter/context.rb +12 -10
  14. data/lib/ffi/libfuse/adapter/fuse2_compat.rb +52 -51
  15. data/lib/ffi/libfuse/adapter/fuse3_support.rb +7 -4
  16. data/lib/ffi/libfuse/adapter/interrupt.rb +1 -1
  17. data/lib/ffi/libfuse/adapter/ruby.rb +499 -148
  18. data/lib/ffi/libfuse/adapter/safe.rb +12 -11
  19. data/lib/ffi/libfuse/adapter.rb +1 -2
  20. data/lib/ffi/libfuse/callbacks.rb +1 -1
  21. data/lib/ffi/libfuse/filesystem/accounting.rb +116 -0
  22. data/lib/ffi/libfuse/filesystem/mapped_dir.rb +74 -0
  23. data/lib/ffi/libfuse/filesystem/mapped_files.rb +141 -0
  24. data/lib/ffi/libfuse/filesystem/pass_through_dir.rb +55 -0
  25. data/lib/ffi/libfuse/filesystem/pass_through_file.rb +45 -0
  26. data/lib/ffi/libfuse/filesystem/utils.rb +102 -0
  27. data/lib/ffi/libfuse/filesystem/virtual_dir.rb +306 -0
  28. data/lib/ffi/libfuse/filesystem/virtual_file.rb +94 -0
  29. data/lib/ffi/libfuse/filesystem/virtual_fs.rb +196 -0
  30. data/lib/ffi/libfuse/filesystem/virtual_node.rb +101 -0
  31. data/lib/ffi/libfuse/filesystem.rb +25 -0
  32. data/lib/ffi/libfuse/fuse2.rb +32 -24
  33. data/lib/ffi/libfuse/fuse3.rb +28 -18
  34. data/lib/ffi/libfuse/fuse_args.rb +71 -34
  35. data/lib/ffi/libfuse/fuse_buffer.rb +128 -26
  36. data/lib/ffi/libfuse/fuse_callbacks.rb +1 -5
  37. data/lib/ffi/libfuse/fuse_common.rb +60 -61
  38. data/lib/ffi/libfuse/fuse_config.rb +134 -143
  39. data/lib/ffi/libfuse/fuse_conn_info.rb +310 -134
  40. data/lib/ffi/libfuse/fuse_context.rb +45 -3
  41. data/lib/ffi/libfuse/fuse_operations.rb +57 -21
  42. data/lib/ffi/libfuse/fuse_opt.rb +1 -1
  43. data/lib/ffi/libfuse/fuse_version.rb +10 -6
  44. data/lib/ffi/libfuse/gem_version.rb +54 -0
  45. data/lib/ffi/libfuse/main.rb +96 -48
  46. data/lib/ffi/libfuse/test_helper.rb +145 -0
  47. data/lib/ffi/libfuse/version.rb +1 -1
  48. data/lib/ffi/libfuse.rb +13 -4
  49. data/lib/ffi/ruby_object.rb +4 -1
  50. data/lib/ffi/stat/constants.rb +9 -0
  51. data/lib/ffi/stat/native.rb +36 -6
  52. data/lib/ffi/stat/time_spec.rb +26 -10
  53. data/lib/ffi/stat.rb +111 -22
  54. data/lib/ffi/stat_vfs.rb +59 -1
  55. data/lib/ffi/struct_wrapper.rb +22 -1
  56. data/sample/hello_fs.rb +54 -0
  57. data/sample/memory_fs.rb +5 -181
  58. data/sample/no_fs.rb +20 -21
  59. data/sample/pass_through_fs.rb +30 -0
  60. metadata +83 -10
  61. data/lib/ffi/libfuse/adapter/thread_local_context.rb +0 -36
  62. data/lib/ffi/libfuse/test/operations.rb +0 -56
  63. data/lib/ffi/libfuse/test.rb +0 -3
@@ -5,77 +5,78 @@ module FFI
5
5
  module Adapter
6
6
  # Wrapper module to assist filesystem written for Fuse3 to be compatible with Fuse2
7
7
  module Fuse2Compat
8
- # @!visibility private
9
8
  # Wrapper shim for fuse methods to ensure compatibility with Fuse2
10
- module Fuse2Prepend
9
+ module Prepend
11
10
  include Adapter
12
11
 
13
- def getattr(path, stat, fuse_file_info = nil)
14
- super(path, stat, fuse_file_info)
15
- end
16
-
17
- def truncate(path, size, fuse_file_info = nil)
18
- super(path, size, fuse_file_info)
19
- end
12
+ if FUSE_MAJOR_VERSION == 2
13
+ # @!visibility private
14
+ def getattr(path, stat, fuse_file_info = nil)
15
+ super(path, stat, fuse_file_info)
16
+ end
20
17
 
21
- def init(fuse_conn_info, fuse_config = nil)
22
- super(fuse_conn_info, fuse_config)
23
- end
18
+ def truncate(path, size, fuse_file_info = nil)
19
+ super(path, size, fuse_file_info)
20
+ end
24
21
 
25
- def chown(path, uid, gid, fuse_file_info = nil)
26
- super(path, uid, gid, fuse_file_info)
27
- end
22
+ def init(fuse_conn_info, fuse_config = nil)
23
+ super(fuse_conn_info, fuse_config)
24
+ end
28
25
 
29
- def chmod(path, mode, fuse_file_info = nil)
30
- super(path, mode, fuse_file_info)
31
- end
26
+ def chown(path, uid, gid, fuse_file_info = nil)
27
+ super(path, uid, gid, fuse_file_info)
28
+ end
32
29
 
33
- def utimens(path, atime, mtime, fuse_file_info = nil)
34
- super(path, atime, mtime, fuse_file_info)
35
- end
30
+ def chmod(path, mode, fuse_file_info = nil)
31
+ super(path, mode, fuse_file_info)
32
+ end
36
33
 
37
- def readdir(path, buffer, filler, offset, fuse_file_info, fuse_readdir_flag = 0)
38
- filler = proc { |buf, name, stat, off = 0, _fuse_fill_dir_flag = 0| filler.call(buf, name, stat, off) }
39
- super(path, buffer, filler, offset, fuse_file_info, fuse_readdir_flag)
40
- end
34
+ def utimens(path, atime, mtime, fuse_file_info = nil)
35
+ super(path, atime, mtime, fuse_file_info)
36
+ end
41
37
 
42
- def fgetattr(*args)
43
- getattr(*args)
44
- end
38
+ def readdir(path, buffer, filler, offset, fuse_file_info, fuse_readdir_flag = 0)
39
+ f3_fill = proc { |buf, name, stat, off = 0, _fuse_fill_dir_flag = 0| filler.call(buf, name, stat, off) }
40
+ super(path, buffer, f3_fill, offset, fuse_file_info, fuse_readdir_flag)
41
+ end
45
42
 
46
- def ftruncate(*args)
47
- truncate(*args)
48
- end
43
+ def fgetattr(path, stat, ffi)
44
+ stat.clear # For some reason (at least on OSX) the stat is not clear when this is called.
45
+ getattr(path, stat, ffi)
46
+ 0
47
+ end
49
48
 
50
- def fuse_respond_to?(fuse_method)
51
- fuse_method = fuse_method[1..].to_sym if %i[fgetattr ftruncate].include?(fuse_method)
52
- super(fuse_method)
53
- end
49
+ def ftruncate(*args)
50
+ truncate(*args)
51
+ end
54
52
 
55
- def fuse_flags
56
- res = defined?(super) ? super : []
57
- if respond_to?(:init_fuse_config)
58
- fuse_config = FuseConfig.new
59
- init_fuse_config(fuse_config, :fuse2)
60
- res << :nullpath_ok if fuse_config.nullpath_ok?
53
+ def fuse_respond_to?(fuse_method)
54
+ fuse_method = fuse_method[1..].to_sym if %i[fgetattr ftruncate].include?(fuse_method)
55
+ super(fuse_method)
61
56
  end
62
57
 
63
- res
64
- end
65
- end
58
+ def fuse_flags
59
+ res = defined?(super) ? super : []
60
+ if respond_to?(:init_fuse_config)
61
+ fuse_config = FuseConfig.new
62
+ init_fuse_config(fuse_config, :fuse2)
63
+ res << :nullpath_ok if fuse_config.nullpath_ok?
64
+ end
66
65
 
67
- # @!visibility private
68
- module Fuse3Prepend
69
- def init(*args)
70
- init_fuse_config(args.detect { |a| a.is_a?(FuseConfig) }) if respond_to?(:init_fuse_config)
71
- super if defined?(super)
66
+ res
67
+ end
68
+
69
+ else
70
+ def init(*args)
71
+ init_fuse_config(args.detect { |a| a.is_a?(FuseConfig) }) if respond_to?(:init_fuse_config)
72
+ super if defined?(super)
73
+ end
72
74
  end
73
75
  end
74
76
 
75
77
  # @!visibility private
76
78
  def self.included(mod)
77
- prepend_module = Libfuse.FUSE_MAJOR_VERSION == 2 ? Fuse2Prepend : Fuse3Prepend
78
- mod.prepend(prepend_module)
79
+ mod.prepend(Prepend)
79
80
  end
80
81
 
81
82
  # @!method init_fuse_config(fuse_config,compat)
@@ -12,7 +12,6 @@ module FFI
12
12
  #
13
13
  module Fuse3Support
14
14
  # The actual module methods that are prepended
15
- # @!visibility private
16
15
  module Prepend
17
16
  include Adapter
18
17
 
@@ -23,14 +22,14 @@ module FFI
23
22
 
24
23
  def getattr(*args)
25
24
  fi = args.pop
26
- return fgetattr(*args, fi) if fi && respond_to?(:fgetattr)
25
+ return fgetattr(*args, fi) if fi && fuse_super_respond_to?(:fgetattr)
27
26
 
28
27
  super(*args)
29
28
  end
30
29
 
31
30
  def truncate(*args)
32
31
  fi = args.pop
33
- return ftruncate(*args, fi) if fi && respond_to?(:ftruncate)
32
+ return ftruncate(*args, fi) if fi && fuse_super_respond_to?(:ftruncate)
34
33
 
35
34
  super(*args)
36
35
  end
@@ -51,7 +50,7 @@ module FFI
51
50
  # but there is no way to handle OMIT
52
51
  def utimens(*args)
53
52
  args.pop
54
- super(*args)
53
+ super(*args) if defined?(super)
55
54
  end
56
55
 
57
56
  def init(*args)
@@ -74,6 +73,10 @@ module FFI
74
73
 
75
74
  super(*args, &block)
76
75
  end
76
+
77
+ def fuse_respond_to(fuse_callback)
78
+ super || (%i[truncate getattr].include?(fuse_callback) && fuse_super_respond_to?("f#{fuse_callback}"))
79
+ end
77
80
  end
78
81
 
79
82
  # @!visibility private
@@ -27,7 +27,7 @@ module FFI
27
27
 
28
28
  # @raise [Errno::EINTR] if the fuse request is marked as interrupted
29
29
  def interrupt_callback(*args)
30
- return -Errno::EINTR::Errno if Libfuse.fuse_interrupted?
30
+ Libfuse.raise_interrupt
31
31
 
32
32
  yield(*args)
33
33
  end