MCPcopy
hub / github.com/containerd/containerd / Activate

Method Activate

core/mount/manager/manager.go:132–567  ·  view source on GitHub ↗
(ctx context.Context, name string, mounts []mount.Mount, opts ...mount.ActivateOpt)

Source from the content-addressed store, hash-verified

130}
131
132func (mm *mountManager) Activate(ctx context.Context, name string, mounts []mount.Mount, opts ...mount.ActivateOpt) (info mount.ActivationInfo, retErr error) {
133 namespace, err := namespaces.NamespaceRequired(ctx)
134 if err != nil {
135 return mount.ActivationInfo{}, err
136 }
137
138 // Serialize concurrent activations of the same name to prevent a
139 // racing Activate from misidentifying an in-progress activation as
140 // a stale record and destroying it.
141 if err := mm.activate.Lock(ctx, name); err != nil {
142 return mount.ActivationInfo{}, err
143 }
144 defer mm.activate.Unlock(name)
145
146 log.G(ctx).WithField("name", name).WithField("mounts", mounts).Debugf("activating mount")
147
148 lid, leased := leases.FromContext(ctx)
149
150 var config mount.ActivateOptions
151 for _, opt := range opts {
152 opt(&config)
153 }
154
155 shouldTransform := func(p string, t string) bool {
156 p = p + "/*"
157 for _, mt := range config.AllowMountTypes {
158 if mt == p || mt == t {
159 return false
160 }
161 }
162 return true
163 }
164
165 shouldHandle := func(t string) bool {
166 return !slices.Contains(config.AllowMountTypes, t)
167 }
168
169 transforms := map[string]mount.Transformer{
170 "format": mountFormatter{},
171 "mkfs": &mkfs{
172 rootMap: mm.rootMap,
173 },
174 "mkdir": &mkdir{
175 rootMap: mm.rootMap,
176 },
177 }
178
179 start := time.Now()
180 // highest index of a mount
181 // first system mount is the first index which should be mounted by the system
182 var firstSystemMount = -1
183 var mountConv [][]mount.Transformer
184 var handlers []mount.Handler
185 for i := range mounts {
186 mountType := mounts[i].Type
187
188 // Check is the source needs transformation, any transform operation requires
189 // mounting with the mount manager.

Callers

nothing calls this directly

Calls 15

NamespaceRequiredFunction · 0.92
FromContextFunction · 0.92
WriteLabelsFunction · 0.92
WriteTimestampsFunction · 0.92
UnmountFunction · 0.92
putActiveMountFunction · 0.85
putSystemMountFunction · 0.85
PutMethod · 0.80
readIDFunction · 0.70
encodeIDFunction · 0.70
unmountAllFunction · 0.70
LockMethod · 0.65

Tested by

no test coverage detected