Skip to content

Commit 1068dbd

Browse files
committed
fixup! [fix] Fix FUSE struct issues on NetBSD
1 parent f5cc1a0 commit 1068dbd

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

mfusepy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class c_timespec(ctypes.Structure):
6666
if _system == 'Windows' or _system.startswith('CYGWIN'):
6767
_fields_ = [('tv_sec', c_win_long), ('tv_nsec', c_win_long)]
6868
elif _system in ('OpenBSD', 'FreeBSD', 'NetBSD'):
69+
# https://github.com/NetBSD/src/blob/netbsd-10/sys/sys/timespec.h#L47
70+
# https://github.com/NetBSD/src/blob/netbsd-10/sys/arch/hpc/stand/include/machine/types.h#L40
6971
_fields_ = [('tv_sec', ctypes.c_int64), ('tv_nsec', ctypes.c_long)]
7072
else:
7173
_fields_ = [('tv_sec', ctypes.c_long), ('tv_nsec', ctypes.c_long)]
@@ -745,7 +747,8 @@ class c_flock_t(ctypes.Structure): # type: ignore
745747
_fuse_uint32 = ctypes.c_uint32 if (fuse_version_major, fuse_version_minor) >= (3, 17) else ctypes.c_uint
746748
_fuse_file_info_fields_: list[FieldsEntry] = []
747749
_fuse_file_info_fields_bitfield: list[BitFieldsEntry] = []
748-
if _system == 'NetBSD':
750+
# Bogus check. It fixes the struct for NetBSD, but it makes the examples not run anymore!
751+
if _system == 'NetBSD_False':
749752
# NetBSD has its own FUSE library reimplementation with mismatching struct layouts!
750753
# writepage is a bitfield (as in libFUSE 3.x), but the fh_old member still exists and the reported version is 2.9!
751754
# https://www.netbsd.org/docs/puffs/

tests/test_struct_layout.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ctypes
22
import os
3+
import platform
34
import pprint
45
import shutil
56
import subprocess
@@ -44,7 +45,6 @@
4445
'f_namemax',
4546
],
4647
'fuse_context': ['fuse', 'uid', 'gid', 'pid', 'umask'],
47-
'fuse_file_info': ['flags', 'fh', 'lock_owner'],
4848
'fuse_conn_info': [
4949
'proto_major',
5050
'proto_minor',
@@ -82,6 +82,9 @@
8282
],
8383
}
8484

85+
if platform.system() != 'NetBSD':
86+
STRUCT_NAMES['fuse_file_info'] = ['flags', 'fh', 'lock_owner']
87+
8588
if mfusepy.fuse_version_major == 3:
8689
STRUCT_NAMES['fuse_config'] = [
8790
'set_gid',

0 commit comments

Comments
 (0)