ffi-libfuse 0.4.1 → 0.4.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 791ea233a078177b2dd6a9b1cf9a75a64ed05d243de71ebf52a8028b11795653
4
- data.tar.gz: 45d9d235948d5c4cdd09cd8ae168914e82caad31df8a2ce1727d8ed6bb2ff9ad
3
+ metadata.gz: ec6fbc45e44267c8b9a5515e5c504c132d8bc3f84155beeeb4b53832fda8add6
4
+ data.tar.gz: ef54c7d9820fe3449419e9880f2959f4c9524c0136f2a9d570038fe150efcb9d
5
5
  SHA512:
6
- metadata.gz: '00301169c26144390a94545130326eb20c4661af57c2fd612f2ba477ba957b1f76e316fafb7f6da41431a97bab3a6e05523dd9d40a6f1f276d956e2f04aecf5a'
7
- data.tar.gz: a3ea2914410e7f2c4e284df9a0ed500a0c70adc59504bfd93dd398b1396be1467f07071b20d2b7bfd68be465e6c1151889975d747b33969d9a53bff9e9561f47
6
+ metadata.gz: bc88763ee5ad1bc5a47b0314c78adbb4c28b531647f2b074f143302dfa1ea26ea724d83a5340c4ea54aeaeb00c6ef6b0d5a4a8dd383f02db697a65b8eed32780
7
+ data.tar.gz: f2090ddf215602e5b3b7f5ef7a09607b4dfd30e7e4ac661487b1c2ca5d6bdf39fa9aa85bb19d8e04c39a9f1c96be7d324a0a5d31676f6144fff9751dbb8175d1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.4](https://github.com/lwoggardner/ffi-libfuse/compare/v0.4.3...v0.4.4) (2024-12-29)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * fuse buffer adding NUL character when creating from a String ([#35](https://github.com/lwoggardner/ffi-libfuse/issues/35)) ([e07ebfe](https://github.com/lwoggardner/ffi-libfuse/commit/e07ebfeff4001a7d48ad457604e9f5f9191f96de)), closes [#34](https://github.com/lwoggardner/ffi-libfuse/issues/34)
9
+
10
+ ## [0.4.3](https://github.com/lwoggardner/ffi-libfuse/compare/v0.4.2...v0.4.3) (2024-12-25)
11
+
12
+
13
+ ### Miscellaneous Chores
14
+
15
+ * release 0.4.3 ([341e2ce](https://github.com/lwoggardner/ffi-libfuse/commit/341e2ce3a2cf362bf2bdc2433ea0d1e1c843775c))
16
+
17
+ ## [0.4.2](https://github.com/lwoggardner/ffi-libfuse/compare/v0.4.1...v0.4.2) (2024-12-16)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * bugs in Adapter::Safe and virtual filesystem operations ([decf7ae](https://github.com/lwoggardner/ffi-libfuse/commit/decf7ae024eee4bb565f67abfe493a14e5fa9cca))
23
+
3
24
  ## [0.4.1](https://github.com/lwoggardner/ffi-libfuse/compare/v0.4.0...v0.4.1) (2024-10-26)
4
25
 
5
26
 
data/README.md CHANGED
@@ -4,7 +4,7 @@ Ruby FFI Binding for [libfuse](https://github.com/libfuse/libfuse)
4
4
 
5
5
  ## Requirements
6
6
 
7
- * Ruby 2.7
7
+ * Ruby 2.7, 3.2+
8
8
  * Linux: libfuse (Fuse2) or libfuse3 (Fuse3)
9
9
  * MacOS: macFuse (https://osxfuse.github.io/)
10
10
 
@@ -60,17 +60,18 @@ module FFI
60
60
  # For void callbacks
61
61
  # @return [Integer]
62
62
  # For path callbacks, either 0 for success or a negative errno value
63
- def safe_callback(fuse_method, *args, default_errno: Errno::ENOTRECOVERABLE::Errno)
63
+ def safe_callback(fuse_method, *args, default_errno: Errno::ENOTRECOVERABLE::Errno, &block)
64
64
  if FuseOperations::MEANINGFUL_RETURN.include?(fuse_method)
65
- safe_meaningful_integer_callback(fuse_method, *args, default_errno: default_errno)
65
+ safe_meaningful_integer_callback(fuse_method, *args, default_errno: default_errno, &block)
66
66
  elsif FuseOperations::VOID_RETURN.include?(fuse_method)
67
- safe_void_callback(fuse_method, *args)
67
+ safe_void_callback(fuse_method, *args, &block)
68
68
  else
69
- safe_integer_callback(fuse_method, *args, default_errno: default_errno)
69
+ safe_integer_callback(fuse_method, *args, default_errno: default_errno, &block)
70
70
  end
71
71
  end
72
72
 
73
- private
73
+ # private
74
+ # @visibility private
74
75
 
75
76
  def safe_integer_callback(_, *args, default_errno: Errno::ENOTRECOVERABLE::Errno)
76
77
  safe_errno(default_errno) do
@@ -78,20 +79,23 @@ module FFI
78
79
  result.is_a?(Integer) && result.negative? ? result : 0
79
80
  end
80
81
  end
82
+ private_class_method :safe_integer_callback
81
83
 
82
84
  def safe_meaningful_integer_callback(_, *args, default_errno: Errno::ENOTRECOVERABLE::Errno)
83
85
  safe_errno(default_errno) do
84
86
  yield(*args).to_i
85
87
  end
86
88
  end
89
+ private_class_method :safe_meaningful_integer_callback
87
90
 
88
91
  def safe_errno(default_errno)
89
92
  yield
90
93
  rescue SystemCallError => e
91
94
  -e.errno
92
- rescue StandardError, ScriptError
95
+ rescue StandardError, ScriptError => _e
93
96
  -default_errno.abs
94
97
  end
98
+ private_class_method :safe_errno
95
99
 
96
100
  # Process callbacks that return void, simply by swallowing unexpected errors
97
101
  def safe_void_callback(_, *args)
@@ -101,6 +105,7 @@ module FFI
101
105
  # Swallow unexpected exceptions
102
106
  nil
103
107
  end
108
+ private_class_method :safe_void_callback
104
109
  end
105
110
  end
106
111
  end
@@ -28,7 +28,7 @@ module FFI
28
28
  def getattr(path, stat = nil, _ffi = nil)
29
29
  return super unless root?(path)
30
30
 
31
- stat&.directory(@root.virtual_stat.merge({ nlink: entries.size + 2 }))
31
+ stat&.directory(**@root.virtual_stat.merge({ nlink: entries.size + 2 }))
32
32
 
33
33
  self
34
34
  end
@@ -20,6 +20,7 @@ module FFI
20
20
 
21
21
  # Create an empty synthetic file
22
22
  def initialize(accounting: nil)
23
+ @nlink = 1
23
24
  super
24
25
  end
25
26
 
@@ -75,7 +75,7 @@ module FFI
75
75
  end
76
76
 
77
77
  def listxattr(path, buf = nil, size = nil)
78
- return path_method(__method__, path) unless root?(path)
78
+ return path_method(__method__, path, buf, size) unless root?(path)
79
79
  return virtual_xattr.keys unless buf
80
80
 
81
81
  Adapter::Ruby.listxattr(buf, size) { virtual_xattr.keys }
@@ -59,7 +59,7 @@ module FFI
59
59
 
60
60
  # @overload fill(str:)
61
61
  # Create a memory buffer from str
62
- # @param [String,#to_s] str
62
+ # @param [String] str
63
63
  #
64
64
  # @overload fill(size:)
65
65
  # Allocate an empty memory buffer of size bytes
@@ -86,12 +86,11 @@ module FFI
86
86
  # @return [self]
87
87
  def fill(
88
88
  str: nil,
89
- mem: str ? FFI::MemoryPointer.from_string(str.to_s) : FFI::Pointer::NULL, size: mem.null? ? 0 : mem.size,
89
+ mem: mem_from_bytes(str),
90
+ size: mem.null? ? 0 : mem.size,
90
91
  fd: -1, fd_retry: false, pos: nil # rubocop:disable Naming/MethodParameterName
91
-
92
92
  )
93
-
94
- # Allocate size bytes if we've been given a null pointer
93
+ # Allocate size bytes if we've been given a null pointer and size is > 0
95
94
  mem = FFI::MemoryPointer.new(:char, size, true) if fd == -1 && mem.null? && size.positive?
96
95
 
97
96
  mem.autorelease = to_ptr.autorelease? unless mem.null?
@@ -107,6 +106,15 @@ module FFI
107
106
  self[:pos] = pos || 0
108
107
  self
109
108
  end
109
+
110
+ private
111
+
112
+ def mem_from_bytes(str)
113
+ return FFI::Pointer::NULL unless str
114
+ return FFI::Pointer::NULL if str.empty?
115
+
116
+ FFI::MemoryPointer.new(:char, str.bytesize).write_bytes(str)
117
+ end
110
118
  end
111
119
  end
112
120
  end
@@ -147,7 +147,7 @@ module FFI
147
147
  # close/redirect file descriptors
148
148
  $stdin.close
149
149
 
150
- [$stdout, $stderr].each { |io| io.reopen('/dev/null', 'w') }
150
+ [$stdout, $stderr].each { |io| io.reopen(File::NULL, 'w') }
151
151
 
152
152
  pw.write([0].pack('c'))
153
153
  ensure
@@ -3,6 +3,6 @@
3
3
  module FFI
4
4
  # Ruby FFI Binding for [libfuse](https://github.com/libfuse/libfuse)
5
5
  module Libfuse
6
- VERSION = '0.4.1'
6
+ VERSION = '0.4.4'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-libfuse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Gardner
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-26 00:00:00.000000000 Z
11
+ date: 2024-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -122,7 +122,7 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- description:
125
+ description:
126
126
  email:
127
127
  - grant@lastweekend.com.au
128
128
  executables: []
@@ -200,13 +200,13 @@ files:
200
200
  - sample/memory_fs.rb
201
201
  - sample/no_fs.rb
202
202
  - sample/pass_through_fs.rb
203
- homepage:
203
+ homepage:
204
204
  licenses:
205
205
  - MIT
206
206
  metadata:
207
207
  source_code_uri: https://github.com/lwoggardner/ffi-libfuse
208
208
  rubygems_mfa_required: 'true'
209
- post_install_message:
209
+ post_install_message:
210
210
  rdoc_options: []
211
211
  require_paths:
212
212
  - lib
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  version: '0'
223
223
  requirements: []
224
224
  rubygems_version: 3.1.6
225
- signing_key:
225
+ signing_key:
226
226
  specification_version: 4
227
227
  summary: FFI Bindings for Libfuse
228
228
  test_files: []