Python lib error: undefined symbol: btrfs_util_subvolume_is_valid
Getting
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/rawfile/rawfile.py", line 5, in <module>
import bd2fs
File "/rawfile/bd2fs.py", line 24, in <module>
from filesystem import get_from_device_or_fallback
File "/rawfile/filesystem/__init__.py", line 4, in <module>
from .btrfs import BTRFS
File "/rawfile/filesystem/btrfs.py", line 11, in <module>
from btrfsutil import (
...<6 lines>...
)
ImportError: /opt/pysetup/.venv/lib/python3.13/site-packages/btrfsutil.cpython-313-x86_64-linux-gnu.so: undefined symbol: btrfs_util_subvolume_is_valid
while using btrfsutil in python
Here is my complete import statement
from btrfsutil import (
create_subvolume,
set_default_subvolume,
get_default_subvolume,
subvolume_path,
create_snapshot,
delete_subvolume,
)
strings /opt/pysetup/.venv/lib/python3.13/site-packages/btrfsutil.cpython-313-x86_64-linux-gnu.so | grep btrfs_util_subvolume_is_valid
btrfs_util_subvolume_is_valid
btrfs_util_subvolume_is_valid_fd
btrfs_util_subvolume_is_valid_fd
btrfs_util_subvolume_is_valid
btrfs_util_subvolume_is_valid
btrfs_util_subvolume_is_valid_fd
shows that btrfs_util_subvolume_is_valid is available but I can't use btrfsutil
Right, this is a bug in the exported functions from python that do not match the new symbol aliases added in 0.1.3 (27e965f53887697f4a2108b6315ddb3ddb460748, 6.7).
The fix is (probably) just mechanical:
- add aliases to the implementations in libbtrfsutil/python/*.c, eg. for is_subvolume add
__attribute__((alias(orig)))subvolume_is_valid - copy the entry in libbtrfsutil/python/module.c for each new alias
- update libbtrfsutil/python/btrfsutilpy.h publich with the new aliases
- add coverage for the aliases to the tests: replace old names with aliases and add a simple test for the old names only
@kdave
We have moved from btrfsutil into using commands since they are more stable and it was a long time since this issue has been created
Yeah, understandable. Unfortunatelly the util and python library has been neglected, mostly fixups. But you've uncovered a big deficiency in the API, it'll get fixed over time so you might use the bindings again in the future.
Fixed in devel.