(ctx context.Context, m Mount, mp string, _ []ActiveMount)
| 34 | } |
| 35 | |
| 36 | func (loopbackHandler) Mount(ctx context.Context, m Mount, mp string, _ []ActiveMount) (ActiveMount, error) { |
| 37 | if m.Type != "loop" { |
| 38 | return ActiveMount{}, errdefs.ErrNotImplemented |
| 39 | } |
| 40 | params := LoopParams{ |
| 41 | Autoclear: true, |
| 42 | } |
| 43 | // TODO: Handle readonly |
| 44 | // TODO: Handle direct io |
| 45 | |
| 46 | t := time.Now() |
| 47 | loop, err := SetupLoop(m.Source, params) |
| 48 | if err != nil { |
| 49 | return ActiveMount{}, err |
| 50 | } |
| 51 | defer loop.Close() |
| 52 | |
| 53 | if err := os.Symlink(loop.Name(), mp); err != nil { |
| 54 | return ActiveMount{}, err |
| 55 | } |
| 56 | |
| 57 | if err := setLoopAutoclear(loop, false); err != nil { |
| 58 | return ActiveMount{}, err |
| 59 | } |
| 60 | |
| 61 | return ActiveMount{ |
| 62 | Mount: m, |
| 63 | MountedAt: &t, |
| 64 | MountPoint: mp, |
| 65 | }, nil |
| 66 | } |
| 67 | |
| 68 | func (loopbackHandler) Unmount(ctx context.Context, path string) error { |
| 69 | loopdev, err := os.Readlink(path) |
nothing calls this directly
no test coverage detected