aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2016-02-22 10:00:45 +0000
committerRon Yorston <rmy@pobox.com>2016-02-22 10:00:45 +0000
commit371c20c008254a36e7157df6c13dc2e4cf87d6fd (patch)
treea214c03f6617dffa60df2192b312a46c93b7c19f /miscutils
parentab879a41ab674129ef1593cda181cc8b64d0dadf (diff)
parent3a5cc989025eefe03fda0552b253a4a8f015a761 (diff)
downloadbusybox-w32-371c20c008254a36e7157df6c13dc2e4cf87d6fd.tar.gz
busybox-w32-371c20c008254a36e7157df6c13dc2e4cf87d6fd.tar.bz2
busybox-w32-371c20c008254a36e7157df6c13dc2e4cf87d6fd.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/nandwrite.c22
-rw-r--r--miscutils/setsid.c19
2 files changed, 27 insertions, 14 deletions
diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c
index 247fc72f4..c95cbb21e 100644
--- a/miscutils/nandwrite.c
+++ b/miscutils/nandwrite.c
@@ -29,16 +29,18 @@
29//kbuild:lib-$(CONFIG_NANDDUMP) += nandwrite.o 29//kbuild:lib-$(CONFIG_NANDDUMP) += nandwrite.o
30 30
31//usage:#define nandwrite_trivial_usage 31//usage:#define nandwrite_trivial_usage
32//usage: "[-p] [-s ADDR] MTD_DEVICE [FILE]" 32//usage: "[-np] [-s ADDR] MTD_DEVICE [FILE]"
33//usage:#define nandwrite_full_usage "\n\n" 33//usage:#define nandwrite_full_usage "\n\n"
34//usage: "Write to MTD_DEVICE\n" 34//usage: "Write to MTD_DEVICE\n"
35//usage: "\n -n Write without ecc"
35//usage: "\n -p Pad to page size" 36//usage: "\n -p Pad to page size"
36//usage: "\n -s ADDR Start address" 37//usage: "\n -s ADDR Start address"
37 38
38//usage:#define nanddump_trivial_usage 39//usage:#define nanddump_trivial_usage
39//usage: "[-o]" IF_LONG_OPTS(" [--bb=padbad|skipbad]") " [-s ADDR] [-l LEN] [-f FILE] MTD_DEVICE" 40//usage: "[-no]" IF_LONG_OPTS(" [--bb=padbad|skipbad]") " [-s ADDR] [-l LEN] [-f FILE] MTD_DEVICE"
40//usage:#define nanddump_full_usage "\n\n" 41//usage:#define nanddump_full_usage "\n\n"
41//usage: "Dump MTD_DEVICE\n" 42//usage: "Dump MTD_DEVICE\n"
43//usage: "\n -n Read without ecc"
42//usage: "\n -o Dump oob data" 44//usage: "\n -o Dump oob data"
43//usage: "\n -s ADDR Start address" 45//usage: "\n -s ADDR Start address"
44//usage: "\n -l LEN Length" 46//usage: "\n -l LEN Length"
@@ -57,10 +59,11 @@
57 59
58#define OPT_p (1 << 0) /* nandwrite only */ 60#define OPT_p (1 << 0) /* nandwrite only */
59#define OPT_o (1 << 0) /* nanddump only */ 61#define OPT_o (1 << 0) /* nanddump only */
60#define OPT_s (1 << 1) 62#define OPT_n (1 << 1)
61#define OPT_f (1 << 2) 63#define OPT_s (1 << 2)
62#define OPT_l (1 << 3) 64#define OPT_f (1 << 3)
63#define OPT_bb (1 << 4) /* must be the last one in the list */ 65#define OPT_l (1 << 4)
66#define OPT_bb (1 << 5) /* must be the last one in the list */
64 67
65#define BB_PADBAD (1 << 0) 68#define BB_PADBAD (1 << 0)
66#define BB_SKIPBAD (1 << 1) 69#define BB_SKIPBAD (1 << 1)
@@ -125,10 +128,10 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv)
125 applet_long_options = 128 applet_long_options =
126 "bb\0" Required_argument "\xff"; /* no short equivalent */ 129 "bb\0" Required_argument "\xff"; /* no short equivalent */
127#endif 130#endif
128 opts = getopt32(argv, "os:f:l:", &opt_s, &opt_f, &opt_l, &opt_bb); 131 opts = getopt32(argv, "ons:f:l:", &opt_s, &opt_f, &opt_l, &opt_bb);
129 } else { /* nandwrite */ 132 } else { /* nandwrite */
130 opt_complementary = "-1:?2"; 133 opt_complementary = "-1:?2";
131 opts = getopt32(argv, "ps:", &opt_s); 134 opts = getopt32(argv, "pns:", &opt_s);
132 } 135 }
133 argv += optind; 136 argv += optind;
134 137
@@ -144,6 +147,9 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv)
144 fd = xopen(argv[0], IS_NANDWRITE ? O_RDWR : O_RDONLY); 147 fd = xopen(argv[0], IS_NANDWRITE ? O_RDWR : O_RDONLY);
145 xioctl(fd, MEMGETINFO, &meminfo); 148 xioctl(fd, MEMGETINFO, &meminfo);
146 149
150 if (opts & OPT_n)
151 xioctl(fd, MTDFILEMODE, (void *)MTD_FILE_MODE_RAW);
152
147 mtdoffset = xstrtou(opt_s, 0); 153 mtdoffset = xstrtou(opt_s, 0);
148 if (IS_NANDDUMP && (opts & OPT_l)) { 154 if (IS_NANDDUMP && (opts & OPT_l)) {
149 unsigned length = xstrtou(opt_l, 0); 155 unsigned length = xstrtou(opt_l, 0);
diff --git a/miscutils/setsid.c b/miscutils/setsid.c
index 637081b6c..1b27377b2 100644
--- a/miscutils/setsid.c
+++ b/miscutils/setsid.c
@@ -15,19 +15,22 @@
15 */ 15 */
16 16
17//usage:#define setsid_trivial_usage 17//usage:#define setsid_trivial_usage
18//usage: "PROG ARGS" 18//usage: "[-c] PROG ARGS"
19//usage:#define setsid_full_usage "\n\n" 19//usage:#define setsid_full_usage "\n\n"
20//usage: "Run PROG in a new session. PROG will have no controlling terminal\n" 20//usage: "Run PROG in a new session. PROG will have no controlling terminal\n"
21//usage: "and will not be affected by keyboard signals (Ctrl-C etc).\n" 21//usage: "and will not be affected by keyboard signals (^C etc).\n"
22//usage: "See setsid(2) for details." 22//usage: "\n -c Set controlling terminal to stdin"
23 23
24#include "libbb.h" 24#include "libbb.h"
25 25
26int setsid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 26int setsid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
27int setsid_main(int argc UNUSED_PARAM, char **argv) 27int setsid_main(int argc UNUSED_PARAM, char **argv)
28{ 28{
29 if (!argv[1]) 29 unsigned opt;
30 bb_show_usage(); 30
31 opt_complementary = "-1"; /* at least one arg */
32 opt = getopt32(argv, "c");
33 argv += optind;
31 34
32 /* setsid() is allowed only when we are not a process group leader. 35 /* setsid() is allowed only when we are not a process group leader.
33 * Otherwise our PID serves as PGID of some existing process group 36 * Otherwise our PID serves as PGID of some existing process group
@@ -61,6 +64,10 @@ int setsid_main(int argc UNUSED_PARAM, char **argv)
61 setsid(); 64 setsid();
62 } 65 }
63 66
64 argv++; 67 if (opt) {
68 /* -c: set (with stealing) controlling tty */
69 ioctl(0, TIOCSCTTY, 1);
70 }
71
65 BB_EXECVP_or_die(argv); 72 BB_EXECVP_or_die(argv);
66} 73}