Skip to content

Commit 14da787

Browse files
committed
fixup! [fix] Fix FUSE struct issues on NetBSD
1 parent 1ea63d0 commit 14da787

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

mfusepy.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,6 @@ def get_fuse_version(libfuse):
158158
f"Found library {_libfuse_path} has wrong major version: {fuse_version_major}. Expected FUSE 2!"
159159
)
160160

161-
print("FOUND FUSE LIBRARY VERSION:", fuse_version_major, fuse_version_minor)
162-
163-
if _system == 'NetBSD' and (fuse_version_major, fuse_version_minor) == (2, 9):
164-
# For some reason, NetBSD return 2.9 even though the API is 3.10!
165-
# The correct version is important for the struct layout!
166-
# https://github.com/NetBSD/src/blob/netbsd-10/lib/librefuse/fuse.h#L58-L59
167-
fuse_version_major = 3
168-
fuse_version_minor = 10
169161

170162
# Some platforms, like macOS 15, define ENOATTR and ENODATA with different values.
171163
# For missing xattrs, errno is set to the ENOATTR value (e.g. in getxattr and removexattr).
@@ -943,10 +935,14 @@ class fuse_bufvec(ctypes.Structure):
943935
('proto_major', ctypes.c_uint),
944936
('proto_minor', ctypes.c_uint),
945937
]
938+
# For some reason, NetBSD return 2.9 even though the API is 3.10!
939+
# The correct version is important for the struct layout!
940+
# https://github.com/NetBSD/src/blob/netbsd-10/lib/librefuse/fuse.h#L58-L59
941+
# However, the fuse_operations layout probably fits the advertised version because I had segfaults from utimens!
946942
if fuse_version_major == 2 or _system == 'NetBSD': # No idea why NetBSD did not remove it -.-
947943
_fuse_conn_info_fields += [('async_read', _fuse_uint32)]
948944
_fuse_conn_info_fields += [('max_write', _fuse_uint32)]
949-
if fuse_version_major == 3:
945+
if fuse_version_major == 3 or _system == 'NetBSD':
950946
_fuse_conn_info_fields += [('max_read', _fuse_uint32)]
951947
_fuse_conn_info_fields += [
952948
('max_readahead', _fuse_uint32),
@@ -955,11 +951,11 @@ class fuse_bufvec(ctypes.Structure):
955951
('max_background', _fuse_uint32), # Added in 2.9
956952
('congestion_threshold', _fuse_uint32), # Added in 2.9
957953
]
958-
if fuse_version_major == 2:
954+
if fuse_version_major == 2 and _system != 'NetBSD':
959955
_fuse_conn_info_fields += [('reserved', _fuse_uint32 * 23)]
960-
elif fuse_version_major == 3:
956+
elif fuse_version_major == 3 or _system == 'NetBSD':
961957
_fuse_conn_info_fields += [('time_gran', _fuse_uint32)]
962-
if fuse_version_minor < 17:
958+
if fuse_version_minor < 17 or _system == 'NetBSD':
963959
_fuse_conn_info_fields += [('reserved', _fuse_uint32 * 22)]
964960
else:
965961
_fuse_conn_info_fields += [
@@ -1037,11 +1033,12 @@ class fuse_conn_info(ctypes.Structure): # Added in 2.6 (ABI break of "init" fro
10371033
if fuse_version_minor >= 15 and fuse_version_minor < 17:
10381034
_fuse_config_fields_ += [('parallel_direct_writes', ctypes.c_int)]
10391035

1040-
_fuse_config_fields_ += [
1041-
('show_help', _fuse_int32),
1042-
('modules', ctypes.c_char_p),
1043-
('debug', _fuse_int32),
1044-
]
1036+
if _system != 'NetBSD':
1037+
_fuse_config_fields_ += [
1038+
('show_help', _fuse_int32),
1039+
('modules', ctypes.c_char_p),
1040+
('debug', _fuse_int32),
1041+
]
10451042

10461043
if fuse_version_minor >= 17:
10471044
_fuse_config_fields_ += [

0 commit comments

Comments
 (0)