Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

facts: server.Mounts: fix whitespaces and escaped characters #1313

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

lemmi
Copy link
Contributor

@lemmi lemmi commented Mar 18, 2025

The mount command can not be parsed unambigiously. Whitespaces in paths and , in option lists are not escaped. See the new tests for examples the old code can not handle.

This patch switches to reading from /proc/self/mountinfo instead (see man 5 proc for documentation) where strings are properly escaped.

While /proc/self/mountinfo provides a lot more details, these are ignored to keep compatibility with the old type. If there is a need, the missing fields can be easily added.

@Fizzadar 461d8ec introduced handling "map devices". I'm not sure what they are. I'd love to see a line from /proc/self/mountinfo, so we can test against that.

@lemmi lemmi force-pushed the server.Mounts branch 2 times, most recently from 72b64f1 to 844e816 Compare March 18, 2025 08:47
Copy link
Member

@Fizzadar Fizzadar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this is a great change @lemmi!

@Fizzadar 461d8ec introduced handling "map devices". I'm not sure what they are. I'd love to see a line from /proc/self/mountinfo, so we can test against that.

Heh.. I'm not sure I remember, will see if I can dig up some more info on that..

The `mount` command can not be parsed unambigiously. Whitespaces in paths
and , in option lists are not escaped. See the new tests for examples
the old code can not handle.

This patch switches to reading from `/proc/self/mountinfo` instead (see man 5
proc for documentation) where strings are properly escaped.

While `/proc/self/mountinfo` provides a lot more details, these are
ignored to keep compatibility with the old type. If there is a need, the
missing fields can be easily added.
@lemmi
Copy link
Contributor Author

lemmi commented Mar 27, 2025

Heh.. I'm not sure I remember, will see if I can dig up some more info on that..

I think I saw something related to lvm volumes. But I'm not using them anywhere at the moment.

I had another look into how exactly the kernel escapes the strings to get rid of the encode().decode(...) chain and replaced that with a specific conversion.

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.

2 participants