Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Lawrence =?iso-8859-13?q?D=FFOliveiro?= Newsgroups: comp.lang.python Subject: Re: Python linuxfs Modules Date: Tue, 17 Mar 2026 21:26:00 -0000 (UTC) Organization: A noiseless patient Spider Lines: 49 Message-ID: <10pcgt7$39968$3@dont-email.me> References: <10pask7$2m01c$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 17 Mar 2026 21:26:00 +0000 (UTC) Injection-Info: dont-email.me; posting-host="826ddadae121c482abf76a9551f185a7"; logging-data="3450056"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fa0PFG5Hw3Wp5EgafgjDM" User-Agent: Pan/0.165 (Kostiantynivka) Cancel-Lock: sha1:bDV19BTKEFh3IWh9cQULf7apbRM= Xref: csiph.com comp.lang.python:197740 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.