aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/Config.src14
-rw-r--r--miscutils/Kbuild.src2
-rw-r--r--miscutils/adjtimex.c2
-rw-r--r--miscutils/bbconfig.c22
-rw-r--r--miscutils/beep.c2
-rw-r--r--miscutils/chat.c2
-rw-r--r--miscutils/chrt.c2
-rw-r--r--miscutils/conspy.c2
-rw-r--r--miscutils/crond.c2
-rw-r--r--miscutils/crontab.c2
-rw-r--r--miscutils/dc.c2
-rw-r--r--miscutils/devfsd.c2
-rw-r--r--miscutils/devmem.c2
-rw-r--r--miscutils/eject.c2
-rw-r--r--miscutils/fbsplash.c2
-rw-r--r--miscutils/flash_eraseall.c2
-rw-r--r--miscutils/flash_lock_unlock.c2
-rw-r--r--miscutils/flashcp.c2
-rw-r--r--miscutils/hdparm.c2
-rw-r--r--miscutils/inotifyd.c2
-rw-r--r--miscutils/ionice.c2
-rw-r--r--miscutils/last.c2
-rw-r--r--miscutils/last_fancy.c2
-rw-r--r--miscutils/less.c2
-rw-r--r--miscutils/makedevs.c2
-rw-r--r--miscutils/man.c2
-rw-r--r--miscutils/microcom.c2
-rw-r--r--miscutils/mountpoint.c2
-rw-r--r--miscutils/mt.c2
-rw-r--r--miscutils/nandwrite.c142
-rw-r--r--miscutils/raidautorun.c2
-rw-r--r--miscutils/readahead.c2
-rw-r--r--miscutils/rfkill.c2
-rw-r--r--miscutils/runlevel.c2
-rw-r--r--miscutils/rx.c2
-rw-r--r--miscutils/strings.c2
-rw-r--r--miscutils/taskset.c2
-rw-r--r--miscutils/time.c2
-rw-r--r--miscutils/ttysize.c2
-rw-r--r--miscutils/ubi_attach_detach.c6
-rw-r--r--miscutils/wall.c2
-rw-r--r--miscutils/watchdog.c2
42 files changed, 219 insertions, 41 deletions
diff --git a/miscutils/Config.src b/miscutils/Config.src
index cadaabb65..151f61bcc 100644
--- a/miscutils/Config.src
+++ b/miscutils/Config.src
@@ -22,6 +22,20 @@ config BBCONFIG
22 The bbconfig applet will print the config file with which 22 The bbconfig applet will print the config file with which
23 busybox was built. 23 busybox was built.
24 24
25config FEATURE_COMPRESS_BBCONFIG
26 bool "Compress bbconfig data"
27 default y
28 depends on BBCONFIG
29 help
30 Store bbconfig data in compressed form, uncompress them on-the-fly
31 before output.
32
33 If you have a really tiny busybox with few applets enabled (and
34 bunzip2 isn't one of them), the overhead of the decompressor might
35 be noticeable. Also, if you run executables directly from ROM
36 and have very little memory, this might not be a win. Otherwise,
37 you probably want this.
38
25config BEEP 39config BEEP
26 bool "beep" 40 bool "beep"
27 default y 41 default y
diff --git a/miscutils/Kbuild.src b/miscutils/Kbuild.src
index d9bf14312..8c498643b 100644
--- a/miscutils/Kbuild.src
+++ b/miscutils/Kbuild.src
@@ -2,7 +2,7 @@
2# 2#
3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org> 3# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4# 4#
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under GPLv2, see file LICENSE in this source tree.
6 6
7lib-y:= 7lib-y:=
8 8
diff --git a/miscutils/adjtimex.c b/miscutils/adjtimex.c
index a6f323ba2..8e8ff8c0a 100644
--- a/miscutils/adjtimex.c
+++ b/miscutils/adjtimex.c
@@ -8,7 +8,7 @@
8 * 8 *
9 * busyboxed 20 March 2001, Larry Doolittle <ldoolitt@recycle.lbl.gov> 9 * busyboxed 20 March 2001, Larry Doolittle <ldoolitt@recycle.lbl.gov>
10 * 10 *
11 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 11 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
12 */ 12 */
13 13
14#include "libbb.h" 14#include "libbb.h"
diff --git a/miscutils/bbconfig.c b/miscutils/bbconfig.c
index 0d649b4e5..286077168 100644
--- a/miscutils/bbconfig.c
+++ b/miscutils/bbconfig.c
@@ -3,10 +3,32 @@
3 */ 3 */
4#include "libbb.h" 4#include "libbb.h"
5#include "bbconfigopts.h" 5#include "bbconfigopts.h"
6#if ENABLE_FEATURE_COMPRESS_BBCONFIG
7# include "unarchive.h"
8# include "bbconfigopts_bz2.h"
9#endif
6 10
7int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 11int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
8int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) 12int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
9{ 13{
14#if ENABLE_FEATURE_COMPRESS_BBCONFIG
15 bunzip_data *bd;
16 int i = start_bunzip(&bd,
17 /* src_fd: */ -1,
18 /* inbuf: */ (void *)bbconfig_config_bz2,
19 /* len: */ sizeof(bbconfig_config_bz2));
20 /* read_bunzip can longjmp to start_bunzip, and ultimately
21 * end up here with i != 0 on read data errors! Not trivial */
22 if (!i) {
23 /* Cannot use xmalloc: will leak bd in NOFORK case! */
24 char *outbuf = malloc_or_warn(sizeof(bbconfig_config));
25 if (outbuf) {
26 read_bunzip(bd, outbuf, sizeof(bbconfig_config));
27 full_write1_str(outbuf);
28 }
29 }
30#else
10 full_write1_str(bbconfig_config); 31 full_write1_str(bbconfig_config);
32#endif
11 return 0; 33 return 0;
12} 34}
diff --git a/miscutils/beep.c b/miscutils/beep.c
index b0ee7ea25..013a72543 100644
--- a/miscutils/beep.c
+++ b/miscutils/beep.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 2009 Bernhard Reutner-Fischer 5 * Copyright (C) 2009 Bernhard Reutner-Fischer
6 * 6 *
7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 * 8 *
9 */ 9 */
10#include "libbb.h" 10#include "libbb.h"
diff --git a/miscutils/chat.c b/miscutils/chat.c
index 3ffd7b228..2040c3f6a 100644
--- a/miscutils/chat.c
+++ b/miscutils/chat.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com> 6 * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
7 * 7 *
8 * Licensed under GPLv2, see file LICENSE in this tarball for details. 8 * Licensed under GPLv2, see file LICENSE in this source tree.
9 */ 9 */
10#include "libbb.h" 10#include "libbb.h"
11 11
diff --git a/miscutils/chrt.c b/miscutils/chrt.c
index d5f87c4d7..c40277b39 100644
--- a/miscutils/chrt.c
+++ b/miscutils/chrt.c
@@ -3,7 +3,7 @@
3 * chrt - manipulate real-time attributes of a process 3 * chrt - manipulate real-time attributes of a process
4 * Copyright (c) 2006-2007 Bernhard Reutner-Fischer 4 * Copyright (c) 2006-2007 Bernhard Reutner-Fischer
5 * 5 *
6 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 6 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
7 */ 7 */
8#include <sched.h> 8#include <sched.h>
9#include "libbb.h" 9#include "libbb.h"
diff --git a/miscutils/conspy.c b/miscutils/conspy.c
index 02b13e9c8..01928b35f 100644
--- a/miscutils/conspy.c
+++ b/miscutils/conspy.c
@@ -7,7 +7,7 @@
7 * Based on Russell Stuart's conspy.c 7 * Based on Russell Stuart's conspy.c
8 * http://ace-host.stuart.id.au/russell/files/conspy.c 8 * http://ace-host.stuart.id.au/russell/files/conspy.c
9 * 9 *
10 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 10 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
11 */ 11 */
12 12
13//applet:IF_CONSPY(APPLET(conspy, _BB_DIR_BIN, _BB_SUID_DROP)) 13//applet:IF_CONSPY(APPLET(conspy, _BB_DIR_BIN, _BB_SUID_DROP))
diff --git a/miscutils/crond.c b/miscutils/crond.c
index d028eb089..fddddcd8c 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -8,7 +8,7 @@
8 * (version 2.3.2) 8 * (version 2.3.2)
9 * Vladimir Oleynik <dzo@simtreas.ru> (C) 2002 9 * Vladimir Oleynik <dzo@simtreas.ru> (C) 2002
10 * 10 *
11 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 11 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
12 */ 12 */
13 13
14#include "libbb.h" 14#include "libbb.h"
diff --git a/miscutils/crontab.c b/miscutils/crontab.c
index b8a5abc64..163e15dce 100644
--- a/miscutils/crontab.c
+++ b/miscutils/crontab.c
@@ -7,7 +7,7 @@
7 * Copyright 1994 Matthew Dillon (dillon@apollo.west.oic.com) 7 * Copyright 1994 Matthew Dillon (dillon@apollo.west.oic.com)
8 * Vladimir Oleynik <dzo@simtreas.ru> (C) 2002 8 * Vladimir Oleynik <dzo@simtreas.ru> (C) 2002
9 * 9 *
10 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 10 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
11 */ 11 */
12 12
13#include "libbb.h" 13#include "libbb.h"
diff --git a/miscutils/dc.c b/miscutils/dc.c
index 767d746e0..777ec1654 100644
--- a/miscutils/dc.c
+++ b/miscutils/dc.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 3 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index 4ccb76d95..8f19288cc 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 3 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
4 */ 4 */
5 5
6/* 6/*
diff --git a/miscutils/devmem.c b/miscutils/devmem.c
index 39b580840..7a9f533af 100644
--- a/miscutils/devmem.c
+++ b/miscutils/devmem.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 2 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
3 * Copyright (C) 2000, Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl) 3 * Copyright (C) 2000, Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
4 * Copyright (C) 2008, BusyBox Team. -solar 4/26/08 4 * Copyright (C) 2008, BusyBox Team. -solar 4/26/08
5 */ 5 */
diff --git a/miscutils/eject.c b/miscutils/eject.c
index a869c6311..63d20d3ad 100644
--- a/miscutils/eject.c
+++ b/miscutils/eject.c
@@ -5,7 +5,7 @@
5 * Copyright (C) 2004 Peter Willis <psyphreak@phreaker.net> 5 * Copyright (C) 2004 Peter Willis <psyphreak@phreaker.net>
6 * Copyright (C) 2005 Tito Ragusa <farmatito@tiscali.it> 6 * Copyright (C) 2005 Tito Ragusa <farmatito@tiscali.it>
7 * 7 *
8 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 */ 9 */
10 10
11/* 11/*
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index a031cbd3a..6b84563a3 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -2,7 +2,7 @@
2/* 2/*
3 * Copyright (C) 2008 Michele Sanges <michele.sanges@gmail.com> 3 * Copyright (C) 2008 Michele Sanges <michele.sanges@gmail.com>
4 * 4 *
5 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 5 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
6 * 6 *
7 * Usage: 7 * Usage:
8 * - use kernel option 'vga=xxx' or otherwise enable framebuffer device. 8 * - use kernel option 'vga=xxx' or otherwise enable framebuffer device.
diff --git a/miscutils/flash_eraseall.c b/miscutils/flash_eraseall.c
index ca00a130e..53aad3d52 100644
--- a/miscutils/flash_eraseall.c
+++ b/miscutils/flash_eraseall.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Renamed to flash_eraseall.c 8 * Renamed to flash_eraseall.c
9 * 9 *
10 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 10 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
11 */ 11 */
12 12
13#include "libbb.h" 13#include "libbb.h"
diff --git a/miscutils/flash_lock_unlock.c b/miscutils/flash_lock_unlock.c
index f4e2f73b2..fcb836b07 100644
--- a/miscutils/flash_lock_unlock.c
+++ b/miscutils/flash_lock_unlock.c
@@ -1,7 +1,7 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* Ported to busybox from mtd-utils. 2/* Ported to busybox from mtd-utils.
3 * 3 *
4 * Licensed under GPLv2, see file LICENSE in this tarball for details. 4 * Licensed under GPLv2, see file LICENSE in this source tree.
5 */ 5 */
6#include "libbb.h" 6#include "libbb.h"
7#include <mtd/mtd-user.h> 7#include <mtd/mtd-user.h>
diff --git a/miscutils/flashcp.c b/miscutils/flashcp.c
index 9472c7527..fe37c3913 100644
--- a/miscutils/flashcp.c
+++ b/miscutils/flashcp.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * (C) 2009 Stefan Seyfried <seife@sphairon.com> 5 * (C) 2009 Stefan Seyfried <seife@sphairon.com>
6 * 6 *
7 * Licensed under GPLv2, see file LICENSE in this tarball for details. 7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */ 8 */
9 9
10#include "libbb.h" 10#include "libbb.h"
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index c6ca3af80..d946c7165 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -5,7 +5,7 @@
5 * Copyright (C) [2003] by [Matteo Croce] <3297627799@wind.it> 5 * Copyright (C) [2003] by [Matteo Croce] <3297627799@wind.it>
6 * Hacked by Tito <farmatito@tiscali.it> for size optimization. 6 * Hacked by Tito <farmatito@tiscali.it> for size optimization.
7 * 7 *
8 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 * 9 *
10 * This program is based on the source code of hdparm: see below... 10 * This program is based on the source code of hdparm: see below...
11 * hdparm.c - Command line interface to get/set hard disk parameters 11 * hdparm.c - Command line interface to get/set hard disk parameters
diff --git a/miscutils/inotifyd.c b/miscutils/inotifyd.c
index 271f3ade1..fe429b636 100644
--- a/miscutils/inotifyd.c
+++ b/miscutils/inotifyd.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com> 6 * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
7 * 7 *
8 * Licensed under GPLv2, see file LICENSE in this tarball for details. 8 * Licensed under GPLv2, see file LICENSE in this source tree.
9 */ 9 */
10 10
11/* 11/*
diff --git a/miscutils/ionice.c b/miscutils/ionice.c
index 6b791c491..481a738ee 100644
--- a/miscutils/ionice.c
+++ b/miscutils/ionice.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 2008 by <u173034@informatik.uni-oldenburg.de> 5 * Copyright (C) 2008 by <u173034@informatik.uni-oldenburg.de>
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9 9
10#include <sys/syscall.h> 10#include <sys/syscall.h>
diff --git a/miscutils/last.c b/miscutils/last.c
index 55c03ae41..888a0a3d1 100644
--- a/miscutils/last.c
+++ b/miscutils/last.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 2003-2004 by Erik Andersen <andersen@codepoet.org> 5 * Copyright (C) 2003-2004 by Erik Andersen <andersen@codepoet.org>
6 * 6 *
7 * Licensed under the GPL version 2, see the file LICENSE in this tarball. 7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */ 8 */
9 9
10#include "libbb.h" 10#include "libbb.h"
diff --git a/miscutils/last_fancy.c b/miscutils/last_fancy.c
index f3ea0375d..7e69fc281 100644
--- a/miscutils/last_fancy.c
+++ b/miscutils/last_fancy.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 2008 by Patricia Muscalu <patricia.muscalu@axis.com> 5 * Copyright (C) 2008 by Patricia Muscalu <patricia.muscalu@axis.com>
6 * 6 *
7 * Licensed under the GPLv2 or later, see the file LICENSE in this tarball. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9 9
10#include "libbb.h" 10#include "libbb.h"
diff --git a/miscutils/less.c b/miscutils/less.c
index da2cd07af..d737e4cba 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 2005 by Rob Sullivan <cogito.ergo.cogito@gmail.com> 5 * Copyright (C) 2005 by Rob Sullivan <cogito.ergo.cogito@gmail.com>
6 * 6 *
7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9 9
10/* 10/*
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c
index 0578d9251..bba7fa61d 100644
--- a/miscutils/makedevs.c
+++ b/miscutils/makedevs.c
@@ -76,7 +76,7 @@ int makedevs_main(int argc, char **argv)
76 76
77#elif ENABLE_FEATURE_MAKEDEVS_TABLE 77#elif ENABLE_FEATURE_MAKEDEVS_TABLE
78 78
79/* Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ 79/* Licensed under GPLv2 or later, see file LICENSE in this source tree. */
80 80
81int makedevs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 81int makedevs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
82int makedevs_main(int argc UNUSED_PARAM, char **argv) 82int makedevs_main(int argc UNUSED_PARAM, char **argv)
diff --git a/miscutils/man.c b/miscutils/man.c
index a4ff274d4..2d3776cf3 100644
--- a/miscutils/man.c
+++ b/miscutils/man.c
@@ -1,6 +1,6 @@
1/* mini man implementation for busybox 1/* mini man implementation for busybox
2 * Copyright (C) 2008 Denys Vlasenko <vda.linux@googlemail.com> 2 * Copyright (C) 2008 Denys Vlasenko <vda.linux@googlemail.com>
3 * Licensed under GPLv2, see file LICENSE in this tarball for details. 3 * Licensed under GPLv2, see file LICENSE in this source tree.
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
diff --git a/miscutils/microcom.c b/miscutils/microcom.c
index 78863d49f..3acbe3023 100644
--- a/miscutils/microcom.c
+++ b/miscutils/microcom.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com> 6 * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
7 * 7 *
8 * Licensed under GPLv2, see file LICENSE in this tarball for details. 8 * Licensed under GPLv2, see file LICENSE in this source tree.
9 */ 9 */
10#include "libbb.h" 10#include "libbb.h"
11 11
diff --git a/miscutils/mountpoint.c b/miscutils/mountpoint.c
index a35c38907..784c3cbfc 100644
--- a/miscutils/mountpoint.c
+++ b/miscutils/mountpoint.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 2005 Bernhard Reutner-Fischer 5 * Copyright (C) 2005 Bernhard Reutner-Fischer
6 * 6 *
7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 * 8 *
9 * Based on sysvinit's mountpoint 9 * Based on sysvinit's mountpoint
10 */ 10 */
diff --git a/miscutils/mt.c b/miscutils/mt.c
index 8df2b75f7..d19866a5f 100644
--- a/miscutils/mt.c
+++ b/miscutils/mt.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 3 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c
new file mode 100644
index 000000000..f42242687
--- /dev/null
+++ b/miscutils/nandwrite.c
@@ -0,0 +1,142 @@
1/*
2 * nandwrite.c - ported to busybox from mtd-utils
3 *
4 * Author: Baruch Siach <baruch@tkos.co.il>, Orex Computed Radiography
5 *
6 * Licensed under GPLv2, see file LICENSE in this source tree.
7 *
8 * TODO: add support for large (>4GB) MTD devices
9 */
10
11//applet:IF_NANDWRITE(APPLET(nandwrite, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
12
13//kbuild:lib-$(CONFIG_NANDWRITE) += nandwrite.o
14
15//config:config NANDWRITE
16//config: bool "nandwrite"
17//config: default n
18//config: depends on PLATFORM_LINUX
19//config: help
20//config: Write to the specified MTD device, with bad blocks awareness
21
22#include "libbb.h"
23#include <mtd/mtd-user.h>
24
25//usage:#define nandwrite_trivial_usage
26//usage: "[-p] [-s ADDR] MTD_DEVICE [FILE]"
27//usage:#define nandwrite_full_usage "\n\n"
28//usage: "Write to the specified MTD device\n"
29//usage: "\nOptions:"
30//usage: "\n -p Pad to page size"
31//usage: "\n -s ADDR Start address"
32
33static unsigned next_good_eraseblock(int fd, struct mtd_info_user *meminfo,
34 unsigned block_offset)
35{
36 while (1) {
37 loff_t offs;
38 if (block_offset >= meminfo->size)
39 bb_error_msg_and_die("not enough space in MTD device");
40 offs = block_offset;
41 if (xioctl(fd, MEMGETBADBLOCK, &offs) == 0)
42 return block_offset;
43 /* ioctl returned 1 => "bad block" */
44 printf("Skipping bad block at 0x%08x\n", block_offset);
45 block_offset += meminfo->erasesize;
46 }
47}
48
49int nandwrite_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
50int nandwrite_main(int argc UNUSED_PARAM, char **argv)
51{
52 unsigned opts;
53 int fd;
54 ssize_t cnt;
55 unsigned mtdoffset, meminfo_writesize, blockstart;
56 struct mtd_info_user meminfo;
57 unsigned char *filebuf;
58 const char *opt_s = "0";
59 enum {
60 OPT_p = (1 << 0),
61 OPT_s = (1 << 1),
62 };
63
64 opt_complementary = "-1:?2";
65 opts = getopt32(argv, "ps:", &opt_s);
66 argv += optind;
67
68 if (argv[1])
69 xmove_fd(xopen_stdin(argv[1]), STDIN_FILENO);
70
71 fd = xopen(argv[0], O_RDWR);
72 xioctl(fd, MEMGETINFO, &meminfo);
73
74 mtdoffset = bb_strtou(opt_s, NULL, 0);
75 if (errno)
76 bb_error_msg_and_die("invalid number '%s'", opt_s);
77
78 /* Pull it into a CPU register (hopefully) - smaller code that way */
79 meminfo_writesize = meminfo.writesize;
80
81 if (mtdoffset & (meminfo_writesize - 1))
82 bb_error_msg_and_die("start address is not page aligned");
83
84 filebuf = xmalloc(meminfo_writesize);
85
86 blockstart = mtdoffset & ~(meminfo.erasesize - 1);
87 if (blockstart != mtdoffset) {
88 unsigned tmp;
89 /* mtdoffset is in the middle of an erase block, verify that
90 * this block is OK. Advance mtdoffset only if this block is
91 * bad.
92 */
93 tmp = next_good_eraseblock(fd, &meminfo, blockstart);
94 if (tmp != blockstart) /* bad block(s), advance mtdoffset */
95 mtdoffset = tmp;
96 }
97
98 cnt = -1;
99 while (mtdoffset < meminfo.size) {
100 blockstart = mtdoffset & ~(meminfo.erasesize - 1);
101 if (blockstart == mtdoffset) {
102 /* starting a new eraseblock */
103 mtdoffset = next_good_eraseblock(fd, &meminfo, blockstart);
104 printf("Writing at 0x%08x\n", mtdoffset);
105 }
106 /* get some more data from input */
107 cnt = full_read(STDIN_FILENO, filebuf, meminfo_writesize);
108 if (cnt == 0) {
109 /* even with -p, we do not pad past the end of input
110 * (-p only zero-pads last incomplete page)
111 */
112 break;
113 }
114 if (cnt < meminfo_writesize) {
115 if (!(opts & OPT_p))
116 bb_error_msg_and_die("input size is not rounded up to page size, "
117 "use -p to zero pad");
118 /* zero pad to end of write block */
119 memset(filebuf + cnt, 0, meminfo_writesize - cnt);
120 }
121 xlseek(fd, mtdoffset, SEEK_SET);
122 xwrite(fd, filebuf, meminfo_writesize);
123 mtdoffset += meminfo_writesize;
124 if (cnt < meminfo_writesize)
125 break;
126 }
127
128 if (cnt != 0) {
129 /* We filled entire MTD, but did we reach EOF on input? */
130 if (full_read(STDIN_FILENO, filebuf, meminfo_writesize) != 0) {
131 /* no */
132 bb_error_msg_and_die("not enough space in MTD device");
133 }
134 }
135
136 if (ENABLE_FEATURE_CLEAN_UP) {
137 free(filebuf);
138 close(fd);
139 }
140
141 return EXIT_SUCCESS;
142}
diff --git a/miscutils/raidautorun.c b/miscutils/raidautorun.c
index 113e49ff2..bbfa8577c 100644
--- a/miscutils/raidautorun.c
+++ b/miscutils/raidautorun.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 2006 Bernhard Reutner-Fischer 5 * Copyright (C) 2006 Bernhard Reutner-Fischer
6 * 6 *
7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 * 8 *
9 */ 9 */
10 10
diff --git a/miscutils/readahead.c b/miscutils/readahead.c
index e7b75f12f..dd6de7c45 100644
--- a/miscutils/readahead.c
+++ b/miscutils/readahead.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Copyright (C) 2006 Michael Opdenacker <michael@free-electrons.com> 8 * Copyright (C) 2006 Michael Opdenacker <michael@free-electrons.com>
9 * 9 *
10 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 10 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
11 */ 11 */
12 12
13#include "libbb.h" 13#include "libbb.h"
diff --git a/miscutils/rfkill.c b/miscutils/rfkill.c
index 7d8ad1cfc..b150b2cae 100644
--- a/miscutils/rfkill.c
+++ b/miscutils/rfkill.c
@@ -4,7 +4,7 @@
4* 4*
5* Copyright (C) 2010 Malek Degachi <malek-degachi@laposte.net> 5* Copyright (C) 2010 Malek Degachi <malek-degachi@laposte.net>
6* 6*
7* Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 7* Licensed under GPLv2 or later, see file LICENSE in this source tree.
8*/ 8*/
9#include "libbb.h" 9#include "libbb.h"
10#include <linux/rfkill.h> 10#include <linux/rfkill.h>
diff --git a/miscutils/runlevel.c b/miscutils/runlevel.c
index 83b5a77d4..608e87fe1 100644
--- a/miscutils/runlevel.c
+++ b/miscutils/runlevel.c
@@ -7,7 +7,7 @@
7 * This file is part of the sysvinit suite, 7 * This file is part of the sysvinit suite,
8 * Copyright 1991-1997 Miquel van Smoorenburg. 8 * Copyright 1991-1997 Miquel van Smoorenburg.
9 * 9 *
10 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 10 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
11 * 11 *
12 * initially busyboxified by Bernhard Reutner-Fischer 12 * initially busyboxified by Bernhard Reutner-Fischer
13 */ 13 */
diff --git a/miscutils/rx.c b/miscutils/rx.c
index 4c5d5a19c..de785d53c 100644
--- a/miscutils/rx.c
+++ b/miscutils/rx.c
@@ -10,7 +10,7 @@
10 * 10 *
11 * Copyright (C) 2001 Hewlett-Packard Laboratories 11 * Copyright (C) 2001 Hewlett-Packard Laboratories
12 * 12 *
13 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 13 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
14 * 14 *
15 * This was originally written for blob and then adapted for busybox. 15 * This was originally written for blob and then adapted for busybox.
16 */ 16 */
diff --git a/miscutils/strings.c b/miscutils/strings.c
index b4c5854cf..40478de40 100644
--- a/miscutils/strings.c
+++ b/miscutils/strings.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright 2003 Tito Ragusa <farmatito@tiscali.it> 5 * Copyright 2003 Tito Ragusa <farmatito@tiscali.it>
6 * 6 *
7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9 9
10#include "libbb.h" 10#include "libbb.h"
diff --git a/miscutils/taskset.c b/miscutils/taskset.c
index 08198d5d4..389ef43e4 100644
--- a/miscutils/taskset.c
+++ b/miscutils/taskset.c
@@ -3,7 +3,7 @@
3 * taskset - retrieve or set a processes' CPU affinity 3 * taskset - retrieve or set a processes' CPU affinity
4 * Copyright (c) 2006 Bernhard Reutner-Fischer 4 * Copyright (c) 2006 Bernhard Reutner-Fischer
5 * 5 *
6 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 6 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
7 */ 7 */
8 8
9#include <sched.h> 9#include <sched.h>
diff --git a/miscutils/time.c b/miscutils/time.c
index 9facc3657..6b1c3c42c 100644
--- a/miscutils/time.c
+++ b/miscutils/time.c
@@ -2,7 +2,7 @@
2/* 'time' utility to display resource usage of processes. 2/* 'time' utility to display resource usage of processes.
3 Copyright (C) 1990, 91, 92, 93, 96 Free Software Foundation, Inc. 3 Copyright (C) 1990, 91, 92, 93, 96 Free Software Foundation, Inc.
4 4
5 Licensed under GPL version 2, see file LICENSE in this tarball for details. 5 Licensed under GPLv2, see file LICENSE in this source tree.
6*/ 6*/
7/* Originally written by David Keppel <pardo@cs.washington.edu>. 7/* Originally written by David Keppel <pardo@cs.washington.edu>.
8 Heavily modified by David MacKenzie <djm@gnu.ai.mit.edu>. 8 Heavily modified by David MacKenzie <djm@gnu.ai.mit.edu>.
diff --git a/miscutils/ttysize.c b/miscutils/ttysize.c
index ca9a2ec8d..f93a506a2 100644
--- a/miscutils/ttysize.c
+++ b/miscutils/ttysize.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Copyright (C) 2007 by Denys Vlasenko <vda.linux@googlemail.com> 8 * Copyright (C) 2007 by Denys Vlasenko <vda.linux@googlemail.com>
9 * 9 *
10 * Licensed under the GPL v2, see the file LICENSE in this tarball. 10 * Licensed under GPLv2, see file LICENSE in this source tree.
11 */ 11 */
12#include "libbb.h" 12#include "libbb.h"
13 13
diff --git a/miscutils/ubi_attach_detach.c b/miscutils/ubi_attach_detach.c
index 0d63a10d5..18ffd4df2 100644
--- a/miscutils/ubi_attach_detach.c
+++ b/miscutils/ubi_attach_detach.c
@@ -1,6 +1,6 @@
1/* Ported to busybox from mtd-utils. 1/* Ported to busybox from mtd-utils.
2 * 2 *
3 * Licensed under GPLv2, see file LICENSE in this tarball for details. 3 * Licensed under GPLv2, see file LICENSE in this source tree.
4 */ 4 */
5 5
6//applet:IF_UBIATTACH(APPLET_ODDNAME(ubiattach, ubi_attach_detach, _BB_DIR_USR_SBIN, _BB_SUID_DROP, ubiattach)) 6//applet:IF_UBIATTACH(APPLET_ODDNAME(ubiattach, ubi_attach_detach, _BB_DIR_USR_SBIN, _BB_SUID_DROP, ubiattach))
@@ -63,9 +63,9 @@ int ubi_attach_detach_main(int argc UNUSED_PARAM, char **argv)
63 ubi_ctrl = argv[optind]; 63 ubi_ctrl = argv[optind];
64 64
65 fd = xopen(ubi_ctrl, O_RDWR); 65 fd = xopen(ubi_ctrl, O_RDWR);
66 //fstat(fd, &st); 66 //xfstat(fd, &st, ubi_ctrl);
67 //if (!S_ISCHR(st.st_mode)) 67 //if (!S_ISCHR(st.st_mode))
68 // bb_error_msg_and_die("'%s' is not a char device", ubi_ctrl); 68 // bb_error_msg_and_die("%s: not a char device", ubi_ctrl);
69 69
70 if (do_attach) { 70 if (do_attach) {
71 if (!(opts & OPTION_M)) 71 if (!(opts & OPTION_M))
diff --git a/miscutils/wall.c b/miscutils/wall.c
index 2dbab60b4..eecfc166b 100644
--- a/miscutils/wall.c
+++ b/miscutils/wall.c
@@ -3,7 +3,7 @@
3 * wall - write a message to all logged-in users 3 * wall - write a message to all logged-in users
4 * Copyright (c) 2009 Bernhard Reutner-Fischer 4 * Copyright (c) 2009 Bernhard Reutner-Fischer
5 * 5 *
6 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 6 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
7 */ 7 */
8 8
9#include "libbb.h" 9#include "libbb.h"
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c
index 8e961f0c1..332539658 100644
--- a/miscutils/watchdog.c
+++ b/miscutils/watchdog.c
@@ -6,7 +6,7 @@
6 * Copyright (C) 2006 Bernhard Reutner-Fischer <busybox@busybox.net> 6 * Copyright (C) 2006 Bernhard Reutner-Fischer <busybox@busybox.net>
7 * Copyright (C) 2008 Darius Augulis <augulis.darius@gmail.com> 7 * Copyright (C) 2008 Darius Augulis <augulis.darius@gmail.com>
8 * 8 *
9 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 9 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
10 */ 10 */
11 11
12#include "libbb.h" 12#include "libbb.h"