-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathklibc.patch
328 lines (306 loc) · 8.74 KB
/
klibc.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
--- /dev/null 2012-02-09 20:31:42.211948750 +0400
+++ kinit/Makefile 2012-02-09 18:20:54.129496981 +0400
@@ -0,0 +1,35 @@
+srctree = $(CURDIR)
+
+objs = name_to_dev.o devname.o getarg.o
+objs += kinit.o do_mounts.o ramdisk_load.o initrd.o
+objs += getintfile.o readfile.o xpio.o
+objs += do_mounts_md.o do_mounts_mtd.o nfsroot.o
+
+CFLAGS += -Os -I. -D_GNU_SOURCE -ffunction-sections -fdata-sections
+LDFLAGS += -Wl,--gc-sections -Wl,--print-gc-sections
+
+subdirs += ipconfig
+subdirs += nfsmount
+subdirs += run-init
+subdirs += fstype
+subdirs += resume
+
+# Additional include paths files
+CFLAGS += -I$(srctree)/$(src)/fstype \
+ -I$(srctree)/$(src)/ipconfig \
+ -I$(srctree)/$(src)/nfsmount \
+ -I$(srctree)/$(src)/resume \
+ -I$(srctree)/$(src)/run-init
+
+.PHONY: $(subdirs)
+.EXPORT_ALL_VARIABLES:
+
+all: $(subdirs)
+
+$(subdirs): $(objs)
+ $(MAKE) -C "$@" $(MFLAGS) $(MAKECMDGOALS)
+
+clean: $(subdirs)
+ rm -f -- $(objs)
+
+install: $(subdirs)
--- /dev/null 2012-02-09 20:31:42.211948750 +0400
+++ kinit/nfsmount/Makefile 2012-02-09 18:20:54.130496981 +0400
@@ -0,0 +1,5 @@
+prog = nfsmount
+objs = main.o mount.o portmap.o dummypmap.o sunrpc.o
+CFLAGS += -D_GNU_SOURCE=1
+
+include $(CURDIR)/../rules.mk
--- kinit/nfsmount/sunrpc.c.fix0 2012-02-09 18:20:53.000000000 +0400
+++ kinit/nfsmount/sunrpc.c 2012-02-09 18:20:54.131496981 +0400
@@ -1,8 +1,7 @@
#include <sys/types.h>
#include <sys/socket.h>
-#include <netinet/in.h>
-#include <poll.h>
+#include <sys/poll.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
--- kinit/nfsmount/mount.c.fix0 2012-02-09 18:20:53.000000000 +0400
+++ kinit/nfsmount/mount.c 2012-02-09 18:20:54.132496981 +0400
@@ -1,15 +1,14 @@
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <linux/nfs.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <linux/nfs.h>
+
#include "nfsmount.h"
#include "sunrpc.h"
static uint32_t mount_port;
--- kinit/nfsmount/nfsmount.h.fix0 2012-02-09 18:20:53.000000000 +0400
+++ kinit/nfsmount/nfsmount.h 2012-02-09 18:20:54.133496981 +0400
@@ -1,9 +1,19 @@
#ifndef NFSMOUNT_NFSMOUNT_H
#define NFSMOUNT_NFSMOUNT_H
+#include <sys/socket.h>
+#include <stdint.h>
#include <linux/nfs_mount.h>
+#ifndef MNTPROC_MNT
+#define MNTPROC_MNT 1
+#endif
+
+#ifndef MNTPROC_UMNT
+#define MNTPROC_UMNT 3
+#endif
+
extern int nfs_port;
extern int nfsmount_main(int argc, char *argv[]);
int nfs_mount(const char *rem_name, const char *hostname,
--- kinit/nfsmount/main.c.fix0 2012-02-09 18:20:53.000000000 +0400
+++ kinit/nfsmount/main.c 2012-02-09 18:20:54.135496981 +0400
@@ -1,19 +1,15 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <arpa/inet.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <setjmp.h>
#include <sys/wait.h>
#include <unistd.h>
-#include <klibc/sysconfig.h> /* For _KLIBC_NO_MMU */
-
-#include <linux/nfs_mount.h>
#include "nfsmount.h"
#include "sunrpc.h"
#include "dummypmap.h"
--- kinit/nfsmount/portmap.c.fix0 2012-02-09 18:20:53.000000000 +0400
+++ kinit/nfsmount/portmap.c 2012-02-09 18:20:54.136496981 +0400
@@ -1,6 +1,5 @@
#include <sys/types.h>
-#include <netinet/in.h>
#include <asm/byteorder.h> /* __constant_hton* */
#include <stdio.h>
#include <stdlib.h>
--- kinit/do_mounts_md.c.fix0 2012-02-09 18:20:53.000000000 +0400
+++ kinit/do_mounts_md.c 2012-02-09 18:20:54.137496981 +0400
@@ -15,9 +15,9 @@
#include <string.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/sysmacros.h>
-#include <sys/md.h>
+#include "md.h"
#include <linux/major.h>
#include "kinit.h"
#include "do_mounts.h"
--- /dev/null 2012-02-09 20:31:42.211948750 +0400
+++ kinit/ipconfig/Makefile 2012-02-09 18:20:54.138496981 +0400
@@ -0,0 +1,9 @@
+prog = ipconfig
+# common .o files
+objs := main.o netdev.o packet.o
+# dhcp
+objs += dhcp_proto.o
+# bootp
+objs += bootp_proto.o
+
+include $(CURDIR)/../rules.mk
--- kinit/ipconfig/netdev.c.fix0 2012-02-09 18:20:53.000000000 +0400
+++ kinit/ipconfig/netdev.c 2012-02-09 18:20:54.139496981 +0400
@@ -10,9 +10,9 @@
#include <unistd.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <netinet/in.h>
-#include <linux/route.h>
+#include <net/route.h>
#include <linux/sockios.h>
#include "netdev.h"
--- /dev/null 2012-02-09 20:31:42.211948750 +0400
+++ kinit/run-init/Makefile 2012-02-09 18:20:54.140496981 +0400
@@ -0,0 +1,5 @@
+prog = run-init
+# common .o files
+objs = run-init.o runinitlib.o
+
+include $(CURDIR)/../rules.mk
--- kinit/do_mounts.h.fix0 2012-02-09 18:20:53.000000000 +0400
+++ kinit/do_mounts.h 2012-02-09 18:20:54.141496981 +0400
@@ -7,8 +7,12 @@
#include <sys/types.h>
#include <sys/sysmacros.h>
#include <sys/stat.h>
+#include <linux/fs.h>
+
+#define __makedev(__ma, __mi) \
+ ((((__ma) & 0xfff) << 8)|((__mi) & 0xff)|(((__mi) & 0xfff00) << 12))
#define Root_RAM0 __makedev(1, 0)
/* These device numbers are only used internally */
--- /dev/null 2012-02-09 20:31:42.211948750 +0400
+++ kinit/md.h 2012-02-09 18:20:54.142496981 +0400
@@ -0,0 +1,32 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2006 H. Peter Anvin - All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * sys/md.h
+ *
+ * Defines for the Linux md functionality. Some of this stuff is
+ * userspace-visible but lives in md_k.h, which is user-space unsafe.
+ * Sigh.
+ */
+
+#ifndef _SYS_MD_H
+#define _SYS_MD_H
+
+#define LEVEL_MULTIPATH (-4)
+#define LEVEL_LINEAR (-1)
+#define LEVEL_FAULTY (-5)
+#define MAX_MD_DEVS 256 /* Max number of md dev */
+
+#include <linux/raid/md_u.h>
+#include <linux/raid/md_p.h>
+
+#endif /* _SYS_MD_H */
--- kinit/nfsroot.c.fix0 2012-02-09 18:20:53.000000000 +0400
+++ kinit/nfsroot.c 2012-02-09 18:22:38.077496910 +0400
@@ -1,15 +1,16 @@
#include <arpa/inet.h>
#include <sys/mount.h>
#include <sys/stat.h>
+#include <sys/capability.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "kinit.h"
#include "netdev.h"
-#include "nfsmount.h"
+//#include "nfsmount.h"
static char *sub_client(__u32 client, char *path, size_t len)
{
struct in_addr addr = { client };
--- /dev/null 2012-02-09 20:31:42.211948750 +0400
+++ kinit/resume/Makefile 2012-02-09 18:20:54.144496981 +0400
@@ -0,0 +1,7 @@
+prog = resume
+# common .o files
+objs = resume.o resumelib.o ../getarg.o ../name_to_dev.o ../devname.o
+
+CFLAGS += -I..
+
+include $(CURDIR)/../rules.mk
--- kinit/resume/resume.c.fix0 2012-02-09 18:20:53.000000000 +0400
+++ kinit/resume/resume.c 2012-02-09 18:20:54.145496981 +0400
@@ -8,9 +8,9 @@
#include "resume.h"
char *progname;
-static __noreturn usage(void)
+static void __attribute__ ((noreturn)) usage(void)
{
fprintf(stderr, "Usage: %s /dev/<resumedevice> [offset]\n", progname);
exit(1);
}
--- kinit/kinit.c.fix0 2012-02-09 18:20:53.000000000 +0400
+++ kinit/kinit.c 2012-02-09 18:20:54.146496981 +0400
@@ -8,8 +8,9 @@
#include <alloca.h>
#include <limits.h>
#include <ctype.h>
#include <termios.h>
+#include <unistd.h>
#include "kinit.h"
#include "ipconfig.h"
#include "run-init.h"
--- /dev/null 2012-02-09 20:31:42.211948750 +0400
+++ kinit/rules.mk 2012-02-09 18:20:54.147496981 +0400
@@ -0,0 +1,13 @@
+bindir ?= /usr/bin
+
+$(prog): $(objs)
+ $(CC) $(LDFLAGS) -o $@ $(objs) $(LDLIBS)
+
+all: $(prog)
+
+clean:
+ rm -f -- $(prog) $(objs)
+
+install: $(prog)
+ mkdir -p -- $(DESTDIR)$(bindir)
+ install -s -m755 -- $(prog) $(DESTDIR)$(bindir)
--- /dev/null 2012-02-09 20:31:42.211948750 +0400
+++ kinit/fstype/Makefile 2012-02-09 18:20:54.148496981 +0400
@@ -0,0 +1,4 @@
+prog = fstype
+objs = main.o fstype.o
+
+include $(CURDIR)/../rules.mk
--- kinit/fstype/fstype.c.fix0 2012-02-09 18:20:53.000000000 +0400
+++ kinit/fstype/fstype.c 2012-02-09 18:20:54.149496981 +0400
@@ -9,18 +9,18 @@
* We currently detect the filesystems listed below in the struct
* "imagetype images" (in the order they are listed).
*/
-#include <sys/types.h>
#include <stdio.h>
-#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <endian.h>
#include <netinet/in.h>
#include <sys/utsname.h>
#include <sys/vfs.h>
+#include <linux/types.h>
+#include <asm/byteorder.h>
#define cpu_to_be32(x) __cpu_to_be32(x) /* Needed by romfs_fs.h */
#include "btrfs.h"