python-btrfs icon indicating copy to clipboard operation
python-btrfs copied to clipboard

Optimize examples/fs_info and add path validity checks

Open wu-zhao-min opened this issue 1 month ago • 1 comments

Optimize examples/fs_info and add path validity checks

wu-zhao-min avatar Dec 09 '25 07:12 wu-zhao-min

Hi! Thanks, this makes sense yes. :-) One less ugly error message.

The stuff in examples/ is quite yolo, I mainly quickly created things to test some new functionality, since there's no proper automated test coverage yet. (Shame on me!). But yeah, I chose to do the whole big project of writing all of the API documentation first.

I have one minor remark: technically, btrfs allows calling IOCTL functions using any open file descriptor to anything that has an inode in the filesystem, not only directories. So, you can even do /fs_info.py ./fs_info.py! :-D

The very short help text uses <mountpoint> as a suggestion, but it does not have to be a directory. So I suggest we also allow is_file(). Then, if a curious user goes messing around with the example script, we do not refuse operation while they would actually get proper results!

knorrie avatar Dec 17 '25 16:12 knorrie