MCPcopy
hub / github.com/containerd/containerd / Mount

Method Mount

plugins/mount/erofs/plugin_linux.go:52–160  ·  view source on GitHub ↗
(ctx context.Context, m mount.Mount, mp string, _ []mount.ActiveMount)

Source from the content-addressed store, hash-verified

50}
51
52func (h *erofsMountHandler) Mount(ctx context.Context, m mount.Mount, mp string, _ []mount.ActiveMount) (_ mount.ActiveMount, retErr error) {
53 if m.Type != "erofs" {
54 return mount.ActiveMount{}, errdefs.ErrNotImplemented
55 }
56
57 var dmverityDevice string
58 defer func() {
59 if retErr == nil || dmverityDevice == "" {
60 return
61 }
62 dmverity.Close(dmverityDevice)
63 }()
64
65 // Parse dm-verity metadata path from mount options
66 metadataPath := ""
67 for _, opt := range m.Options {
68 if path, ok := strings.CutPrefix(opt, "X-containerd.dmverity="); ok {
69 metadataPath = path
70 break
71 }
72 }
73
74 // Set up dm-verity device if metadata path is provided
75 if metadataPath != "" {
76 log.G(ctx).WithFields(log.Fields{
77 "source": m.Source,
78 "metadata-path": metadataPath,
79 }).Debug("setting up dm-verity device from mount option")
80
81 metadata, err := dmverity.ReadMetadata(metadataPath)
82 if err != nil {
83 return mount.ActiveMount{}, fmt.Errorf("failed to read dm-verity metadata from %s: %w", metadataPath, err)
84 }
85
86 devicePath, cleanupName, err := setupDmVerityDevice(ctx, m.Source, metadata)
87 dmverityDevice = cleanupName
88 if err != nil {
89 return mount.ActiveMount{}, err
90 }
91 m.Source = devicePath
92 }
93
94 filteredOptions := make([]string, 0, len(m.Options))
95 for _, v := range m.Options {
96 // Skip loop option (handled by loop device setup) and dmverity options (already processed)
97 if v == "loop" || strings.HasPrefix(v, "X-containerd.dmverity=") {
98 continue
99 }
100 filteredOptions = append(filteredOptions, v)
101 }
102 m.Options = filteredOptions
103
104 if err := os.MkdirAll(mp, 0700); err != nil {
105 return mount.ActiveMount{}, err
106 }
107
108 err := error(unix.ENOTBLK)
109 if !forceloop {

Callers

nothing calls this directly

Calls 8

CloseFunction · 0.92
ReadMetadataFunction · 0.92
SetupLoopFunction · 0.92
setupDmVerityDeviceFunction · 0.85
doMountFunction · 0.85
MkdirAllMethod · 0.65
NameMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected