MCPcopy
hub / github.com/containerd/containerd / prepareIDMappedOverlay

Function prepareIDMappedOverlay

core/mount/mount_linux.go:59–74  ·  view source on GitHub ↗

prepareIDMappedOverlay is a helper function to obtain actual "lowerdir=..." mount options. It creates and applies id mapping for each lowerdir. It returns: 1. New options that include new "lowedir=..." mount option. 2. "Clean up" function -- it should be called only if no error is returned. 3. Erro

(usernsFd int, options []string)

Source from the content-addressed store, hash-verified

57// 2. "Clean up" function -- it should be called only if no error is returned.
58// 3. Error -- nil if everything's fine, otherwise an error.
59func prepareIDMappedOverlay(usernsFd int, options []string) ([]string, func(), error) {
60 lowerIdx, lowerDirs := findOverlayLowerdirs(options)
61 if lowerIdx == -1 {
62 return options, nil, fmt.Errorf("failed to parse overlay lowerdir's from given options")
63 }
64
65 tmpLowerdirs, idMapCleanUp, err := doPrepareIDMappedOverlay(tempMountLocation, lowerDirs, usernsFd)
66 if err != nil {
67 return options, idMapCleanUp, fmt.Errorf("failed to create idmapped mount: %w", err)
68 }
69
70 options = append(options[:lowerIdx], options[lowerIdx+1:]...)
71 options = append(options, fmt.Sprintf("lowerdir=%s", strings.Join(tmpLowerdirs, ":")))
72
73 return options, idMapCleanUp, nil
74}
75
76// Mount to the provided target path.
77//

Callers 1

mountMethod · 0.85

Calls 2

findOverlayLowerdirsFunction · 0.85
doPrepareIDMappedOverlayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…