MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / Allocate

Method Allocate

pkg/funclet/storage/loop/loop.go:40–57  ·  view source on GitHub ↗
(fpath string, size uint64)

Source from the content-addressed store, hash-verified

38type storageTypeLoop struct{}
39
40func (s *storageTypeLoop) Allocate(fpath string, size uint64) (storagePath string, err error) {
41
42 if err := file.CreateFile(fpath, int64(size)); err != nil {
43 logs.Errorf("create tmp storage failed: %s", err)
44 return "", err
45 }
46 logs.Infof("finish prepare tmp storage")
47
48 // generate loop device for tmp
49 logs.Infof("start attach loop device for tmp storage")
50 tmpDevice, err := loop.Attach(fpath, 0, false)
51 if err != nil {
52 logs.Errorf("attach tmp storage failed:", err)
53 return "", err
54 }
55 storagePath = tmpDevice.Path()
56 return storagePath, nil
57}
58
59func (s *storageTypeLoop) Recycle() {
60 go recycleLoopDevice()

Callers

nothing calls this directly

Calls 5

CreateFileFunction · 0.92
ErrorfFunction · 0.92
InfofFunction · 0.92
AttachFunction · 0.92
PathMethod · 0.45

Tested by

no test coverage detected