1. A non-empty archive can still be generated, if a dev nodes
file is specified; and
2. cpio itself handles the case of an empty archive
(containing only the trailer entry), for example:
echo -n | cpio -oc | cpio -it
Bug: 328362894
Change-Id: If17796f445e50842249554a1e82478bc375cf5eb
Move all the error reporting over to err()/errx() rather than the
current mix of errx(), fprintf()+exit(), and the homebrew die().
Also make the two "read all the lines in the file" loops match, by
copying the newer getline() style into the older fgets() loop.
Test: treehugger
Change-Id: Ia732df90588d7fd12dfe965e11c6ed72a96b098d
error() is a glibc extension that is not available in musl libc.
err() is a BSD extension, but is present in glibc, musl libc and
bionic.
Test: m USE_HOST_MUSL=true host-native -k
Change-Id: I2ba7bddc2a725826be8be7f80208587b81de9238
Let mkbootfs create a list of dev nodes and directories, based on a
file:
$ mkbootfs -n node_file initramfs/ > initramfs.cpio
This file is following the same format as the kernel usr/ cpio list:
$ cat node_file
# My device nodes
dir dev 0755 0 0
nod dev/null 0600 0 0 c 1 5
Bug: 254835242
Change-Id: Ieb75b1d1026a9426581b6f2b3aa692a05722ba0d
Right now, it just prints "no directories to process". There is also no
indication anywhere about the availability of the -f and -d flags.
Also took the opportunity to perform small quality-of-life improvements,
like updating error messages, hiding internal functions.
Test: (cd system/core/mkbootfs && mma) && ./out/host/linux-x86/bin/mkbootfs
Change-Id: Ia81eff0308e6e2686dde979d47c0bf938afbaf82