Skip to content

Commit

Permalink
fix: mountinfo parsing
Browse files Browse the repository at this point in the history
Fix the parsing of mountinfo when super options has fields with spaces
in, which is the case on WSL as it includes path=C:\\Program Files\...

Fixes uber-go#72
  • Loading branch information
stevenh committed Jul 1, 2023
1 parent d064ede commit 820227b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/cgroups/mountpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ func NewMountPointFromLine(line string) (*MountPoint, error) {

for i, field := range fields[_miFieldIDOptionalFields:] {
if field == _mountInfoOptionalFieldsSep {
// End of optional fields.
fsTypeStart := _miFieldIDOptionalFields + i + 1

// Now we know where the optional fields end, split the line again with a
// limit to avoid issues with spaces in super options as present on WSL.
fields = strings.SplitN(line, _mountInfoSep, fsTypeStart+_miFieldCountSecondHalf)
if len(fields) != fsTypeStart+_miFieldCountSecondHalf {
return nil, mountPointFormatInvalidError{line}
}
Expand Down

0 comments on commit 820227b

Please sign in to comment.