-
-
Notifications
You must be signed in to change notification settings - Fork 417
Fix mountinfo parsing #153 #154
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
Conversation
We should probably add a test for various valid and/or problematic entries. |
Do you have any test cases in mind ? By reading the source code of glib:
I tested the encoded part
There was no need to go so far ... https://man7.org/linux/man-pages/man5/fstab.5.html
EDIT: @muesli ? |
That should we test for as well.
I agree. Nice work so far, will give this a proper review asap. |
@muesli , can you review ? 🙂 |
Signed-off-by: Adrien Kara <adrien@iglou.eu>
Added a getFields function to parse fields as defined in "proc(5)" section "/proc/[pid]/mountinfo". It is possible to use forbidden characters in the mountinfo file, for this Linux kernel encodes them https://github.com/torvalds/linux/blob/master/fs/proc_namespace.c#L87. Skip empty or commented lines. Signed-off-by: Adrien Kara <adrien@iglou.eu>
Signed-off-by: Adrien Kara <adrien@iglou.eu>
Signed-off-by: Adrien Kara <adrien@iglou.eu>
Signed-off-by: Adrien Kara <adrien@iglou.eu>
Signed-off-by: Adrien Kara <adrien@iglou.eu>
Signed-off-by: Adrien Kara <adrien@iglou.eu>
Signed-off-by: Adrien Kara <adrien@iglou.eu>
Ok, I've simplified the mountinfo parsing a bit. Everything seems to be working and testing fine, but maybe you wanna give it one more review as well. |
Cool, I hadn't seen it. Otherwise, it's good to me |
Quick patch to fix
#153 mount -t tmpfs - /tmp -> "found invalid line"
Split directly with strings.Fields instead of "(8) separator: marks the end of the optional fields"
Todo:
Spaces into "optional fields"(The Linux kernel test does not support space on it https://github.com/torvalds/linux/blob/e55f0c439a2681a3c299bedd99ebe998049fa508/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c#L124)Zero optional fields(It contains at least the type of mount (ro or rw) https://man7.org/linux/man-pages/man5/fstab.5.html https://man7.org/linux/man-pages/man5/proc.5.html)Non zero super optionsOptional fields((7) optional fields: zero or more fields of the form "tag[:value]")Signed-off-by: Adrien Kara adrien@iglou.eu