Commit graph

10 commits

Author SHA1 Message Date
Keir Fraser
c5cec3c71c mkbootfs: Allow invocation with no directories specified
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
2024-05-15 16:05:55 +00:00
Keir Fraser
b2016ecadc mkbootfs: Fix usage message for dev node list files
Bug: 328362894
Change-Id: If44918c52ff5bb0ca207fa4817ac14ae5af8c55f
2024-05-13 13:10:44 +00:00
Keir Fraser
7ae58649ae mkbootfs: Fix -f typo in usage message
Bug: 328362894
Change-Id: I559fb2640cb9fda7dbba172709ad1c3a7f3b6dd9
2024-05-13 13:10:44 +00:00
Elliott Hughes
ad1a0a9b0b mkbootfs: consistency.
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
2023-01-12 04:34:15 +00:00
Colin Cross
6f2ae489d7 Use err() instead of error() in mkbootfs
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
2023-01-09 14:15:27 -08:00
Vincent Donnefort
99ab52101c mkbootfs: Add support for a dev node list file
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
2023-01-09 09:31:14 +00:00
Vincent Donnefort
c297135302 mkbootfs: Add support for dev nodes
Add the ability of packaging dev nodes in the CPIO.

Change-Id: Id1c83c8bcd3724de03214788c9af592f9817285f
2023-01-06 17:19:09 +00:00
Vincent Donnefort
7f01774abd mkbootfs: Use getopt_long
Make the arguments more flexible with the help of getopt_long. While at
it, add a mkbootfs help.

Change-Id: I8cb3de9425418651374b9d0a4db5629d1659c3f3
2023-01-06 17:19:09 +00:00
Mateus Azis
023f67b95e Make 'mkbootfs' print a usage message for insufficent args.
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
2022-07-12 16:00:07 -07:00
Yi-Yo Chiang
3987c0663a Rename system/cote/cpio/ -> system/core/mkbootfs/
Test: Presubmit
Change-Id: I1a55ce97817ebb3d7a7e97cb7a41ba61cbe878e3
2021-05-05 19:03:36 +08:00