Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 689952 - genkernel-4.0.0_beta3 doesn't handle firmware filenames containing spaces, when appending them to initramfs
Summary: genkernel-4.0.0_beta3 doesn't handle firmware filenames containing spaces, wh...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: genkernel (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2019-07-16 09:32 UTC by Mariusz Ceier
Modified: 2019-07-16 18:32 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mariusz Ceier 2019-07-16 09:32:55 UTC
I'm using genkernel-4.0.0_beta3 and executing `genkernel --menuconfig --firmware all`.
When genkernel starts appending firmware files to initramfs, ls prints errors:

*         >> Appending firmware cpio data ...
ls: cannot access './lib/firmware/brcm/brcmfmac43430a0-sdio.ONDA-V80': No such file or directory
ls: cannot access 'PLUS.txt': No such file or directory
*         >> Appending modules cpio data ...

In /lib/firmware/brcm path, there is 'brcmfmac43430a0-sdio.ONDA-V80 PLUS.txt' file which contains 1 space in name. It seems that genkernel doesn't handle it correctly.


Reproducible: Always

Steps to Reproduce:
1. emerge '=sys-kernel/gentoo-sources-5.2.1'
2. eselect kernel set linux-5.2.1-gentoo
3. genkernel --menuconfig --firmware all

Actual Results:  
Genkernel prints:

*         >> Appending firmware cpio data ...
ls: cannot access './lib/firmware/brcm/brcmfmac43430a0-sdio.ONDA-V80': No such file or directory
ls: cannot access 'PLUS.txt': No such file or directory
*         >> Appending modules cpio data ...


Expected Results:  
Genkernel should print:

*         >> Appending firmware cpio data ...
*         >> Appending modules cpio data ...

and correctly handle filenames containing spaces.
Comment 1 Thomas Deutschmann (RETIRED) gentoo-dev 2019-07-16 11:20:18 UTC
The file should be present in initramfs. Can you confirm?

The reported ls error is coming from log_future_cpio_content()'s ls call (https://gitweb.gentoo.org/proj/genkernel.git/tree/gen_initramfs.sh?h=v4.0.0_beta3#n173).

In next version I'll use "find . -print0..." to address this problem.
Comment 2 Mariusz Ceier 2019-07-16 11:34:18 UTC
I don't know how to list the contents of initramfs...

I tried `lsinitrd /boot/initramfs-genkernel-x86_64-5.2.1-gentoo`:

Image: initramfs-genkernel-x86_64-5.2.1-gentoo: 186M
========================================================================
Version:

Arguments:
dracut modules:
========================================================================
drwxr-xr-x   3 root     root            0 Jul 16 10:49 .
drwxr-xr-x   3 root     root            0 Jul 16 10:49 kernel
drwxr-xr-x   3 root     root            0 Jul 16 10:49 kernel/x86
drwxr-xr-x   2 root     root            0 Jul 16 10:49 kernel/x86/microcode
-rw-r--r--   1 root     root        30546 Jul 16 10:49 kernel/x86/microcode/AuthenticAMD.bin
-rw-r--r--   1 root     root      6081536 Jul 16 10:49 kernel/x86/microcode/GenuineIntel.bin
========================================================================


and `cpio -t < /boot/initramfs-genkernel-x86_64-5.2.1-gentoo`:

.
kernel
kernel/x86
kernel/x86/microcode
kernel/x86/microcode/GenuineIntel.bin
kernel/x86/microcode/AuthenticAMD.bin
11940 blocks


either there's no firmware, or I'm doing something wrong.
Comment 3 Mariusz Ceier 2019-07-16 11:54:11 UTC
I just verified that with the old genkernel, initramfs is compressed and after uncompressing it contains firmware files. But with new genkernel it's uncompressed cpio archive that contains only microcode files, though the size of that archive is comparable to the size of old initramfs. Binwalk shows there's bzip2 compressed data after cpio archive... not sure if that's correct (for booting the system):

