From 3d9cd1e5f102d5e59011ec4baca2662f3dacbad4 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Wed, 9 Apr 2014 11:13:54 -0600 Subject: [PATCH] Fix spurious mtab symlink error when /etc doesn't exist yet symlink /proc/mounts /var/lib/docker/btrfs/subvolumes/1763d6602b8b871f0a79754f1cb0a31b3928bb95de5232b1b8c15c60fa1017f6-init/etc/mtab: no such file or directory Docker-DCO-1.1-Signed-off-by: Andrew Page (github: tianon) --- graph/graph.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/graph/graph.go b/graph/graph.go index 5b08ce3cf1..9ebfc3daa6 100644 --- a/graph/graph.go +++ b/graph/graph.go @@ -272,15 +272,15 @@ func SetupInitLayer(initLayer string) error { if _, err := os.Stat(path.Join(initLayer, pth)); err != nil { if os.IsNotExist(err) { + if err := os.MkdirAll(path.Join(initLayer, path.Dir(pth)), 0755); err != nil { + return err + } switch typ { case "dir": if err := os.MkdirAll(path.Join(initLayer, pth), 0755); err != nil { return err } case "file": - if err := os.MkdirAll(path.Join(initLayer, path.Dir(pth)), 0755); err != nil { - return err - } f, err := os.OpenFile(path.Join(initLayer, pth), os.O_CREATE, 0755) if err != nil { return err