]> git.wh0rd.org - ICEs.git/blame - bfin-rets-insn/initramfs.i.2
add bfin ice
[ICEs.git] / bfin-rets-insn / initramfs.i.2
CommitLineData
45516216 1typedef int (*initcall_t) (void);
2typedef long long __kernel_loff_t;
3typedef __kernel_loff_t loff_t;
4static
5char *message;
6static void error(char *x)
7{
8 if (!message)
9 message = x;
10}
11
12static
13enum state {
14 Start, Collect, GotHeader, SkipIt, GotName, CopyFile, GotSymlink, Reset
15} state, next_state;
16static
17loff_t this_header, next_header;
18static
19char *collected;
20static int do_start(void)
21{
22}
23static int do_collect(void)
24{
25}
26static int do_header(void)
27{
28 if (memcmp(collected, "070707", 6) == 0) {
29 error("incorrect cpio method used: use -H newc option");
30 }
31}
32static int do_skip(void)
33{
34}
35static int do_reset(void)
36{
37}
38static int do_name(void)
39{
40}
41static int do_copy(void)
42{
43}
44static int do_symlink(void)
45{
46}
47static
48int (*actions[]) (void) =
49{
50[Start] = do_start,[Collect] = do_collect,[GotHeader] =
51 do_header,[SkipIt] = do_skip,[GotName] =
52 do_name,[CopyFile] = do_copy,[GotSymlink] =
53 do_symlink,[Reset] = do_reset,};
54static int
55 write_buffer(char *buf,
56 unsigned len)
57{
58 while (!actions[state] ()) ;
59}
60static char *
61 unpack_to_rootfs(char *buf,
62 unsigned len,
63 int check_only)
64{
65 int written;
66 while (!message && len) {
67 if (*buf == '0' && !(this_header & 3)) {
68 written = write_buffer(buf, len);
69 }
70 if (state != Reset)
71 error("junk in gzipped archive");
72 }
73}
74extern char __initramfs_start[], __initramfs_end[];
75static int populate_rootfs(void)
76{
77 char *err =
78 unpack_to_rootfs(__initramfs_start,
79 __initramfs_end - __initramfs_start, 0);
80}
81static initcall_t __initcall_populate_rootfsrootfs __attribute__ ((__used__))
82=
83 populate_rootfs;