0             0x0             ASCII cpio archive (SVR4 with no CRC), file name: ".", file name length: "0x00000002", file size: "0x00000000"
[...]
6082172       0x5CCE7C        ASCII cpio archive (SVR4 with no CRC), file name: "kernel/x86/microcode/AuthenticAMD.bin", file name length: "0x00000026", file size: "0x00007752"
6112868       0x5D4664        ASCII cpio archive (SVR4 with no CRC), file name: "TRAILER!!!", file name length: "0x0000000B", file size: "0x00000000"
6113280       0x5D4800        bzip2 compressed data, block size = 900k
[...]
Comment 4 Thomas Deutschmann (RETIRED) gentoo-dev 2019-07-16 12:12:52 UTC
Well, with binwalk and appended MCU CPIO it's a little bit tricky to get to initramfs. It's easier to re-run with --no-microcode-initramfs and maybe add --no-compress-initramfs as well.
Comment 5 Mariusz Ceier 2019-07-16 12:16:19 UTC
I split the /boot/initramfs-genkernel-x86_64-5.2.1-gentoo, uncompressed bzip2 archive and lsinitrd shows that the firmware file is there:

-rw-r--r--   1 root     root          989 Jul 16 10:46 lib/firmware/brcm/brcmfmac43430a0-sdio.ONDA-V80\ PLUS.txt


Still not sure if this new format of initramfs is correct.
Comment 6 Larry the Git Cow gentoo-dev 2019-07-16 12:19:00 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=e55a6c5c7a39a17bea902301125092e1952a931c

commit e55a6c5c7a39a17bea902301125092e1952a931c
Author:     Thomas Deutschmann <whissi@gentoo.org>
AuthorDate: 2019-07-16 11:31:13 +0000
Commit:     Thomas Deutschmann <whissi@gentoo.org>
CommitDate: 2019-07-16 12:16:00 +0000

    gen_initramfs.sh: Use find with -print0 parameter to support files with whitespaces
    
    Bug: https://bugs.gentoo.org/689952
    Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>

 gen_initramfs.sh | 58 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 29 insertions(+), 29 deletions(-)
Comment 7 Thomas Deutschmann (RETIRED) gentoo-dev 2019-07-16 12:29:19 UTC
The format is correct. It's coming from your kernel configuration. My initramfs will use XZ for example. See https://gitweb.gentoo.org/proj/genkernel.git/tree/gen_initramfs.sh?h=v4.0.0_beta3#n1616: We check which compression method your kernel supports...
Comment 8 Mariusz Ceier 2019-07-16 12:33:38 UTC
I didn't mean the compression, but all tools think it's uncompressed cpio archive. I wonder how kernel will know where to find /init, I doubt it will guess there's compressed initramfs file after that cpio archive...
Comment 9 Mariusz Ceier 2019-07-16 12:45:26 UTC
(In reply to Mariusz Ceier from comment #8)
> I didn't mean the compression, but all tools think it's uncompressed cpio
> archive. I wonder how kernel will know where to find /init, I doubt it will
> guess there's compressed initramfs file after that cpio archive...

I'm talking about the format of /boot/initramfs-genkernel-x86_64-5.2.1-gentoo. Sorry if that wasn't clear.
Comment 10 Thomas Deutschmann (RETIRED) gentoo-dev 2019-07-16 14:09:45 UTC
The format is correct. We are doing exactly what's shown in https://www.kernel.org/doc/Documentation/x86/microcode.txt:

> cat ucode.cpio $INITRD.orig > $INITRD

However, tools out there cannot handle concatenated initrd's very well.

Next beta will produce initramfs which will be supported by dracut's lsinitrd tool (I only have to add some meta data).
Comment 11 Mariusz Ceier 2019-07-16 14:19:15 UTC
(In reply to Thomas Deutschmann from comment #10)
> The format is correct. We are doing exactly what's shown in
> https://www.kernel.org/doc/Documentation/x86/microcode.txt:
> 

Oh, great. Thanks for referencing this. I don't have any more comments to add to this issue ;)
Comment 12 Thomas Deutschmann (RETIRED) gentoo-dev 2019-07-16 18:32:10 UTC
beta4 is now available, thank you for the report.