typedef int (*initcall_t) (void); typedef long long __kernel_loff_t; typedef __kernel_loff_t loff_t; static char *message; static void error(char *x) { if (!message) message = x; } static enum state { Start, Collect, GotHeader, SkipIt, GotName, CopyFile, GotSymlink, Reset } state, next_state; static loff_t this_header, next_header; static char *collected; static int do_start(void) { } static int do_collect(void) { } static int do_header(void) { if (memcmp(collected, "070707", 6) == 0) { error("incorrect cpio method used: use -H newc option"); } } static int do_skip(void) { } static int do_reset(void) { } static int do_name(void) { } static int do_copy(void) { } static int do_symlink(void) { } static int (*actions[]) (void) = { [Start] = do_start,[Collect] = do_collect,[GotHeader] = do_header,[SkipIt] = do_skip,[GotName] = do_name,[CopyFile] = do_copy,[GotSymlink] = do_symlink,[Reset] = do_reset,}; static int write_buffer(char *buf, unsigned len) { while (!actions[state] ()) ; } static char * unpack_to_rootfs(char *buf, unsigned len, int check_only) { int written; while (!message && len) { if (*buf == '0' && !(this_header & 3)) { written = write_buffer(buf, len); } if (state != Reset) error("junk in gzipped archive"); } } extern char __initramfs_start[], __initramfs_end[]; static int populate_rootfs(void) { char *err = unpack_to_rootfs(__initramfs_start, __initramfs_end - __initramfs_start, 0); } static initcall_t __initcall_populate_rootfsrootfs __attribute__ ((__used__)) = populate_rootfs;