-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmount.go
40 lines (32 loc) · 922 Bytes
/
mount.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"github.com/docker/docker/runconfig"
"syscall"
)
// (g *GraphTool) Mount ...
func (g *GraphTool) Mount(imageName string, dest string, options []string) error {
var err error
if err = g.InitDriver(); err != nil {
return err
}
image, err := g.LookupImage(imageName)
if image == nil {
return err
}
fake_image, err := g.graphHandler.Create(nil, "daedbeef", image.ID, "", "", &runconfig.Config{}, &runconfig.Config{})
if err != nil {
return err
}
path, _ := g.graphDriver.Get(fake_image.ID, "graphtool")
if err = syscall.Mount(path, dest, "none", syscall.MS_BIND, ""); err != nil {
return err
}
// We don't need the original reference anymore
// the bind mount is still the last reference to the filesystem
g.graphDriver.Put(fake_image.ID)
return nil
}
// (g *GraphTool) Unmount ...
func (g *GraphTool) Unmount(target string) error {
return syscall.Unmount(target, 0)
}