svn commit: trunk/busybox: console-tools e2fsprogs include libbb lo etc...

vda at busybox.net vda at busybox.net
Sun Mar 25 23:21:06 UTC 2007


Author: vda
Date: 2007-03-25 16:21:05 -0700 (Sun, 25 Mar 2007)
New Revision: 18237

Log:
add NOMMU fixme's; move move_fd from runit_lib to libbb; nuke fd_copy


Modified:
   trunk/busybox/console-tools/openvt.c
   trunk/busybox/e2fsprogs/fsck.c
   trunk/busybox/include/libbb.h
   trunk/busybox/libbb/xfuncs.c
   trunk/busybox/loginutils/login.c
   trunk/busybox/networking/zcip.c
   trunk/busybox/runit/runit_lib.c
   trunk/busybox/runit/runit_lib.h
   trunk/busybox/runit/runsv.c
   trunk/busybox/runit/runsvdir.c
   trunk/busybox/runit/svlogd.c


Changeset:
Modified: trunk/busybox/console-tools/openvt.c
===================================================================
--- trunk/busybox/console-tools/openvt.c	2007-03-25 21:50:18 UTC (rev 18236)
+++ trunk/busybox/console-tools/openvt.c	2007-03-25 23:21:05 UTC (rev 18237)
@@ -22,8 +22,9 @@
 		bb_show_usage();
 	}
 	/* check for illegal vt number: < 1 or > 63 */
-	sprintf(vtname, VC_FORMAT, (int)xatoul_range(argv[1], 1, 63));
+	sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[1], 1, 63));
 
