Skip to content

Decode every escape in /proc/self/mounts, not only spaces - #73

Open
kevin9327 wants to merge 1 commit into
tobi:mainfrom
kevin9327:mounts-escapes
Open

kevin9327 wants to merge 1 commit into
tobi:mainfrom
kevin9327:mounts-escapes

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

parse_mounts and device_in read /proc/self/mounts but only turn \040 back into a space. The kernel escapes four characters in these fields (space \040, tab \011, newline \012, backslash \134), and parse_mountinfo already decodes all of them in one pass with unescape_octal. So the same mount can come out differently depending on which table was read:

/dev/sda1 /media/My\040Disk\134040 ext4 rw 0 0
  • parse_mountinfo → /media/My Disk\040 (correct)
  • parse_mounts → /media/My Disk\134040 before this change, so the point never matches a real path

The same happens for a mount point with a tab or backslash in its name, and for a source with a space (//nas/My\040Share). parse_mounts feeds the removal guard's mount points (read_mount_points), foreign_mounts, volume_root and the volume list, so such a mount point isn't recognized as one there.

This uses unescape_octal for the source and mount point in parse_mounts and device_in, the two fields parse_mountinfo decodes.

Test: mounts_escapes_are_decoded_once, mirroring mountinfo_escapes_are_decoded_once for parse_mounts and device_in. It fails on main (left: "/media/My Disk\\134040") and passes with the change.

cargo test -p disktree-core --lib     # 137 passed; the same 4 failures as on main here
                                      # (trash / one-volume tests that depend on this sandbox's mounts)
cargo clippy -p disktree-core --all-targets
cargo fmt --check

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant