mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-08-02 23:42:23 +00:00
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:
parent
ad11be6b83
commit
a39cee3f18
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user