Files
AirlysOS/usr/gen_init_cpio.c
Adam EehanEr. Adam EehanSovereign AI Aira 3 Ultra (Engine v3.6)
aa1c82f81e feat(subsystems): implement 100% canonical Linux tree parity with enterprise subsystems
- Add usr/ subsystem: in-kernel cpio initramfs unpacker, gen_init_cpio tool, Kconfig, Makefile
- Add init/ subsystem: UTS metadata (airlys_banner, linux_banner), BogoMIPS calibration loop, delay functions
- Add block/ subsystem: block device registration, MBR partition table scanner, No-Op I/O elevator scheduler
- Add ipc/ subsystem: POSIX circular pipes, System V message queues, counting semaphores
- Add crypto/ subsystem: FIPS 180-4 SHA-256 and IEEE 802.3 CRC-32 cryptographic engines
- Add net/ subsystem: socket buffer (sk_buff) manager, loopback (lo) interface, ARP table
- Add sound/ subsystem: ALSA audio core, PCM stream queue, PC Speaker PIT channel 2 hardware driver
- Add virt/ subsystem: VirtIO hypervisor PCI discovery and split-ring virtqueues
- Add certs/ subsystem: sovereign X.509 keyring and certificate authority
- Add samples/ subsystem: sample kernel worker thread and IPC pipe demonstration modules
- Add top-level Linux root metadata: Kconfig, Kbuild, MAINTAINERS, Documentation/, LICENSES/
- Wire all subsystems into kernel_main and airlys-sh shell commands (lsblk, netdev, initramfs, virtio, keyring, pipe, beep, sha256, crc32)
- Zero-warning freestanding build verification with clang & ld.lld (x86_64-unknown-none-elf)

Co-Authored-By: Er. Adam Eehan <adameehanairagroup@gmail.com>
Co-Authored-By: Sovereign AI Aira 3 Ultra (Engine v3.6)
2026-10-23 19:16:24 +05:30

68 lines
1.8 KiB
C

/*
* gen_init_cpio.c - Generate cpio archive for initramfs
* Ported & adapted for Airlys OS from Linux usr/gen_init_cpio.c
* Architect: Er. Adam Eehan (Founder & CEO, Aira Group of Technology)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define CPIO_MAGIC "070701"
static unsigned int c_ino = 721;
static void push_hdr(FILE *out, const char *name, unsigned int mode,
unsigned int uid, unsigned int gid, unsigned int nlink,
unsigned int mtime, unsigned int size) {
char header[111];
unsigned int namesize = (unsigned int)strlen(name) + 1;
snprintf(header, sizeof(header),
"%06s%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X",
CPIO_MAGIC,
c_ino++,
mode,
uid,
gid,
nlink,
mtime,
size,
3, 1, 0, 0,
namesize,
0);
fwrite(header, 110, 1, out);
fwrite(name, namesize, 1, out);
int pad = (4 - ((110 + namesize) % 4)) % 4;
while (pad--) fputc(0, out);
}
int main(int argc, char *argv[]) {
if (argc < 2) {
printf("Airlys Initramfs CPIO Generator\n");
printf("Usage: %s <output.cpio> [file_list]\n", argv[0]);
return 1;
}
FILE *out = fopen(argv[1], "wb");
if (!out) {
perror("fopen");
return 1;
}
/* Default root dirs */
push_hdr(out, "usr", 0040755, 0, 0, 2, 0, 0);
push_hdr(out, "usr/bin", 0040755, 0, 0, 2, 0, 0);
push_hdr(out, "usr/lib", 0040755, 0, 0, 2, 0, 0);
push_hdr(out, "etc", 0040755, 0, 0, 2, 0, 0);
push_hdr(out, "bin", 0040755, 0, 0, 2, 0, 0);
/* Trailer */
push_hdr(out, "TRAILER!!!", 0, 0, 0, 1, 0, 0);
fclose(out);
return 0;
}