From a39cee3f18b26442b7be872d426932961c007c86 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Mon, 16 Apr 2018 14:38:03 +0100 Subject: [PATCH] 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 --- src/initrd/initrd.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/initrd/initrd.go b/src/initrd/initrd.go index 2a4a27a06..6575cdf85 100644 --- a/src/initrd/initrd.go +++ b/src/initrd/initrd.go @@ -8,6 +8,7 @@ import ( "io" "io/ioutil" "path/filepath" + "strings" "github.com/moby/tool/src/pad4" "github.com/surma/gocpio" @@ -121,26 +122,26 @@ func CopySplitTar(w *Writer, r *tar.Reader) (kernel []byte, cmdline string, ucod if err != nil { return } - switch thdr.Name { - case "boot/kernel": + switch { + case thdr.Name == "boot/kernel": kernel, err = ioutil.ReadAll(r) if err != nil { return } - case "boot/cmdline": + case thdr.Name == "boot/cmdline": var buf []byte buf, err = ioutil.ReadAll(r) if err != nil { return } cmdline = string(buf) - case "boot/ucode.cpio": + case thdr.Name == "boot/ucode.cpio": ucode, err = ioutil.ReadAll(r) if err != nil { return } - case "boot": - // skip this entry + case strings.HasPrefix(thdr.Name, "boot/"): + // skip the rest of ./boot default: _, err = copyTarEntry(w, thdr, r) if err != nil {