getCommonDirectory finds the common directory among the lowerDirs passed in. "/" and "." are considered invalid common directories and are treated as error
(lowerDirs []string)
| 303 | // getCommonDirectory finds the common directory among the lowerDirs passed in. |
| 304 | // "/" and "." are considered invalid common directories and are treated as error |
| 305 | func getCommonDirectory(lowerDirs []string) (string, error) { |
| 306 | commonPrefix := longestCommonPrefix(lowerDirs) |
| 307 | if commonPrefix == "" { |
| 308 | return "", fmt.Errorf("no common prefix found") |
| 309 | } |
| 310 | |
| 311 | // Ensure the common prefix ends at a directory boundary |
| 312 | commonPrefix = path.Dir(commonPrefix) |
| 313 | |
| 314 | if commonPrefix == "." || commonPrefix == "/" { |
| 315 | return "", fmt.Errorf("invalid common directory: %s", commonPrefix) |
| 316 | } |
| 317 | |
| 318 | return commonPrefix, nil |
| 319 | } |
| 320 | |
| 321 | // buildIDMappedPaths constructs new lower directory paths through an idmapped mount of the commonDir. |
| 322 | // It takes the original lowerDirs, the commonDir of those dirs, and rewrites the paths |
searching dependent graphs…