aboutsummaryrefslogtreecommitdiff
path: root/runit
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-03-25 23:21:05 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-03-25 23:21:05 +0000
commit377526f2266c1473e0c699408c59a269c839263a (patch)
tree71e46e02914c97077eaa77e12a726b29240b27f6 /runit
parent3c705200344cd09aa84e28e3c13e3595b3e764fb (diff)
downloadbusybox-w32-377526f2266c1473e0c699408c59a269c839263a.tar.gz
busybox-w32-377526f2266c1473e0c699408c59a269c839263a.tar.bz2
busybox-w32-377526f2266c1473e0c699408c59a269c839263a.zip
add NOMMU fixme's; move move_fd from runit_lib to libbb; nuke fd_copy
git-svn-id: svn://busybox.net/trunk/busybox@18237 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'runit')
-rw-r--r--runit/runit_lib.c28
-rw-r--r--runit/runit_lib.h6
-rw-r--r--runit/runsv.c6
-rw-r--r--runit/runsvdir.c2
-rw-r--r--runit/svlogd.c14
5 files changed, 9 insertions, 47 deletions
diff --git a/runit/runit_lib.c b/runit/runit_lib.c
index 0830314df..4762096b4 100644
--- a/runit/runit_lib.c
+++ b/runit/runit_lib.c
@@ -61,34 +61,6 @@ int coe(int fd)
61} 61}
62 62
63 63
64/*** fd_copy.c ***/
65
66int fd_copy(int to,int from)
67{
68 if (to == from)
69 return 0;
70 if (fcntl(from,F_GETFL,0) == -1)
71 return -1;
72 close(to);
73 if (fcntl(from,F_DUPFD,to) == -1)
74 return -1;
75 return 0;
76}
77
78
79/*** fd_move.c ***/
80
81int fd_move(int to,int from)
82{
83 if (to == from)
84 return 0;
85 if (fd_copy(to,from) == -1)
86 return -1;
87 close(from);
88 return 0;
89}
90
91
92/*** fmt_ptime.c ***/ 64/*** fmt_ptime.c ***/
93 65
94void fmt_ptime30nul(char *s, struct taia *ta) { 66void fmt_ptime30nul(char *s, struct taia *ta) {
diff --git a/runit/runit_lib.h b/runit/runit_lib.h
index 7b268e276..9fe4166bc 100644
--- a/runit/runit_lib.h
+++ b/runit/runit_lib.h
@@ -40,12 +40,6 @@ extern int coe(int);
40#define direntry struct dirent 40#define direntry struct dirent
41 41
42 42
43/*** fd.h ***/
44
45extern int fd_copy(int,int);
46extern int fd_move(int,int);
47
48
49/*** tai.h ***/ 43/*** tai.h ***/
50 44
51struct tai { 45struct tai {
diff --git a/runit/runsv.c b/runit/runsv.c
index cd806851e..018456847 100644
--- a/runit/runsv.c
+++ b/runit/runsv.c
@@ -251,7 +251,7 @@ static unsigned custom(struct svdir *s, char c)
251 return 0; 251 return 0;
252 } 252 }
253 if (!pid) { 253 if (!pid) {
254 if (haslog && fd_copy(1, logpipe[1]) == -1) 254 if (haslog && dup2(logpipe[1], 1) == -1)
255 warn_cannot("setup stdout for control/?"); 255 warn_cannot("setup stdout for control/?");
256 prog[0] = a; 256 prog[0] = a;
257 prog[1] = NULL; 257 prog[1] = NULL;
@@ -312,13 +312,13 @@ static void startservice(struct svdir *s)
312 /* child */ 312 /* child */
313 if (haslog) { 313 if (haslog) {
314 if (s->islog) { 314 if (s->islog) {
315 if (fd_copy(0, logpipe[0]) == -1) 315 if (dup2(logpipe[0], 0) == -1)
316 fatal_cannot("setup filedescriptor for ./log/run"); 316 fatal_cannot("setup filedescriptor for ./log/run");
317 close(logpipe[1]); 317 close(logpipe[1]);
318 if (chdir("./log") == -1) 318 if (chdir("./log") == -1)
319 fatal_cannot("change directory to ./log"); 319 fatal_cannot("change directory to ./log");
320 } else { 320 } else {
321 if (fd_copy(1, logpipe[1]) == -1) 321 if (dup2(logpipe[1], 1) == -1)
322 fatal_cannot("setup filedescriptor for ./run"); 322 fatal_cannot("setup filedescriptor for ./run");
323 close(logpipe[0]); 323 close(logpipe[0]);
324 } 324 }
diff --git a/runit/runsvdir.c b/runit/runsvdir.c
index 2f54cfef8..cce2c5d9c 100644
--- a/runit/runsvdir.c
+++ b/runit/runsvdir.c
@@ -191,7 +191,7 @@ static int setup_log(void)
191 coe(logpipe[0]); 191 coe(logpipe[0]);
192 ndelay_on(logpipe[0]); 192 ndelay_on(logpipe[0]);
193 ndelay_on(logpipe[1]); 193 ndelay_on(logpipe[1]);
194 if (fd_copy(2, logpipe[1]) == -1) { 194 if (dup2(logpipe[1], 2) == -1) {
195 warnx("cannot set filedescriptor for log"); 195 warnx("cannot set filedescriptor for log");
196 return -1; 196 return -1;
197 } 197 }
diff --git a/runit/svlogd.c b/runit/svlogd.c
index e454bace8..fb834a403 100644
--- a/runit/svlogd.c
+++ b/runit/svlogd.c
@@ -153,12 +153,10 @@ static unsigned processorstart(struct logdir *ld)
153 if (verbose) 153 if (verbose)
154 bb_error_msg(INFO"processing: %s/%s", ld->name, ld->fnsave); 154 bb_error_msg(INFO"processing: %s/%s", ld->name, ld->fnsave);
155 fd = xopen(ld->fnsave, O_RDONLY|O_NDELAY); 155 fd = xopen(ld->fnsave, O_RDONLY|O_NDELAY);
156 if (fd_move(0, fd) == -1) 156 xmove_fd(fd, 0);
157 bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
158 ld->fnsave[26] = 't'; 157 ld->fnsave[26] = 't';
159 fd = xopen(ld->fnsave, O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT); 158 fd = xopen(ld->fnsave, O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT);
160 if (fd_move(1, fd) == -1) 159 xmove_fd(fd, 1);
161 bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
162 fd = open_read("state"); 160 fd = open_read("state");
163 if (fd == -1) { 161 if (fd == -1) {
164 if (errno != ENOENT) 162 if (errno != ENOENT)
@@ -166,17 +164,15 @@ static unsigned processorstart(struct logdir *ld)
166 close(xopen("state", O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT)); 164 close(xopen("state", O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT));
167 fd = xopen("state", O_RDONLY|O_NDELAY); 165 fd = xopen("state", O_RDONLY|O_NDELAY);
168 } 166 }
169 if (fd_move(4, fd) == -1) 167 xmove_fd(fd, 4);
170 bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
171 fd = xopen("newstate", O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT); 168 fd = xopen("newstate", O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT);
172 if (fd_move(5, fd) == -1) 169 xmove_fd(fd, 5);
173 bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
174 170
175// getenv("SHELL")? 171// getenv("SHELL")?
176 prog[0] = (char*)"sh"; 172 prog[0] = (char*)"sh";
177 prog[1] = (char*)"-c"; 173 prog[1] = (char*)"-c";
178 prog[2] = ld->processor; 174 prog[2] = ld->processor;
179 prog[3] = '\0'; 175 prog[3] = NULL;
180 execve("/bin/sh", prog, environ); 176 execve("/bin/sh", prog, environ);
181 bb_perror_msg_and_die(FATAL"cannot %s processor %s", "run", ld->name); 177 bb_perror_msg_and_die(FATAL"cannot %s processor %s", "run", ld->name);
182 } 178 }