MCPcopy
hub / github.com/opencontainers/runc / loadState

Function loadState

libcontainer/factory_linux.go:150–172  ·  view source on GitHub ↗
(root string)

Source from the content-addressed store, hash-verified

148}
149
150func loadState(root string) (*State, error) {
151 stateFilePath, err := securejoin.SecureJoin(root, stateFilename)
152 if err != nil {
153 return nil, err
154 }
155 f, err := os.Open(stateFilePath)
156 if err != nil {
157 if errors.Is(err, os.ErrNotExist) {
158 return nil, ErrNotExist
159 }
160 return nil, err
161 }
162 defer f.Close()
163 var state *State
164 if err := json.NewDecoder(f).Decode(&state); err != nil {
165 return nil, err
166 }
167 // Cgroup v1 fs manager expect Resources to never be nil.
168 if state.Config.Cgroups.Resources == nil {
169 state.Config.Cgroups.Resources = &cgroups.Resources{}
170 }
171 return state, nil
172}
173
174// validateID checks if the supplied container ID is valid, returning
175// the ErrInvalidID in case it is not.

Callers 1

LoadFunction · 0.85

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…