Parse /proc/mounts and find/list mountpoints (Not a wrapper of findmnt)
Project description
mntfinder
Parse /proc/mounts and find/list mountpoints.
This project IS NOT a wrapper of findmnt
.
Install
Just run the command: pip install mntfinder
.
Or you can download and install the wheel file from release page manually.
Examples
All functions shown below can search for mountpoints in /proc/<pid>/mounts
via the keyword argument pid
. If not specified pid
, these functions will search in /proc/mounts
(it is usually linked to /proc/self/mounts
.)
mntfinder.findMountPointByTarget(target: str | os.PathLike[str], *, pid: int | None = None) -> MountPoint | None
import mntfinder
mountpoint = mntfinder.findMountPointByTarget('/mnt/data')
if mountpoint:
print(f"Mount point found: {mountpoint.source} -> {mountpoint.target} (Filesystem type: {mountpoint.fstype})")
else:
print("Mount point not found")
mntfinder.listAllMountPoints(*, source: str | None = None, target: str | os.PathLike[str] | None = None, fstype: str | None = None, pid: int | None = None) -> list[MountPoint]
Retrieve all mount points
import mntfinder
mountpoints = mntfinder.listAllMountPoints()
Retrieve mount points with a specific source
import mntfinder
mountpoints = mntfinder.listAllMountPoints(source='/dev/sda1')
Retrieve mount points with a specific target
import mntfinder
mountpoints = mntfinder.listAllMountPoints(target='/mnt/data')
Retrieve mount points with a specific file system type
import mntfinder
mountpoints = mntfinder.listAllMountPoints(fstype='ext4')
mntfinder.isMountPoint(target: str | PathLike[str], *, source: str | None = None, fstype: str | None = None, pid: int | None = None) -> bool
import mntfinder
is_mount = mntfinder.isMountPoint('/mnt/data', source='/dev/sdb1', fstype='ext4')
if is_mount:
print('/mnt/data is a mountpoint')
else:
print('/mnt/data is not a mountpoint')
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
mntfinder-0.1.0.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for mntfinder-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aed2352a825eab7e5783f53395eee03affd100a3c76ed8f43c6a628f27030a42 |
|
MD5 | 206bb948abb9213dd69572d6b49b4c44 |
|
BLAKE2b-256 | 5d815979eca33022b4618dbdf5ba4fa36f6dc7da35c78a728cc78490c84365ab |