Open
Description
I would like to warn when the free space is low, in a graphical app. So my script runs unprivileged. FileSystem.usage()
always requires root. Is it possible to have it work like btrfs filesystem usage
, which prints the filesystem's grand totals?
$ python3
Python 3.12.6 (main, Sep 7 2024, 14:20:15) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import btrfs
>>> with btrfs.FileSystem("/") as fs:
... print(fs.usage())
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/usr/lib/python3/dist-packages/btrfs/ctree.py", line 1061, in usage
return btrfs.fs_usage.FsUsage(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/btrfs/fs_usage.py", line 423, in __init__
devices = list(fs.devices())
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/btrfs/ctree.py", line 835, in devices
for header, data in btrfs.ioctl.search_v2(self.fd, tree, min_key, max_key):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/btrfs/ioctl.py", line 462, in _search
fcntl.ioctl(fd, IOC_TREE_SEARCH_V2, buf)
PermissionError: [Errno 1] Operation not permitted
Metadata
Metadata
Assignees
Labels
No labels