Skip to main content

Wrapper around sys/mount.h

Project description

PyPI - Python Version PyPI - License black

lint mypy

Simple python wrapper around sys/mount.h’s mount and umount2 libc functions.

Installation

This package is available on PyPI, so it can be installed with pip or another regular package manager you use:

python3 -m pip install mount

Usage

This library is a tiny wrapper around mount and umount2 functions, so most information about them you can find in man 2 mount and man 2 umount.

Generally there are only 4 objects provided by this package:

  • mount.mount function that is wrapper around mount libc function.

  • mount.umount function that is wrapper around umount2 libc function.

  • mount.MountFlag enum with available mount flags.

  • mount.UmountFlag enum with available umount flags.

mount and umount functions raises OSError on errors.

Here is a simple script that will mount in-memory 1G temporary filesystem with NOEXEC and NOSYMFOLLOW flags in temporary created directory:

from tempfile import TemporaryDirectory
from mount import mount, MountFlag


if __name__ == "__main__":
    target = TemporaryDirectory()
    mount("tmpfs", target.name, "tmpfs", MountFlag.NOEXEC | MountFlag.NOSYMFOLLOW, "size=1G")
    print("Mounted to: ", target)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mount-1.0.0.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

mount-1.0.0-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page