aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog1
-rw-r--r--TODO338
-rw-r--r--applets/busybox.c196
-rw-r--r--archival/tar.c513
-rw-r--r--busybox.c196
-rw-r--r--busybox.def.h4
-rw-r--r--console-tools/loadkmap.c4
-rw-r--r--coreutils/date.c4
-rw-r--r--coreutils/dd.c24
-rw-r--r--coreutils/ls.c5
-rw-r--r--coreutils/tee.c6
-rw-r--r--date.c4
-rw-r--r--dd.c24
-rw-r--r--fbset.c16
-rw-r--r--fdflush.c4
-rw-r--r--freeramdisk.c4
-rw-r--r--fsck_minix.c6
-rw-r--r--init.c3
-rw-r--r--init/init.c3
-rw-r--r--internal.h8
-rw-r--r--loadkmap.c4
-rw-r--r--ls.c5
-rw-r--r--mount.c4
-rw-r--r--tar.c513
-rw-r--r--tee.c6
-rw-r--r--umount.c4
-rw-r--r--util-linux/fbset.c16
-rw-r--r--util-linux/fdflush.c4
-rw-r--r--util-linux/freeramdisk.c4
-rw-r--r--util-linux/fsck_minix.c6
-rw-r--r--util-linux/mount.c4
-rw-r--r--util-linux/umount.c4
-rw-r--r--utility.c6
33 files changed, 1112 insertions, 831 deletions
diff --git a/Changelog b/Changelog
index c0ffd23cd..f3899dc12 100644
--- a/Changelog
+++ b/Changelog
@@ -55,6 +55,7 @@
55 * all mallocs now use xmalloc (and so are OOM error safe), and 55 * all mallocs now use xmalloc (and so are OOM error safe), and
56 the common error handling saves a few bytes. Thanks to 56 the common error handling saves a few bytes. Thanks to
57 Bob Tinsley <bob@earthrise.demon.co.uk> for the patch. 57 Bob Tinsley <bob@earthrise.demon.co.uk> for the patch.
58 * Fix "+" parsing bug in date, from "Merle F. McClelland" <mfm@cts.com>.
58 59
59 60
60 -Erik Andersen 61 -Erik Andersen
diff --git a/TODO b/TODO
index daa21cffd..87f48db38 100644
--- a/TODO
+++ b/TODO
@@ -128,3 +128,341 @@ I'll add this to the TODO list,
128 does also... 128 does also...
129 129
130 130
131------------------------------------------------------------------
132
133
134Date: Fri, 25 Feb 2000 08:23:12 +0000 (GMT)
135From: Riley Williams <rhw@MemAlpha.CX>
136X-Sender: rhw@moo.cus.org.uk
137To: almesber@lrc.di.epfl.ch
138Cc: "Albert D. Cahalan" <acahalan@cs.uml.edu>,
139 Linux Kernel <linux-kernel@vger.rutgers.edu>
140Subject: Re: What /proc should contain [was: /proc/driver/microcode]
141In-Reply-To: <20000224165245.A29790@lrc.di.epfl.ch>
142Message-ID: <Pine.LNX.4.21.0002250806220.8741-100000@moo.cus.org.uk>
143Sender: owner-linux-kernel@vger.rutgers.edu
144Precedence: bulk
145
146Hi there.
147
148 >> Nope, most /proc access is does via programs written in C.
149
150 > That varies a lot from file to file. E.g. I haven't seen any
151 > programs that are specificly designed to read /proc/atm/* yet,
152 > and I know of only one (fuser) that reads /proc/mounts,
153 > extracting only partial information (just to pick two examples
154 > that I'm quite familiar with).
155
156As a point of reference, here's a slightly tweaked analysis of the
157programs on the system I'm reading your mail on. Basically, I ran the
158following script...
159
160 Q> #!/bin/bash
161 Q> function use() {
162 Q> for Z in $* ; do
163 Q> strings $Z | grep /proc | sed "s=^=$Z ="
164 Q> done
165 Q> }
166 Q> use /{,s}bin/* /usr/{,s}bin/* | sort -u | tee proc-usage
167
168...and then went through it removing comments and print format
169strings. Replace /proc with /dev and you'd soon have an equivalent
170list for that - although I can report that such is MUCH larger...
171
172There are three programs therein that refer to /proc/mounts ...
173
174 /bin/mount
175 /bin/umount
176 /usr/bin/eject
177
178...and, as you stated, none that refer to /proc/atm on this system.
179However, as this is a RedHat Linux 5.0 based system, that's not
180necessarily an up to date reference thereto...
181
182Here's the list anyway...
183
184/bin/kill /proc/%d/cmdline
185/bin/kill /proc/%d/stat
186
187/bin/mount /proc/devices
188/bin/mount /proc/filesystems
189/bin/mount /proc/mounts
190
191/bin/netstat /proc/net
192/bin/netstat /proc/net/appletalk
193/bin/netstat /proc/net/ax25
194/bin/netstat /proc/net/ax25_route
195/bin/netstat /proc/net/dev
196/bin/netstat /proc/net/ip_masquerade
197/bin/netstat /proc/net/ipx
198/bin/netstat /proc/net/ipx_route
199/bin/netstat /proc/net/netstat
200/bin/netstat /proc/net/nr
201/bin/netstat /proc/net/nr_neigh
202/bin/netstat /proc/net/nr_nodes
203/bin/netstat /proc/net/raw
204/bin/netstat /proc/net/route
205/bin/netstat /proc/net/rt_cache
206/bin/netstat /proc/net/snmp
207/bin/netstat /proc/net/tcp
208/bin/netstat /proc/net/udp
209/bin/netstat /proc/net/unix
210
211/bin/umount /proc/devices
212/bin/umount /proc/mounts
213
214/sbin/arp /proc/net/appletalk
215/sbin/arp /proc/net/arp
216/sbin/arp /proc/net/ax25
217/sbin/arp /proc/net/ipx
218/sbin/arp /proc/net/nr
219/sbin/arp /proc/net/unix
220
221/sbin/cardctl /proc/devices
222
223/sbin/cardmgr /proc/devices
224
225/sbin/fdisk /proc/ide/%s/media
226/sbin/fdisk /proc/scsi/scsi
227
228/sbin/getty /proc/version
229
230/sbin/ifconfig /proc/net
231/sbin/ifconfig /proc/net/appletalk
232/sbin/ifconfig /proc/net/ax25
233/sbin/ifconfig /proc/net/dev
234/sbin/ifconfig /proc/net/ipx
235/sbin/ifconfig /proc/net/nr
236/sbin/ifconfig /proc/net/unix
237
238/sbin/ifup /proc/sys/kernel/modprobe
239
240/sbin/ipchains /proc/net/ip_fwchains
241/sbin/ipchains /proc/net/ip_fwnames
242/sbin/ipchains /proc/net/ip_masquerade
243/sbin/ipchains /proc/sys/net/ipv4/ip_forward
244
245/sbin/ipmaddr /proc/net/dev_mcast
246/sbin/ipmaddr /proc/net/igmp
247/sbin/ipmaddr /proc/net/igmp6
248
249/sbin/iptunnel /proc/net/dev
250
251/sbin/killall5 /proc/%s/cmdline
252/sbin/killall5 /proc/%s/exe
253/sbin/killall5 /proc/%s/stat
254/sbin/killall5 /proc/version
255
256/sbin/klogd /proc/kmsg
257
258/sbin/lsmod /proc/modules
259
260/sbin/modprobe /proc/modules
261
262/sbin/pidof /proc/%s/cmdline
263/sbin/pidof /proc/%s/exe
264/sbin/pidof /proc/%s/stat
265/sbin/pidof /proc/version
266
267/sbin/probe /proc/pci
268
269/sbin/rarp /proc/net/ax25
270/sbin/rarp /proc/net/nr
271/sbin/rarp /proc/net/rarp
272
273/sbin/rmmod /proc/modules
274
275/sbin/rmmod.static /proc/modules
276
277/sbin/route /proc/net/appletalk
278/sbin/route /proc/net/ax25
279/sbin/route /proc/net/ax25_route
280/sbin/route /proc/net/ipx
281/sbin/route /proc/net/ipx_route
282/sbin/route /proc/net/nr
283/sbin/route /proc/net/nr_neigh
284/sbin/route /proc/net/nr_nodes
285/sbin/route /proc/net/route
286/sbin/route /proc/net/rt_cache
287/sbin/route /proc/net/unix
288
289/sbin/scsi_info /proc/scsi
290/sbin/scsi_info /proc/scsi/%s
291/sbin/scsi_info /proc/scsi/scsi
292
293/sbin/slattach /proc/net/ax25
294/sbin/slattach /proc/net/nr
295
296/sbin/swapoff /proc/swaps
297
298/sbin/swapon /proc/swaps
299
300/sbin/uugetty /proc/version
301
302/usr/bin/dig /proc/
303/usr/bin/dig /proc/interrupts
304/usr/bin/dig /proc/meminfo
305/usr/bin/dig /proc/rtc
306/usr/bin/dig /proc/self/status
307/usr/bin/dig /proc/stat
308
309/usr/bin/dnsquery /proc/
310/usr/bin/dnsquery /proc/interrupts
311/usr/bin/dnsquery /proc/meminfo
312/usr/bin/dnsquery /proc/rtc
313/usr/bin/dnsquery /proc/self/status
314/usr/bin/dnsquery /proc/stat
315
316/usr/bin/eject /proc/mounts
317
318/usr/bin/emacs /proc/loadavg
319
320/usr/bin/fetchmail /proc/net/dev
321
322/usr/bin/free /proc/meminfo
323
324/usr/bin/gmake /proc/loadavg
325
326/usr/bin/gpm-root /proc/loadavg
327/usr/bin/gpm-root /proc/meminfo
328
329/usr/bin/host /proc/
330/usr/bin/host /proc/interrupts
331/usr/bin/host /proc/meminfo
332/usr/bin/host /proc/rtc
333/usr/bin/host /proc/self/status
334/usr/bin/host /proc/stat
335
336/usr/bin/hoststat /proc/loadavg
337
338/usr/bin/hwdiag /proc/cpuinfo
339/usr/bin/hwdiag /proc/pci
340/usr/bin/hwdiag /proc/scsi/scsi
341/usr/bin/hwdiag /proc/version
342
343/usr/bin/lsdev /proc/dma
344/usr/bin/lsdev /proc/interrupts
345/usr/bin/lsdev /proc/ioports
346
347/usr/bin/mailq /proc/loadavg
348
349/usr/bin/make /proc/loadavg
350
351/usr/bin/mcookie /proc/loadavg
352/usr/bin/mcookie /proc/stat
353
354/usr/bin/newaliases /proc/loadavg
355
356/usr/bin/nslookup /proc/
357/usr/bin/nslookup /proc/interrupts
358/usr/bin/nslookup /proc/meminfo
359/usr/bin/nslookup /proc/rtc
360/usr/bin/nslookup /proc/self/status
361/usr/bin/nslookup /proc/stat
362
363/usr/bin/nsupdate /proc/
364/usr/bin/nsupdate /proc/interrupts
365/usr/bin/nsupdate /proc/meminfo
366/usr/bin/nsupdate /proc/rtc
367/usr/bin/nsupdate /proc/self/status
368/usr/bin/nsupdate /proc/stat
369
370/usr/bin/pgp /proc/version
371/usr/bin/pgpe /proc/version
372/usr/bin/pgpk /proc/version
373/usr/bin/pgps /proc/version
374/usr/bin/pgpv /proc/version
375
376/usr/bin/procinfo /proc/cmdline
377/usr/bin/procinfo /proc/devices
378/usr/bin/procinfo /proc/dma
379/usr/bin/procinfo /proc/filesystems
380/usr/bin/procinfo /proc/interrupts
381/usr/bin/procinfo /proc/loadavg
382/usr/bin/procinfo /proc/meminfo
383/usr/bin/procinfo /proc/modules
384/usr/bin/procinfo /proc/stat
385/usr/bin/procinfo /proc/uptime
386/usr/bin/procinfo /proc/version
387
388/usr/bin/purgestat /proc/loadavg
389
390/usr/bin/screen /proc/loadavg
391
392/usr/bin/strace /proc/%d/stat
393
394/usr/bin/top /proc/cpuinfo
395/usr/bin/top /proc/meminfo
396/usr/bin/top /proc/stat
397
398/usr/bin/vmstat /proc/%s/stat
399/usr/bin/vmstat /proc/meminfo
400/usr/bin/vmstat /proc/stat
401
402/usr/sbin/atd /proc/loadavg
403
404/usr/sbin/dnskeygen /proc/
405/usr/sbin/dnskeygen /proc/interrupts
406/usr/sbin/dnskeygen /proc/meminfo
407/usr/sbin/dnskeygen /proc/rtc
408/usr/sbin/dnskeygen /proc/self/status
409/usr/sbin/dnskeygen /proc/stat
410
411/usr/sbin/fuser /proc/%d/stat
412/usr/sbin/fuser /proc/net/%s
413/usr/sbin/fuser /proc/net/unix
414
415/usr/sbin/in.identd /proc/net/tcp
416
417/usr/sbin/irpd /proc/
418/usr/sbin/irpd /proc/interrupts
419/usr/sbin/irpd /proc/meminfo
420/usr/sbin/irpd /proc/rtc
421/usr/sbin/irpd /proc/self/status
422/usr/sbin/irpd /proc/stat
423
424/usr/sbin/named /proc/
425/usr/sbin/named /proc/interrupts
426/usr/sbin/named /proc/meminfo
427/usr/sbin/named /proc/rtc
428/usr/sbin/named /proc/self/status
429/usr/sbin/named /proc/stat
430
431/usr/sbin/named-xfer /proc/
432/usr/sbin/named-xfer /proc/interrupts
433/usr/sbin/named-xfer /proc/meminfo
434/usr/sbin/named-xfer /proc/rtc
435/usr/sbin/named-xfer /proc/self/status
436/usr/sbin/named-xfer /proc/stat
437
438/usr/sbin/readprofile /proc/profile
439
440/usr/sbin/rwhod /proc/loadavg
441/usr/sbin/rwhod /proc/uptime
442
443/usr/sbin/sendmail /proc/loadavg
444
445/usr/sbin/setconsole /proc/openprom/options
446/usr/sbin/setconsole /proc/openprom/options/${console}-mode
447/usr/sbin/setconsole /proc/openprom/options/input-device
448/usr/sbin/setconsole /proc/openprom/options/output-device
449
450Best wishes from Riley.
451
452 * Copyright (C) 1999, Memory Alpha Systems.
453 * All rights and wrongs reserved.
454
455+----------------------------------------------------------------------+
456| There is something frustrating about the quality and speed of Linux |
457| development, ie., the quality is too high and the speed is too high, |
458| in other words, I can implement this XXXX feature, but I bet someone |
459| else has already done so and is just about to release their patch. |
460+----------------------------------------------------------------------+
461 * http://www.memalpha.cx/Linux/Kernel/
462
463
464-
465To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
466the body of a message to majordomo@vger.rutgers.edu
467Please read the FAQ at http://www.tux.org/lkml/
468
diff --git a/applets/busybox.c b/applets/busybox.c
index ee745e73e..95fee63d6 100644
--- a/applets/busybox.c
+++ b/applets/busybox.c
@@ -32,301 +32,301 @@ void *__libc_stack_end;
32 32
33static const struct Applet applets[] = { 33static const struct Applet applets[] = {
34 34
35#ifdef BB_BASENAME //usr/bin/basename 35#ifdef BB_BASENAME
36 {"basename", basename_main, _BB_DIR_USR_BIN}, 36 {"basename", basename_main, _BB_DIR_USR_BIN},
37#endif 37#endif
38#ifdef BB_BUSYBOX //bin 38#ifdef BB_BUSYBOX
39 {"busybox", busybox_main, _BB_DIR_BIN}, 39 {"busybox", busybox_main, _BB_DIR_BIN},
40#endif 40#endif
41#ifdef BB_BLOCK_DEVICE //sbin 41#ifdef BB_BLOCK_DEVICE
42 {"block_device", block_device_main, _BB_DIR_SBIN}, 42 {"block_device", block_device_main, _BB_DIR_SBIN},
43#endif 43#endif
44#ifdef BB_CAT //bin 44#ifdef BB_CAT
45 {"cat", cat_main, _BB_DIR_BIN}, 45 {"cat", cat_main, _BB_DIR_BIN},
46#endif 46#endif
47#ifdef BB_CHMOD_CHOWN_CHGRP //bin 47#ifdef BB_CHMOD_CHOWN_CHGRP
48 {"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN}, 48 {"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN},
49#endif 49#endif
50#ifdef BB_CHMOD_CHOWN_CHGRP //bin 50#ifdef BB_CHMOD_CHOWN_CHGRP
51 {"chown", chmod_chown_chgrp_main, _BB_DIR_BIN}, 51 {"chown", chmod_chown_chgrp_main, _BB_DIR_BIN},
52#endif 52#endif
53#ifdef BB_CHMOD_CHOWN_CHGRP //bin 53#ifdef BB_CHMOD_CHOWN_CHGRP
54 {"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN}, 54 {"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN},
55#endif 55#endif
56#ifdef BB_CHROOT //sbin 56#ifdef BB_CHROOT
57 {"chroot", chroot_main, _BB_DIR_SBIN}, 57 {"chroot", chroot_main, _BB_DIR_SBIN},
58#endif 58#endif
59#ifdef BB_CLEAR //usr/bin 59#ifdef BB_CLEAR
60 {"clear", clear_main, _BB_DIR_USR_BIN}, 60 {"clear", clear_main, _BB_DIR_USR_BIN},
61#endif 61#endif
62#ifdef BB_CHVT //usr/bin 62#ifdef BB_CHVT
63 {"chvt", chvt_main, _BB_DIR_USR_BIN}, 63 {"chvt", chvt_main, _BB_DIR_USR_BIN},
64#endif 64#endif
65#ifdef BB_CP_MV //bin 65#ifdef BB_CP_MV
66 {"cp", cp_mv_main, _BB_DIR_BIN}, 66 {"cp", cp_mv_main, _BB_DIR_BIN},
67#endif 67#endif
68#ifdef BB_CP_MV //bin 68#ifdef BB_CP_MV
69 {"mv", cp_mv_main, _BB_DIR_BIN}, 69 {"mv", cp_mv_main, _BB_DIR_BIN},
70#endif 70#endif
71#ifdef BB_DATE //bin 71#ifdef BB_DATE
72 {"date", date_main, _BB_DIR_BIN}, 72 {"date", date_main, _BB_DIR_BIN},
73#endif 73#endif
74#ifdef BB_DD //bin 74#ifdef BB_DD
75 {"dd", dd_main, _BB_DIR_BIN}, 75 {"dd", dd_main, _BB_DIR_BIN},
76#endif 76#endif
77#ifdef BB_DF //bin 77#ifdef BB_DF
78 {"df", df_main, _BB_DIR_BIN}, 78 {"df", df_main, _BB_DIR_BIN},
79#endif 79#endif
80#ifdef BB_DIRNAME //usr/bin 80#ifdef BB_DIRNAME
81 {"dirname", dirname_main, _BB_DIR_USR_BIN}, 81 {"dirname", dirname_main, _BB_DIR_USR_BIN},
82#endif 82#endif
83#ifdef BB_DMESG //bin 83#ifdef BB_DMESG
84 {"dmesg", dmesg_main, _BB_DIR_BIN}, 84 {"dmesg", dmesg_main, _BB_DIR_BIN},
85#endif 85#endif
86#ifdef BB_DU //bin 86#ifdef BB_DU
87 {"du", du_main, _BB_DIR_BIN}, 87 {"du", du_main, _BB_DIR_BIN},
88#endif 88#endif
89#ifdef BB_DUTMP //usr/sbin 89#ifdef BB_DUTMP
90 {"dutmp", dutmp_main, _BB_DIR_USR_SBIN}, 90 {"dutmp", dutmp_main, _BB_DIR_USR_SBIN},
91#endif 91#endif
92#ifdef BB_ECHO //bin 92#ifdef BB_ECHO
93 {"echo", echo_main, _BB_DIR_BIN}, 93 {"echo", echo_main, _BB_DIR_BIN},
94#endif 94#endif
95#ifdef BB_FBSET //usr/sbin 95#ifdef BB_FBSET
96 {"fbset", fbset_main, _BB_DIR_USR_SBIN}, 96 {"fbset", fbset_main, _BB_DIR_USR_SBIN},
97#endif 97#endif
98#ifdef BB_FDFLUSH //bin 98#ifdef BB_FDFLUSH
99 {"fdflush", fdflush_main, _BB_DIR_BIN}, 99 {"fdflush", fdflush_main, _BB_DIR_BIN},
100#endif 100#endif
101#ifdef BB_FIND //usr/bin 101#ifdef BB_FIND
102 {"find", find_main, _BB_DIR_USR_BIN}, 102 {"find", find_main, _BB_DIR_USR_BIN},
103#endif 103#endif
104#ifdef BB_FREE //usr/bin 104#ifdef BB_FREE
105 {"free", free_main, _BB_DIR_USR_BIN}, 105 {"free", free_main, _BB_DIR_USR_BIN},
106#endif 106#endif
107#ifdef BB_FREERAMDISK //sbin 107#ifdef BB_FREERAMDISK
108 {"freeramdisk", freeramdisk_main, _BB_DIR_SBIN}, 108 {"freeramdisk", freeramdisk_main, _BB_DIR_SBIN},
109#endif 109#endif
110#ifdef BB_DEALLOCVT //usr/bin 110#ifdef BB_DEALLOCVT
111 {"deallocvt", deallocvt_main, _BB_DIR_USR_BIN}, 111 {"deallocvt", deallocvt_main, _BB_DIR_USR_BIN},
112#endif 112#endif
113#ifdef BB_FSCK_MINIX //sbin 113#ifdef BB_FSCK_MINIX
114 {"fsck.minix", fsck_minix_main, _BB_DIR_SBIN}, 114 {"fsck.minix", fsck_minix_main, _BB_DIR_SBIN},
115#endif 115#endif
116#ifdef BB_MKFS_MINIX //sbin 116#ifdef BB_MKFS_MINIX
117 {"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN}, 117 {"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN},
118#endif 118#endif
119#ifdef BB_GREP //bin 119#ifdef BB_GREP
120 {"grep", grep_main, _BB_DIR_BIN}, 120 {"grep", grep_main, _BB_DIR_BIN},
121#endif 121#endif
122#ifdef BB_HALT //sbin 122#ifdef BB_HALT
123 {"halt", halt_main, _BB_DIR_SBIN}, 123 {"halt", halt_main, _BB_DIR_SBIN},
124#endif 124#endif
125#ifdef BB_HEAD //bin 125#ifdef BB_HEAD
126 {"head", head_main, _BB_DIR_BIN}, 126 {"head", head_main, _BB_DIR_BIN},
127#endif 127#endif
128#ifdef BB_HOSTID //usr/bin 128#ifdef BB_HOSTID
129 {"hostid", hostid_main, _BB_DIR_USR_BIN}, 129 {"hostid", hostid_main, _BB_DIR_USR_BIN},
130#endif 130#endif
131#ifdef BB_HOSTNAME //bin 131#ifdef BB_HOSTNAME
132 {"hostname", hostname_main, _BB_DIR_BIN}, 132 {"hostname", hostname_main, _BB_DIR_BIN},
133#endif 133#endif
134#ifdef BB_INIT //sbin 134#ifdef BB_INIT
135 {"init", init_main, _BB_DIR_SBIN}, 135 {"init", init_main, _BB_DIR_SBIN},
136#endif 136#endif
137#ifdef BB_INSMOD //sbin 137#ifdef BB_INSMOD
138 {"insmod", insmod_main, _BB_DIR_SBIN}, 138 {"insmod", insmod_main, _BB_DIR_SBIN},
139#endif 139#endif
140#ifdef BB_FEATURE_LINUXRC // 140#ifdef BB_FEATURE_LINUXRC //
141 {"linuxrc", init_main, _BB_DIR_ROOT}, 141 {"linuxrc", init_main, _BB_DIR_ROOT},
142#endif 142#endif
143#ifdef BB_KILL //bin 143#ifdef BB_KILL
144 {"kill", kill_main, _BB_DIR_BIN}, 144 {"kill", kill_main, _BB_DIR_BIN},
145#endif 145#endif
146#ifdef BB_KILLALL //usr/bin 146#ifdef BB_KILLALL
147 {"killall", kill_main, _BB_DIR_USR_BIN}, 147 {"killall", kill_main, _BB_DIR_USR_BIN},
148#endif 148#endif
149#ifdef BB_LENGTH //usr/bin 149#ifdef BB_LENGTH
150 {"length", length_main, _BB_DIR_USR_BIN}, 150 {"length", length_main, _BB_DIR_USR_BIN},
151#endif 151#endif
152#ifdef BB_LN //bin 152#ifdef BB_LN
153 {"ln", ln_main, _BB_DIR_BIN}, 153 {"ln", ln_main, _BB_DIR_BIN},
154#endif 154#endif
155#ifdef BB_LOADACM //usr/bin 155#ifdef BB_LOADACM
156 {"loadacm", loadacm_main, _BB_DIR_USR_BIN}, 156 {"loadacm", loadacm_main, _BB_DIR_USR_BIN},
157#endif 157#endif
158#ifdef BB_LOADFONT //usr/bin 158#ifdef BB_LOADFONT
159 {"loadfont", loadfont_main, _BB_DIR_USR_BIN}, 159 {"loadfont", loadfont_main, _BB_DIR_USR_BIN},
160#endif 160#endif
161#ifdef BB_LOADKMAP //sbin 161#ifdef BB_LOADKMAP
162 {"loadkmap", loadkmap_main, _BB_DIR_SBIN}, 162 {"loadkmap", loadkmap_main, _BB_DIR_SBIN},
163#endif 163#endif
164#ifdef BB_LS //bin 164#ifdef BB_LS
165 {"ls", ls_main, _BB_DIR_BIN}, 165 {"ls", ls_main, _BB_DIR_BIN},
166#endif 166#endif
167#ifdef BB_LSMOD //sbin 167#ifdef BB_LSMOD
168 {"lsmod", lsmod_main, _BB_DIR_SBIN}, 168 {"lsmod", lsmod_main, _BB_DIR_SBIN},
169#endif 169#endif
170#ifdef BB_MAKEDEVS //sbin 170#ifdef BB_MAKEDEVS
171 {"makedevs", makedevs_main, _BB_DIR_SBIN}, 171 {"makedevs", makedevs_main, _BB_DIR_SBIN},
172#endif 172#endif
173#ifdef BB_MATH //usr/bin 173#ifdef BB_MATH
174 {"math", math_main, _BB_DIR_USR_BIN}, 174 {"math", math_main, _BB_DIR_USR_BIN},
175#endif 175#endif
176#ifdef BB_MKDIR //bin 176#ifdef BB_MKDIR
177 {"mkdir", mkdir_main, _BB_DIR_BIN}, 177 {"mkdir", mkdir_main, _BB_DIR_BIN},
178#endif 178#endif
179#ifdef BB_MKFIFO //usr/bin 179#ifdef BB_MKFIFO
180 {"mkfifo", mkfifo_main, _BB_DIR_USR_BIN}, 180 {"mkfifo", mkfifo_main, _BB_DIR_USR_BIN},
181#endif 181#endif
182#ifdef BB_MKNOD //bin 182#ifdef BB_MKNOD
183 {"mknod", mknod_main, _BB_DIR_BIN}, 183 {"mknod", mknod_main, _BB_DIR_BIN},
184#endif 184#endif
185#ifdef BB_MKSWAP //sbin 185#ifdef BB_MKSWAP
186 {"mkswap", mkswap_main, _BB_DIR_SBIN}, 186 {"mkswap", mkswap_main, _BB_DIR_SBIN},
187#endif 187#endif
188#ifdef BB_MNC //usr/bin 188#ifdef BB_MNC
189 {"mnc", mnc_main, _BB_DIR_USR_BIN}, 189 {"mnc", mnc_main, _BB_DIR_USR_BIN},
190#endif 190#endif
191#ifdef BB_MORE //bin 191#ifdef BB_MORE
192 {"more", more_main, _BB_DIR_BIN}, 192 {"more", more_main, _BB_DIR_BIN},
193#endif 193#endif
194#ifdef BB_MOUNT //bin 194#ifdef BB_MOUNT
195 {"mount", mount_main, _BB_DIR_BIN}, 195 {"mount", mount_main, _BB_DIR_BIN},
196#endif 196#endif
197#ifdef BB_MT //bin 197#ifdef BB_MT
198 {"mt", mt_main, _BB_DIR_BIN}, 198 {"mt", mt_main, _BB_DIR_BIN},
199#endif 199#endif
200#ifdef BB_NSLOOKUP //usr/bin 200#ifdef BB_NSLOOKUP
201 {"nslookup", nslookup_main, _BB_DIR_USR_BIN}, 201 {"nslookup", nslookup_main, _BB_DIR_USR_BIN},
202#endif 202#endif
203#ifdef BB_PING //bin 203#ifdef BB_PING
204 {"ping", ping_main, _BB_DIR_BIN}, 204 {"ping", ping_main, _BB_DIR_BIN},
205#endif 205#endif
206#ifdef BB_POWEROFF //sbin 206#ifdef BB_POWEROFF
207 {"poweroff", poweroff_main, _BB_DIR_SBIN}, 207 {"poweroff", poweroff_main, _BB_DIR_SBIN},
208#endif 208#endif
209#ifdef BB_PRINTF //usr/bin 209#ifdef BB_PRINTF
210 {"printf", printf_main, _BB_DIR_USR_BIN}, 210 {"printf", printf_main, _BB_DIR_USR_BIN},
211#endif 211#endif
212#ifdef BB_PS //bin 212#ifdef BB_PS
213 {"ps", ps_main, _BB_DIR_BIN}, 213 {"ps", ps_main, _BB_DIR_BIN},
214#endif 214#endif
215#ifdef BB_PWD //bin 215#ifdef BB_PWD
216 {"pwd", pwd_main, _BB_DIR_BIN}, 216 {"pwd", pwd_main, _BB_DIR_BIN},
217#endif 217#endif
218#ifdef BB_REBOOT //sbin 218#ifdef BB_REBOOT
219 {"reboot", reboot_main, _BB_DIR_SBIN}, 219 {"reboot", reboot_main, _BB_DIR_SBIN},
220#endif 220#endif
221#ifdef BB_RM //bin 221#ifdef BB_RM
222 {"rm", rm_main, _BB_DIR_BIN}, 222 {"rm", rm_main, _BB_DIR_BIN},
223#endif 223#endif
224#ifdef BB_RMDIR //bin 224#ifdef BB_RMDIR
225 {"rmdir", rmdir_main, _BB_DIR_BIN}, 225 {"rmdir", rmdir_main, _BB_DIR_BIN},
226#endif 226#endif
227#ifdef BB_RMMOD //sbin 227#ifdef BB_RMMOD
228 {"rmmod", rmmod_main, _BB_DIR_SBIN}, 228 {"rmmod", rmmod_main, _BB_DIR_SBIN},
229#endif 229#endif
230#ifdef BB_SED //bin 230#ifdef BB_SED
231 {"sed", sed_main, _BB_DIR_BIN}, 231 {"sed", sed_main, _BB_DIR_BIN},
232#endif 232#endif
233#ifdef BB_SH //bin 233#ifdef BB_SH
234 {"sh", shell_main, _BB_DIR_BIN}, 234 {"sh", shell_main, _BB_DIR_BIN},
235#endif 235#endif
236#ifdef BB_SFDISK //sbin 236#ifdef BB_SFDISK
237 {"fdisk", sfdisk_main, _BB_DIR_SBIN}, 237 {"fdisk", sfdisk_main, _BB_DIR_SBIN},
238#ifdef BB_SFDISK //sbin 238#ifdef BB_SFDISK
239#endif 239#endif
240 {"sfdisk", sfdisk_main, _BB_DIR_SBIN}, 240 {"sfdisk", sfdisk_main, _BB_DIR_SBIN},
241#endif 241#endif
242#ifdef BB_SLEEP //bin 242#ifdef BB_SLEEP
243 {"sleep", sleep_main, _BB_DIR_BIN}, 243 {"sleep", sleep_main, _BB_DIR_BIN},
244#endif 244#endif
245#ifdef BB_SORT //bin 245#ifdef BB_SORT
246 {"sort", sort_main, _BB_DIR_BIN}, 246 {"sort", sort_main, _BB_DIR_BIN},
247#endif 247#endif
248#ifdef BB_SYNC //bin 248#ifdef BB_SYNC
249 {"sync", sync_main, _BB_DIR_BIN}, 249 {"sync", sync_main, _BB_DIR_BIN},
250#endif 250#endif
251#ifdef BB_SYSLOGD //sbin 251#ifdef BB_SYSLOGD
252 {"syslogd", syslogd_main, _BB_DIR_SBIN}, 252 {"syslogd", syslogd_main, _BB_DIR_SBIN},
253#endif 253#endif
254#ifdef BB_LOGGER //usr/bin 254#ifdef BB_LOGGER
255 {"logger", logger_main, _BB_DIR_USR_BIN}, 255 {"logger", logger_main, _BB_DIR_USR_BIN},
256#endif 256#endif
257#ifdef BB_LOGNAME //usr/bin 257#ifdef BB_LOGNAME
258 {"logname", logname_main, _BB_DIR_USR_BIN}, 258 {"logname", logname_main, _BB_DIR_USR_BIN},
259#endif 259#endif
260#ifdef BB_SWAPONOFF //sbin 260#ifdef BB_SWAPONOFF
261 {"swapon", swap_on_off_main, _BB_DIR_SBIN}, 261 {"swapon", swap_on_off_main, _BB_DIR_SBIN},
262#endif 262#endif
263#ifdef BB_SWAPONOFF //sbin 263#ifdef BB_SWAPONOFF
264 {"swapoff", swap_on_off_main, _BB_DIR_SBIN}, 264 {"swapoff", swap_on_off_main, _BB_DIR_SBIN},
265#endif 265#endif
266#ifdef BB_TAIL //usr/bin 266#ifdef BB_TAIL
267 {"tail", tail_main, _BB_DIR_USR_BIN}, 267 {"tail", tail_main, _BB_DIR_USR_BIN},
268#endif 268#endif
269#ifdef BB_TAR //bin 269#ifdef BB_TAR
270 {"tar", tar_main, _BB_DIR_BIN}, 270 {"tar", tar_main, _BB_DIR_BIN},
271#endif 271#endif
272#ifdef BB_TELNET //usr/bin 272#ifdef BB_TELNET
273 {"telnet", telnet_main, _BB_DIR_USR_BIN}, 273 {"telnet", telnet_main, _BB_DIR_USR_BIN},
274#endif 274#endif
275#ifdef BB_TEST //usr/bin 275#ifdef BB_TEST
276 {"[", test_main, _BB_DIR_USR_BIN}, 276 {"[", test_main, _BB_DIR_USR_BIN},
277#endif 277#endif
278#ifdef BB_TEST //usr/bin 278#ifdef BB_TEST
279 {"test", test_main, _BB_DIR_USR_BIN}, 279 {"test", test_main, _BB_DIR_USR_BIN},
280#endif 280#endif
281#ifdef BB_TEE //bin 281#ifdef BB_TEE
282 {"tee", tee_main, _BB_DIR_BIN}, 282 {"tee", tee_main, _BB_DIR_BIN},
283#endif 283#endif
284#ifdef BB_TOUCH //usr/bin 284#ifdef BB_TOUCH
285 {"touch", touch_main, _BB_DIR_USR_BIN}, 285 {"touch", touch_main, _BB_DIR_USR_BIN},
286#endif 286#endif
287#ifdef BB_TR //usr/bin 287#ifdef BB_TR
288 {"tr", tr_main, _BB_DIR_USR_BIN}, 288 {"tr", tr_main, _BB_DIR_USR_BIN},
289#endif 289#endif
290#ifdef BB_TRUE_FALSE //bin 290#ifdef BB_TRUE_FALSE
291 {"true", true_main, _BB_DIR_BIN}, 291 {"true", true_main, _BB_DIR_BIN},
292#endif 292#endif
293#ifdef BB_TRUE_FALSE //bin 293#ifdef BB_TRUE_FALSE
294 {"false", false_main, _BB_DIR_BIN}, 294 {"false", false_main, _BB_DIR_BIN},
295#endif 295#endif
296#ifdef BB_TTY //usr/bin 296#ifdef BB_TTY
297 {"tty", tty_main, _BB_DIR_USR_BIN}, 297 {"tty", tty_main, _BB_DIR_USR_BIN},
298#endif 298#endif
299#ifdef BB_UMOUNT //bin 299#ifdef BB_UMOUNT
300 {"umount", umount_main, _BB_DIR_BIN}, 300 {"umount", umount_main, _BB_DIR_BIN},
301#endif 301#endif
302#ifdef BB_UNAME //bin 302#ifdef BB_UNAME
303 {"uname", uname_main, _BB_DIR_BIN}, 303 {"uname", uname_main, _BB_DIR_BIN},
304#endif 304#endif
305#ifdef BB_UPTIME //usr/bin 305#ifdef BB_UPTIME
306 {"uptime", uptime_main, _BB_DIR_USR_BIN}, 306 {"uptime", uptime_main, _BB_DIR_USR_BIN},
307#endif 307#endif
308#ifdef BB_UNIQ //bin 308#ifdef BB_UNIQ
309 {"uniq", uniq_main, _BB_DIR_BIN}, 309 {"uniq", uniq_main, _BB_DIR_BIN},
310#endif 310#endif
311#ifdef BB_UPDATE //sbin 311#ifdef BB_UPDATE
312 {"update", update_main, _BB_DIR_SBIN}, 312 {"update", update_main, _BB_DIR_SBIN},
313#endif 313#endif
314#ifdef BB_WC //usr/bin 314#ifdef BB_WC
315 {"wc", wc_main, _BB_DIR_USR_BIN}, 315 {"wc", wc_main, _BB_DIR_USR_BIN},
316#endif 316#endif
317#ifdef BB_WHOAMI //usr/bin 317#ifdef BB_WHOAMI
318 {"whoami", whoami_main, _BB_DIR_USR_BIN}, 318 {"whoami", whoami_main, _BB_DIR_USR_BIN},
319#endif 319#endif
320#ifdef BB_YES //usr/bin 320#ifdef BB_YES
321 {"yes", yes_main, _BB_DIR_USR_BIN}, 321 {"yes", yes_main, _BB_DIR_USR_BIN},
322#endif 322#endif
323#ifdef BB_GUNZIP //bin 323#ifdef BB_GUNZIP
324 {"zcat", gunzip_main, _BB_DIR_BIN}, 324 {"zcat", gunzip_main, _BB_DIR_BIN},
325#endif 325#endif
326#ifdef BB_GUNZIP //bin 326#ifdef BB_GUNZIP
327 {"gunzip", gunzip_main, _BB_DIR_BIN}, 327 {"gunzip", gunzip_main, _BB_DIR_BIN},
328#endif 328#endif
329#ifdef BB_GZIP //bin 329#ifdef BB_GZIP
330 {"gzip", gzip_main, _BB_DIR_BIN}, 330 {"gzip", gzip_main, _BB_DIR_BIN},
331#endif 331#endif
332 {0} 332 {0}
diff --git a/archival/tar.c b/archival/tar.c
index 8f802de64..8f83d04a6 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -68,57 +68,84 @@ static const char tar_usage[] =
68#endif 68#endif
69 69
70 70
71/* 71/* Tar file constants */
72 * Tar file constants.
73 */
74#define TAR_BLOCK_SIZE 512
75#define TAR_NAME_SIZE 100
76 72
77 73
78/* 74/* POSIX tar Header Block, from POSIX 1003.1-1990 */
79 * The POSIX (and basic GNU) tar header format. 75struct TarHeader
80 * This structure is always embedded in a TAR_BLOCK_SIZE sized block 76{
81 * with zero padding. We only process this information minimally. 77 /* byte offset */
82 */ 78 char name[100]; /* 0 */
83typedef struct { 79 char mode[8]; /* 100 */
84 char name[TAR_NAME_SIZE]; 80 char uid[8]; /* 108 */
85 char mode[8]; 81 char gid[8]; /* 116 */
86 char uid[8]; 82 char size[12]; /* 124 */
87 char gid[8]; 83 char mtime[12]; /* 136 */
88 char size[12]; 84 char chksum[8]; /* 148 */
89 char mtime[12]; 85 char typeflag; /* 156 */
90 char checkSum[8]; 86 char linkname[100]; /* 157 */
91 char typeFlag; 87 char magic[6]; /* 257 */
92 char linkName[TAR_NAME_SIZE]; 88 char version[2]; /* 263 */
93 char magic[6]; 89 char uname[32]; /* 265 */
94 char version[2]; 90 char gname[32]; /* 297 */
95 char uname[32]; 91 char devmajor[8]; /* 329 */
96 char gname[32]; 92 char devminor[8]; /* 337 */
97 char devMajor[8]; 93 char prefix[155]; /* 345 */
98 char devMinor[8]; 94 /* padding 500 */
99 char prefix[155]; 95};
100} TarHeader; 96typedef struct TarHeader TarHeader;
101 97
102#define TAR_MAGIC "ustar" 98
103#define TAR_VERSION "00" 99/* A few useful constants */
104 100#define TAR_MAGIC "ustar" /* ustar and a null */
105#define TAR_TYPE_REGULAR '0' 101#define TAR_VERSION "00" /* 00 and no null */
106#define TAR_TYPE_HARD_LINK '1' 102#define TAR_MAGIC_LEN 6
107#define TAR_TYPE_SOFT_LINK '2' 103#define TAR_VERSION_LEN 2
104#define TAR_NAME_LEN 100
105#define TAR_BLOCK_SIZE 512
106
107/* A nice enum with all the possible tar file content types */
108enum TarFileType
109{
110 REGTYPE = '0', /* regular file */
111 REGTYPE0 = '\0', /* regular file (ancient bug compat)*/
112 LNKTYPE = '1', /* hard link */
113 SYMTYPE = '2', /* symbolic link */
114 CHRTYPE = '3', /* character special */
115 BLKTYPE = '4', /* block special */
116 DIRTYPE = '5', /* directory */
117 FIFOTYPE = '6', /* FIFO special */
118 CONTTYPE = '7', /* reserved */
119};
120typedef enum TarFileType TarFileType;
121
122/* This struct ignores magic, non-numeric user name,
123 * non-numeric group name, and the checksum, since
124 * these are all ignored by BusyBox tar. */
125struct TarInfo
126{
127 int tarFd; /* An open file descriptor for reading from the tarball */
128 char * name; /* File name */
129 mode_t mode; /* Unix mode, including device bits. */
130 uid_t uid; /* Numeric UID */
131 gid_t gid; /* Numeric GID */
132 size_t size; /* Size of file */
133 time_t mtime; /* Last-modified time */
134 enum TarFileType type; /* Regular, directory, link, etc */
135 char * linkname; /* Name for symbolic and hard links */
136 dev_t device; /* Special device for mknod() */
137};
138typedef struct TarInfo TarInfo;
139
140/* Static data */
141static const unsigned long TarChecksumOffset = (const unsigned long)&(((TarHeader *)0)->chksum);
108 142
109 143
110/* 144/*
111 * Static data. 145 * Static data.
112 */ 146 */
113static int listFlag;
114static int extractFlag;
115static int createFlag;
116static int verboseFlag;
117static int tostdoutFlag;
118
119static int inHeader; // <- check me 147static int inHeader; // <- check me
120static int badHeader; 148static int badHeader;
121static int errorFlag;
122static int skipFileFlag; 149static int skipFileFlag;
123static int warnedRoot; 150static int warnedRoot;
124static int eofFlag; 151static int eofFlag;
@@ -134,7 +161,6 @@ static time_t mtime;
134/* 161/*
135 * Static data associated with the tar file. 162 * Static data associated with the tar file.
136 */ 163 */
137static const char *tarName;
138static int tarFd; 164static int tarFd;
139static dev_t tarDev; 165static dev_t tarDev;
140static ino_t tarInode; 166static ino_t tarInode;
@@ -143,35 +169,25 @@ static ino_t tarInode;
143/* 169/*
144 * Local procedures to restore files from a tar file. 170 * Local procedures to restore files from a tar file.
145 */ 171 */
146static void readTarFile(int fileCount, char **fileTable); 172static int readTarFile(const char* tarName, int extractFlag, int listFlag,
173 int tostdoutFlag, int verboseFlag);
147static void readData(const char *cp, int count); 174static void readData(const char *cp, int count);
148static long getOctal(const char *cp, int len); 175static long getOctal(const char *cp, int len);
149 176static int parseTarHeader(struct TarHeader *rawHeader, struct TarInfo *header);
150static void readHeader(const TarHeader * hp,
151
152 int fileCount, char **fileTable);
153
154static int wantFileName(const char *fileName, 177static int wantFileName(const char *fileName,
155 178 int argc, char **argv);
156 int fileCount, char **fileTable);
157 179
158#ifdef BB_FEATURE_TAR_CREATE 180#ifdef BB_FEATURE_TAR_CREATE
159/* 181/*
160 * Local procedures to save files into a tar file. 182 * Local procedures to save files into a tar file.
161 */ 183 */
162static void saveFile(const char *fileName, int seeLinks); 184static void saveFile(const char *fileName, int seeLinks);
163
164static void saveRegularFile(const char *fileName, 185static void saveRegularFile(const char *fileName,
165
166 const struct stat *statbuf); 186 const struct stat *statbuf);
167
168static void saveDirectory(const char *fileName, 187static void saveDirectory(const char *fileName,
169
170 const struct stat *statbuf); 188 const struct stat *statbuf);
171
172static void writeHeader(const char *fileName, const struct stat *statbuf); 189static void writeHeader(const char *fileName, const struct stat *statbuf);
173 190static void writeTarFile(int argc, char **argv);
174static void writeTarFile(int fileCount, char **fileTable);
175static void writeTarBlock(const char *buf, int len); 191static void writeTarBlock(const char *buf, int len);
176static int putOctal(char *cp, int len, long value); 192static int putOctal(char *cp, int len, long value);
177 193
@@ -180,7 +196,13 @@ static int putOctal(char *cp, int len, long value);
180 196
181extern int tar_main(int argc, char **argv) 197extern int tar_main(int argc, char **argv)
182{ 198{
199 const char *tarName=NULL;
183 const char *options; 200 const char *options;
201 int listFlag = FALSE;
202 int extractFlag = FALSE;
203 int createFlag = FALSE;
204 int verboseFlag = FALSE;
205 int tostdoutFlag = FALSE;
184 206
185 argc--; 207 argc--;
186 argv++; 208 argv++;
@@ -188,21 +210,7 @@ extern int tar_main(int argc, char **argv)
188 if (argc < 1) 210 if (argc < 1)
189 usage(tar_usage); 211 usage(tar_usage);
190 212
191 213 /* Parse options */
192 errorFlag = FALSE;
193 extractFlag = FALSE;
194 createFlag = FALSE;
195 listFlag = FALSE;
196 verboseFlag = FALSE;
197 tostdoutFlag = FALSE;
198 tarName = NULL;
199 tarDev = 0;
200 tarInode = 0;
201 tarFd = -1;
202
203 /*
204 * Parse the options.
205 */
206 if (**argv == '-') 214 if (**argv == '-')
207 options = (*argv++) + 1; 215 options = (*argv++) + 1;
208 else 216 else
@@ -212,13 +220,12 @@ extern int tar_main(int argc, char **argv)
212 for (; *options; options++) { 220 for (; *options; options++) {
213 switch (*options) { 221 switch (*options) {
214 case 'f': 222 case 'f':
215 if (tarName != NULL) { 223 if (tarName != NULL)
216 fprintf(stderr, "Only one 'f' option allowed\n"); 224 fatalError( "Only one 'f' option allowed\n");
217
218 exit(FALSE);
219 }
220 225
221 tarName = *argv++; 226 tarName = *argv++;
227 if (tarName == NULL)
228 fatalError( "Option requires an argument: No file specified\n");
222 argc--; 229 argc--;
223 230
224 break; 231 break;
@@ -253,9 +260,8 @@ extern int tar_main(int argc, char **argv)
253 break; 260 break;
254 261
255 default: 262 default:
256 fprintf(stderr, "Unknown tar flag '%c'\n" 263 fatalError( "Unknown tar flag '%c'\n"
257 "Try `tar --help' for more information\n", *options); 264 "Try `tar --help' for more information\n", *options);
258 exit(FALSE);
259 } 265 }
260 } 266 }
261 267
@@ -265,23 +271,22 @@ extern int tar_main(int argc, char **argv)
265 */ 271 */
266 if (createFlag == TRUE) { 272 if (createFlag == TRUE) {
267#ifndef BB_FEATURE_TAR_CREATE 273#ifndef BB_FEATURE_TAR_CREATE
268 fprintf(stderr, 274 fatalError( "This version of tar was not compiled with tar creation support.\n");
269 "This version of tar was not compiled with tar creation support.\n");
270 exit(FALSE);
271#else 275#else
272 writeTarFile(argc, argv); 276 exit(writeTarFile(argc, argv));
273#endif 277#endif
274 } else { 278 } else {
275 readTarFile(argc, argv); 279 exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag));
276 } 280 }
277 if (errorFlag == TRUE) {
278 fprintf(stderr, "\n");
279 }
280 exit(!errorFlag);
281 281
282 flagError: 282 flagError:
283 fprintf(stderr, "Exactly one of 'c', 'x' or 't' must be specified\n"); 283 fatalError( "Exactly one of 'c', 'x' or 't' must be specified\n");
284 exit(FALSE); 284}
285
286static void
287tarExtractRegularFile(TarInfo *header, int extractFlag, int listFlag, int tostdoutFlag, int verboseFlag)
288{
289
285} 290}
286 291
287 292
@@ -289,178 +294,148 @@ extern int tar_main(int argc, char **argv)
289 * Read a tar file and extract or list the specified files within it. 294 * Read a tar file and extract or list the specified files within it.
290 * If the list is empty than all files are extracted or listed. 295 * If the list is empty than all files are extracted or listed.
291 */ 296 */
292static void readTarFile(int fileCount, char **fileTable) 297static int readTarFile(const char* tarName, int extractFlag, int listFlag,
298 int tostdoutFlag, int verboseFlag)
293{ 299{
294 const char *cp; 300 int status, tarFd=0;
295 int cc; 301 int errorFlag=FALSE;
296 int inCc; 302 TarHeader rawHeader;
297 int blockSize; 303 TarInfo header;
298 char buf[BUF_SIZE];
299
300 skipFileFlag = FALSE;
301 badHeader = FALSE;
302 warnedRoot = FALSE;
303 eofFlag = FALSE;
304 inHeader = TRUE;
305 inCc = 0;
306 dataCc = 0;
307 outFd = -1;
308 blockSize = sizeof(buf);
309 cp = buf;
310 304
311 /* 305 /* Open the tar file for reading. */
312 * Open the tar file for reading. 306 if (!strcmp(tarName, "-"))
313 */
314 if ((tarName == NULL) || !strcmp(tarName, "-")) {
315 tarFd = fileno(stdin); 307 tarFd = fileno(stdin);
316 } else 308 else
317 tarFd = open(tarName, O_RDONLY); 309 tarFd = open(tarName, O_RDONLY);
318
319 if (tarFd < 0) { 310 if (tarFd < 0) {
320 perror(tarName); 311 errorMsg( "Error opening '%s': %s", tarName, strerror(errno));
321 errorFlag = TRUE; 312 return ( FALSE);
322 return;
323 } 313 }
324 314
325 /* 315 /* Read the tar file */
326 * Read blocks from the file until an end of file header block 316 while ( (status = fullRead(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) {
327 * has been seen. (A real end of file from a read is an error.) 317 /* Now see if the header looks ok */
328 */ 318 if ( parseTarHeader(&rawHeader, &header) == FALSE ) {
329 while (eofFlag == FALSE) { 319 close( tarFd);
330 /* 320 if ( *(header.name) == '\0' ) {
331 * Read the next block of data if necessary. 321 goto endgame;
332 * This will be a large block if possible, which we will 322 } else {
333 * then process in the small tar blocks. 323 errorFlag=TRUE;
334 */ 324 errorMsg("Bad tar header, skipping\n");
335 if (inCc <= 0) { 325 continue;
336 cp = buf;
337 inCc = fullRead(tarFd, buf, blockSize);
338
339 if (inCc < 0) {
340 perror(tarName);
341 errorFlag = TRUE;
342 goto done;
343 }
344
345 if (inCc == 0) {
346 fprintf(stderr,
347 "Unexpected end of file from \"%s\"", tarName);
348 errorFlag = TRUE;
349 goto done;
350 } 326 }
351 } 327 }
352 328 if ( *(header.name) == '\0' )
353 /* 329 goto endgame;
354 * If we are expecting a header block then examine it. 330
355 */ 331 /* If we got here, we can be certain we have a legitimate
356 if (inHeader == TRUE) { 332 * header to work with. So work with it. */
357 readHeader((const TarHeader *) cp, fileCount, fileTable); 333 switch ( header.type ) {
358 334 case REGTYPE:
359 cp += TAR_BLOCK_SIZE; 335 case REGTYPE0:
360 inCc -= TAR_BLOCK_SIZE; 336 /* If the name ends in a '/' then assume it is
361 337 * supposed to be a directory, and fall through */
362 continue; 338 if (header.name[strlen(header.name)-1] != '/') {
339 tarExtractRegularFile(&header, extractFlag, listFlag, tostdoutFlag, verboseFlag);
340 break;
341 }
342#if 0
343 case Directory:
344 tarExtractDirectory( &header, extractFlag, listFlag, tostdoutFlag, verboseFlag);
345 break;
346 case HardLink:
347 tarExtractHardLink( &header, extractFlag, listFlag, tostdoutFlag, verboseFlag);
348 break;
349 case SymbolicLink:
350 tarExtractSymLink( &header, extractFlag, listFlag, tostdoutFlag, verboseFlag);
351 break;
352 case CharacterDevice:
353 case BlockDevice:
354 case FIFO:
355 tarExtractSpecial( &header, extractFlag, listFlag, tostdoutFlag, verboseFlag);
356 break;
357#endif
358 default:
359 close( tarFd);
360 return( FALSE);
363 } 361 }
364
365 /*
366 * We are currently handling the data for a file.
367 * Process the minimum of the amount of data we have available
368 * and the amount left to be processed for the file.
369 */
370 cc = inCc;
371
372 if (cc > dataCc)
373 cc = dataCc;
374
375 readData(cp, cc);
376
377 /*
378 * If the amount left isn't an exact multiple of the tar block
379 * size then round it up to the next block boundary since there
380 * is padding at the end of the file.
381 */
382 if (cc % TAR_BLOCK_SIZE)
383 cc += TAR_BLOCK_SIZE - (cc % TAR_BLOCK_SIZE);
384
385 cp += cc;
386 inCc -= cc;
387 } 362 }
388 363
389 done: 364 close(tarFd);
390 /* 365 if (status > 0) {
391 * Close the tar file if needed. 366 /* Bummer - we read a partial header */
392 */ 367 errorMsg( "Error reading '%s': %s", tarName, strerror(errno));
393 if ((tarFd >= 0) && (close(tarFd) < 0)) 368 return ( FALSE);
394 perror(tarName);
395
396 /*
397 * Close the output file if needed.
398 * This is only done here on a previous error and so no
399 * message is required on errors.
400 */
401 if (tostdoutFlag == FALSE) {
402 if (outFd >= 0) {
403 close(outFd);
404 }
405 } 369 }
370 else
371 return( status);
372
373 /* Stuff we do when we know we are done with the file */
374endgame:
375 close( tarFd);
376 if ( *(header.name) == '\0' ) {
377 if (errorFlag==FALSE)
378 return( TRUE);
379 }
380 return( FALSE);
406} 381}
407 382
408
409/* 383/*
410 * Examine the header block that was just read. 384 * Read an octal value in a field of the specified width, with optional
411 * This can specify the information for another file, or it can mark 385 * spaces on both sides of the number and with an optional null character
412 * the end of the tar file. 386 * at the end. Returns -1 on an illegal format.
413 */ 387 */
414static void 388static long getOctal(const char *cp, int size)
415readHeader(const TarHeader * hp, int fileCount, char **fileTable)
416{ 389{
417 int checkSum; 390 long val = 0;
418 int cc;
419 int hardLink;
420 int softLink;
421 int devFileFlag;
422 unsigned int major;
423 unsigned int minor;
424 long size;
425 struct utimbuf utb;
426
427 /*
428 * If the block is completely empty, then this is the end of the
429 * archive file. If the name is null, then just skip this header.
430 */
431 outName = hp->name;
432
433 if (*outName == '\0') {
434 for (cc = TAR_BLOCK_SIZE; cc > 0; cc--) {
435 if (*outName++)
436 return;
437 }
438 391
439 eofFlag = TRUE; 392 for(;(size > 0) && (*cp == ' '); cp++, size--);
440 393 if ((size == 0) || !isOctal(*cp))
441 return; 394 return -1;
395 for(; (size > 0) && isOctal(*cp); size--) {
396 val = val * 8 + *cp++ - '0';
442 } 397 }
398 for (;(size > 0) && (*cp == ' '); cp++, size--);
399 if ((size > 0) && *cp)
400 return -1;
401 return val;
402}
443 403
444 /* 404/* Parse the tar header and fill in the nice struct with the details */
445 * There is another file in the archive to examine. 405static int
446 * Extract the encoded information and check it. 406parseTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
447 */ 407{
448 mode = getOctal(hp->mode, sizeof(hp->mode)); 408 long major, minor, chksum, sum;
449 uid = getOctal(hp->uid, sizeof(hp->uid)); 409
450 gid = getOctal(hp->gid, sizeof(hp->gid)); 410 header->name = rawHeader->name;
451 size = getOctal(hp->size, sizeof(hp->size)); 411 header->mode = getOctal(rawHeader->mode, sizeof(rawHeader->mode));
452 mtime = getOctal(hp->mtime, sizeof(hp->mtime)); 412 header->uid = getOctal(rawHeader->uid, sizeof(rawHeader->uid));
453 checkSum = getOctal(hp->checkSum, sizeof(hp->checkSum)); 413 header->gid = getOctal(rawHeader->gid, sizeof(rawHeader->gid));
454 major = getOctal(hp->devMajor, sizeof(hp->devMajor)); 414 header->size = getOctal(rawHeader->size, sizeof(rawHeader->size));
455 minor = getOctal(hp->devMinor, sizeof(hp->devMinor)); 415 header->mtime = getOctal(rawHeader->mtime, sizeof(rawHeader->mtime));
456 416 chksum = getOctal(rawHeader->chksum, sizeof(rawHeader->chksum));
457 if ((mode < 0) || (uid < 0) || (gid < 0) || (size < 0)) { 417 header->type = rawHeader->typeflag;
458 if (badHeader == FALSE) 418 header->linkname = rawHeader->linkname;
459 fprintf(stderr, "Bad tar header, skipping\n"); 419 header->device = MAJOR(getOctal(rawHeader->devmajor, sizeof(rawHeader->devmajor))) |
460 420 MINOR(getOctal(rawHeader->devminor, sizeof(rawHeader->devminor)));
461 badHeader = TRUE; 421
422 /* Check the checksum */
423 sum = ' ' * sizeof(rawHeader->chksum);
424 for ( i = TarChecksumOffset; i > 0; i-- )
425 sum += *s++;
426 s += sizeof(h->chksum);
427 for ( i = (512 - TarChecksumOffset - sizeof(h->chksum)); i > 0; i-- )
428 sum += *s++;
429 if (sum == checksum )
430 return ( TRUE);
431 return( FALSE);
432}
462 433
463 return; 434#if 0
435 if ((header->mode < 0) || (header->uid < 0) ||
436 (header->gid < 0) || (header->size < 0)) {
437 errorMsg(stderr, "Bad tar header, skipping\n");
438 return( FALSE);
464 } 439 }
465 440
466 badHeader = FALSE; 441 badHeader = FALSE;
@@ -502,7 +477,7 @@ readHeader(const TarHeader * hp, int fileCount, char **fileTable)
502 * See if we want this file to be restored. 477 * See if we want this file to be restored.
503 * If not, then set up to skip it. 478 * If not, then set up to skip it.
504 */ 479 */
505 if (wantFileName(outName, fileCount, fileTable) == FALSE) { 480 if (wantFileName(outName, argc, argv) == FALSE) {
506 if (!hardLink && !softLink && (S_ISREG(mode) || S_ISCHR(mode) 481 if (!hardLink && !softLink && (S_ISREG(mode) || S_ISCHR(mode)
507 || S_ISBLK(mode) || S_ISSOCK(mode) 482 || S_ISBLK(mode) || S_ISSOCK(mode)
508 || S_ISFIFO(mode))) { 483 || S_ISFIFO(mode))) {
@@ -726,7 +701,7 @@ static void readData(const char *cp, int count)
726 * Returns TRUE if the file is selected. 701 * Returns TRUE if the file is selected.
727 */ 702 */
728static int 703static int
729wantFileName(const char *fileName, int fileCount, char **fileTable) 704wantFileName(const char *fileName, int argc, char **argv)
730{ 705{
731 const char *pathName; 706 const char *pathName;
732 int fileLength; 707 int fileLength;
@@ -735,7 +710,7 @@ wantFileName(const char *fileName, int fileCount, char **fileTable)
735 /* 710 /*
736 * If there are no files in the list, then the file is wanted. 711 * If there are no files in the list, then the file is wanted.
737 */ 712 */
738 if (fileCount == 0) 713 if (argc == 0)
739 return TRUE; 714 return TRUE;
740 715
741 fileLength = strlen(fileName); 716 fileLength = strlen(fileName);
@@ -743,8 +718,8 @@ wantFileName(const char *fileName, int fileCount, char **fileTable)
743 /* 718 /*
744 * Check each of the test paths. 719 * Check each of the test paths.
745 */ 720 */
746 while (fileCount-- > 0) { 721 while (argc-- > 0) {
747 pathName = *fileTable++; 722 pathName = *argv++;
748 723
749 pathLength = strlen(pathName); 724 pathLength = strlen(pathName);
750 725
@@ -762,43 +737,6 @@ wantFileName(const char *fileName, int fileCount, char **fileTable)
762 return FALSE; 737 return FALSE;
763} 738}
764 739
765/*
766 * Read an octal value in a field of the specified width, with optional
767 * spaces on both sides of the number and with an optional null character
768 * at the end. Returns -1 on an illegal format.
769 */
770static long getOctal(const char *cp, int len)
771{
772 long val;
773
774 while ((len > 0) && (*cp == ' ')) {
775 cp++;
776 len--;
777 }
778
779 if ((len == 0) || !isOctal(*cp))
780 return -1;
781
782 val = 0;
783
784 while ((len > 0) && isOctal(*cp)) {
785 val = val * 8 + *cp++ - '0';
786 len--;
787 }
788
789 while ((len > 0) && (*cp == ' ')) {
790 cp++;
791 len--;
792 }
793
794 if ((len > 0) && *cp)
795 return -1;
796
797 return val;
798}
799
800
801
802 740
803/* From here to the end of the file is the tar writing stuff. 741/* From here to the end of the file is the tar writing stuff.
804 * If you do not have BB_FEATURE_TAR_CREATE defined, this will 742 * If you do not have BB_FEATURE_TAR_CREATE defined, this will
@@ -809,14 +747,14 @@ static long getOctal(const char *cp, int len)
809/* 747/*
810 * Write a tar file containing the specified files. 748 * Write a tar file containing the specified files.
811 */ 749 */
812static void writeTarFile(int fileCount, char **fileTable) 750static void writeTarFile(int argc, char **argv)
813{ 751{
814 struct stat statbuf; 752 struct stat statbuf;
815 753
816 /* 754 /*
817 * Make sure there is at least one file specified. 755 * Make sure there is at least one file specified.
818 */ 756 */
819 if (fileCount <= 0) { 757 if (argc <= 0) {
820 fprintf(stderr, "No files specified to be saved\n"); 758 fprintf(stderr, "No files specified to be saved\n");
821 errorFlag = TRUE; 759 errorFlag = TRUE;
822 } 760 }
@@ -852,8 +790,8 @@ static void writeTarFile(int fileCount, char **fileTable)
852 * Append each file name into the archive file. 790 * Append each file name into the archive file.
853 * Follow symbolic links for these top level file names. 791 * Follow symbolic links for these top level file names.
854 */ 792 */
855 while (errorFlag == FALSE && (fileCount-- > 0)) { 793 while (errorFlag == FALSE && (argc-- > 0)) {
856 saveFile(*fileTable++, FALSE); 794 saveFile(*argv++, FALSE);
857 } 795 }
858 796
859 /* 797 /*
@@ -1284,3 +1222,4 @@ static int putOctal(char *cp, int len, long value)
1284#endif 1222#endif
1285 1223
1286/* END CODE */ 1224/* END CODE */
1225#endif
diff --git a/busybox.c b/busybox.c
index ee745e73e..95fee63d6 100644
--- a/busybox.c
+++ b/busybox.c
@@ -32,301 +32,301 @@ void *__libc_stack_end;
32 32
33static const struct Applet applets[] = { 33static const struct Applet applets[] = {
34 34
35#ifdef BB_BASENAME //usr/bin/basename 35#ifdef BB_BASENAME
36 {"basename", basename_main, _BB_DIR_USR_BIN}, 36 {"basename", basename_main, _BB_DIR_USR_BIN},
37#endif 37#endif
38#ifdef BB_BUSYBOX //bin 38#ifdef BB_BUSYBOX
39 {"busybox", busybox_main, _BB_DIR_BIN}, 39 {"busybox", busybox_main, _BB_DIR_BIN},
40#endif 40#endif
41#ifdef BB_BLOCK_DEVICE //sbin 41#ifdef BB_BLOCK_DEVICE
42 {"block_device", block_device_main, _BB_DIR_SBIN}, 42 {"block_device", block_device_main, _BB_DIR_SBIN},
43#endif 43#endif
44#ifdef BB_CAT //bin 44#ifdef BB_CAT
45 {"cat", cat_main, _BB_DIR_BIN}, 45 {"cat", cat_main, _BB_DIR_BIN},
46#endif 46#endif
47#ifdef BB_CHMOD_CHOWN_CHGRP //bin 47#ifdef BB_CHMOD_CHOWN_CHGRP
48 {"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN}, 48 {"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN},
49#endif 49#endif
50#ifdef BB_CHMOD_CHOWN_CHGRP //bin 50#ifdef BB_CHMOD_CHOWN_CHGRP
51 {"chown", chmod_chown_chgrp_main, _BB_DIR_BIN}, 51 {"chown", chmod_chown_chgrp_main, _BB_DIR_BIN},
52#endif 52#endif
53#ifdef BB_CHMOD_CHOWN_CHGRP //bin 53#ifdef BB_CHMOD_CHOWN_CHGRP
54 {"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN}, 54 {"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN},
55#endif 55#endif
56#ifdef BB_CHROOT //sbin 56#ifdef BB_CHROOT
57 {"chroot", chroot_main, _BB_DIR_SBIN}, 57 {"chroot", chroot_main, _BB_DIR_SBIN},
58#endif 58#endif
59#ifdef BB_CLEAR //usr/bin 59#ifdef BB_CLEAR
60 {"clear", clear_main, _BB_DIR_USR_BIN}, 60 {"clear", clear_main, _BB_DIR_USR_BIN},
61#endif 61#endif
62#ifdef BB_CHVT //usr/bin 62#ifdef BB_CHVT
63 {"chvt", chvt_main, _BB_DIR_USR_BIN}, 63 {"chvt", chvt_main, _BB_DIR_USR_BIN},
64#endif 64#endif
65#ifdef BB_CP_MV //bin 65#ifdef BB_CP_MV
66 {"cp", cp_mv_main, _BB_DIR_BIN}, 66 {"cp", cp_mv_main, _BB_DIR_BIN},
67#endif 67#endif
68#ifdef BB_CP_MV //bin 68#ifdef BB_CP_MV
69 {"mv", cp_mv_main, _BB_DIR_BIN}, 69 {"mv", cp_mv_main, _BB_DIR_BIN},
70#endif 70#endif
71#ifdef BB_DATE //bin 71#ifdef BB_DATE
72 {"date", date_main, _BB_DIR_BIN}, 72 {"date", date_main, _BB_DIR_BIN},
73#endif 73#endif
74#ifdef BB_DD //bin 74#ifdef BB_DD
75 {"dd", dd_main, _BB_DIR_BIN}, 75 {"dd", dd_main, _BB_DIR_BIN},
76#endif 76#endif
77#ifdef BB_DF //bin 77#ifdef BB_DF
78 {"df", df_main, _BB_DIR_BIN}, 78 {"df", df_main, _BB_DIR_BIN},
79#endif 79#endif
80#ifdef BB_DIRNAME //usr/bin 80#ifdef BB_DIRNAME
81 {"dirname", dirname_main, _BB_DIR_USR_BIN}, 81 {"dirname", dirname_main, _BB_DIR_USR_BIN},
82#endif 82#endif
83#ifdef BB_DMESG //bin 83#ifdef BB_DMESG
84 {"dmesg", dmesg_main, _BB_DIR_BIN}, 84 {"dmesg", dmesg_main, _BB_DIR_BIN},
85#endif 85#endif
86#ifdef BB_DU //bin 86#ifdef BB_DU
87 {"du", du_main, _BB_DIR_BIN}, 87 {"du", du_main, _BB_DIR_BIN},
88#endif 88#endif
89#ifdef BB_DUTMP //usr/sbin 89#ifdef BB_DUTMP
90 {"dutmp", dutmp_main, _BB_DIR_USR_SBIN}, 90 {"dutmp", dutmp_main, _BB_DIR_USR_SBIN},
91#endif 91#endif
92#ifdef BB_ECHO //bin 92#ifdef BB_ECHO
93 {"echo", echo_main, _BB_DIR_BIN}, 93 {"echo", echo_main, _BB_DIR_BIN},
94#endif 94#endif
95#ifdef BB_FBSET //usr/sbin 95#ifdef BB_FBSET
96 {"fbset", fbset_main, _BB_DIR_USR_SBIN}, 96 {"fbset", fbset_main, _BB_DIR_USR_SBIN},
97#endif 97#endif
98#ifdef BB_FDFLUSH //bin 98#ifdef BB_FDFLUSH
99 {"fdflush", fdflush_main, _BB_DIR_BIN}, 99 {"fdflush", fdflush_main, _BB_DIR_BIN},
100#endif 100#endif
101#ifdef BB_FIND //usr/bin 101#ifdef BB_FIND
102 {"find", find_main, _BB_DIR_USR_BIN}, 102 {"find", find_main, _BB_DIR_USR_BIN},
103#endif 103#endif
104#ifdef BB_FREE //usr/bin 104#ifdef BB_FREE
105 {"free", free_main, _BB_DIR_USR_BIN}, 105 {"free", free_main, _BB_DIR_USR_BIN},
106#endif 106#endif
107#ifdef BB_FREERAMDISK //sbin 107#ifdef BB_FREERAMDISK
108 {"freeramdisk", freeramdisk_main, _BB_DIR_SBIN}, 108 {"freeramdisk", freeramdisk_main, _BB_DIR_SBIN},
109#endif 109#endif
110#ifdef BB_DEALLOCVT //usr/bin 110#ifdef BB_DEALLOCVT
111 {"deallocvt", deallocvt_main, _BB_DIR_USR_BIN}, 111 {"deallocvt", deallocvt_main, _BB_DIR_USR_BIN},
112#endif 112#endif
113#ifdef BB_FSCK_MINIX //sbin 113#ifdef BB_FSCK_MINIX
114 {"fsck.minix", fsck_minix_main, _BB_DIR_SBIN}, 114 {"fsck.minix", fsck_minix_main, _BB_DIR_SBIN},
115#endif 115#endif
116#ifdef BB_MKFS_MINIX //sbin 116#ifdef BB_MKFS_MINIX
117 {"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN}, 117 {"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN},
118#endif 118#endif
119#ifdef BB_GREP //bin 119#ifdef BB_GREP
120 {"grep", grep_main, _BB_DIR_BIN}, 120 {"grep", grep_main, _BB_DIR_BIN},
121#endif 121#endif
122#ifdef BB_HALT //sbin 122#ifdef BB_HALT
123 {"halt", halt_main, _BB_DIR_SBIN}, 123 {"halt", halt_main, _BB_DIR_SBIN},
124#endif 124#endif
125#ifdef BB_HEAD //bin 125#ifdef BB_HEAD
126 {"head", head_main, _BB_DIR_BIN}, 126 {"head", head_main, _BB_DIR_BIN},
127#endif 127#endif
128#ifdef BB_HOSTID //usr/bin 128#ifdef BB_HOSTID
129 {"hostid", hostid_main, _BB_DIR_USR_BIN}, 129 {"hostid", hostid_main, _BB_DIR_USR_BIN},
130#endif 130#endif
131#ifdef BB_HOSTNAME //bin 131#ifdef BB_HOSTNAME
132 {"hostname", hostname_main, _BB_DIR_BIN}, 132 {"hostname", hostname_main, _BB_DIR_BIN},
133#endif 133#endif
134#ifdef BB_INIT //sbin 134#ifdef BB_INIT
135 {"init", init_main, _BB_DIR_SBIN}, 135 {"init", init_main, _BB_DIR_SBIN},
136#endif 136#endif
137#ifdef BB_INSMOD //sbin 137#ifdef BB_INSMOD
138 {"insmod", insmod_main, _BB_DIR_SBIN}, 138 {"insmod", insmod_main, _BB_DIR_SBIN},
139#endif 139#endif
140#ifdef BB_FEATURE_LINUXRC // 140#ifdef BB_FEATURE_LINUXRC //
141 {"linuxrc", init_main, _BB_DIR_ROOT}, 141 {"linuxrc", init_main, _BB_DIR_ROOT},
142#endif 142#endif
143#ifdef BB_KILL //bin 143#ifdef BB_KILL
144 {"kill", kill_main, _BB_DIR_BIN}, 144 {"kill", kill_main, _BB_DIR_BIN},
145#endif 145#endif
146#ifdef BB_KILLALL //usr/bin 146#ifdef BB_KILLALL
147 {"killall", kill_main, _BB_DIR_USR_BIN}, 147 {"killall", kill_main, _BB_DIR_USR_BIN},
148#endif 148#endif
149#ifdef BB_LENGTH //usr/bin 149#ifdef BB_LENGTH
150 {"length", length_main, _BB_DIR_USR_BIN}, 150 {"length", length_main, _BB_DIR_USR_BIN},
151#endif 151#endif
152#ifdef BB_LN //bin 152#ifdef BB_LN
153 {"ln", ln_main, _BB_DIR_BIN}, 153 {"ln", ln_main, _BB_DIR_BIN},
154#endif 154#endif
155#ifdef BB_LOADACM //usr/bin 155#ifdef BB_LOADACM
156 {"loadacm", loadacm_main, _BB_DIR_USR_BIN}, 156 {"loadacm", loadacm_main, _BB_DIR_USR_BIN},
157#endif 157#endif
158#ifdef BB_LOADFONT //usr/bin 158#ifdef BB_LOADFONT
159 {"loadfont", loadfont_main, _BB_DIR_USR_BIN}, 159 {"loadfont", loadfont_main, _BB_DIR_USR_BIN},
160#endif 160#endif
161#ifdef BB_LOADKMAP //sbin 161#ifdef BB_LOADKMAP
162 {"loadkmap", loadkmap_main, _BB_DIR_SBIN}, 162 {"loadkmap", loadkmap_main, _BB_DIR_SBIN},
163#endif 163#endif
164#ifdef BB_LS //bin 164#ifdef BB_LS
165 {"ls", ls_main, _BB_DIR_BIN}, 165 {"ls", ls_main, _BB_DIR_BIN},
166#endif 166#endif
167#ifdef BB_LSMOD //sbin 167#ifdef BB_LSMOD
168 {"lsmod", lsmod_main, _BB_DIR_SBIN}, 168 {"lsmod", lsmod_main, _BB_DIR_SBIN},
169#endif 169#endif
170#ifdef BB_MAKEDEVS //sbin 170#ifdef BB_MAKEDEVS
171 {"makedevs", makedevs_main, _BB_DIR_SBIN}, 171 {"makedevs", makedevs_main, _BB_DIR_SBIN},
172#endif 172#endif
173#ifdef BB_MATH //usr/bin 173#ifdef BB_MATH
174 {"math", math_main, _BB_DIR_USR_BIN}, 174 {"math", math_main, _BB_DIR_USR_BIN},
175#endif 175#endif
176#ifdef BB_MKDIR //bin 176#ifdef BB_MKDIR
177 {"mkdir", mkdir_main, _BB_DIR_BIN}, 177 {"mkdir", mkdir_main, _BB_DIR_BIN},
178#endif 178#endif
179#ifdef BB_MKFIFO //usr/bin 179#ifdef BB_MKFIFO
180 {"mkfifo", mkfifo_main, _BB_DIR_USR_BIN}, 180 {"mkfifo", mkfifo_main, _BB_DIR_USR_BIN},
181#endif 181#endif
182#ifdef BB_MKNOD //bin 182#ifdef BB_MKNOD
183 {"mknod", mknod_main, _BB_DIR_BIN}, 183 {"mknod", mknod_main, _BB_DIR_BIN},
184#endif 184#endif
185#ifdef BB_MKSWAP //sbin 185#ifdef BB_MKSWAP
186 {"mkswap", mkswap_main, _BB_DIR_SBIN}, 186 {"mkswap", mkswap_main, _BB_DIR_SBIN},
187#endif 187#endif
188#ifdef BB_MNC //usr/bin 188#ifdef BB_MNC
189 {"mnc", mnc_main, _BB_DIR_USR_BIN}, 189 {"mnc", mnc_main, _BB_DIR_USR_BIN},
190#endif 190#endif
191#ifdef BB_MORE //bin 191#ifdef BB_MORE
192 {"more", more_main, _BB_DIR_BIN}, 192 {"more", more_main, _BB_DIR_BIN},
193#endif 193#endif
194#ifdef BB_MOUNT //bin 194#ifdef BB_MOUNT
195 {"mount", mount_main, _BB_DIR_BIN}, 195 {"mount", mount_main, _BB_DIR_BIN},
196#endif 196#endif
197#ifdef BB_MT //bin 197#ifdef BB_MT
198 {"mt", mt_main, _BB_DIR_BIN}, 198 {"mt", mt_main, _BB_DIR_BIN},
199#endif 199#endif
200#ifdef BB_NSLOOKUP //usr/bin 200#ifdef BB_NSLOOKUP
201 {"nslookup", nslookup_main, _BB_DIR_USR_BIN}, 201 {"nslookup", nslookup_main, _BB_DIR_USR_BIN},
202#endif 202#endif
203#ifdef BB_PING //bin 203#ifdef BB_PING
204 {"ping", ping_main, _BB_DIR_BIN}, 204 {"ping", ping_main, _BB_DIR_BIN},
205#endif 205#endif
206#ifdef BB_POWEROFF //sbin 206#ifdef BB_POWEROFF
207 {"poweroff", poweroff_main, _BB_DIR_SBIN}, 207 {"poweroff", poweroff_main, _BB_DIR_SBIN},
208#endif 208#endif
209#ifdef BB_PRINTF //usr/bin 209#ifdef BB_PRINTF
210 {"printf", printf_main, _BB_DIR_USR_BIN}, 210 {"printf", printf_main, _BB_DIR_USR_BIN},
211#endif 211#endif
212#ifdef BB_PS //bin 212#ifdef BB_PS
213 {"ps", ps_main, _BB_DIR_BIN}, 213 {"ps", ps_main, _BB_DIR_BIN},
214#endif 214#endif
215#ifdef BB_PWD //bin 215#ifdef BB_PWD
216 {"pwd", pwd_main, _BB_DIR_BIN}, 216 {"pwd", pwd_main, _BB_DIR_BIN},
217#endif 217#endif
218#ifdef BB_REBOOT //sbin 218#ifdef BB_REBOOT
219 {"reboot", reboot_main, _BB_DIR_SBIN}, 219 {"reboot", reboot_main, _BB_DIR_SBIN},
220#endif 220#endif
221#ifdef BB_RM //bin 221#ifdef BB_RM
222 {"rm", rm_main, _BB_DIR_BIN}, 222 {"rm", rm_main, _BB_DIR_BIN},
223#endif 223#endif
224#ifdef BB_RMDIR //bin 224#ifdef BB_RMDIR
225 {"rmdir", rmdir_main, _BB_DIR_BIN}, 225 {"rmdir", rmdir_main, _BB_DIR_BIN},
226#endif 226#endif
227#ifdef BB_RMMOD //sbin 227#ifdef BB_RMMOD
228 {"rmmod", rmmod_main, _BB_DIR_SBIN}, 228 {"rmmod", rmmod_main, _BB_DIR_SBIN},
229#endif 229#endif
230#ifdef BB_SED //bin 230#ifdef BB_SED
231 {"sed", sed_main, _BB_DIR_BIN}, 231 {"sed", sed_main, _BB_DIR_BIN},
232#endif 232#endif
233#ifdef BB_SH //bin 233#ifdef BB_SH
234 {"sh", shell_main, _BB_DIR_BIN}, 234 {"sh", shell_main, _BB_DIR_BIN},
235#endif 235#endif
236#ifdef BB_SFDISK //sbin 236#ifdef BB_SFDISK
237 {"fdisk", sfdisk_main, _BB_DIR_SBIN}, 237 {"fdisk", sfdisk_main, _BB_DIR_SBIN},
238#ifdef BB_SFDISK //sbin 238#ifdef BB_SFDISK
239#endif 239#endif
240 {"sfdisk", sfdisk_main, _BB_DIR_SBIN}, 240 {"sfdisk", sfdisk_main, _BB_DIR_SBIN},
241#endif 241#endif
242#ifdef BB_SLEEP //bin 242#ifdef BB_SLEEP
243 {"sleep", sleep_main, _BB_DIR_BIN}, 243 {"sleep", sleep_main, _BB_DIR_BIN},
244#endif 244#endif
245#ifdef BB_SORT //bin 245#ifdef BB_SORT
246 {"sort", sort_main, _BB_DIR_BIN}, 246 {"sort", sort_main, _BB_DIR_BIN},
247#endif 247#endif
248#ifdef BB_SYNC //bin 248#ifdef BB_SYNC
249 {"sync", sync_main, _BB_DIR_BIN}, 249 {"sync", sync_main, _BB_DIR_BIN},
250#endif 250#endif
251#ifdef BB_SYSLOGD //sbin 251#ifdef BB_SYSLOGD
252 {"syslogd", syslogd_main, _BB_DIR_SBIN}, 252 {"syslogd", syslogd_main, _BB_DIR_SBIN},
253#endif 253#endif
254#ifdef BB_LOGGER //usr/bin 254#ifdef BB_LOGGER
255 {"logger", logger_main, _BB_DIR_USR_BIN}, 255 {"logger", logger_main, _BB_DIR_USR_BIN},
256#endif 256#endif
257#ifdef BB_LOGNAME //usr/bin 257#ifdef BB_LOGNAME
258 {"logname", logname_main, _BB_DIR_USR_BIN}, 258 {"logname", logname_main, _BB_DIR_USR_BIN},
259#endif 259#endif
260#ifdef BB_SWAPONOFF //sbin 260#ifdef BB_SWAPONOFF
261 {"swapon", swap_on_off_main, _BB_DIR_SBIN}, 261 {"swapon", swap_on_off_main, _BB_DIR_SBIN},
262#endif 262#endif
263#ifdef BB_SWAPONOFF //sbin 263#ifdef BB_SWAPONOFF
264 {"swapoff", swap_on_off_main, _BB_DIR_SBIN}, 264 {"swapoff", swap_on_off_main, _BB_DIR_SBIN},
265#endif 265#endif
266#ifdef BB_TAIL //usr/bin 266#ifdef BB_TAIL
267 {"tail", tail_main, _BB_DIR_USR_BIN}, 267 {"tail", tail_main, _BB_DIR_USR_BIN},
268#endif 268#endif
269#ifdef BB_TAR //bin 269#ifdef BB_TAR
270 {"tar", tar_main, _BB_DIR_BIN}, 270 {"tar", tar_main, _BB_DIR_BIN},
271#endif 271#endif
272#ifdef BB_TELNET //usr/bin 272#ifdef BB_TELNET
273 {"telnet", telnet_main, _BB_DIR_USR_BIN}, 273 {"telnet", telnet_main, _BB_DIR_USR_BIN},
274#endif 274#endif
275#ifdef BB_TEST //usr/bin 275#ifdef BB_TEST
276 {"[", test_main, _BB_DIR_USR_BIN}, 276 {"[", test_main, _BB_DIR_USR_BIN},
277#endif 277#endif
278#ifdef BB_TEST //usr/bin 278#ifdef BB_TEST
279 {"test", test_main, _BB_DIR_USR_BIN}, 279 {"test", test_main, _BB_DIR_USR_BIN},
280#endif 280#endif
281#ifdef BB_TEE //bin 281#ifdef BB_TEE
282 {"tee", tee_main, _BB_DIR_BIN}, 282 {"tee", tee_main, _BB_DIR_BIN},
283#endif 283#endif
284#ifdef BB_TOUCH //usr/bin 284#ifdef BB_TOUCH
285 {"touch", touch_main, _BB_DIR_USR_BIN}, 285 {"touch", touch_main, _BB_DIR_USR_BIN},
286#endif 286#endif
287#ifdef BB_TR //usr/bin 287#ifdef BB_TR
288 {"tr", tr_main, _BB_DIR_USR_BIN}, 288 {"tr", tr_main, _BB_DIR_USR_BIN},
289#endif 289#endif
290#ifdef BB_TRUE_FALSE //bin 290#ifdef BB_TRUE_FALSE
291 {"true", true_main, _BB_DIR_BIN}, 291 {"true", true_main, _BB_DIR_BIN},
292#endif 292#endif
293#ifdef BB_TRUE_FALSE //bin 293#ifdef BB_TRUE_FALSE
294 {"false", false_main, _BB_DIR_BIN}, 294 {"false", false_main, _BB_DIR_BIN},
295#endif 295#endif
296#ifdef BB_TTY //usr/bin 296#ifdef BB_TTY
297 {"tty", tty_main, _BB_DIR_USR_BIN}, 297 {"tty", tty_main, _BB_DIR_USR_BIN},
298#endif 298#endif
299#ifdef BB_UMOUNT //bin 299#ifdef BB_UMOUNT
300 {"umount", umount_main, _BB_DIR_BIN}, 300 {"umount", umount_main, _BB_DIR_BIN},
301#endif 301#endif
302#ifdef BB_UNAME //bin 302#ifdef BB_UNAME
303 {"uname", uname_main, _BB_DIR_BIN}, 303 {"uname", uname_main, _BB_DIR_BIN},
304#endif 304#endif
305#ifdef BB_UPTIME //usr/bin 305#ifdef BB_UPTIME
306 {"uptime", uptime_main, _BB_DIR_USR_BIN}, 306 {"uptime", uptime_main, _BB_DIR_USR_BIN},
307#endif 307#endif
308#ifdef BB_UNIQ //bin 308#ifdef BB_UNIQ
309 {"uniq", uniq_main, _BB_DIR_BIN}, 309 {"uniq", uniq_main, _BB_DIR_BIN},
310#endif 310#endif
311#ifdef BB_UPDATE //sbin 311#ifdef BB_UPDATE
312 {"update", update_main, _BB_DIR_SBIN}, 312 {"update", update_main, _BB_DIR_SBIN},
313#endif 313#endif
314#ifdef BB_WC //usr/bin 314#ifdef BB_WC
315 {"wc", wc_main, _BB_DIR_USR_BIN}, 315 {"wc", wc_main, _BB_DIR_USR_BIN},
316#endif 316#endif
317#ifdef BB_WHOAMI //usr/bin 317#ifdef BB_WHOAMI
318 {"whoami", whoami_main, _BB_DIR_USR_BIN}, 318 {"whoami", whoami_main, _BB_DIR_USR_BIN},
319#endif 319#endif
320#ifdef BB_YES //usr/bin 320#ifdef BB_YES
321 {"yes", yes_main, _BB_DIR_USR_BIN}, 321 {"yes", yes_main, _BB_DIR_USR_BIN},
322#endif 322#endif
323#ifdef BB_GUNZIP //bin 323#ifdef BB_GUNZIP
324 {"zcat", gunzip_main, _BB_DIR_BIN}, 324 {"zcat", gunzip_main, _BB_DIR_BIN},
325#endif 325#endif
326#ifdef BB_GUNZIP //bin 326#ifdef BB_GUNZIP
327 {"gunzip", gunzip_main, _BB_DIR_BIN}, 327 {"gunzip", gunzip_main, _BB_DIR_BIN},
328#endif 328#endif
329#ifdef BB_GZIP //bin 329#ifdef BB_GZIP
330 {"gzip", gzip_main, _BB_DIR_BIN}, 330 {"gzip", gzip_main, _BB_DIR_BIN},
331#endif 331#endif
332 {0} 332 {0}
diff --git a/busybox.def.h b/busybox.def.h
index cfafc29c8..388219a52 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -185,6 +185,10 @@
185#define BB_FEATURE_SH_COMMAND_EDITING 185#define BB_FEATURE_SH_COMMAND_EDITING
186// 186//
187// 187//
188//Turn on extra fbset options
189//#define BB_FEATURE_FBSET_FANCY
190//
191//
188// End of Features List 192// End of Features List
189// 193//
190// 194//
diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c
index aa4f6bbc8..fe533d522 100644
--- a/console-tools/loadkmap.c
+++ b/console-tools/loadkmap.c
@@ -87,6 +87,8 @@ int loadkmap_main(int argc, char **argv)
87 } 87 }
88 } 88 }
89 } 89 }
90 close(fd); 90 /* Don't bother to close files. Exit does that
91 * automagically, so we can save a few bytes */
92 /* close(fd); */
91 return 0; 93 return 0;
92} 94}
diff --git a/coreutils/date.c b/coreutils/date.c
index 652db8d74..199a894c0 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -202,8 +202,8 @@ int date_main(int argc, char **argv)
202 usage(date_usage); 202 usage(date_usage);
203 } 203 }
204 } else { 204 } else {
205 if ((date_fmt == NULL) && (strcmp(*argv, "+") == 0)) 205 if ((date_fmt == NULL) && (**argv == '+'))
206 date_fmt = *argv; 206 date_fmt = *argv + 1; /* Skip over the '+' */
207 else if (date_str == NULL) { 207 else if (date_str == NULL) {
208 set_time = 1; 208 set_time = 1;
209 date_str = *argv; 209 date_str = *argv;
diff --git a/coreutils/dd.c b/coreutils/dd.c
index f40dec712..d50cf746b 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -125,9 +125,12 @@ extern int dd_main(int argc, char **argv)
125 inFd = open(inFile, 0); 125 inFd = open(inFile, 0);
126 126
127 if (inFd < 0) { 127 if (inFd < 0) {
128 perror(inFile); 128 /* Note that we are not freeing buf or closing
129 free(buf); 129 * files here to save a few bytes. This exits
130 exit(FALSE); 130 * here anyways... */
131
132 /* free(buf); */
133 fatalError( inFile);
131 } 134 }
132 135
133 if (outFile == NULL) 136 if (outFile == NULL)
@@ -136,10 +139,13 @@ extern int dd_main(int argc, char **argv)
136 outFd = open(outFile, O_WRONLY | O_CREAT | O_TRUNC, 0666); 139 outFd = open(outFile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
137 140
138 if (outFd < 0) { 141 if (outFd < 0) {
139 perror(outFile); 142 /* Note that we are not freeing buf or closing
140 close(inFd); 143 * files here to save a few bytes. This exits
141 free(buf); 144 * here anyways... */
142 exit(FALSE); 145
146 /* close(inFd);
147 free(buf); */
148 fatalError( outFile);
143 } 149 }
144 150
145 lseek(inFd, skipBlocks * blockSize, SEEK_SET); 151 lseek(inFd, skipBlocks * blockSize, SEEK_SET);
@@ -180,9 +186,13 @@ extern int dd_main(int argc, char **argv)
180 perror(inFile); 186 perror(inFile);
181 187
182 cleanup: 188 cleanup:
189 /* Note that we are not freeing memory or closing
190 * files here, to save a few bytes. */
191#if 0
183 close(inFd); 192 close(inFd);
184 close(outFd); 193 close(outFd);
185 free(buf); 194 free(buf);
195#endif
186 196
187 printf("%ld+%d records in\n", (long) (intotal / blockSize), 197 printf("%ld+%d records in\n", (long) (intotal / blockSize),
188 (intotal % blockSize) != 0); 198 (intotal % blockSize) != 0);
diff --git a/coreutils/ls.c b/coreutils/ls.c
index c2266f533..c4856cb71 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -70,11 +70,6 @@
70#define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)]) 70#define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)])
71#endif 71#endif
72 72
73#ifndef MAJOR
74#define MAJOR(dev) (((dev)>>8)&0xff)
75#define MINOR(dev) ((dev)&0xff)
76#endif
77
78#define FMT_AUTO 0 73#define FMT_AUTO 0
79#define FMT_LONG 1 /* one record per line, extended info */ 74#define FMT_LONG 1 /* one record per line, extended info */
80#define FMT_SINGLE 2 /* one record per line */ 75#define FMT_SINGLE 2 /* one record per line */
diff --git a/coreutils/tee.c b/coreutils/tee.c
index a3a1c8132..018fe117b 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -125,8 +125,10 @@ int tee_main(int argc, char **argv)
125 125
126 /* clean up */ 126 /* clean up */
127 FL_apply(tee_fclose, 0); 127 FL_apply(tee_fclose, 0);
128 free(FileList); 128 /* Don't bother to close files Exit does that
129 * automagically, so we can save a few bytes */
130 /* free(FileList); */
129 exit(0); 131 exit(0);
130} 132}
131 133
132/* $Id: tee.c,v 1.7 2000/03/08 00:14:35 beppu Exp $ */ 134/* $Id: tee.c,v 1.8 2000/03/23 01:09:18 erik Exp $ */
diff --git a/date.c b/date.c
index 652db8d74..199a894c0 100644
--- a/date.c
+++ b/date.c
@@ -202,8 +202,8 @@ int date_main(int argc, char **argv)
202 usage(date_usage); 202 usage(date_usage);
203 } 203 }
204 } else { 204 } else {
205 if ((date_fmt == NULL) && (strcmp(*argv, "+") == 0)) 205 if ((date_fmt == NULL) && (**argv == '+'))
206 date_fmt = *argv; 206 date_fmt = *argv + 1; /* Skip over the '+' */
207 else if (date_str == NULL) { 207 else if (date_str == NULL) {
208 set_time = 1; 208 set_time = 1;
209 date_str = *argv; 209 date_str = *argv;
diff --git a/dd.c b/dd.c
index f40dec712..d50cf746b 100644
--- a/dd.c
+++ b/dd.c
@@ -125,9 +125,12 @@ extern int dd_main(int argc, char **argv)
125 inFd = open(inFile, 0); 125 inFd = open(inFile, 0);
126 126
127 if (inFd < 0) { 127 if (inFd < 0) {
128 perror(inFile); 128 /* Note that we are not freeing buf or closing
129 free(buf); 129 * files here to save a few bytes. This exits
130 exit(FALSE); 130 * here anyways... */
131
132 /* free(buf); */
133 fatalError( inFile);
131 } 134 }
132 135
133 if (outFile == NULL) 136 if (outFile == NULL)
@@ -136,10 +139,13 @@ extern int dd_main(int argc, char **argv)
136 outFd = open(outFile, O_WRONLY | O_CREAT | O_TRUNC, 0666); 139 outFd = open(outFile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
137 140
138 if (outFd < 0) { 141 if (outFd < 0) {
139 perror(outFile); 142 /* Note that we are not freeing buf or closing
140 close(inFd); 143 * files here to save a few bytes. This exits
141 free(buf); 144 * here anyways... */
142 exit(FALSE); 145
146 /* close(inFd);
147 free(buf); */
148 fatalError( outFile);
143 } 149 }
144 150
145 lseek(inFd, skipBlocks * blockSize, SEEK_SET); 151 lseek(inFd, skipBlocks * blockSize, SEEK_SET);
@@ -180,9 +186,13 @@ extern int dd_main(int argc, char **argv)
180 perror(inFile); 186 perror(inFile);
181 187
182 cleanup: 188 cleanup:
189 /* Note that we are not freeing memory or closing
190 * files here, to save a few bytes. */
191#if 0
183 close(inFd); 192 close(inFd);
184 close(outFd); 193 close(outFd);
185 free(buf); 194 free(buf);
195#endif
186 196
187 printf("%ld+%d records in\n", (long) (intotal / blockSize), 197 printf("%ld+%d records in\n", (long) (intotal / blockSize),
188 (intotal % blockSize) != 0); 198 (intotal % blockSize) != 0);
diff --git a/fbset.c b/fbset.c
index a75e431db..7ca41733b 100644
--- a/fbset.c
+++ b/fbset.c
@@ -62,7 +62,7 @@
62#define CMD_ALL 11 62#define CMD_ALL 11
63#define CMD_INFO 12 63#define CMD_INFO 12
64 64
65#ifdef BB_FBSET_FANCY 65#ifdef BB_FEATURE_FBSET_FANCY
66#define CMD_XRES 13 66#define CMD_XRES 13
67#define CMD_YRES 14 67#define CMD_YRES 14
68#define CMD_VXRES 15 68#define CMD_VXRES 15
@@ -105,7 +105,7 @@ struct cmdoptions_t {
105 "-vsync", 1, CMD_VSYNC}, { 105 "-vsync", 1, CMD_VSYNC}, {
106 "-laced", 1, CMD_LACED}, { 106 "-laced", 1, CMD_LACED}, {
107 "-double", 1, CMD_DOUBLE}, 107 "-double", 1, CMD_DOUBLE},
108#ifdef BB_FBSET_FANCY 108#ifdef BB_FEATURE_FBSET_FANCY
109 { 109 {
110 "--help", 0, CMD_HELP}, { 110 "--help", 0, CMD_HELP}, {
111 "-all", 0, CMD_ALL}, { 111 "-all", 0, CMD_ALL}, {
@@ -164,8 +164,7 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn,
164 } 164 }
165 } 165 }
166#else 166#else
167 fprintf(stderr, 167 errorMsg( "mode reading not compiled in\n");
168 "W: mode reading was disabled on this copy of fbset; ignoring request\n");
169#endif 168#endif
170 return 0; 169 return 0;
171} 170}
@@ -199,7 +198,7 @@ static void showmode(struct fb_var_screeninfo *v)
199 v->vsync_len); 198 v->vsync_len);
200 } 199 }
201 printf("\nmode \"%ux%u-%u\"\n", v->xres, v->yres, (int) (vrate + 0.5)); 200 printf("\nmode \"%ux%u-%u\"\n", v->xres, v->yres, (int) (vrate + 0.5));
202#ifdef BB_FBSET_FANCY 201#ifdef BB_FEATURE_FBSET_FANCY
203 printf("\t# D: %.3f MHz, H: %.3f kHz, V: %.3f Hz\n", drate / 1e6, 202 printf("\t# D: %.3f MHz, H: %.3f kHz, V: %.3f Hz\n", drate / 1e6,
204 hrate / 1e3, vrate); 203 hrate / 1e3, vrate);
205#endif 204#endif
@@ -283,7 +282,7 @@ extern int fbset_main(int argc, char **argv)
283 varset.hsync_len = strtoul(argv[6], 0, 0); 282 varset.hsync_len = strtoul(argv[6], 0, 0);
284 varset.vsync_len = strtoul(argv[7], 0, 0); 283 varset.vsync_len = strtoul(argv[7], 0, 0);
285 break; 284 break;
286#ifdef BB_FBSET_FANCY 285#ifdef BB_FEATURE_FBSET_FANCY
287 case CMD_XRES: 286 case CMD_XRES:
288 varset.xres = strtoul(argv[1], 0, 0); 287 varset.xres = strtoul(argv[1], 0, 0);
289 break; 288 break;
@@ -323,7 +322,8 @@ extern int fbset_main(int argc, char **argv)
323 if (ioctl(fh, FBIOPUT_VSCREENINFO, &var)) 322 if (ioctl(fh, FBIOPUT_VSCREENINFO, &var))
324 PERROR("fbset(ioctl)"); 323 PERROR("fbset(ioctl)");
325 showmode(&var); 324 showmode(&var);
326 close(fh); 325 /* Don't close the file, as exiting will take care of that */
326 /* close(fh); */
327 327
328 return (TRUE); 328 exit (TRUE);
329} 329}
diff --git a/fdflush.c b/fdflush.c
index 0b154c8a6..201cea898 100644
--- a/fdflush.c
+++ b/fdflush.c
@@ -44,7 +44,9 @@ extern int fdflush_main(int argc, char **argv)
44 } 44 }
45 45
46 value = ioctl(fd, FDFLUSH, 0); 46 value = ioctl(fd, FDFLUSH, 0);
47 close(fd); 47 /* Don't bother closing. Exit does
48 * that, so we can save a few bytes */
49 /* close(fd); */
48 50
49 if (value) { 51 if (value) {
50 perror(*argv); 52 perror(*argv);
diff --git a/freeramdisk.c b/freeramdisk.c
index 43d42d424..06937a70f 100644
--- a/freeramdisk.c
+++ b/freeramdisk.c
@@ -55,7 +55,9 @@ freeramdisk_main(int argc, char **argv)
55 if (ioctl(f, BLKFLSBUF) < 0) { 55 if (ioctl(f, BLKFLSBUF) < 0) {
56 fatalError( "freeramdisk: failed ioctl on %s: %s", rname, strerror(errno)); 56 fatalError( "freeramdisk: failed ioctl on %s: %s", rname, strerror(errno));
57 } 57 }
58 close(f); 58 /* Don't bother closing. Exit does
59 * that, so we can save a few bytes */
60 /* close(f); */
59 exit(TRUE); 61 exit(TRUE);
60} 62}
61 63
diff --git a/fsck_minix.c b/fsck_minix.c
index 47e81ce42..aa0a82432 100644
--- a/fsck_minix.c
+++ b/fsck_minix.c
@@ -1242,6 +1242,7 @@ static void alloc_name_list(void)
1242 name_list[i] = xmalloc(sizeof(char) * PATH_MAX + 1); 1242 name_list[i] = xmalloc(sizeof(char) * PATH_MAX + 1);
1243} 1243}
1244 1244
1245#if 0
1245/* execute this atexit() to deallocate name_list[] */ 1246/* execute this atexit() to deallocate name_list[] */
1246/* piptigger was here */ 1247/* piptigger was here */
1247static void free_name_list(void) 1248static void free_name_list(void)
@@ -1257,6 +1258,7 @@ static void free_name_list(void)
1257 free(name_list); 1258 free(name_list);
1258 } 1259 }
1259} 1260}
1261#endif
1260 1262
1261extern int fsck_minix_main(int argc, char **argv) 1263extern int fsck_minix_main(int argc, char **argv)
1262{ 1264{
@@ -1265,7 +1267,9 @@ extern int fsck_minix_main(int argc, char **argv)
1265 int retcode = 0; 1267 int retcode = 0;
1266 1268
1267 alloc_name_list(); 1269 alloc_name_list();
1268 atexit(free_name_list); 1270 /* Don't bother to free memory. Exit does
1271 * that automagically, so we can save a few bytes */
1272 //atexit(free_name_list);
1269 1273
1270 if (argc && *argv) 1274 if (argc && *argv)
1271 program_name = *argv; 1275 program_name = *argv;
diff --git a/init.c b/init.c
index de5e2c05f..907916537 100644
--- a/init.c
+++ b/init.c
@@ -825,6 +825,9 @@ extern int init_main(int argc, char **argv)
825 reboot(RB_DISABLE_CAD); 825 reboot(RB_DISABLE_CAD);
826#endif 826#endif
827 827
828 /* Figure out what kernel this is running */
829 kernelVersion = get_kernel_revision();
830
828 /* Figure out where the default console should be */ 831 /* Figure out where the default console should be */
829 console_init(); 832 console_init();
830 833
diff --git a/init/init.c b/init/init.c
index de5e2c05f..907916537 100644
--- a/init/init.c
+++ b/init/init.c
@@ -825,6 +825,9 @@ extern int init_main(int argc, char **argv)
825 reboot(RB_DISABLE_CAD); 825 reboot(RB_DISABLE_CAD);
826#endif 826#endif
827 827
828 /* Figure out what kernel this is running */
829 kernelVersion = get_kernel_revision();
830
828 /* Figure out where the default console should be */ 831 /* Figure out where the default console should be */
829 console_init(); 832 console_init();
830 833
diff --git a/internal.h b/internal.h
index 9f9461def..84624b394 100644
--- a/internal.h
+++ b/internal.h
@@ -46,6 +46,12 @@
46#define BUF_SIZE 8192 46#define BUF_SIZE 8192
47#define EXPAND_ALLOC 1024 47#define EXPAND_ALLOC 1024
48 48
49
50#ifndef MAJOR
51#define MAJOR(dev) (((dev)>>8)&0xff)
52#define MINOR(dev) ((dev)&0xff)
53#endif
54
49#define isBlank(ch) (((ch) == ' ') || ((ch) == '\t')) 55#define isBlank(ch) (((ch) == ' ') || ((ch) == '\t'))
50#define isDecimal(ch) (((ch) >= '0') && ((ch) <= '9')) 56#define isDecimal(ch) (((ch) >= '0') && ((ch) <= '9'))
51#define isOctal(ch) (((ch) >= '0') && ((ch) <= '7')) 57#define isOctal(ch) (((ch) >= '0') && ((ch) <= '7'))
@@ -201,14 +207,12 @@ extern uid_t my_getpwnam(char *name);
201extern gid_t my_getgrnam(char *name); 207extern gid_t my_getgrnam(char *name);
202extern void my_getpwuid(char* name, uid_t uid); 208extern void my_getpwuid(char* name, uid_t uid);
203extern void my_getgrgid(char* group, gid_t gid); 209extern void my_getgrgid(char* group, gid_t gid);
204extern int get_kernel_revision();
205extern int get_console_fd(char* tty_name); 210extern int get_console_fd(char* tty_name);
206extern struct mntent *findMountPoint(const char *name, const char *table); 211extern struct mntent *findMountPoint(const char *name, const char *table);
207extern void write_mtab(char* blockDevice, char* directory, 212extern void write_mtab(char* blockDevice, char* directory,
208 char* filesystemType, long flags, char* string_flags); 213 char* filesystemType, long flags, char* string_flags);
209extern void erase_mtab(const char * name); 214extern void erase_mtab(const char * name);
210extern void mtab_read(void); 215extern void mtab_read(void);
211extern void mtab_free(void);
212extern char *mtab_first(void **iter); 216extern char *mtab_first(void **iter);
213extern char *mtab_next(void **iter); 217extern char *mtab_next(void **iter);
214extern char *mtab_getinfo(const char *match, const char which); 218extern char *mtab_getinfo(const char *match, const char which);
diff --git a/loadkmap.c b/loadkmap.c
index aa4f6bbc8..fe533d522 100644
--- a/loadkmap.c
+++ b/loadkmap.c
@@ -87,6 +87,8 @@ int loadkmap_main(int argc, char **argv)
87 } 87 }
88 } 88 }
89 } 89 }
90 close(fd); 90 /* Don't bother to close files. Exit does that
91 * automagically, so we can save a few bytes */
92 /* close(fd); */
91 return 0; 93 return 0;
92} 94}
diff --git a/ls.c b/ls.c
index c2266f533..c4856cb71 100644
--- a/ls.c
+++ b/ls.c
@@ -70,11 +70,6 @@
70#define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)]) 70#define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)])
71#endif 71#endif
72 72
73#ifndef MAJOR
74#define MAJOR(dev) (((dev)>>8)&0xff)
75#define MINOR(dev) ((dev)&0xff)
76#endif
77
78#define FMT_AUTO 0 73#define FMT_AUTO 0
79#define FMT_LONG 1 /* one record per line, extended info */ 74#define FMT_LONG 1 /* one record per line, extended info */
80#define FMT_SINGLE 2 /* one record per line */ 75#define FMT_SINGLE 2 /* one record per line */
diff --git a/mount.c b/mount.c
index 03891371a..30a060fc1 100644
--- a/mount.c
+++ b/mount.c
@@ -348,8 +348,12 @@ extern int mount_main(int argc, char **argv)
348 mntentlist[i].mnt_opts, mntentlist[i].mnt_freq, 348 mntentlist[i].mnt_opts, mntentlist[i].mnt_freq,
349 mntentlist[i].mnt_passno); 349 mntentlist[i].mnt_passno);
350 } 350 }
351 /* Don't bother to close files or free memory. Exit
352 * does that automagically, so we can save a few bytes */
353#if 0
351 free( mntentlist); 354 free( mntentlist);
352 close(fd); 355 close(fd);
356#endif
353 exit(TRUE); 357 exit(TRUE);
354 } 358 }
355#else 359#else
diff --git a/tar.c b/tar.c
index 8f802de64..8f83d04a6 100644
--- a/tar.c
+++ b/tar.c
@@ -68,57 +68,84 @@ static const char tar_usage[] =
68#endif 68#endif
69 69
70 70
71/* 71/* Tar file constants */
72 * Tar file constants.
73 */
74#define TAR_BLOCK_SIZE 512
75#define TAR_NAME_SIZE 100
76 72
77 73
78/* 74/* POSIX tar Header Block, from POSIX 1003.1-1990 */
79 * The POSIX (and basic GNU) tar header format. 75struct TarHeader
80 * This structure is always embedded in a TAR_BLOCK_SIZE sized block 76{
81 * with zero padding. We only process this information minimally. 77 /* byte offset */
82 */ 78 char name[100]; /* 0 */
83typedef struct { 79 char mode[8]; /* 100 */
84 char name[TAR_NAME_SIZE]; 80 char uid[8]; /* 108 */
85 char mode[8]; 81 char gid[8]; /* 116 */
86 char uid[8]; 82 char size[12]; /* 124 */
87 char gid[8]; 83 char mtime[12]; /* 136 */
88 char size[12]; 84 char chksum[8]; /* 148 */
89 char mtime[12]; 85 char typeflag; /* 156 */
90 char checkSum[8]; 86 char linkname[100]; /* 157 */
91 char typeFlag; 87 char magic[6]; /* 257 */
92 char linkName[TAR_NAME_SIZE]; 88 char version[2]; /* 263 */
93 char magic[6]; 89 char uname[32]; /* 265 */
94 char version[2]; 90 char gname[32]; /* 297 */
95 char uname[32]; 91 char devmajor[8]; /* 329 */
96 char gname[32]; 92 char devminor[8]; /* 337 */
97 char devMajor[8]; 93 char prefix[155]; /* 345 */
98 char devMinor[8]; 94 /* padding 500 */
99 char prefix[155]; 95};
100} TarHeader; 96typedef struct TarHeader TarHeader;
101 97
102#define TAR_MAGIC "ustar" 98
103#define TAR_VERSION "00" 99/* A few useful constants */
104 100#define TAR_MAGIC "ustar" /* ustar and a null */
105#define TAR_TYPE_REGULAR '0' 101#define TAR_VERSION "00" /* 00 and no null */
106#define TAR_TYPE_HARD_LINK '1' 102#define TAR_MAGIC_LEN 6
107#define TAR_TYPE_SOFT_LINK '2' 103#define TAR_VERSION_LEN 2
104#define TAR_NAME_LEN 100
105#define TAR_BLOCK_SIZE 512
106
107/* A nice enum with all the possible tar file content types */
108enum TarFileType
109{
110 REGTYPE = '0', /* regular file */
111 REGTYPE0 = '\0', /* regular file (ancient bug compat)*/
112 LNKTYPE = '1', /* hard link */
113 SYMTYPE = '2', /* symbolic link */
114 CHRTYPE = '3', /* character special */
115 BLKTYPE = '4', /* block special */
116 DIRTYPE = '5', /* directory */
117 FIFOTYPE = '6', /* FIFO special */
118 CONTTYPE = '7', /* reserved */
119};
120typedef enum TarFileType TarFileType;
121
122/* This struct ignores magic, non-numeric user name,
123 * non-numeric group name, and the checksum, since
124 * these are all ignored by BusyBox tar. */
125struct TarInfo
126{
127 int tarFd; /* An open file descriptor for reading from the tarball */
128 char * name; /* File name */
129 mode_t mode; /* Unix mode, including device bits. */
130 uid_t uid; /* Numeric UID */
131 gid_t gid; /* Numeric GID */
132 size_t size; /* Size of file */
133 time_t mtime; /* Last-modified time */
134 enum TarFileType type; /* Regular, directory, link, etc */
135 char * linkname; /* Name for symbolic and hard links */
136 dev_t device; /* Special device for mknod() */
137};
138typedef struct TarInfo TarInfo;
139
140/* Static data */
141static const unsigned long TarChecksumOffset = (const unsigned long)&(((TarHeader *)0)->chksum);
108 142
109 143
110/* 144/*
111 * Static data. 145 * Static data.
112 */ 146 */
113static int listFlag;
114static int extractFlag;
115static int createFlag;
116static int verboseFlag;
117static int tostdoutFlag;
118
119static int inHeader; // <- check me 147static int inHeader; // <- check me
120static int badHeader; 148static int badHeader;
121static int errorFlag;
122static int skipFileFlag; 149static int skipFileFlag;
123static int warnedRoot; 150static int warnedRoot;
124static int eofFlag; 151static int eofFlag;
@@ -134,7 +161,6 @@ static time_t mtime;
134/* 161/*
135 * Static data associated with the tar file. 162 * Static data associated with the tar file.
136 */ 163 */
137static const char *tarName;
138static int tarFd; 164static int tarFd;
139static dev_t tarDev; 165static dev_t tarDev;
140static ino_t tarInode; 166static ino_t tarInode;
@@ -143,35 +169,25 @@ static ino_t tarInode;
143/* 169/*
144 * Local procedures to restore files from a tar file. 170 * Local procedures to restore files from a tar file.
145 */ 171 */
146static void readTarFile(int fileCount, char **fileTable); 172static int readTarFile(const char* tarName, int extractFlag, int listFlag,
173 int tostdoutFlag, int verboseFlag);
147static void readData(const char *cp, int count); 174static void readData(const char *cp, int count);
148static long getOctal(const char *cp, int len); 175static long getOctal(const char *cp, int len);
149 176static int parseTarHeader(struct TarHeader *rawHeader, struct TarInfo *header);
150static void readHeader(const TarHeader * hp,
151
152 int fileCount, char **fileTable);
153
154static int wantFileName(const char *fileName, 177static int wantFileName(const char *fileName,
155 178 int argc, char **argv);
156 int fileCount, char **fileTable);
157 179
158#ifdef BB_FEATURE_TAR_CREATE 180#ifdef BB_FEATURE_TAR_CREATE
159/* 181/*
160 * Local procedures to save files into a tar file. 182 * Local procedures to save files into a tar file.
161 */ 183 */
162static void saveFile(const char *fileName, int seeLinks); 184static void saveFile(const char *fileName, int seeLinks);
163
164static void saveRegularFile(const char *fileName, 185static void saveRegularFile(const char *fileName,
165
166 const struct stat *statbuf); 186 const struct stat *statbuf);
167
168static void saveDirectory(const char *fileName, 187static void saveDirectory(const char *fileName,
169
170 const struct stat *statbuf); 188 const struct stat *statbuf);
171
172static void writeHeader(const char *fileName, const struct stat *statbuf); 189static void writeHeader(const char *fileName, const struct stat *statbuf);
173 190static void writeTarFile(int argc, char **argv);
174static void writeTarFile(int fileCount, char **fileTable);
175static void writeTarBlock(const char *buf, int len); 191static void writeTarBlock(const char *buf, int len);
176static int putOctal(char *cp, int len, long value); 192static int putOctal(char *cp, int len, long value);
177 193
@@ -180,7 +196,13 @@ static int putOctal(char *cp, int len, long value);
180 196
181extern int tar_main(int argc, char **argv) 197extern int tar_main(int argc, char **argv)
182{ 198{
199 const char *tarName=NULL;
183 const char *options; 200 const char *options;
201 int listFlag = FALSE;
202 int extractFlag = FALSE;
203 int createFlag = FALSE;
204 int verboseFlag = FALSE;
205 int tostdoutFlag = FALSE;
184 206
185 argc--; 207 argc--;
186 argv++; 208 argv++;
@@ -188,21 +210,7 @@ extern int tar_main(int argc, char **argv)
188 if (argc < 1) 210 if (argc < 1)
189 usage(tar_usage); 211 usage(tar_usage);
190 212
191 213 /* Parse options */
192 errorFlag = FALSE;
193 extractFlag = FALSE;
194 createFlag = FALSE;
195 listFlag = FALSE;
196 verboseFlag = FALSE;
197 tostdoutFlag = FALSE;
198 tarName = NULL;
199 tarDev = 0;
200 tarInode = 0;
201 tarFd = -1;
202
203 /*
204 * Parse the options.
205 */
206 if (**argv == '-') 214 if (**argv == '-')
207 options = (*argv++) + 1; 215 options = (*argv++) + 1;
208 else 216 else
@@ -212,13 +220,12 @@ extern int tar_main(int argc, char **argv)
212 for (; *options; options++) { 220 for (; *options; options++) {
213 switch (*options) { 221 switch (*options) {
214 case 'f': 222 case 'f':
215 if (tarName != NULL) { 223 if (tarName != NULL)
216 fprintf(stderr, "Only one 'f' option allowed\n"); 224 fatalError( "Only one 'f' option allowed\n");
217
218 exit(FALSE);
219 }
220 225
221 tarName = *argv++; 226 tarName = *argv++;
227 if (tarName == NULL)
228 fatalError( "Option requires an argument: No file specified\n");
222 argc--; 229 argc--;
223 230
224 break; 231 break;
@@ -253,9 +260,8 @@ extern int tar_main(int argc, char **argv)
253 break; 260 break;
254 261
255 default: 262 default:
256 fprintf(stderr, "Unknown tar flag '%c'\n" 263 fatalError( "Unknown tar flag '%c'\n"
257 "Try `tar --help' for more information\n", *options); 264 "Try `tar --help' for more information\n", *options);
258 exit(FALSE);
259 } 265 }
260 } 266 }
261 267
@@ -265,23 +271,22 @@ extern int tar_main(int argc, char **argv)
265 */ 271 */
266 if (createFlag == TRUE) { 272 if (createFlag == TRUE) {
267#ifndef BB_FEATURE_TAR_CREATE 273#ifndef BB_FEATURE_TAR_CREATE
268 fprintf(stderr, 274 fatalError( "This version of tar was not compiled with tar creation support.\n");
269 "This version of tar was not compiled with tar creation support.\n");
270 exit(FALSE);
271#else 275#else
272 writeTarFile(argc, argv); 276 exit(writeTarFile(argc, argv));
273#endif 277#endif
274 } else { 278 } else {
275 readTarFile(argc, argv); 279 exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag));
276 } 280 }
277 if (errorFlag == TRUE) {
278 fprintf(stderr, "\n");
279 }
280 exit(!errorFlag);
281 281
282 flagError: 282 flagError:
283 fprintf(stderr, "Exactly one of 'c', 'x' or 't' must be specified\n"); 283 fatalError( "Exactly one of 'c', 'x' or 't' must be specified\n");
284 exit(FALSE); 284}
285
286static void
287tarExtractRegularFile(TarInfo *header, int extractFlag, int listFlag, int tostdoutFlag, int verboseFlag)
288{
289
285} 290}
286 291
287 292
@@ -289,178 +294,148 @@ extern int tar_main(int argc, char **argv)
289 * Read a tar file and extract or list the specified files within it. 294 * Read a tar file and extract or list the specified files within it.
290 * If the list is empty than all files are extracted or listed. 295 * If the list is empty than all files are extracted or listed.
291 */ 296 */
292static void readTarFile(int fileCount, char **fileTable) 297static int readTarFile(const char* tarName, int extractFlag, int listFlag,
298 int tostdoutFlag, int verboseFlag)
293{ 299{
294 const char *cp; 300 int status, tarFd=0;
295 int cc; 301 int errorFlag=FALSE;
296 int inCc; 302 TarHeader rawHeader;
297 int blockSize; 303 TarInfo header;
298 char buf[BUF_SIZE];
299
300 skipFileFlag = FALSE;
301 badHeader = FALSE;
302 warnedRoot = FALSE;
303 eofFlag = FALSE;
304 inHeader = TRUE;
305 inCc = 0;
306 dataCc = 0;
307 outFd = -1;
308 blockSize = sizeof(buf);
309 cp = buf;
310 304
311 /* 305 /* Open the tar file for reading. */
312 * Open the tar file for reading. 306 if (!strcmp(tarName, "-"))
313 */
314 if ((tarName == NULL) || !strcmp(tarName, "-")) {
315 tarFd = fileno(stdin); 307 tarFd = fileno(stdin);
316 } else 308 else
317 tarFd = open(tarName, O_RDONLY); 309 tarFd = open(tarName, O_RDONLY);
318
319 if (tarFd < 0) { 310 if (tarFd < 0) {
320 perror(tarName); 311 errorMsg( "Error opening '%s': %s", tarName, strerror(errno));
321 errorFlag = TRUE; 312 return ( FALSE);
322 return;
323 } 313 }
324 314
325 /* 315 /* Read the tar file */
326 * Read blocks from the file until an end of file header block 316 while ( (status = fullRead(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) {
327 * has been seen. (A real end of file from a read is an error.) 317 /* Now see if the header looks ok */
328 */ 318 if ( parseTarHeader(&rawHeader, &header) == FALSE ) {
329 while (eofFlag == FALSE) { 319 close( tarFd);
330 /* 320 if ( *(header.name) == '\0' ) {
331 * Read the next block of data if necessary. 321 goto endgame;
332 * This will be a large block if possible, which we will 322 } else {
333 * then process in the small tar blocks. 323 errorFlag=TRUE;
334 */ 324 errorMsg("Bad tar header, skipping\n");
335 if (inCc <= 0) { 325 continue;
336 cp = buf;
337 inCc = fullRead(tarFd, buf, blockSize);
338
339 if (inCc < 0) {
340 perror(tarName);
341 errorFlag = TRUE;
342 goto done;
343 }
344
345 if (inCc == 0) {
346 fprintf(stderr,
347 "Unexpected end of file from \"%s\"", tarName);
348 errorFlag = TRUE;
349 goto done;
350 } 326 }
351 } 327 }
352 328 if ( *(header.name) == '\0' )
353 /* 329 goto endgame;
354 * If we are expecting a header block then examine it. 330
355 */ 331 /* If we got here, we can be certain we have a legitimate
356 if (inHeader == TRUE) { 332 * header to work with. So work with it. */
357 readHeader((const TarHeader *) cp, fileCount, fileTable); 333 switch ( header.type ) {
358 334 case REGTYPE:
359 cp += TAR_BLOCK_SIZE; 335 case REGTYPE0:
360 inCc -= TAR_BLOCK_SIZE; 336 /* If the name ends in a '/' then assume it is
361 337 * supposed to be a directory, and fall through */
362 continue; 338 if (header.name[strlen(header.name)-1] != '/') {
339 tarExtractRegularFile(&header, extractFlag, listFlag, tostdoutFlag, verboseFlag);
340 break;
341 }
342#if 0
343 case Directory:
344 tarExtractDirectory( &header, extractFlag, listFlag, tostdoutFlag, verboseFlag);
345 break;
346 case HardLink:
347 tarExtractHardLink( &header, extractFlag, listFlag, tostdoutFlag, verboseFlag);
348 break;
349 case SymbolicLink:
350 tarExtractSymLink( &header, extractFlag, listFlag, tostdoutFlag, verboseFlag);
351 break;
352 case CharacterDevice:
353 case BlockDevice:
354 case FIFO:
355 tarExtractSpecial( &header, extractFlag, listFlag, tostdoutFlag, verboseFlag);
356 break;
357#endif
358 default:
359 close( tarFd);
360 return( FALSE);
363 } 361 }
364
365 /*
366 * We are currently handling the data for a file.
367 * Process the minimum of the amount of data we have available
368 * and the amount left to be processed for the file.
369 */
370 cc = inCc;
371
372 if (cc > dataCc)
373 cc = dataCc;
374
375 readData(cp, cc);
376
377 /*
378 * If the amount left isn't an exact multiple of the tar block
379 * size then round it up to the next block boundary since there
380 * is padding at the end of the file.
381 */
382 if (cc % TAR_BLOCK_SIZE)
383 cc += TAR_BLOCK_SIZE - (cc % TAR_BLOCK_SIZE);
384
385 cp += cc;
386 inCc -= cc;
387 } 362 }
388 363
389 done: 364 close(tarFd);
390 /* 365 if (status > 0) {
391 * Close the tar file if needed. 366 /* Bummer - we read a partial header */
392 */ 367 errorMsg( "Error reading '%s': %s", tarName, strerror(errno));
393 if ((tarFd >= 0) && (close(tarFd) < 0)) 368 return ( FALSE);
394 perror(tarName);
395
396 /*
397 * Close the output file if needed.
398 * This is only done here on a previous error and so no
399 * message is required on errors.
400 */
401 if (tostdoutFlag == FALSE) {
402 if (outFd >= 0) {
403 close(outFd);
404 }
405 } 369 }
370 else
371 return( status);
372
373 /* Stuff we do when we know we are done with the file */
374endgame:
375 close( tarFd);
376 if ( *(header.name) == '\0' ) {
377 if (errorFlag==FALSE)
378 return( TRUE);
379 }
380 return( FALSE);
406} 381}
407 382
408
409/* 383/*
410 * Examine the header block that was just read. 384 * Read an octal value in a field of the specified width, with optional
411 * This can specify the information for another file, or it can mark 385 * spaces on both sides of the number and with an optional null character
412 * the end of the tar file. 386 * at the end. Returns -1 on an illegal format.
413 */ 387 */
414static void 388static long getOctal(const char *cp, int size)
415readHeader(const TarHeader * hp, int fileCount, char **fileTable)
416{ 389{
417 int checkSum; 390 long val = 0;
418 int cc;
419 int hardLink;
420 int softLink;
421 int devFileFlag;
422 unsigned int major;
423 unsigned int minor;
424 long size;
425 struct utimbuf utb;
426
427 /*
428 * If the block is completely empty, then this is the end of the
429 * archive file. If the name is null, then just skip this header.
430 */
431 outName = hp->name;
432
433 if (*outName == '\0') {
434 for (cc = TAR_BLOCK_SIZE; cc > 0; cc--) {
435 if (*outName++)
436 return;
437 }
438 391
439 eofFlag = TRUE; 392 for(;(size > 0) && (*cp == ' '); cp++, size--);
440 393 if ((size == 0) || !isOctal(*cp))
441 return; 394 return -1;
395 for(; (size > 0) && isOctal(*cp); size--) {
396 val = val * 8 + *cp++ - '0';
442 } 397 }
398 for (;(size > 0) && (*cp == ' '); cp++, size--);
399 if ((size > 0) && *cp)
400 return -1;
401 return val;
402}
443 403
444 /* 404/* Parse the tar header and fill in the nice struct with the details */
445 * There is another file in the archive to examine. 405static int
446 * Extract the encoded information and check it. 406parseTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
447 */ 407{
448 mode = getOctal(hp->mode, sizeof(hp->mode)); 408 long major, minor, chksum, sum;
449 uid = getOctal(hp->uid, sizeof(hp->uid)); 409
450 gid = getOctal(hp->gid, sizeof(hp->gid)); 410 header->name = rawHeader->name;
451 size = getOctal(hp->size, sizeof(hp->size)); 411 header->mode = getOctal(rawHeader->mode, sizeof(rawHeader->mode));
452 mtime = getOctal(hp->mtime, sizeof(hp->mtime)); 412 header->uid = getOctal(rawHeader->uid, sizeof(rawHeader->uid));
453 checkSum = getOctal(hp->checkSum, sizeof(hp->checkSum)); 413 header->gid = getOctal(rawHeader->gid, sizeof(rawHeader->gid));
454 major = getOctal(hp->devMajor, sizeof(hp->devMajor)); 414 header->size = getOctal(rawHeader->size, sizeof(rawHeader->size));
455 minor = getOctal(hp->devMinor, sizeof(hp->devMinor)); 415 header->mtime = getOctal(rawHeader->mtime, sizeof(rawHeader->mtime));
456 416 chksum = getOctal(rawHeader->chksum, sizeof(rawHeader->chksum));
457 if ((mode < 0) || (uid < 0) || (gid < 0) || (size < 0)) { 417 header->type = rawHeader->typeflag;
458 if (badHeader == FALSE) 418 header->linkname = rawHeader->linkname;
459 fprintf(stderr, "Bad tar header, skipping\n"); 419 header->device = MAJOR(getOctal(rawHeader->devmajor, sizeof(rawHeader->devmajor))) |
460 420 MINOR(getOctal(rawHeader->devminor, sizeof(rawHeader->devminor)));
461 badHeader = TRUE; 421
422 /* Check the checksum */
423 sum = ' ' * sizeof(rawHeader->chksum);
424 for ( i = TarChecksumOffset; i > 0; i-- )
425 sum += *s++;
426 s += sizeof(h->chksum);
427 for ( i = (512 - TarChecksumOffset - sizeof(h->chksum)); i > 0; i-- )
428 sum += *s++;
429 if (sum == checksum )
430 return ( TRUE);
431 return( FALSE);
432}
462 433
463 return; 434#if 0
435 if ((header->mode < 0) || (header->uid < 0) ||
436 (header->gid < 0) || (header->size < 0)) {
437 errorMsg(stderr, "Bad tar header, skipping\n");
438 return( FALSE);
464 } 439 }
465 440
466 badHeader = FALSE; 441 badHeader = FALSE;
@@ -502,7 +477,7 @@ readHeader(const TarHeader * hp, int fileCount, char **fileTable)
502 * See if we want this file to be restored. 477 * See if we want this file to be restored.
503 * If not, then set up to skip it. 478 * If not, then set up to skip it.
504 */ 479 */
505 if (wantFileName(outName, fileCount, fileTable) == FALSE) { 480 if (wantFileName(outName, argc, argv) == FALSE) {
506 if (!hardLink && !softLink && (S_ISREG(mode) || S_ISCHR(mode) 481 if (!hardLink && !softLink && (S_ISREG(mode) || S_ISCHR(mode)
507 || S_ISBLK(mode) || S_ISSOCK(mode) 482 || S_ISBLK(mode) || S_ISSOCK(mode)
508 || S_ISFIFO(mode))) { 483 || S_ISFIFO(mode))) {
@@ -726,7 +701,7 @@ static void readData(const char *cp, int count)
726 * Returns TRUE if the file is selected. 701 * Returns TRUE if the file is selected.
727 */ 702 */
728static int 703static int
729wantFileName(const char *fileName, int fileCount, char **fileTable) 704wantFileName(const char *fileName, int argc, char **argv)
730{ 705{
731 const char *pathName; 706 const char *pathName;
732 int fileLength; 707 int fileLength;
@@ -735,7 +710,7 @@ wantFileName(const char *fileName, int fileCount, char **fileTable)
735 /* 710 /*
736 * If there are no files in the list, then the file is wanted. 711 * If there are no files in the list, then the file is wanted.
737 */ 712 */
738 if (fileCount == 0) 713 if (argc == 0)
739 return TRUE; 714 return TRUE;
740 715
741 fileLength = strlen(fileName); 716 fileLength = strlen(fileName);
@@ -743,8 +718,8 @@ wantFileName(const char *fileName, int fileCount, char **fileTable)
743 /* 718 /*
744 * Check each of the test paths. 719 * Check each of the test paths.
745 */ 720 */
746 while (fileCount-- > 0) { 721 while (argc-- > 0) {
747 pathName = *fileTable++; 722 pathName = *argv++;
748 723
749 pathLength = strlen(pathName); 724 pathLength = strlen(pathName);
750 725
@@ -762,43 +737,6 @@ wantFileName(const char *fileName, int fileCount, char **fileTable)
762 return FALSE; 737 return FALSE;
763} 738}
764 739
765/*
766 * Read an octal value in a field of the specified width, with optional
767 * spaces on both sides of the number and with an optional null character
768 * at the end. Returns -1 on an illegal format.
769 */
770static long getOctal(const char *cp, int len)
771{
772 long val;
773
774 while ((len > 0) && (*cp == ' ')) {
775 cp++;
776 len--;
777 }
778
779 if ((len == 0) || !isOctal(*cp))
780 return -1;
781
782 val = 0;
783
784 while ((len > 0) && isOctal(*cp)) {
785 val = val * 8 + *cp++ - '0';
786 len--;
787 }
788
789 while ((len > 0) && (*cp == ' ')) {
790 cp++;
791 len--;
792 }
793
794 if ((len > 0) && *cp)
795 return -1;
796
797 return val;
798}
799
800
801
802 740
803/* From here to the end of the file is the tar writing stuff. 741/* From here to the end of the file is the tar writing stuff.
804 * If you do not have BB_FEATURE_TAR_CREATE defined, this will 742 * If you do not have BB_FEATURE_TAR_CREATE defined, this will
@@ -809,14 +747,14 @@ static long getOctal(const char *cp, int len)
809/* 747/*
810 * Write a tar file containing the specified files. 748 * Write a tar file containing the specified files.
811 */ 749 */
812static void writeTarFile(int fileCount, char **fileTable) 750static void writeTarFile(int argc, char **argv)
813{ 751{
814 struct stat statbuf; 752 struct stat statbuf;
815 753
816 /* 754 /*
817 * Make sure there is at least one file specified. 755 * Make sure there is at least one file specified.
818 */ 756 */
819 if (fileCount <= 0) { 757 if (argc <= 0) {
820 fprintf(stderr, "No files specified to be saved\n"); 758 fprintf(stderr, "No files specified to be saved\n");
821 errorFlag = TRUE; 759 errorFlag = TRUE;
822 } 760 }
@@ -852,8 +790,8 @@ static void writeTarFile(int fileCount, char **fileTable)
852 * Append each file name into the archive file. 790 * Append each file name into the archive file.
853 * Follow symbolic links for these top level file names. 791 * Follow symbolic links for these top level file names.
854 */ 792 */
855 while (errorFlag == FALSE && (fileCount-- > 0)) { 793 while (errorFlag == FALSE && (argc-- > 0)) {
856 saveFile(*fileTable++, FALSE); 794 saveFile(*argv++, FALSE);
857 } 795 }
858 796
859 /* 797 /*
@@ -1284,3 +1222,4 @@ static int putOctal(char *cp, int len, long value)
1284#endif 1222#endif
1285 1223
1286/* END CODE */ 1224/* END CODE */
1225#endif
diff --git a/tee.c b/tee.c
index a3a1c8132..018fe117b 100644
--- a/tee.c
+++ b/tee.c
@@ -125,8 +125,10 @@ int tee_main(int argc, char **argv)
125 125
126 /* clean up */ 126 /* clean up */
127 FL_apply(tee_fclose, 0); 127 FL_apply(tee_fclose, 0);
128 free(FileList); 128 /* Don't bother to close files Exit does that
129 * automagically, so we can save a few bytes */
130 /* free(FileList); */
129 exit(0); 131 exit(0);
130} 132}
131 133
132/* $Id: tee.c,v 1.7 2000/03/08 00:14:35 beppu Exp $ */ 134/* $Id: tee.c,v 1.8 2000/03/23 01:09:18 erik Exp $ */
diff --git a/umount.c b/umount.c
index c34bf5fc3..23973fc85 100644
--- a/umount.c
+++ b/umount.c
@@ -145,6 +145,9 @@ char *mtab_next(void **iter)
145 return mp; 145 return mp;
146} 146}
147 147
148/* Don't bother to clean up, since exit() does that
149 * automagically, so we can save a few bytes */
150#if 0
148void mtab_free(void) 151void mtab_free(void)
149{ 152{
150 struct _mtab_entry_t *this, *next; 153 struct _mtab_entry_t *this, *next;
@@ -160,6 +163,7 @@ void mtab_free(void)
160 this = next; 163 this = next;
161 } 164 }
162} 165}
166#endif
163 167
164static int do_umount(const char *name, int useMtab) 168static int do_umount(const char *name, int useMtab)
165{ 169{
diff --git a/util-linux/fbset.c b/util-linux/fbset.c
index a75e431db..7ca41733b 100644
--- a/util-linux/fbset.c
+++ b/util-linux/fbset.c
@@ -62,7 +62,7 @@
62#define CMD_ALL 11 62#define CMD_ALL 11
63#define CMD_INFO 12 63#define CMD_INFO 12
64 64
65#ifdef BB_FBSET_FANCY 65#ifdef BB_FEATURE_FBSET_FANCY
66#define CMD_XRES 13 66#define CMD_XRES 13
67#define CMD_YRES 14 67#define CMD_YRES 14
68#define CMD_VXRES 15 68#define CMD_VXRES 15
@@ -105,7 +105,7 @@ struct cmdoptions_t {
105 "-vsync", 1, CMD_VSYNC}, { 105 "-vsync", 1, CMD_VSYNC}, {
106 "-laced", 1, CMD_LACED}, { 106 "-laced", 1, CMD_LACED}, {
107 "-double", 1, CMD_DOUBLE}, 107 "-double", 1, CMD_DOUBLE},
108#ifdef BB_FBSET_FANCY 108#ifdef BB_FEATURE_FBSET_FANCY
109 { 109 {
110 "--help", 0, CMD_HELP}, { 110 "--help", 0, CMD_HELP}, {
111 "-all", 0, CMD_ALL}, { 111 "-all", 0, CMD_ALL}, {
@@ -164,8 +164,7 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn,
164 } 164 }
165 } 165 }
166#else 166#else
167 fprintf(stderr, 167 errorMsg( "mode reading not compiled in\n");
168 "W: mode reading was disabled on this copy of fbset; ignoring request\n");
169#endif 168#endif
170 return 0; 169 return 0;
171} 170}
@@ -199,7 +198,7 @@ static void showmode(struct fb_var_screeninfo *v)
199 v->vsync_len); 198 v->vsync_len);
200 } 199 }
201 printf("\nmode \"%ux%u-%u\"\n", v->xres, v->yres, (int) (vrate + 0.5)); 200 printf("\nmode \"%ux%u-%u\"\n", v->xres, v->yres, (int) (vrate + 0.5));
202#ifdef BB_FBSET_FANCY 201#ifdef BB_FEATURE_FBSET_FANCY
203 printf("\t# D: %.3f MHz, H: %.3f kHz, V: %.3f Hz\n", drate / 1e6, 202 printf("\t# D: %.3f MHz, H: %.3f kHz, V: %.3f Hz\n", drate / 1e6,
204 hrate / 1e3, vrate); 203 hrate / 1e3, vrate);
205#endif 204#endif
@@ -283,7 +282,7 @@ extern int fbset_main(int argc, char **argv)
283 varset.hsync_len = strtoul(argv[6], 0, 0); 282 varset.hsync_len = strtoul(argv[6], 0, 0);
284 varset.vsync_len = strtoul(argv[7], 0, 0); 283 varset.vsync_len = strtoul(argv[7], 0, 0);
285 break; 284 break;
286#ifdef BB_FBSET_FANCY 285#ifdef BB_FEATURE_FBSET_FANCY
287 case CMD_XRES: 286 case CMD_XRES:
288 varset.xres = strtoul(argv[1], 0, 0); 287 varset.xres = strtoul(argv[1], 0, 0);
289 break; 288 break;
@@ -323,7 +322,8 @@ extern int fbset_main(int argc, char **argv)
323 if (ioctl(fh, FBIOPUT_VSCREENINFO, &var)) 322 if (ioctl(fh, FBIOPUT_VSCREENINFO, &var))
324 PERROR("fbset(ioctl)"); 323 PERROR("fbset(ioctl)");
325 showmode(&var); 324 showmode(&var);
326 close(fh); 325 /* Don't close the file, as exiting will take care of that */
326 /* close(fh); */
327 327
328 return (TRUE); 328 exit (TRUE);
329} 329}
diff --git a/util-linux/fdflush.c b/util-linux/fdflush.c
index 0b154c8a6..201cea898 100644
--- a/util-linux/fdflush.c
+++ b/util-linux/fdflush.c
@@ -44,7 +44,9 @@ extern int fdflush_main(int argc, char **argv)
44 } 44 }
45 45
46 value = ioctl(fd, FDFLUSH, 0); 46 value = ioctl(fd, FDFLUSH, 0);
47 close(fd); 47 /* Don't bother closing. Exit does
48 * that, so we can save a few bytes */
49 /* close(fd); */
48 50
49 if (value) { 51 if (value) {
50 perror(*argv); 52 perror(*argv);
diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c
index 43d42d424..06937a70f 100644
--- a/util-linux/freeramdisk.c
+++ b/util-linux/freeramdisk.c
@@ -55,7 +55,9 @@ freeramdisk_main(int argc, char **argv)
55 if (ioctl(f, BLKFLSBUF) < 0) { 55 if (ioctl(f, BLKFLSBUF) < 0) {
56 fatalError( "freeramdisk: failed ioctl on %s: %s", rname, strerror(errno)); 56 fatalError( "freeramdisk: failed ioctl on %s: %s", rname, strerror(errno));
57 } 57 }
58 close(f); 58 /* Don't bother closing. Exit does
59 * that, so we can save a few bytes */
60 /* close(f); */
59 exit(TRUE); 61 exit(TRUE);
60} 62}
61 63
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index 47e81ce42..aa0a82432 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -1242,6 +1242,7 @@ static void alloc_name_list(void)
1242 name_list[i] = xmalloc(sizeof(char) * PATH_MAX + 1); 1242 name_list[i] = xmalloc(sizeof(char) * PATH_MAX + 1);
1243} 1243}
1244 1244
1245#if 0
1245/* execute this atexit() to deallocate name_list[] */ 1246/* execute this atexit() to deallocate name_list[] */
1246/* piptigger was here */ 1247/* piptigger was here */
1247static void free_name_list(void) 1248static void free_name_list(void)
@@ -1257,6 +1258,7 @@ static void free_name_list(void)
1257 free(name_list); 1258 free(name_list);
1258 } 1259 }
1259} 1260}
1261#endif
1260 1262
1261extern int fsck_minix_main(int argc, char **argv) 1263extern int fsck_minix_main(int argc, char **argv)
1262{ 1264{
@@ -1265,7 +1267,9 @@ extern int fsck_minix_main(int argc, char **argv)
1265 int retcode = 0; 1267 int retcode = 0;
1266 1268
1267 alloc_name_list(); 1269 alloc_name_list();
1268 atexit(free_name_list); 1270 /* Don't bother to free memory. Exit does
1271 * that automagically, so we can save a few bytes */
1272 //atexit(free_name_list);
1269 1273
1270 if (argc && *argv) 1274 if (argc && *argv)
1271 program_name = *argv; 1275 program_name = *argv;
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 03891371a..30a060fc1 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -348,8 +348,12 @@ extern int mount_main(int argc, char **argv)
348 mntentlist[i].mnt_opts, mntentlist[i].mnt_freq, 348 mntentlist[i].mnt_opts, mntentlist[i].mnt_freq,
349 mntentlist[i].mnt_passno); 349 mntentlist[i].mnt_passno);
350 } 350 }
351 /* Don't bother to close files or free memory. Exit
352 * does that automagically, so we can save a few bytes */
353#if 0
351 free( mntentlist); 354 free( mntentlist);
352 close(fd); 355 close(fd);
356#endif
353 exit(TRUE); 357 exit(TRUE);
354 } 358 }
355#else 359#else
diff --git a/util-linux/umount.c b/util-linux/umount.c
index c34bf5fc3..23973fc85 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -145,6 +145,9 @@ char *mtab_next(void **iter)
145 return mp; 145 return mp;
146} 146}
147 147
148/* Don't bother to clean up, since exit() does that
149 * automagically, so we can save a few bytes */
150#if 0
148void mtab_free(void) 151void mtab_free(void)
149{ 152{
150 struct _mtab_entry_t *this, *next; 153 struct _mtab_entry_t *this, *next;
@@ -160,6 +163,7 @@ void mtab_free(void)
160 this = next; 163 this = next;
161 } 164 }
162} 165}
166#endif
163 167
164static int do_umount(const char *name, int useMtab) 168static int do_umount(const char *name, int useMtab)
165{ 169{
diff --git a/utility.c b/utility.c
index c779cc6ba..a39ecd935 100644
--- a/utility.c
+++ b/utility.c
@@ -112,10 +112,10 @@ extern void fatalError(char *s, ...)
112 exit( FALSE); 112 exit( FALSE);
113} 113}
114 114
115#if defined (BB_INIT) || defined (BB_PS) 115#if defined BB_INIT
116/* Returns kernel version encoded as major*65536 + minor*256 + patch, 116/* Returns kernel version encoded as major*65536 + minor*256 + patch,
117 * so, for example, to check if the kernel is greater than 2.2.11: 117 * so, for example, to check if the kernel is greater than 2.2.11:
118 * if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> } 118 * if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> }
119 */ 119 */
120int get_kernel_revision() 120int get_kernel_revision()
121{ 121{
@@ -129,7 +129,7 @@ int get_kernel_revision()
129 sscanf(name.version, "%d.%d.%d", &major, &minor, &patch); 129 sscanf(name.version, "%d.%d.%d", &major, &minor, &patch);
130 return major * 65536 + minor * 256 + patch; 130 return major * 65536 + minor * 256 + patch;
131} 131}
132#endif /* BB_INIT || BB_PS */ 132#endif /* BB_INIT */
133 133
134#if defined (BB_CP_MV) || defined (BB_DU) 134#if defined (BB_CP_MV) || defined (BB_DU)
135 135