Metadata-Version: 2.5
Name: newmount
Version: 0.1.0
Summary: Python bindings for the Linux mount API
Project-URL: Homepage, https://quad4.io
Project-URL: Repository, https://github.com/Quad4-Software/newmount
Project-URL: Issues, https://github.com/Quad4-Software/newmount/issues
Project-URL: Changelog, https://github.com/Quad4-Software/newmount/blob/master/CHANGELOG.md
Author: Quad4
License-Expression: 0BSD
License-File: LICENSE
Keywords: filesystems,fsopen,linux,mount,namespaces
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Security
Classifier: Topic :: System :: Operating System Kernels :: Linux
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# newmount

[![CI](https://github.com/Quad4-Software/newmount/actions/workflows/ci.yml/badge.svg)](https://github.com/Quad4-Software/newmount/actions/workflows/ci.yml)
[![CodeQL](https://github.com/Quad4-Software/newmount/actions/workflows/codeql.yml/badge.svg)](https://github.com/Quad4-Software/newmount/actions/workflows/codeql.yml)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/Quad4-Software/newmount/badge)](https://securityscorecards.dev/viewer/?uri=github.com/Quad4-Software/newmount)
[![PyPI](https://img.shields.io/pypi/v/newmount.svg)](https://pypi.org/project/newmount/)
[![License: 0BSD](https://img.shields.io/badge/license-0BSD-blue)](LICENSE)

Dependency-free ctypes bindings for the Linux mount API: the classic
mount(2)/umount2(2) calls, and the new mount API (kernel 5.2+) built on
fsopen, fsconfig, fsmount, open_tree, move_mount, fspick and
mount_setattr.

Requires Python 3.10+ and Linux. Mounting needs CAP_SYS_ADMIN; an
unprivileged process gets there inside a user+mount namespace
(`unshare -Urm`).

## Install

    pip install newmount

## Example: classic bind mount

    import newmount

    # bind recursively, then remount read-only
    newmount.bind("/srv/data", "/mnt/data", readonly=True)

## Example: clone, reconfigure and attach with the new API

    import newmount

    # clone the tree, flip the clone read-only, attach it
    with newmount.open_tree_clone("/srv/data") as tree:
        tree.apply_attrs(set=newmount.MOUNT_ATTR_RDONLY)
        tree.attach("/mnt/data")

    # or build a fresh filesystem from scratch
    with newmount.FsContext("tmpfs") as ctx:
        ctx.set("size", "16m")
        ctx.create()
        with ctx.mount() as mnt:
            mnt.attach("/mnt/scratch")

## Development

    uv sync --group dev
    make check

License: 0BSD. Quad4 Software, https://quad4.io
