-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[disk][linux]: fix parsing mount option when use 1/mounts on Partition #1861
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
disk/disk_linux.go
Outdated
Opts: strings.Fields(fields[3]), | ||
Opts: strings.Split(fields[3], ","), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No test to update/add for the issue you describe?
7b5356f
to
d63507d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where mount options were incorrectly parsed when falling back to reading /proc/1/mounts, and it adds tests for the parsing functions.
- Fixes mount option parsing by splitting comma-separated options.
- Introduces dedicated functions parseFieldsOnMounts and parseFieldsOnMountinfo along with corresponding tests.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
disk/disk_linux_test.go | Added tests for both mountinfo and mounts parsing logic. |
disk/disk_linux.go | Updated the parsing logic and error handling in PartitionsWithContext. |
8224b2a
to
9896b27
Compare
451e4cf
to
0e773f1
Compare
Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
0e773f1
to
d3578cf
Compare
This fixes #1858.
On
disk.Parition()
When we can not read/proc/1/mountinfo
because version <2.6.26, fallback to read/proc/1/mounts
. However, mount options are not splitted.Here is a example line of
mounts
,and this is parsed like this,
opts
is just one long line.This PR fixes this issue.
Add tests
This PR also split parse to
parseFieldsOnMounts
andparseFieldsOnMountinfo
. These functions are used according to which file is used. And also introduce tests for those functions.