Remove loopback mount bind
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume.charmes@docker.com> (github: creack)
This commit is contained in:
parent
4f641377e0
commit
a8b87a47b6
1 changed files with 5 additions and 22 deletions
|
@ -38,9 +38,8 @@ func setupNewMountNamespace(rootfs, console string, readonly bool) error {
|
||||||
if err := copyDevNodes(rootfs); err != nil {
|
if err := copyDevNodes(rootfs); err != nil {
|
||||||
return fmt.Errorf("copy dev nodes %s", err)
|
return fmt.Errorf("copy dev nodes %s", err)
|
||||||
}
|
}
|
||||||
if err := setupLoopbackDevices(rootfs); err != nil {
|
// In non-privileged mode, this fails. Discard the error.
|
||||||
return fmt.Errorf("setup loopback devices %s", err)
|
setupLoopbackDevices(rootfs)
|
||||||
}
|
|
||||||
if err := setupDev(rootfs); err != nil {
|
if err := setupDev(rootfs); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -102,29 +101,13 @@ func copyDevNodes(rootfs string) error {
|
||||||
|
|
||||||
func setupLoopbackDevices(rootfs string) error {
|
func setupLoopbackDevices(rootfs string) error {
|
||||||
for i := 0; ; i++ {
|
for i := 0; ; i++ {
|
||||||
var (
|
if err := copyDevNode(rootfs, fmt.Sprintf("loop%d", i)); err != nil {
|
||||||
device = fmt.Sprintf("loop%d", i)
|
|
||||||
source = filepath.Join("/dev", device)
|
|
||||||
dest = filepath.Join(rootfs, "dev", device)
|
|
||||||
)
|
|
||||||
|
|
||||||
if _, err := os.Stat(source); err != nil {
|
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
break
|
||||||
}
|
|
||||||
if _, err := os.Stat(dest); err == nil {
|
|
||||||
os.Remove(dest)
|
|
||||||
}
|
|
||||||
f, err := os.Create(dest)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
f.Close()
|
|
||||||
if err := system.Mount(source, dest, "none", syscall.MS_BIND, ""); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue