[continued from previous message]
+ fprintf(stream, "\
+\n\
+Usage: unmkinitramfs [-v|--verbose] INITRAMFS-FILE DIRECTORY\n\
+\n\
+Options:\n\
+ -v | --verbose Display verbose messages about extraction\n\
+\n\
+See unmkinitramfs(8) for further details.\n\
+\n"
+ );
+}
+
+int main(int argc, char **argv)
+{
+ int opt;
+ bool do_list = false;
+ bool verbose = false;
+ const char *in_filename;
+ FILE *in_file;
+ const char *out_dirname = NULL;
+ char *out_subdirname = NULL;
+ const char *cpio_optv[3];
+ int cpio_optc;
+ struct cpio_proc cpio_proc = { 0 };
+ unsigned int early_count = 0;
+ bool ok;
+
+ /* Parse options */
+ opterr = 0;
+ while ((opt = getopt_long(argc, argv, "hv", long_opts, NULL)) >= 0) {
+ switch (opt) {
+ case '?':
+ usage(stderr);
+ return 2;
+ case 'h':
+ usage(stdout);
+ return 0;
+ case 'l':
+ do_list = true;
+ break;
+ case 'v':
+ verbose = true;
+ break;
+ }
+ }
+
+ /* Check number of non-option arguments */
+ if (argc - optind != (do_list ? 1 : 2)) {
+ usage(stderr);
+ return 2;
+ }
+
+ /* Set up input file and output directory */
+ in_filename = argv[optind];
+ in_file = fopen(in_filename, "rb");
+ if (!in_file)
+ err(1, "%s", in_filename);
+ if (!do_list) {
+ out_dirname = argv[optind + 1];
+ if (!mkdir_allow_exist(out_dirname, 0777))
+ err(1, "%s", out_dirname);
+ out_subdirname = malloc(strlen(out_dirname) + 20);
+ if (!out_subdirname)
+ err(1, "malloc");
+ }
+
+ /* Set up extra options for cpio */
+ cpio_optc = 0;
+ if (do_list) {
+ cpio_optv[cpio_optc++] = "--list";
+ } else {
+ cpio_optv[cpio_optc++] = "-D";
+ cpio_optv[cpio_optc++] = out_subdirname;
+ }
+ if (verbose)
+ cpio_optv[cpio_optc++] = "-v";
+
+ /* Iterate over archives within the initramfs */
+ for (;;) {
+ unsigned char magic_buf[MAX_MAGIC_LEN];
+ size_t read_len;
+ const struct magic_entry *me;
+
+ /* Peek at first bytes of next archive; handle EOF */
+ read_len = fread(magic_buf, 1, sizeof(magic_buf), in_file);
+ if (read_len == 0) {
+ /*
+ * EOF with no compresed archive. Add back a
+ * trailer to keep cpio happy.
+ */
+ if (ferror(in_file)) {
+ warn("%s", in_filename);
+ ok = false;
+ }
+ if (cpio_proc.pid && !write_trailer(cpio_proc.pipe))
+ ok = false;
+ break;
+ }
+ fseek(in_file, -(long)read_len, SEEK_CUR);
+
+ /* Identify format */
+ for (me = magic_table; me->magic_len; ++me)
+ if (read_len >= me->magic_len &&
+ memcmp(magic_buf, me->magic, me->magic_len) == 0)
+ break;
+ if (me->magic_len == 0) {
+ warnx("%s: unrecognised compression or corrupted file", + in_filename);
+ ok = false;
+ break;
+ }
+
+ /*
+ * Extract the archive to an "early" or "early<n>"
+ * subdirectory if:
+ * - We have not already started the main cpio process
+ * - We are not listing
+ * - This looks like an early initramfs (uncompressed
+ * and contains files under kernel/)
+ */
+ if (!cpio_proc.pid && !do_list &&
+ me->format == FORMAT_CPIO_NEW &&
+ detect_early_initramfs(in_file, in_filename)) {
+ struct cpio_proc early_cpio_proc;
+
+ if (++early_count == 1)
+ sprintf(out_subdirname, "%s/early",
+ out_dirname);
+ else
+ sprintf(out_subdirname, "%s/early%u",
+ out_dirname, early_count);
+ if (!mkdir_allow_exist(out_subdirname, 0777)) {
+ warn("%s", out_subdirname);
+ ok = false;
+ break;
+ }
+ if (!spawn_cpio(cpio_optc, cpio_optv,
+ &early_cpio_proc)) {
+ ok = false;
+ break;
+ }
+ ok = handle_uncompressed(in_file, in_filename,
+ early_cpio_proc.pipe)
+ && write_trailer(early_cpio_proc.pipe);
+ if (!end_cpio(&early_cpio_proc, ok))
+ ok = false;
+ if (!ok)
+ break;
+ } else {
+ /*
+ * Otherwise, extract to either the base
+ * output directory or a "main" subdirectory,
+ * depending on whether we already created
+ * subdirectories.
+ */
+ if (!cpio_proc.pid) {
+ if (do_list) {
+ ;
+ } else if (early_count) {
+ sprintf(out_subdirname, "%s/main",
+ out_dirname);
+ if (!mkdir_allow_exist(out_subdirname, + 0777)) {
+ warn("%s", out_subdirname);
+ ok = false;
+ break;
+ }
+ } else {
+ strcpy(out_subdirname, out_dirname);
+ }
+ if (!spawn_cpio(cpio_optc, cpio_optv,
+ &cpio_proc)) {
+ ok = false;
+ break;
+ }
+ }
+ if (me->format == FORMAT_CPIO_NEW) {
+ ok = handle_uncompressed(in_file, in_filename, + cpio_proc.pipe);
+ if (!ok)
+ break;
+ } else {
+ ok = handle_compressed(in_file, me->format,
+ cpio_proc.pipe);
+ break;
+ }
+ }
+ }
+
+ fclose(in_file);
+
+ if (cpio_proc.pid && !end_cpio(&cpio_proc, ok))
+ ok = false;
+
+ return !ok;
+}
--===============1190599967176425659==--
Received: (at 1107203-done) by bugs.debian.org; 3 Jun 2025 18:18:42 +0000 X-Spam-Checker-Version: SpamAssassin 4.0.1-bugs.debian.org_2005_01_02
(2024-03-25) on buxtehude.debian.org
X-Spam-Level:
X-Spam-Status: No, score=-104.1 required=4.0 tests=BAYES_00,DKIM_SIGNED,
DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,
SPF_NONE,TVD_SPACE_RATIO,USER_IN_DKIM_WELCOMELIST autolearn=ham
autolearn_force=no version=4.0.1-bugs.debian.org_2005_01_02 X-Spam-Bayes: score:0.0000 Tokens: new, 9; hammy, 86; neutral, 12; spammy, 0.
spammytokens: hammytokens:0.000-+--initramfstools,
0.000-+--initramfs-tools, 0.000-+--Hx-spam-relays-external:16a8,
0.000-+--H*r:16a8, 0.000-+--H*RU:16a8
Return-path: <
[email protected]>
Received: from mitropoulos.debian.org ([2001:648:2ffc:deb:216:61ff:fe9d:958d]:40370)
from C=NA,ST=NA,L=Ankh Morpork,O=Debian SMTP,OU=Debian SMTP CA,CN=mitropoulos.debian.org,EMAIL=
[email protected] (verified)
by buxtehude.debian.org with esmtps (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)
(Exim 4.96)
(envelope-from <
[email protected]>)
id 1uMWDh-00Em6R-2L
for
[email protected];
Tue, 03 Jun 2025 18:18:42 +0000
Received: from respighi.debian.org ([2a02:16a8:dc41:100::131]:55494)
from C=NA,ST=NA,L=Ankh Morpork,O=Debian SMTP,OU=Debian SMTP CA,CN=respighi.debian.org,EMAIL=
[email protected] (verified)
by mitropoulos.debian.org with esmtps (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)
(Exim 4.94.2)
(envelope-from <
[email protected]>)
id 1uMWDf-003lUV-V2
for
[email protected]; Tue, 03 Jun 2025 18:18:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=respighi.debian.org; s=smtpauto.respighi; h=Date:From:Message-Id:
Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:To:Reply-To:Cc:
Content-ID:Content-Description:In-Reply-To:References;
bh=93zk2qxw1u6bLOFczU6vEHgGcQPwGJ4TAm7G37WxKms=; b=eQDpRMZx8tBO/UmXJg1AggTbrE
tnFdlzHNZdqjncV5wwLPGVLXV+F6+m+TPM91sW1qyJnKiyfnjJdWTzuJsXT6X/+OHxJ7/q7kC0MSB
BPS7yadzrsWyB9taEivjvP3ldQDvIWyS6Q1jFQFSxP640DjvSMPpbGpDxZppl97t37luViU6WDJlq
jpt25j/6gJegZzlJVvTEOsso0VWDOpvnWHp0eEdSpIKAbFVjiF4jbdgud6e260AXMSRKhsHBF/GOJ
/hZNHbCTejQnZ4H8D7aJL0JZsHtntKiGMpmCFmnVkf8arRtdlkaXC6nj33CaNV0H3IzAnXFaW7F89
rnMpSxFA==;
Received: from ivodd by respighi.debian.org with local (Exim 4.96)
(envelope-from <
[email protected]>)
id 1uMWDd-004oA9-0V;
Tue, 03 Jun 2025 18:18:37 +0000
To:
[email protected]
Subject: unblock initramfs-tools
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
Message-Id: <
[email protected]>
From: Ivo De Decker <
[email protected]>
Date: Tue, 03 Jun 2025 18:18:37 +0000
Unblocked initramfs-tools.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)