Nerves.Runtime.MountInfo (nerves_runtime v0.13.9)

View Source

Utilities for getting information about mounted filesystems Mount information is parsed from /proc/self/mountinfo. For complete field descriptions, see the Linux manual.

Summary

Types

A list of mount records

Information about a single mount point

Functions

Find mount information by its mount point

Returns information about all mounted filesystems

Parses mountinfo content into a list of mount_info structs.

Checks if a mount point is mounted read-only

Types

mount_info()

@type mount_info() :: [mount_record()]

A list of mount records

mount_record()

@type mount_record() :: %{
  mount_id: integer(),
  parent_id: integer(),
  major_minor: String.t(),
  root: String.t(),
  mount_point: String.t(),
  mount_options: [String.t()],
  optional_fields: [String.t()],
  fs_type: String.t(),
  mount_source: String.t(),
  super_options: [String.t()]
}

Information about a single mount point

Each mount record contains the following fields:

  • mount_id - a unique identifier for the mount
  • parent_id - the ID of the parent mount
  • major_minor - the major:minor device number
  • root - the pathname of the directory in the filesystem which forms the root of this mount
  • mount_point - the pathname of the mount point relative to the process's root directory
  • mount_options - per-mount options
  • optional_fields - zero or more fields of the form tag[:value]
  • fs_type - the filesystem type in the form type[.subtype]
  • mount_source - filesystem-specific information or none
  • super_options - per-superblock options

Functions

find_by_mount_point(mounts \\ get_mounts!(), target)

@spec find_by_mount_point(mount_info(), String.t()) :: mount_record() | nil

Find mount information by its mount point

get_mounts!()

@spec get_mounts!() :: mount_info()

Returns information about all mounted filesystems

Raises an exception if /proc/self/mountinfo cannot be read, since this file is guaranteed to exist on Nerves and Linux systems.

parse(mountinfo_contents)

@spec parse(String.t()) :: mount_info()

Parses mountinfo content into a list of mount_info structs.

read_only?(mount_record)

@spec read_only?(mount_record()) :: boolean()

Checks if a mount point is mounted read-only

This checks the mount options to see if the file system was mounted read-only. It could have originally been mounted writable, but an error caused Linux to automatically remount it read-only.