muesli/duf · critical

reading mountinfo %q: %w

Error message

reading mountinfo %q: %w

What it means

The mounts function on Linux reads /proc/self/mountinfo via readLines. If that read fails (missing file, permission problem, or I/O error), it wraps the cause as "reading mountinfo %q: %w". The mount table is essential input, so the error aborts mount enumeration.

Source

Thrown at mounts_linux.go:58

	// (9) mount source: filesystem specific information or "none".
	mountinfoMountSource = 9
	// (10) super options: per super block options.
	mountinfoSuperOptions = 10
)

// Stat returns the mountpoint's stat information.
func (m *Mount) Stat() unix.Statfs_t {
	return m.Metadata.(unix.Statfs_t)
}

func mounts() ([]Mount, []string, error) {
	var warnings []string

	filename := "/proc/self/mountinfo"
	lines, err := readLines(filename)
	if err != nil {
		// wrapcheck: add context to the error.
		return nil, nil, fmt.Errorf("reading mountinfo %q: %w", filename, err)
	}

	ret := make([]Mount, 0, len(lines))
	for _, line := range lines {
		nb, fields := parseMountInfoLine(line)
		if nb == 0 {
			continue
		}

		// if the number of fields does not match the structure of mountinfo,
		// emit a warning and ignore the line.
		if nb < 10 || nb > 11 {
			warnings = append(warnings, fmt.Sprintf("found invalid mountinfo line: %s", line))
			continue
		}

		// blockDeviceID := fields[mountinfoMountID]
		mountPoint := fields[mountinfoMountPoint]

View on GitHub (pinned to 4636deb4a7)

Solutions

  1. Ensure /proc is mounted in the environment (e.g. mount -t proc proc /proc in containers).
  2. Check the wrapped %w error to see the underlying cause (ENOENT vs EACCES).
  3. Run the program with sufficient permissions or outside the restricting sandbox.
  4. Fall back to a different mount enumeration API if available in your environment.

Example fix

// docker run without proc
$ docker run --rm app
// after
$ docker run --rm -v /proc:/proc:ro app  # or just ensure default /proc is present
Defensive patterns

Strategy: fallback

Validate before calling

if _, err := os.Stat("/proc/self/mountinfo"); err != nil {
	log.Fatal("/proc is not available: ", err)
}

Try / catch

mounts, warns, err := mounts()
if err != nil {
	if errors.Is(err, os.ErrPermission) || errors.Is(err, os.ErrNotExist) {
		log.Fatal("procfs unavailable: ", err)
	}
}

Prevention

When it happens

Trigger: readLines("/proc/self/mountinfo") returns an error: the proc filesystem is not mounted, the file is unreadable due to sandboxing/permissions, or a transient I/O error occurs.

Common situations: Running inside minimal containers without /proc mounted, restricted sandboxes (seccomp/AppArmor) blocking /proc access, or unusual environments where procfs is hidden.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of muesli/duf@4636deb4a7 (2026-09-06). Data as JSON: /api/errors/6f41ee0ae87efca0. Report an issue: GitHub.