initrd: Skip rest of ./boot

For the initrd we only want to extract kernel, cmdline, and
the ucode CPIO archive. Skip whatever is left in ./boot

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2018-04-16 14:38:03 +01:00
parent ad11be6b83
commit a39cee3f18

View File

@ -8,6 +8,7 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"path/filepath" "path/filepath"
"strings"
"github.com/moby/tool/src/pad4" "github.com/moby/tool/src/pad4"
"github.com/surma/gocpio" "github.com/surma/gocpio"
@ -121,26 +122,26 @@ func CopySplitTar(w *Writer, r *tar.Reader) (kernel []byte, cmdline string, ucod
if err != nil { if err != nil {
return return
} }
switch thdr.Name { switch {
case "boot/kernel": case thdr.Name == "boot/kernel":
kernel, err = ioutil.ReadAll(r) kernel, err = ioutil.ReadAll(r)
if err != nil { if err != nil {
return return
} }
case "boot/cmdline": case thdr.Name == "boot/cmdline":
var buf []byte var buf []byte
buf, err = ioutil.ReadAll(r) buf, err = ioutil.ReadAll(r)
if err != nil { if err != nil {
return return
} }
cmdline = string(buf) cmdline = string(buf)
case "boot/ucode.cpio": case thdr.Name == "boot/ucode.cpio":
ucode, err = ioutil.ReadAll(r) ucode, err = ioutil.ReadAll(r)
if err != nil { if err != nil {
return return
} }
case "boot": case strings.HasPrefix(thdr.Name, "boot/"):
// skip this entry // skip the rest of ./boot
default: default:
_, err = copyTarEntry(w, thdr, r) _, err = copyTarEntry(w, thdr, r)
if err != nil { if err != nil {