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)
| 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. |
| 59 | func 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 | // |
no test coverage detected
searching dependent graphs…