func parseMountEntry()

in gce-containers-startup/volumes/volumes.go [148:170]


func parseMountEntry(entry string) (*mount, error) {
	if strings.HasPrefix(entry, "#") { // The entry is a comment.
		return nil, nil
	}
	parts := strings.Split(entry, " ")
	if len(parts) < 4 {
		return nil, fmt.Errorf("invalid format: expected at least 4 space-separated columns")
	}
	// There may be 4 escaped characters (space (\040), tab (\011), newline (\012)
	// and backslash (\134)), so we unescape them if necessary.
	unescape := strings.NewReplacer(
		`\040`, "\040",
		`\011`, "\011",
		`\012`, "\012",
		`\134`, "\134",
	)
	return &mount{
		device:     unescape.Replace(parts[0]),
		mountPoint: unescape.Replace(parts[1]),
		fsType:     unescape.Replace(parts[2]),
		options:    unescape.Replace(parts[3]),
	}, nil
}