From 3c5040b0f6a4f6ff3381e4d79afd36a27f891476 Mon Sep 17 00:00:00 2001 From: Tycho Andersen Date: Wed, 29 Mar 2017 21:37:15 -0600 Subject: [PATCH] init: fake supporting hard links slightly differently Instead, make a hard link a symlink. This isn't much better, but it allows some cases (e.g. installing GCC on moby via alpine) to work. Signed-off-by: Tycho Andersen --- src/initrd/initrd.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/initrd/initrd.go b/src/initrd/initrd.go index 528d7319f..9a0fa5b54 100644 --- a/src/initrd/initrd.go +++ b/src/initrd/initrd.go @@ -19,15 +19,16 @@ type Writer struct { cw *cpio.Writer } -func typeconv(t byte) int64 { - switch t { +func typeconv(thdr *tar.Header) int64 { + switch thdr.Typeflag { case tar.TypeReg: return cpio.TYPE_REG case tar.TypeRegA: return cpio.TYPE_REG - // Currently hard links not supported + // Currently hard links not supported very well :) case tar.TypeLink: - return cpio.TYPE_REG + thdr.Linkname = "/" + thdr.Linkname + return cpio.TYPE_SYMLINK case tar.TypeSymlink: return cpio.TYPE_SYMLINK case tar.TypeChar: @@ -54,7 +55,7 @@ func CopyTar(w *Writer, r *tar.Reader) (written int64, err error) { if err != nil { return } - tp := typeconv(thdr.Typeflag) + tp := typeconv(thdr) if tp == -1 { return written, errors.New("cannot convert tar file") }