Skip to content

fix(disk): stop dropping filesystems whose mount point has unusual ch… - #1063

Merged
kesselb merged 1 commit into
masterfrom
fix/disk-info-mount-point-parsing
Aug 2, 2026
Merged

kesselb merged 1 commit into
masterfrom
fix/disk-info-mount-point-parsing

Conversation

@karlitschek

@karlitschek karlitschek commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

…aracters

getDiskInfo() matched the mount point against a character class — [\w/-.] on Linux, [\w/-] on FreeBSD, which did not even allow a dot. A mount point containing anything outside that set failed the whole line, and because the pattern is applied per line with preg_match_all, failing the line removed the entire filesystem from the report. No warning and no log entry: it simply was not there.

A space is enough. So is a non-ASCII character, since \w does not cover one without the unicode flag, and so are brackets. On the new fixture the old Linux pattern matches 1 of 5 filesystems.

df -P exists precisely so that output is machine readable: one record per line, no wrapping, and the mount point last. The mount point is therefore everything after the capacity column, which is what the pattern now says instead of trying to predict which characters can appear in a path.

Two smaller changes in the same expression:

Separators are now \s+ rather than \s*. The columns are whitespace separated, so allowing zero whitespace only worked by backtracking.

Used and Capacity are now matched as \S+ rather than requiring digits and a literal percent sign. Nothing reads either of them — used is recomputed from Blocks minus Available — and df prints "-" in them for filesystems that do not report usage, which was another way for a row to disappear. Blocks and Available still require digits, because those are the values actually used.

Verified by running the new tests against the unfixed collectors: Linux reports 1 filesystem where 5 are expected, FreeBSD 1 where 4 are expected, and both pass after the change. The existing 7-disk expectation is untouched, so the new pattern is a superset of the old one on output that already parsed. FreeBSD's getDiskInfo() had no coverage at all and gains its first.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@kesselb
kesselb force-pushed the fix/disk-info-mount-point-parsing branch from 3357bab to 26dd51c Compare August 2, 2026 20:50
`df -P` prints one record per line with the mount point last, so take
everything after the capacity column as the mount point. Filesystems mounted
under a path containing a space, a dot or a non-ASCII character are reported
again.

Used and Capacity are matched as \S+ so that filesystems printing "-" there
are reported too. Blocks and Available still require digits; they are the
only values read.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: Frank Karlitschek <karlitschek@users.noreply.github.com>
@kesselb
kesselb force-pushed the fix/disk-info-mount-point-parsing branch from 26dd51c to 7ad5236 Compare August 2, 2026 20:55
@kesselb
kesselb enabled auto-merge August 2, 2026 20:55
@kesselb kesselb added this to the Nextcloud 35 milestone Aug 2, 2026
@kesselb
kesselb merged commit f699d08 into master Aug 2, 2026
43 checks passed
@kesselb
kesselb deleted the fix/disk-info-mount-point-parsing branch August 2, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants