aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-05-25 04:15:37 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-05-25 04:15:37 +0200
commitbf2af9acb28ed6d8bbe351d669daaa140d0239f0 (patch)
tree3adba401caf5c25406f89ebe053a0d9dbb043b54
parent4f26c97b9a2fdf6d967eafa06c67d04e432840a1 (diff)
downloadbusybox-w32-bf2af9acb28ed6d8bbe351d669daaa140d0239f0.tar.gz
busybox-w32-bf2af9acb28ed6d8bbe351d669daaa140d0239f0.tar.bz2
busybox-w32-bf2af9acb28ed6d8bbe351d669daaa140d0239f0.zip
flash_lock, flash_unlock: new applets
By Thierry Reding (thierry.reding AT avionic-design.de) Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--include/applets.h3
-rw-r--r--include/usage.h11
-rw-r--r--include/xatonum.h4
-rw-r--r--libbb/xatonum_template.c5
-rw-r--r--loginutils/addgroup.c2
-rw-r--r--miscutils/Config.in14
-rw-r--r--miscutils/Kbuild4
-rw-r--r--miscutils/flash_lock_unlock.c69
-rw-r--r--modutils/modprobe-small.c2
-rw-r--r--networking/tc.c4
10 files changed, 112 insertions, 6 deletions
diff --git a/include/applets.h b/include/applets.h
index 7838757f5..5fbb3461e 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -155,8 +155,9 @@ IF_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_NEVER))
155IF_FEATURE_GREP_FGREP_ALIAS(APPLET_ODDNAME(fgrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER, fgrep)) 155IF_FEATURE_GREP_FGREP_ALIAS(APPLET_ODDNAME(fgrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER, fgrep))
156IF_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_NEVER, find)) 156IF_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_NEVER, find))
157IF_FINDFS(APPLET(findfs, _BB_DIR_SBIN, _BB_SUID_MAYBE)) 157IF_FINDFS(APPLET(findfs, _BB_DIR_SBIN, _BB_SUID_MAYBE))
158//IF_FLASH_ERASEALL(APPLET_ODDNAME(flash_eraseall, flash_eraseall, _BB_DIR_USR_SBIN, _BB_SUID_NEVER, flash_eraseall))
159IF_FLASH_ERASEALL(APPLET(flash_eraseall, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) 158IF_FLASH_ERASEALL(APPLET(flash_eraseall, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
159IF_FLASH_LOCK(APPLET_ODDNAME(flash_lock, flash_lock_unlock, _BB_DIR_USR_SBIN, _BB_SUID_NEVER, flash_lock))
160IF_FLASH_UNLOCK(APPLET_ODDNAME(flash_unlock, flash_lock_unlock, _BB_DIR_USR_SBIN, _BB_SUID_NEVER, flash_unlock))
160IF_FOLD(APPLET(fold, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 161IF_FOLD(APPLET(fold, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
161IF_FREE(APPLET(free, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 162IF_FREE(APPLET(free, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
162IF_FREERAMDISK(APPLET(freeramdisk, _BB_DIR_SBIN, _BB_SUID_NEVER)) 163IF_FREERAMDISK(APPLET(freeramdisk, _BB_DIR_SBIN, _BB_SUID_NEVER))
diff --git a/include/usage.h b/include/usage.h
index 1e327fb97..e6069259b 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -1248,6 +1248,17 @@
1248 "$ find / -name passwd\n" \ 1248 "$ find / -name passwd\n" \
1249 "/etc/passwd\n" 1249 "/etc/passwd\n"
1250 1250
1251#define flash_lock_trivial_usage \
1252 "MTD_DEVICE OFFSET SECTORS"
1253#define flash_lock_full_usage "\n\n" \
1254 "Lock part or all of an MTD device. If SECTORS is -1, then all sectors\n" \
1255 "will be locked, regardless of the value of OFFSET"
1256
1257#define flash_unlock_trivial_usage \
1258 "MTD_DEVICE"
1259#define flash_unlock_full_usage "\n\n" \
1260 "Unlock an MTD device"
1261
1251#define flash_eraseall_trivial_usage \ 1262#define flash_eraseall_trivial_usage \
1252 "[-jq] MTD_DEVICE" 1263 "[-jq] MTD_DEVICE"
1253#define flash_eraseall_full_usage "\n\n" \ 1264#define flash_eraseall_full_usage "\n\n" \
diff --git a/include/xatonum.h b/include/xatonum.h
index ee816efb4..864d2a383 100644
--- a/include/xatonum.h
+++ b/include/xatonum.h
@@ -22,6 +22,7 @@ unsigned type xato##UT##_sfx(const char *str, const struct suffix_mult *sfx) FAS
22unsigned type xato##UT(const char *str) FAST_FUNC; \ 22unsigned type xato##UT(const char *str) FAST_FUNC; \
23type xstrto##T##_range_sfx(const char *str, int b, type l, type u, const struct suffix_mult *sfx) FAST_FUNC; \ 23type xstrto##T##_range_sfx(const char *str, int b, type l, type u, const struct suffix_mult *sfx) FAST_FUNC; \
24type xstrto##T##_range(const char *str, int b, type l, type u) FAST_FUNC; \ 24type xstrto##T##_range(const char *str, int b, type l, type u) FAST_FUNC; \
25type xstrto##T(const char *str, int b) FAST_FUNC; \
25type xato##T##_range_sfx(const char *str, type l, type u, const struct suffix_mult *sfx) FAST_FUNC; \ 26type xato##T##_range_sfx(const char *str, type l, type u, const struct suffix_mult *sfx) FAST_FUNC; \
26type xato##T##_range(const char *str, type l, type u) FAST_FUNC; \ 27type xato##T##_range(const char *str, type l, type u) FAST_FUNC; \
27type xato##T##_sfx(const char *str, const struct suffix_mult *sfx) FAST_FUNC; \ 28type xato##T##_sfx(const char *str, const struct suffix_mult *sfx) FAST_FUNC; \
@@ -66,6 +67,9 @@ static ALWAYS_INLINE \
66narrow xstrto##N##_range(const char *str, int b, narrow l, narrow u) \ 67narrow xstrto##N##_range(const char *str, int b, narrow l, narrow u) \
67{ return xstrto##W##_range(str, b, l, u); } \ 68{ return xstrto##W##_range(str, b, l, u); } \
68static ALWAYS_INLINE \ 69static ALWAYS_INLINE \
70narrow xstrto##N(const char *str, int b) \
71{ return xstrto##W(str, b); } \
72static ALWAYS_INLINE \
69narrow xato##N##_range_sfx(const char *str, narrow l, narrow u, const struct suffix_mult *sfx) \ 73narrow xato##N##_range_sfx(const char *str, narrow l, narrow u, const struct suffix_mult *sfx) \
70{ return xato##W##_range_sfx(str, l, u, sfx); } \ 74{ return xato##W##_range_sfx(str, l, u, sfx); } \
71static ALWAYS_INLINE \ 75static ALWAYS_INLINE \
diff --git a/libbb/xatonum_template.c b/libbb/xatonum_template.c
index 5e0bb59e6..339a7d35f 100644
--- a/libbb/xatonum_template.c
+++ b/libbb/xatonum_template.c
@@ -157,6 +157,11 @@ type FAST_FUNC xstrto(_range)(const char *numstr, int base, type lower, type upp
157 return xstrto(_range_sfx)(numstr, base, lower, upper, NULL); 157 return xstrto(_range_sfx)(numstr, base, lower, upper, NULL);
158} 158}
159 159
160type FAST_FUNC xstrto()(const char *numstr, int base)
161{
162 return xstrto(_range_sfx)(numstr, base, XSTR_TYPE_MIN, XSTR_TYPE_MAX, NULL);
163}
164
160type FAST_FUNC xato(_range_sfx)(const char *numstr, 165type FAST_FUNC xato(_range_sfx)(const char *numstr,
161 type lower, 166 type lower,
162 type upper, 167 type upper,
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index dc60788e0..e49278efe 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -30,7 +30,7 @@ static void xgroup_study(struct group *g)
30 } 30 }
31 31
32 /* if a specific gid is requested, the --system switch and */ 32 /* if a specific gid is requested, the --system switch and */
33 /* min and max values are overriden, and the range of valid */ 33 /* min and max values are overridden, and the range of valid */
34 /* gid values is set to [0, INT_MAX] */ 34 /* gid values is set to [0, INT_MAX] */
35 if (!(option_mask32 & OPT_GID)) { 35 if (!(option_mask32 & OPT_GID)) {
36 if (option_mask32 & OPT_SYSTEM_ACCOUNT) { 36 if (option_mask32 & OPT_SYSTEM_ACCOUNT) {
diff --git a/miscutils/Config.in b/miscutils/Config.in
index 7feaf4a87..06ff51a7c 100644
--- a/miscutils/Config.in
+++ b/miscutils/Config.in
@@ -250,6 +250,20 @@ config FBSPLASH
250 "NN" (ASCII decimal number) - percentage to show on progress bar 250 "NN" (ASCII decimal number) - percentage to show on progress bar
251 "exit" - well you guessed it 251 "exit" - well you guessed it
252 252
253config FLASH_LOCK
254 bool "flash_lock"
255 default n
256 help
257 The flash_lock binary from mtd-utils as of git head 5ec0c10d0. This
258 utility locks part or all of the flash device.
259
260config FLASH_UNLOCK
261 bool "flash_unlock"
262 default n
263 help
264 The flash_unlock binary from mtd-utils as of git head 5ec0c10d0. This
265 utility unlocks part or all of the flash device.
266
253config FLASH_ERASEALL 267config FLASH_ERASEALL
254 bool "flash_eraseall" 268 bool "flash_eraseall"
255 default n 269 default n
diff --git a/miscutils/Kbuild b/miscutils/Kbuild
index 23d7d8d49..8ae8a488a 100644
--- a/miscutils/Kbuild
+++ b/miscutils/Kbuild
@@ -16,7 +16,9 @@ lib-$(CONFIG_DEVFSD) += devfsd.o
16lib-$(CONFIG_DEVMEM) += devmem.o 16lib-$(CONFIG_DEVMEM) += devmem.o
17lib-$(CONFIG_EJECT) += eject.o 17lib-$(CONFIG_EJECT) += eject.o
18lib-$(CONFIG_FBSPLASH) += fbsplash.o 18lib-$(CONFIG_FBSPLASH) += fbsplash.o
19lib-$(CONFIG_FLASH_ERASEALL) += flash_eraseall.o 19lib-$(CONFIG_FLASH_ERASEALL) += flash_eraseall.o
20lib-$(CONFIG_FLASH_LOCK) += flash_lock_unlock.o
21lib-$(CONFIG_FLASH_UNLOCK) += flash_lock_unlock.o
20lib-$(CONFIG_IONICE) += ionice.o 22lib-$(CONFIG_IONICE) += ionice.o
21lib-$(CONFIG_HDPARM) += hdparm.o 23lib-$(CONFIG_HDPARM) += hdparm.o
22lib-$(CONFIG_INOTIFYD) += inotifyd.o 24lib-$(CONFIG_INOTIFYD) += inotifyd.o
diff --git a/miscutils/flash_lock_unlock.c b/miscutils/flash_lock_unlock.c
new file mode 100644
index 000000000..f4e2f73b2
--- /dev/null
+++ b/miscutils/flash_lock_unlock.c
@@ -0,0 +1,69 @@
1/* vi: set sw=4 ts=4: */
2/* Ported to busybox from mtd-utils.
3 *
4 * Licensed under GPLv2, see file LICENSE in this tarball for details.
5 */
6#include "libbb.h"
7#include <mtd/mtd-user.h>
8
9int flash_lock_unlock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
10int flash_lock_unlock_main(int argc UNUSED_PARAM, char **argv)
11{
12 /* note: fields in these structs are 32-bits.
13 * apparently we can't win anything by using off_t
14 * or long long's for offset and/or sectors vars. */
15 struct mtd_info_user info;
16 struct erase_info_user lock;
17 unsigned long offset;
18 long sectors;
19 int fd;
20
21#define do_lock (ENABLE_FLASH_LOCK && (!ENABLE_FLASH_UNLOCK || (applet_name[6] == 'l')))
22
23 if (!argv[1])
24 bb_show_usage();
25
26 /* parse offset and number of sectors to lock */
27 offset = 0;
28 sectors = -1;
29 if (do_lock) {
30 if (!argv[2] || !argv[3])
31 bb_show_usage();
32 offset = xstrtoul(argv[2], 0);
33 sectors = xstrtol(argv[3], 0);
34 }
35
36 fd = xopen(argv[1], O_RDWR);
37
38 xioctl(fd, MEMGETINFO, &info);
39
40 lock.start = 0;
41 lock.length = info.size;
42 if (do_lock) {
43 unsigned long size = info.size - info.erasesize;
44 if (offset > size) {
45 bb_error_msg_and_die("%lx is beyond device size %lx\n",
46 offset, size);
47 }
48
49 if (sectors == -1) {
50 sectors = info.size / info.erasesize;
51 } else {
52// isn't this useless?
53 unsigned long num = info.size / info.erasesize;
54 if (sectors > num) {
55 bb_error_msg_and_die("%ld are too many "
56 "sectors, device only has "
57 "%ld\n", sectors, num);
58 }
59 }
60
61 lock.start = offset;
62 lock.length = sectors * info.erasesize;
63 xioctl(fd, MEMLOCK, &lock);
64 } else {
65 xioctl(fd, MEMUNLOCK, &lock);
66 }
67
68 return EXIT_SUCCESS;
69}
diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c
index 3fd7bf5ad..0d78033c3 100644
--- a/modutils/modprobe-small.c
+++ b/modutils/modprobe-small.c
@@ -656,7 +656,7 @@ depmod -[aA] [-n -e -v -q -V -r -u]
656 [-b basedirectory] [forced_version] 656 [-b basedirectory] [forced_version]
657depmod [-n -e -v -q -r -u] [-F kernelsyms] module1.ko module2.ko ... 657depmod [-n -e -v -q -r -u] [-F kernelsyms] module1.ko module2.ko ...
658If no arguments (except options) are given, "depmod -a" is assumed. 658If no arguments (except options) are given, "depmod -a" is assumed.
659depmod will output a dependancy list suitable for the modprobe utility. 659depmod will output a dependency list suitable for the modprobe utility.
660Options: 660Options:
661 -a, --all Probe all modules 661 -a, --all Probe all modules
662 -A, --quick Only does the work if there's a new module 662 -A, --quick Only does the work if there's a new module
diff --git a/networking/tc.c b/networking/tc.c
index 79cdd7c55..4e84faae9 100644
--- a/networking/tc.c
+++ b/networking/tc.c
@@ -322,7 +322,7 @@ static int print_qdisc(const struct sockaddr_nl *who UNUSED_PARAM,
322 int qqq = index_in_strings(_q_, name); 322 int qqq = index_in_strings(_q_, name);
323 if (qqq == 0) { /* pfifo_fast aka prio */ 323 if (qqq == 0) { /* pfifo_fast aka prio */
324 prio_print_opt(tb[TCA_OPTIONS]); 324 prio_print_opt(tb[TCA_OPTIONS]);
325 } else if (qqq == 1) { /* class based queueing */ 325 } else if (qqq == 1) { /* class based queuing */
326 cbq_print_opt(tb[TCA_OPTIONS]); 326 cbq_print_opt(tb[TCA_OPTIONS]);
327 } else 327 } else
328 bb_error_msg("unknown %s", name); 328 bb_error_msg("unknown %s", name);
@@ -388,7 +388,7 @@ static int print_class(const struct sockaddr_nl *who UNUSED_PARAM,
388 int qqq = index_in_strings(_q_, name); 388 int qqq = index_in_strings(_q_, name);
389 if (qqq == 0) { /* pfifo_fast aka prio */ 389 if (qqq == 0) { /* pfifo_fast aka prio */
390 /* nothing. */ /*prio_print_opt(tb[TCA_OPTIONS]);*/ 390 /* nothing. */ /*prio_print_opt(tb[TCA_OPTIONS]);*/
391 } else if (qqq == 1) { /* class based queueing */ 391 } else if (qqq == 1) { /* class based queuing */
392 /* cbq_print_copt() is identical to cbq_print_opt(). */ 392 /* cbq_print_copt() is identical to cbq_print_opt(). */
393 cbq_print_opt(tb[TCA_OPTIONS]); 393 cbq_print_opt(tb[TCA_OPTIONS]);
394 } else 394 } else