libmount-sys

Crates.iolibmount-sys
lib.rslibmount-sys
version
sourcesrc
created_at2019-06-26 06:51:06.263934+00
updated_at2025-03-18 23:35:44.270945+00
descriptionUnsafe Rust bindings for libmount of util-linux
homepage
repositoryhttps://gitlab.com/wtm/libmount-sys
max_upload_size
id143684
Cargo.toml error:TOML parse error at line 21, column 1 | 21 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
maowtm (micromaomao)

documentation

https://docs.rs/libmount-sys

README

crates.io docs.rs

libmount-sys: Unsafe Rust bindings for libmount of util-linux

The libmount library is used to, among other things:

  • Parse /etc/fstab, /etc/mtab and /proc/self/mountinfo files,
  • Manage the mtab file,
  • Evaluate mount options.

This crate is Linux-specific. Building it for non-Linux platforms, or for the Linux kernel, results in an empty crate.

This crate links to libmount, and requires it to be installed. See below for example installation instructions.

Installing libmount

This crate links to libmount, and requires it to be installed.

The library, its C header files, and the clang compiler need to be installed on the build machine. On Debian, for example, one can install that as follows:

sudo apt install clang libmount-dev

If the library is linked dynamically (most typical configuration), then it needs to be installed on the target computer in order to run the resulting program. On Debian, for example, one can install it as follows:

sudo apt install libmount1

Supported environment variables

This crate depends on some environment variables, and variants of those. For each environment variable (e.g., CC), the following are the accepted variants of it:

  • <var>_<target>, e.g., CC_aarch64-unknown-linux-gnu.
  • <var>_<target-with-underscores>, e.g., CC_aarch64_unknown_linux_gnu.
  • TARGET_<var>, e.g., TARGET_CC.
  • <var>, e.g., CC.

The following environment variables (and their variants) affect how this crate is built:

  • LIBMOUNT_STATIC
  • LIBMOUNT_PATH
  • LIBMOUNT_INCLUDE_DIR
  • LIBMOUNT_LIB_DIR
  • SYSROOT
  • CC
  • CFLAGS

Dynamic or static linking

This crate links to libmount dynamically if possible, except when targeting platforms based on the musl C library.

This behavior can be changed either by setting the environment variable LIBMOUNT_STATIC to 1, or by enabling the crate feature static. If both are defined, then the value of LIBMOUNT_STATIC takes precedence.

Setting LIBMOUNT_STATIC to 0 mandates dynamic linking.

Finding libmount library and headers

By default, this crate finds libmount headers and library based on the default target C compiler.

This behavior can be changed by:

  • Either defining the environment variable LIBMOUNT_PATH to the path of a directory containing the subdirectories include and lib where the headers and library are installed.
  • Or by defining one or both of the environment variables LIBMOUNT_INCLUDE_DIR and LIBMOUNT_LIB_DIR to paths to the directories where headers and library are present. If LIBMOUNT_PATH is also defined, then LIBMOUNT_INCLUDE_DIR and LIBMOUNT_LIB_DIR take precedence.

Depending on this crate

This crate provides the following variables to other crates that depend on it:

  • DEP_LIBMOUNT_INCLUDE: Path of the directory where library C header files reside.
  • DEP_LIBMOUNT_LIB: Path of the directory where the library binary resides.

Versioning

This project adheres to Semantic Versioning. The CHANGELOG.md file details notable changes over time.

Commit count: 1

cargo fmt