+//FIXME NOMMU
 	if (fork() == 0) {
 		/* child */
 		/* leave current vt (controlling tty) */

Modified: trunk/busybox/e2fsprogs/fsck.c
===================================================================
--- trunk/busybox/e2fsprogs/fsck.c	2007-03-25 21:50:18 UTC (rev 18236)
+++ trunk/busybox/e2fsprogs/fsck.c	2007-03-25 23:21:05 UTC (rev 18237)
@@ -667,7 +667,8 @@
 	/* Fork and execute the correct program. */
 	pid = -1;
 	if (!noexecute) {
-		pid = fork(); /* TODO: NOMMU friendly way (vfork)? */
+/* TODO: NOMMU friendly way (vfork)? */
+		pid = fork();
 		if (pid < 0)
 			bb_perror_msg_and_die("fork");
 		if (pid == 0) {

Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2007-03-25 21:50:18 UTC (rev 18236)
+++ trunk/busybox/include/libbb.h	2007-03-25 23:21:05 UTC (rev 18237)
@@ -250,10 +250,12 @@
 /* TODO: sometimes modifies its parameter, which
  * makes it rather inconvenient at times: */
 extern char *bb_get_last_path_component(char *path);
-extern int ndelay_on(int fd);
-extern int ndelay_off(int fd);
 
+int ndelay_on(int fd);
+int ndelay_off(int fd);
+void xmove_fd(int, int);
 
+
 extern DIR *xopendir(const char *path);
 extern DIR *warn_opendir(const char *path);
 
@@ -616,6 +618,8 @@
 extern void print_login_issue(const char *issue_file, const char *tty);
 extern void print_login_prompt(void);
 #ifdef BB_NOMMU
+extern pid_t BUG_fork_is_unavailable_on_nommu(void);
+#define fork() BUG_fork_is_unavailable_on_nommu()
 extern void vfork_daemon_rexec(int nochdir, int noclose, char **argv);
 extern smallint re_execed;
 #endif

Modified: trunk/busybox/libbb/xfuncs.c
===================================================================
--- trunk/busybox/libbb/xfuncs.c	2007-03-25 21:50:18 UTC (rev 18236)
+++ trunk/busybox/libbb/xfuncs.c	2007-03-25 23:21:05 UTC (rev 18237)
@@ -133,6 +133,16 @@
 	return fcntl(fd,F_SETFL,fcntl(fd,F_GETFL,0) & ~O_NONBLOCK);
 }
 
+// "Renumber" opened fd
+void xmove_fd(int from, int to)
+{
+	if (from == to)
+		return;
+	if (dup2(from, to) != to)
+		bb_perror_msg_and_die("cannot duplicate file descriptor");
+	close(from);
+}
+
 // Die with an error message if we can't write the entire buffer.
 void xwrite(int fd, const void *buf, size_t count)
 {

Modified: trunk/busybox/loginutils/login.c
===================================================================
--- trunk/busybox/loginutils/login.c	2007-03-25 21:50:18 UTC (rev 18236)
+++ trunk/busybox/loginutils/login.c	2007-03-25 23:21:05 UTC (rev 18237)
@@ -337,7 +337,7 @@
 	fchown(0, pw->pw_uid, pw->pw_gid);
 	fchmod(0, 0600);
 
-	/* TODO: be nommu-friendly, use spawn? */
+/* TODO: be nommu-friendly, use spawn? */
 	if (ENABLE_LOGIN_SCRIPTS) {
 		char *script = getenv("LOGIN_PRE_SUID_SCRIPT");
 		if (script) {

Modified: trunk/busybox/networking/zcip.c
===================================================================
--- trunk/busybox/networking/zcip.c	2007-03-25 21:50:18 UTC (rev 18236)
+++ trunk/busybox/networking/zcip.c	2007-03-25 23:21:05 UTC (rev 18237)
@@ -272,6 +272,7 @@
 	// daemonize now; don't delay system startup
 	if (!FOREGROUND) {
 		/* bb_daemonize(); - bad, will close fd! */
+//NOMMU
 		xdaemon(0, 0);
 		bb_info_msg("start, interface %s", intf);
 	}

Modified: trunk/busybox/runit/runit_lib.c
===================================================================
--- trunk/busybox/runit/runit_lib.c	2007-03-25 21:50:18 UTC (rev 18236)
+++ trunk/busybox/runit/runit_lib.c	2007-03-25 23:21:05 UTC (rev 18237)
@@ -61,34 +61,6 @@
 }
 
 
-/*** fd_copy.c ***/
-
-int fd_copy(int to,int from)
-{
-	if (to == from)
-		return 0;
-	if (fcntl(from,F_GETFL,0) == -1)
-		return -1;
-	close(to);
-	if (fcntl(from,F_DUPFD,to) == -1)
-		return -1;
-	return 0;
-}
-
-
-/*** fd_move.c ***/
-
-int fd_move(int to,int from)
-{
-	if (to == from)
-		return 0;
-	if (fd_copy(to,from) == -1)
-		return -1;
-	close(from);
-	return 0;
-}
-
-
 /*** fmt_ptime.c ***/
 
 void fmt_ptime30nul(char *s, struct taia *ta) {

Modified: trunk/busybox/runit/runit_lib.h
===================================================================
--- trunk/busybox/runit/runit_lib.h	2007-03-25 21:50:18 UTC (rev 18236)
+++ trunk/busybox/runit/runit_lib.h	2007-03-25 23:21:05 UTC (rev 18237)
@@ -40,12 +40,6 @@
 #define direntry struct dirent
 
 
-/*** fd.h ***/
-
-extern int fd_copy(int,int);
-extern int fd_move(int,int);
-
-
 /*** tai.h ***/
 
 struct tai {

Modified: trunk/busybox/runit/runsv.c
===================================================================
--- trunk/busybox/runit/runsv.c	2007-03-25 21:50:18 UTC (rev 18236)
+++ trunk/busybox/runit/runsv.c	2007-03-25 23:21:05 UTC (rev 18237)
@@ -251,7 +251,7 @@
 				return 0;
 			}
 			if (!pid) {
-				if (haslog && fd_copy(1, logpipe[1]) == -1)
+				if (haslog && dup2(logpipe[1], 1) == -1)
 					warn_cannot("setup stdout for control/?");
 				prog[0] = a;
 				prog[1] = NULL;
@@ -312,13 +312,13 @@
 		/* child */
 		if (haslog) {
 			if (s->islog) {
-				if (fd_copy(0, logpipe[0]) == -1)
+				if (dup2(logpipe[0], 0) == -1)
 					fatal_cannot("setup filedescriptor for ./log/run");
 				close(logpipe[1]);
 				if (chdir("./log") == -1)
 					fatal_cannot("change directory to ./log");
 			} else {
-				if (fd_copy(1, logpipe[1]) == -1)
+				if (dup2(logpipe[1], 1) == -1)
 					fatal_cannot("setup filedescriptor for ./run");
 				close(logpipe[0]);
 			}

Modified: trunk/busybox/runit/runsvdir.c
===================================================================
--- trunk/busybox/runit/runsvdir.c	2007-03-25 21:50:18 UTC (rev 18236)
+++ trunk/busybox/runit/runsvdir.c	2007-03-25 23:21:05 UTC (rev 18237)
@@ -191,7 +191,7 @@
 	coe(logpipe[0]);
 	ndelay_on(logpipe[0]);
 	ndelay_on(logpipe[1]);
-	if (fd_copy(2, logpipe[1]) == -1) {
+	if (dup2(logpipe[1], 2) == -1) {
 		warnx("cannot set filedescriptor for log");
 		return -1;
 	}

Modified: trunk/busybox/runit/svlogd.c
===================================================================
--- trunk/busybox/runit/svlogd.c	2007-03-25 21:50:18 UTC (rev 18236)
+++ trunk/busybox/runit/svlogd.c	2007-03-25 23:21:05 UTC (rev 18237)
@@ -153,12 +153,10 @@
 		if (verbose)
 			bb_error_msg(INFO"processing: %s/%s", ld->name, ld->fnsave);
 		fd = xopen(ld->fnsave, O_RDONLY|O_NDELAY);
-		if (fd_move(0, fd) == -1)
-			bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
+		xmove_fd(fd, 0);
 		ld->fnsave[26] = 't';
 		fd = xopen(ld->fnsave, O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT);
-		if (fd_move(1, fd) == -1)
-			bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
+		xmove_fd(fd, 1);
 		fd = open_read("state");
 		if (fd == -1) {
 			if (errno != ENOENT)
@@ -166,17 +164,15 @@
 			close(xopen("state", O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT));
 			fd = xopen("state", O_RDONLY|O_NDELAY);
 		}
-		if (fd_move(4, fd) == -1)
-			bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
+		xmove_fd(fd, 4);
 		fd = xopen("newstate", O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT);
-		if (fd_move(5, fd) == -1)
-			bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
+		xmove_fd(fd, 5);
 
 // getenv("SHELL")?
 		prog[0] = (char*)"sh";
 		prog[1] = (char*)"-c";
 		prog[2] = ld->processor;
-		prog[3] = '\0';
+		prog[3] = NULL;
 		execve("/bin/sh", prog, environ);
 		bb_perror_msg_and_die(FATAL"cannot %s processor %s", "run", ld->name);
 	}




More information about the busybox-cvs mailing list