Cope with double quotes in Linux Mountinfo

Signed-off-by: Johannes Frey <me@johannes-frey.de>
This commit is contained in:
Johannes Frey
2020-06-16 08:53:36 +02:00
parent 705b8527d4
commit 87f9fdb065
2 changed files with 50 additions and 2 deletions

View File

@@ -81,11 +81,11 @@ func parseInfoFile(r io.Reader) ([]Info, error) {
p.Major, _ = strconv.Atoi(mm[0])
p.Minor, _ = strconv.Atoi(mm[1])
p.Root, err = strconv.Unquote(`"` + fields[3] + `"`)
p.Root, err = strconv.Unquote(`"` + strings.Replace(fields[3], `"`, `\"`, -1) + `"`)
if err != nil {
return nil, errors.Wrapf(err, "parsing '%s' failed: unable to unquote root field", fields[3])
}
p.Mountpoint, err = strconv.Unquote(`"` + fields[4] + `"`)
p.Mountpoint, err = strconv.Unquote(`"` + strings.Replace(fields[4], `"`, `\"`, -1) + `"`)
if err != nil {
return nil, errors.Wrapf(err, "parsing '%s' failed: unable to unquote mount point field", fields[4])
}