-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unprivileged free space info #48
Comments
My script is doing this, is there a better way, sorry I'm a newbie at btrfs
|
Hi! This is an interesting puzzle. Some of the btrfs kernel api functions indeed do require root level access, and some don't. Since So, if you're in for a fun exercise to quickly learn more about btrfs, then what you could do is:
This is exactly the type of little programs that this Python btrfs library is intended for to make. To figure out what I just did that here, the output is not that long. This will already tell you which actual kernel functions it's using. Look for the lines that look like In the strace output, you can see that one of the first things it tries is calling After getting some numbers, the I hope this helps as some starting tips to start playing around! |
Some extra things: In strace output, this is where it tries to search btrfs metadata tree 3 (
The shortest way to get chunk objects in a list with python-btrfs is:
There you get the same error! When
We can do:
From that info it learns that the highest device number in the filesystem is 1 (max_id=1), and then it just tries looking up info about device 0 (number 0 is normally not in use, but it can be e.g. during a device replace operation) and device 1:
We can do:
Etcetera... Use the python-btrfs reference docs for info about all the different objects and their fields etc. :) |
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 likebtrfs filesystem usage
, which prints the filesystem's grand totals?The text was updated successfully, but these errors were encountered: