{"record":{"id":"6f41ee0ae87efca0","repo":"muesli/duf","slug":"reading-mountinfo-q-w","errorCode":null,"errorMessage":"reading mountinfo %q: %w","messagePattern":"reading mountinfo %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"mounts_linux.go","lineNumber":58,"sourceCode":"\t// (9) mount source: filesystem specific information or \"none\".\n\tmountinfoMountSource = 9\n\t// (10) super options: per super block options.\n\tmountinfoSuperOptions = 10\n)\n\n// Stat returns the mountpoint's stat information.\nfunc (m *Mount) Stat() unix.Statfs_t {\n\treturn m.Metadata.(unix.Statfs_t)\n}\n\nfunc mounts() ([]Mount, []string, error) {\n\tvar warnings []string\n\n\tfilename := \"/proc/self/mountinfo\"\n\tlines, err := readLines(filename)\n\tif err != nil {\n\t\t// wrapcheck: add context to the error.\n\t\treturn nil, nil, fmt.Errorf(\"reading mountinfo %q: %w\", filename, err)\n\t}\n\n\tret := make([]Mount, 0, len(lines))\n\tfor _, line := range lines {\n\t\tnb, fields := parseMountInfoLine(line)\n\t\tif nb == 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\t// if the number of fields does not match the structure of mountinfo,\n\t\t// emit a warning and ignore the line.\n\t\tif nb < 10 || nb > 11 {\n\t\t\twarnings = append(warnings, fmt.Sprintf(\"found invalid mountinfo line: %s\", line))\n\t\t\tcontinue\n\t\t}\n\n\t\t// blockDeviceID := fields[mountinfoMountID]\n\t\tmountPoint := fields[mountinfoMountPoint]","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/muesli/duf/blob/4636deb4a7b707a9f04c602db033f9837e50b3f6/mounts_linux.go#L40-L76","documentation":"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.","triggerScenarios":"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.","commonSituations":"Running inside minimal containers without /proc mounted, restricted sandboxes (seccomp/AppArmor) blocking /proc access, or unusual environments where procfs is hidden.","solutions":["Ensure /proc is mounted in the environment (e.g. mount -t proc proc /proc in containers).","Check the wrapped %w error to see the underlying cause (ENOENT vs EACCES).","Run the program with sufficient permissions or outside the restricting sandbox.","Fall back to a different mount enumeration API if available in your environment."],"exampleFix":"// docker run without proc\n$ docker run --rm app\n// after\n$ docker run --rm -v /proc:/proc:ro app  # or just ensure default /proc is present","handlingStrategy":"fallback","validationCode":"if _, err := os.Stat(\"/proc/self/mountinfo\"); err != nil {\n\tlog.Fatal(\"/proc is not available: \", err)\n}","typeGuard":null,"tryCatchPattern":"mounts, warns, err := mounts()\nif err != nil {\n\tif errors.Is(err, os.ErrPermission) || errors.Is(err, os.ErrNotExist) {\n\t\tlog.Fatal(\"procfs unavailable: \", err)\n\t}\n}","preventionTips":["Ensure /proc is mounted when running in containers.","Check sandbox/seccomp policies allow reading /proc/self/mountinfo.","Prefer running the tool in an environment with standard procfs access."],"tags":["go","linux","filesystem","procfs"],"backgroundTag":"file-read-failed","analyzedSha":"4636deb4a7b707a9f04c602db033f9837e50b3f6","analyzedAt":"2026-09-06T02:31:58.576Z","contentChangedAt":"2026-09-06T02:31:58.576Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}