MCPcopy
hub / github.com/containerd/containerd / getCommonDirectory

Function getCommonDirectory

core/mount/mount_linux.go:305–319  ·  view source on GitHub ↗

getCommonDirectory finds the common directory among the lowerDirs passed in. "/" and "." are considered invalid common directories and are treated as error

(lowerDirs []string)

Source from the content-addressed store, hash-verified

303// getCommonDirectory finds the common directory among the lowerDirs passed in.
304// "/" and "." are considered invalid common directories and are treated as error
305func 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

Callers 2

TestGetCommonDirectoryFunction · 0.85
doPrepareIDMappedOverlayFunction · 0.85

Calls 2

longestCommonPrefixFunction · 0.85
DirMethod · 0.80

Tested by 1

TestGetCommonDirectoryFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…