MCPcopy
hub / github.com/containerd/containerd / createImgFile

Function createImgFile

integration/client/mount_manager_linux_test.go:191–221  ·  view source on GitHub ↗
(t *testing.T, name string)

Source from the content-addressed store, hash-verified

189}
190
191func createImgFile(t *testing.T, name string) string {
192 mkfs, err := exec.LookPath("mkfs.xfs")
193 if err != nil {
194 t.Skipf("Could not find mkfs.xfs: %v", err)
195 }
196
197 loopbackSize := int64(300 << 20) // 300 MB
198
199 f := filepath.Join(t.TempDir(), name)
200 devFile, err := os.OpenFile(f, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
201 require.NoError(t, err)
202
203 if err := devFile.Truncate(loopbackSize); err != nil {
204 devFile.Close()
205 t.Fatalf("failed to resize %s file: %v", f, err)
206 }
207
208 if err := devFile.Sync(); err != nil {
209 devFile.Close()
210 t.Fatalf("failed to sync %s file: %v", f, err)
211 }
212 devFile.Close()
213
214 if out, err := exec.Command(mkfs, f).CombinedOutput(); err != nil {
215 t.Fatalf("failed to make xfs filesystem (out: %q): %v", out, err)
216 }
217
218 setupMount(t, f)
219
220 return f
221}
222
223func setupMount(t *testing.T, f string) {
224 root := t.TempDir()

Callers 1

TestMountAtRuntimeFunction · 0.85

Calls 4

setupMountFunction · 0.85
TruncateMethod · 0.65
CloseMethod · 0.65
SyncMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…