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