Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #197740

Re: Python linuxfs Modules

From Lawrence D’Oliveiro <ldo@nz.invalid>
Newsgroups comp.lang.python
Subject Re: Python linuxfs Modules
Date 2026-03-17 21:26 +0000
Organization A noiseless patient Spider
Message-ID <10pcgt7$39968$3@dont-email.me> (permalink)
References <10pask7$2m01c$1@dont-email.me> <c51f175a-5e17-8e2e-d50b-128f148a036d@hotmail.com>

Show all headers | View raw


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, with
signs of an eighth on the way. I deal with that by attach API version
info 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 version
from the current kernel with

    LL_VERSION = linuxpriv.get_landlock_version()

then I can collect sets of available access attributes with constructs
like:

* 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 the
man pages I’ve been reading so far. Similarly the mount API -- both go
so far back that I don’t think any kernels that don’t implement them
are 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 ease
programming, as in the examples above.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Python linuxfs Modules Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-17 06:33 +0000
  Re: Python linuxfs Modules Oguz Kaan Ocal <oguzkaanocal3169@hotmail.com> - 2026-03-17 14:30 +0300
    Re: Python linuxfs Modules Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-17 21:26 +0000
      Re: Python linuxfs Modules Oguz Kaan Ocal <oguzkaanocal3169@hotmail.com> - 2026-03-22 14:14 +0300
  Re: Python linuxfs Modules Paul Rubin <no.email@nospam.invalid> - 2026-03-17 23:28 -0700
    Re: Python linuxfs Modules Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-18 08:04 +0000
      Re: Python linuxfs Modules Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-21 23:10 +0000
  Re: Python linuxfs Modules DFS <nospam@dfs.com> - 2026-04-08 12:26 -0400

csiph-web