]>
Commit | Line | Data |
---|---|---|
45516216 | 1 | typedef int (*initcall_t) (void); |
2 | typedef long long __kernel_loff_t; | |
3 | typedef __kernel_loff_t loff_t; | |
4 | static __attribute__ ((__section__(".init.data"))) | |
5 | char *message; | |
6 | static void __attribute__ ((__section__(".init.text"))) error(char *x) | |
7 | { | |
8 | if (!message) | |
9 | message = x; | |
10 | } | |
11 | ||
12 | static __attribute__ ((__section__(".init.data"))) | |
13 | enum state { | |
14 | Start, Collect, GotHeader, SkipIt, GotName, CopyFile, GotSymlink, Reset | |
15 | } state, next_state; | |
16 | static __attribute__ ((__section__(".init.data"))) | |
17 | loff_t this_header, next_header; | |
18 | static __attribute__ ((__section__(".init.data"))) | |
19 | char *collected; | |
20 | static int __attribute__ ((__section__(".init.text"))) do_start(void) | |
21 | { | |
22 | } | |
23 | static int __attribute__ ((__section__(".init.text"))) do_collect(void) | |
24 | { | |
25 | } | |
26 | static int __attribute__ ((__section__(".init.text"))) do_header(void) | |
27 | { | |
28 | if (memcmp(collected, "070707", 6) == 0) { | |
29 | error("incorrect cpio method used: use -H newc option"); | |
30 | } | |
31 | } | |
32 | static int __attribute__ ((__section__(".init.text"))) do_skip(void) | |
33 | { | |
34 | } | |
35 | static int __attribute__ ((__section__(".init.text"))) do_reset(void) | |
36 | { | |
37 | } | |
38 | static int __attribute__ ((__section__(".init.text"))) do_name(void) | |
39 | { | |
40 | } | |
41 | static int __attribute__ ((__section__(".init.text"))) do_copy(void) | |
42 | { | |
43 | } | |
44 | static int __attribute__ ((__section__(".init.text"))) do_symlink(void) | |
45 | { | |
46 | } | |
47 | static __attribute__ ((__section__(".init.data"))) | |
48 | int (*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,}; | |
54 | static int | |
55 | __attribute__ ((__section__(".init.text"))) write_buffer(char *buf, | |
56 | unsigned len) | |
57 | { | |
58 | while (!actions[state] ()) ; | |
59 | } | |
60 | static char * | |
61 | __attribute__ ((__section__(".init.text"))) 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 | } | |
74 | extern char __initramfs_start[], __initramfs_end[]; | |
75 | static int __attribute__ ((__section__(".init.text"))) populate_rootfs(void) | |
76 | { | |
77 | char *err = | |
78 | unpack_to_rootfs(__initramfs_start, | |
79 | __initramfs_end - __initramfs_start, 0); | |
80 | } | |
81 | static initcall_t __initcall_populate_rootfsrootfs __attribute__ ((__used__)) | |
82 | __attribute__ ((__section__(".initcall" "rootfs" ".init"))) = | |
83 | populate_rootfs; |