python_linuxfs <https://gitlab.com/ldo/python_linuxfs> is a set ofInteresting approach. Regarding the linuxacl and linuxmount modules: how
Python modules providing higher-level wrappers around various
Linux-specific system APIs. Some of these already have support in the
?os? module in the standard Python library, but most don?t. Even for
the ones that do, I think my wrappers are nicer to use, because they
avoid the requirement for working with bitmasks and use sets of
symbolic bit enums instead (with easy conversions between both forms).
The package is split into five modules:
* linuxfs -- file/directory functions and common utilities used by
other modules
* linuxacl -- access-control-list functions
* linuxmount -- enhanced Linux mount API
* linuxpriv -- privilege control, i.e. the Linux landlock API
* linuxproc -- process control: prctl (selected), pidfd,
signalfd and signal mask sets, namespaces
Regarding the linuxacl and linuxmount modules: how do you handle compatibility across different kernel versions? Since some of these
APIs (like Landlock or newer mount features) are relatively recent,
does the library provide graceful fallbacks or just raise NotImplementedError?
Using sets of enums instead of bitmasks is definitely 'The Pythonic
Way'. It makes the code much more self-documenting.
python_linuxfs <https://gitlab.com/ldo/python_linuxfs> is a set of
Python modules providing higher-level wrappers around various
Linux-specific system APIs. Some of these already have support in the
?os? module in the standard Python library, but most don?t.
There were a few things like this that were missing for years. I was
going to suggest adding them to your modules, but it looks like
they've finally made it to the Python world elsewhere.
Actually, I have a plan to go further. I have figured out that the
contents of an ACL can be expressed most naturally as a Python
object with the following components:
On Tue, 17 Mar 2026 14:30:42 +0300, Oguz Kaan Ocal wrote:> Regarding the linuxacl and linuxmount modules: how do you handle> compatibility across different kernel versions? Since some of these> APIs (like Landlock or newer mount features) are relatively recent,> does the library provide graceful fallbacks or just raise> NotImplementedError?Landlock in particular has been through about 7 versions so far, withsigns of an eighth on the way. I deal with that by attach API versioninfo to the relevant enums.For example, if you look at my Python version of the ?sandboxer?sample program in the Landlock documentation, I get the API versionfrom the current kernel with LL_VERSION = linuxpriv.get_landlock_version()then I can collect sets of available access attributes with constructslike:* All read/write operations on both files and directories: access_file_dir_rw = set \ ( acc for acc in ACCESS_FS if acc.min_version <= LL_VERSION )* Read-only operations on files: access_file_ro = set \ ( acc for acc in ACCESS_FS if acc.min_version <= LL_VERSION and acc.file_op and not acc.write_op )etc.As for libacl, I?m not aware of any API version changes -- not in theman pages I?ve been reading so far. Similarly the mount API -- both goso far back that I don?t think any kernels that don?t implement themare still in any kind of support. Correct me if I?m wrong. ;)> Using sets of enums instead of bitmasks is definitely 'The Pythonic> Way'. It makes the code much more self-documenting.More than that, I can attach extra attributes that can be used to easeprogramming, as in the examples above.Thanks for the explanation, Lawrence. The way you?ve implemented the min_version attribute within the enums for Landlock is actually quite clever?it?s a clean way to handle the evolving nature of that API without cluttering the user-facing code.
python_linuxfs <https://gitlab.com/ldo/python_linuxfs> is a set of
Python modules providing higher-level wrappers around various
Linux-specific system APIs. Some of these already have support in the
?os? module in the standard Python library, but most don?t. Even for
the ones that do, I think my wrappers are nicer to use, because they
avoid the requirement for working with bitmasks and use sets of
symbolic bit enums instead (with easy conversions between both forms).
The package is split into five modules:
* linuxfs -- file/directory functions and common utilities used by
other modules
* linuxacl -- access-control-list functions
* linuxmount -- enhanced Linux mount API
* linuxpriv -- privilege control, i.e. the Linux landlock API
* linuxproc -- process control: prctl (selected), pidfd,
signalfd and signal mask sets, namespaces
| Sysop: | Tetrazocine |
|---|---|
| Location: | Melbourne, VIC, Australia |
| Users: | 15 |
| Nodes: | 8 (0 / 8) |
| Uptime: | 17:01:00 |
| Calls: | 214 |
| Files: | 21,502 |
| Messages: | 83,201 |