MCPcopy Create free account
hub / github.com/containerd/nerdctl / fsWrite

Function fsWrite

pkg/netutil/store.go:62–74  ·  view source on GitHub ↗
(e *CNIEnv, net *NetworkConfig)

Source from the content-addressed store, hash-verified

60}
61
62func fsWrite(e *CNIEnv, net *NetworkConfig) error {
63 filename := getConfigPathForNetworkName(e, net.Name)
64 // FIXME: note that this is still problematic.
65 // Concurrent access may independently first figure out that a given network is missing, and while the lock
66 // here will prevent concurrent writes, one of the routines will fail.
67 // Consuming code MUST account for that scenario.
68 return filesystem.WithLock(filepath.Join(e.NetconfPath, ".nerdctl.lock"), func() error {
69 if _, err := os.Stat(filename); err == nil {
70 return errdefs.ErrAlreadyExists
71 }
72 return filesystem.WriteFile(filename, net.Bytes, 0644)
73 })
74}
75
76func fsRead(e *CNIEnv) ([]*NetworkConfig, error) {
77 var nc []*NetworkConfig

Callers 1

CreateNetworkMethod · 0.85

Calls 4

WithLockFunction · 0.92
WriteFileFunction · 0.92
StatMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…