Crate libmount_sys

Crate libmount_sys 

Source
Expand description

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.

Structs§

libmnt_cache
libmnt_context
libmnt_fs
libmnt_iter
libmnt_lock
libmnt_monitor
libmnt_ns
libmnt_optmap
libmnt_tabdiff
libmnt_table
libmnt_update
mntent

Constants§

LIBMOUNT_MAJOR_VERSION
LIBMOUNT_MINOR_VERSION
LIBMOUNT_PATCH_VERSION
LIBMOUNT_VERSION
MNT_ACT_MOUNT
MNT_ACT_UMOUNT
MNT_ERR_AMBIFS
MNT_ERR_APPLYFLAGS
MNT_ERR_CHMOD
MNT_ERR_CHOWN
MNT_ERR_IDMAP
MNT_ERR_LOCK
MNT_ERR_LOOPDEV
MNT_ERR_LOOPOVERLAP
MNT_ERR_MOUNTOPT
MNT_ERR_NAMESPACE
MNT_ERR_NOFSTAB
MNT_ERR_NOFSTYPE
MNT_ERR_NOSOURCE
MNT_ERR_ONLYONCE
MNT_EX_FAIL
MNT_EX_FILEIO
MNT_EX_SOFTWARE
MNT_EX_SOMEOK
MNT_EX_SUCCESS
MNT_EX_SYSERR
MNT_EX_USAGE
MNT_EX_USER
MNT_INVERT
MNT_ITER_BACKWARD
MNT_ITER_FORWARD
MNT_LINUX_MAP
MNT_MONITOR_TYPE_KERNEL
MNT_MONITOR_TYPE_USERSPACE
MNT_MS_COMMENT
MNT_MS_ENCRYPTION
MNT_MS_FEC_DEVICE
MNT_MS_FEC_OFFSET
MNT_MS_FEC_ROOTS
MNT_MS_GROUP
MNT_MS_HASH_DEVICE
MNT_MS_HASH_OFFSET
MNT_MS_HELPER
MNT_MS_LOOP
MNT_MS_NETDEV
MNT_MS_NOAUTO
MNT_MS_NOFAIL
MNT_MS_OFFSET
MNT_MS_OWNER
MNT_MS_ROOT_HASH
MNT_MS_ROOT_HASH_FILE
MNT_MS_ROOT_HASH_SIG
MNT_MS_SIZELIMIT
MNT_MS_UHELPER
MNT_MS_USER
MNT_MS_USERS
MNT_MS_VERITY_ON_CORRUPTION
MNT_MS_XCOMMENT
MNT_MS_XFSTABCOMM
MNT_NOFSTAB
MNT_NOHLPS
MNT_NOMTAB
MNT_OMODE_APPEND
MNT_OMODE_AUTO
MNT_OMODE_FORCE
MNT_OMODE_FSTAB
MNT_OMODE_IGNORE
MNT_OMODE_MTAB
MNT_OMODE_NOTAB
MNT_OMODE_PREPEND
MNT_OMODE_REPLACE
MNT_OMODE_USER
MNT_PREFIX
MNT_SUPERBLOCK
MNT_TABDIFF_MOUNT
MNT_TABDIFF_MOVE
MNT_TABDIFF_PROPAGATION
MNT_TABDIFF_REMOUNT
MNT_TABDIFF_UMOUNT
MNT_UNIQ_FORWARD
MNT_UNIQ_KEEPTREE
MNT_USERSPACE_MAP
MS_BIND
MS_DIRSYNC
MS_I_VERSION
MS_LAZYTIME
MS_MANDLOCK
MS_MGC_MSK
MS_MGC_VAL
MS_MOVE
MS_NOATIME
MS_NODEV
MS_NODIRATIME
MS_NOEXEC
MS_NOSUID
MS_NOSYMFOLLOW
MS_OWNERSECURE
MS_PRIVATE
MS_PROPAGATION
MS_RDONLY
MS_REC
MS_RELATIME
MS_REMOUNT
MS_SECURE
MS_SHARED
MS_SILENT
MS_SLAVE
MS_STRICTATIME
MS_SYNCHRONOUS
MS_UNBINDABLE

Functions§

mnt_cache_device_has_tag
mnt_cache_find_tag_value
mnt_cache_read_tags
mnt_cache_set_sbprobe
mnt_cache_set_targets
mnt_context_append_options
mnt_context_apply_fstab
mnt_context_disable_canonicalize
mnt_context_disable_helpers
mnt_context_disable_mtab
mnt_context_disable_swapmatch
mnt_context_do_mount
mnt_context_do_umount
mnt_context_enable_fake
mnt_context_enable_force
mnt_context_enable_fork
mnt_context_enable_lazy
mnt_context_enable_loopdel
mnt_context_enable_noautofs
mnt_context_enable_onlyonce
mnt_context_enable_rdonly_umount
mnt_context_enable_rwonly_mount
mnt_context_enable_sloppy
mnt_context_enable_verbose
mnt_context_finalize_mount
mnt_context_finalize_umount
mnt_context_find_umount_fs
mnt_context_force_unrestricted
mnt_context_forced_rdonly
mnt_context_get_cache
mnt_context_get_excode
mnt_context_get_fs
mnt_context_get_fs_userdata
mnt_context_get_fstab
mnt_context_get_fstab_userdata
mnt_context_get_fstype
mnt_context_get_helper_status
mnt_context_get_lock
mnt_context_get_mflags
mnt_context_get_mtab
mnt_context_get_mtab_userdata
mnt_context_get_options
mnt_context_get_optsmode
mnt_context_get_origin_ns
mnt_context_get_source
mnt_context_get_status
mnt_context_get_syscall_errno
mnt_context_get_table
mnt_context_get_target
mnt_context_get_target_ns
mnt_context_get_target_prefix
mnt_context_get_user_mflags
mnt_context_helper_executed
mnt_context_helper_setopt
mnt_context_init_helper
mnt_context_is_child
mnt_context_is_fake
mnt_context_is_force
mnt_context_is_fork
mnt_context_is_fs_mounted
mnt_context_is_lazy
mnt_context_is_loopdel
mnt_context_is_nocanonicalize
mnt_context_is_nohelpers
mnt_context_is_nomtab
mnt_context_is_onlyonce
mnt_context_is_parent
mnt_context_is_rdonly_umount
mnt_context_is_restricted
mnt_context_is_rwonly_mount
mnt_context_is_sloppy
mnt_context_is_swapmatch
mnt_context_is_verbose
mnt_context_mount
mnt_context_next_mount
mnt_context_next_remount
mnt_context_next_umount
mnt_context_prepare_mount
mnt_context_prepare_umount
mnt_context_reset_status
mnt_context_set_cache
mnt_context_set_fs
mnt_context_set_fstab
mnt_context_set_fstype
mnt_context_set_fstype_pattern
mnt_context_set_mflags
mnt_context_set_mountdata
mnt_context_set_options
mnt_context_set_options_pattern
mnt_context_set_optsmode
mnt_context_set_passwd_cb
mnt_context_set_source
mnt_context_set_syscall_status
mnt_context_set_tables_errcb
mnt_context_set_target
mnt_context_set_target_ns
mnt_context_set_target_prefix
mnt_context_set_user_mflags
mnt_context_strerror
mnt_context_switch_ns
mnt_context_switch_origin_ns
mnt_context_switch_target_ns
mnt_context_syscall_called
mnt_context_tab_applied
mnt_context_umount
mnt_context_wait_for_children
mnt_copy_fs
mnt_diff_tables
mnt_free_cache
mnt_free_context
mnt_free_fs
mnt_free_iter
mnt_free_lock
mnt_free_mntent
mnt_free_tabdiff
mnt_free_table
mnt_free_update
mnt_fs_append_attributes
mnt_fs_append_comment
mnt_fs_append_options
mnt_fs_get_attribute
mnt_fs_get_attributes
mnt_fs_get_bindsrc
mnt_fs_get_comment
mnt_fs_get_devno
mnt_fs_get_freq
mnt_fs_get_fs_options
mnt_fs_get_fstype
mnt_fs_get_id
mnt_fs_get_option
mnt_fs_get_optional_fields
mnt_fs_get_options
mnt_fs_get_parent_id
mnt_fs_get_passno
mnt_fs_get_priority
mnt_fs_get_propagation
mnt_fs_get_root
mnt_fs_get_size
mnt_fs_get_source
mnt_fs_get_srcpath
mnt_fs_get_swaptype
mnt_fs_get_table
mnt_fs_get_tag
mnt_fs_get_target
mnt_fs_get_tid
mnt_fs_get_usedsize
mnt_fs_get_user_options
mnt_fs_get_userdata
mnt_fs_get_vfs_options
mnt_fs_get_vfs_options_all
mnt_fs_is_kernel
mnt_fs_is_netfs
mnt_fs_is_pseudofs
mnt_fs_is_regularfs
mnt_fs_is_swaparea
mnt_fs_match_fstype
mnt_fs_match_options
mnt_fs_match_source
mnt_fs_match_target
mnt_fs_prepend_attributes
mnt_fs_prepend_options
mnt_fs_print_debug
mnt_fs_set_attributes
mnt_fs_set_bindsrc
mnt_fs_set_comment
mnt_fs_set_freq
mnt_fs_set_fstype
mnt_fs_set_options
mnt_fs_set_passno
mnt_fs_set_priority
mnt_fs_set_root
mnt_fs_set_source
mnt_fs_set_target
mnt_fs_set_userdata
mnt_fs_strdup_options
mnt_fs_streq_srcpath
mnt_fs_streq_target
mnt_fs_to_mntent
mnt_fstype_is_netfs
mnt_fstype_is_pseudofs
mnt_get_builtin_optmap
mnt_get_fstab_path
mnt_get_fstype
mnt_get_library_features
mnt_get_library_version
mnt_get_mountpoint
mnt_get_mtab_path
mnt_get_swaps_path
mnt_guess_system_root
mnt_has_regular_mtab
mnt_init_debug
mnt_iter_get_direction
mnt_lock_block_signals
mnt_lock_file
mnt_mangle
mnt_match_fstype
mnt_match_options
mnt_monitor_close_fd
mnt_monitor_enable_kernel
mnt_monitor_enable_userspace
mnt_monitor_event_cleanup
mnt_monitor_get_fd
mnt_monitor_next_change
mnt_monitor_wait
mnt_new_cache
mnt_new_context
mnt_new_fs
mnt_new_iter
mnt_new_lock
mnt_new_monitor
mnt_new_tabdiff
mnt_new_table
mnt_new_table_from_dir
mnt_new_table_from_file
mnt_new_update
mnt_optstr_append_option
mnt_optstr_apply_flags
mnt_optstr_deduplicate_option
mnt_optstr_get_flags
mnt_optstr_get_option
mnt_optstr_get_options
mnt_optstr_next_option
mnt_optstr_prepend_option
mnt_optstr_remove_option
mnt_optstr_set_option
mnt_parse_version_string
mnt_pretty_path
mnt_ref_cache
mnt_ref_fs
mnt_ref_monitor
mnt_ref_table
mnt_reset_context
mnt_reset_fs
mnt_reset_iter
mnt_reset_table
mnt_resolve_path
mnt_resolve_spec
mnt_resolve_tag
mnt_resolve_target
mnt_split_optstr
mnt_tabdiff_next_change
mnt_table_add_fs
mnt_table_append_intro_comment
mnt_table_append_trailing_comment
mnt_table_enable_comments
mnt_table_find_devno
mnt_table_find_fs
mnt_table_find_mountpoint
mnt_table_find_next_fs
mnt_table_find_pair
mnt_table_find_source
mnt_table_find_srcpath
mnt_table_find_tag
mnt_table_find_target
mnt_table_find_target_with_option
mnt_table_first_fs
mnt_table_get_cache
mnt_table_get_intro_comment
mnt_table_get_nents
mnt_table_get_root_fs
mnt_table_get_trailing_comment
mnt_table_get_userdata
mnt_table_insert_fs
mnt_table_is_empty
mnt_table_is_fs_mounted
mnt_table_last_fs
mnt_table_move_fs
mnt_table_next_child_fs
mnt_table_next_fs
mnt_table_over_fs
mnt_table_parse_dir
mnt_table_parse_file
mnt_table_parse_fstab
mnt_table_parse_mtab
mnt_table_parse_stream
mnt_table_parse_swaps
mnt_table_remove_fs
mnt_table_replace_file
mnt_table_set_cache
mnt_table_set_intro_comment
mnt_table_set_iter
mnt_table_set_parser_errcb
mnt_table_set_trailing_comment
mnt_table_set_userdata
mnt_table_uniq_fs
mnt_table_with_comments
mnt_table_write_file
mnt_tag_is_valid
mnt_unlock_file
mnt_unmangle
mnt_unref_cache
mnt_unref_fs
mnt_unref_monitor
mnt_unref_table
mnt_update_force_rdonly
mnt_update_get_filename
mnt_update_get_fs
mnt_update_get_mflags
mnt_update_is_ready
mnt_update_set_fs
mnt_update_table

Type Aliases§

FILE
__dev_t
__off_t
__pid_t
_bindgen_ty_1
_bindgen_ty_2
_bindgen_ty_3
_bindgen_ty_4
_bindgen_ty_5
_bindgen_ty_6
_bindgen_ty_7
dev_t
off_t
pid_t