------------------------------------------------------------------------
r16211 | vda | 2006-09-23 22:10:03 -0400 (Sat, 23 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/loginutils/vlock.c

vlock: make message shorter

 ------------------------------------------------------------------------

Index: loginutils/vlock.c
===================================================================
--- loginutils/vlock.c	(revision 16210)
+++ loginutils/vlock.c	(revision 16211)
@@ -108,7 +108,7 @@
 	tcsetattr(STDIN_FILENO, TCSANOW, &term);
 
 	do {
-		printf("Virtual Console%s locked. Enter %s's password to unlock\n", (o_lock_all) ? "s" : "", pw->pw_name);
+		printf("Virtual Console%s locked by %s.\n", (o_lock_all) ? "s" : "", pw->pw_name);
 		if (correct_password(pw)) {
 			break;
 		}

 ------------------------------------------------------------------------
r16210 | vda | 2006-09-23 21:01:01 -0400 (Sat, 23 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/util-linux/mount.c

mount: fix breakage from recent changes (spurious -ro mounts)

 ------------------------------------------------------------------------

Index: util-linux/mount.c
===================================================================
--- util-linux/mount.c	(revision 16209)
+++ util-linux/mount.c	(revision 16210)
@@ -9,10 +9,6 @@
  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
-/* todo:
- * bb_getopt_ulflags();
- */
-
 /* Design notes: There is no spec for mount.  Remind me to write one.
 
    mount_main() calls singlemount() which calls mount_it_now().
@@ -1427,7 +1423,7 @@
 
 int mount_main(int argc, char **argv)
 {
-	enum { OPT_ALL = 0x8 };
+	enum { OPT_ALL = 0x10 };
 
 	char *cmdopts = xstrdup(""), *fstype=0, *storage_path=0;
 	char *opt_o;
@@ -1445,24 +1441,20 @@
 			append_mount_options(&cmdopts,argv[i]+2);
 		} else argv[j++] = argv[i];
 	}
+	argv[j] = 0;
 	argc = j;
 
 	// Parse remaining options
 
-	opt = bb_getopt_ulflags(argc, argv, "o:t:rwavnf", &opt_o, &fstype);
-	if (opt & 1) // -o
-		append_mount_options(&cmdopts, opt_o);
-	//if (opt & 1) // -t
-	if (opt & 2) // -r
-		append_mount_options(&cmdopts, "ro");
-	if (opt & 4) // -w
-		append_mount_options(&cmdopts, "rw");
-	//if (opt & 8) // -a
-	if (opt & 0x10) // -n
-		USE_FEATURE_MTAB_SUPPORT(useMtab = FALSE);
-	if (opt & 0x20) // -f
-		USE_FEATURE_MTAB_SUPPORT(fakeIt = FALSE);
-	//if (opt & 0x40) // ignore -v
+	opt = bb_getopt_ulflags(argc, argv, "o:t:rwanfv", &opt_o, &fstype);
+	if (opt & 0x1) append_mount_options(&cmdopts, opt_o); // -o
+	//if (opt & 0x2) // -t
+	if (opt & 0x4) append_mount_options(&cmdopts, "ro"); // -r
+	if (opt & 0x8) append_mount_options(&cmdopts, "rw"); // -w
+	//if (opt & 0x10) // -a
+	if (opt & 0x20) USE_FEATURE_MTAB_SUPPORT(useMtab = FALSE); // -n
+	if (opt & 0x40) USE_FEATURE_MTAB_SUPPORT(fakeIt = FALSE); // -f
+	//if (opt & 0x80) // -v: ignore
 	argv += optind;
 	argc -= optind;
 

 ------------------------------------------------------------------------
r16209 | landley | 2006-09-23 15:56:21 -0400 (Sat, 23 Sep 2006) | 3 lines
Changed paths:
   M /trunk/busybox/coreutils/uudecode.c

Another attempt at untangling the logic so the compiler can follow it and not
generate pointless warnings.

 ------------------------------------------------------------------------

Index: coreutils/uudecode.c
===================================================================
--- coreutils/uudecode.c	(revision 16208)
+++ coreutils/uudecode.c	(revision 16209)
@@ -142,41 +142,40 @@
 	/* Search for the start of the encoding */
 	while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL) {
 		int (*decode_fn_ptr)(FILE * src, FILE * dst);
-		char *line_ptr = NULL;
-
+		char *line_ptr;
+		FILE *dst_stream;
+		int mode;
+		int ret;
+		
 		if (strncmp(line, "begin-base64 ", 13) == 0) {
 			line_ptr = line + 13;
 			decode_fn_ptr = read_base64;
 		} else if (strncmp(line, "begin ", 6) == 0) {
 			line_ptr = line + 6;
 			decode_fn_ptr = read_stduu;
+		} else {
+			free(line);
+			continue;
 		}
 
-		if (line_ptr) {
-			FILE *dst_stream;
-			int mode;
-			int ret;
-
-			mode = strtoul(line_ptr, NULL, 8);
-			if (outname == NULL) {
-				outname = strchr(line_ptr, ' ');
-				if ((outname == NULL) || (*outname == '\0')) {
-					break;
-				}
-				outname++;
+		mode = strtoul(line_ptr, NULL, 8);
+		if (outname == NULL) {
+			outname = strchr(line_ptr, ' ');
+			if ((outname == NULL) || (*outname == '\0')) {
+				break;
 			}
-			if (strcmp(outname, "-") == 0) {
-				dst_stream = stdout;
-			} else {
-				dst_stream = xfopen(outname, "w");
-				chmod(outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO));
-			}
-			free(line);
-			ret = decode_fn_ptr(src_stream, dst_stream);
-			bb_fclose_nonstdin(src_stream);
-			return(ret);
+			outname++;
 		}
+		if (strcmp(outname, "-") == 0) {
+			dst_stream = stdout;
+		} else {
+			dst_stream = xfopen(outname, "w");
+			chmod(outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO));
+		}
 		free(line);
+		ret = decode_fn_ptr(src_stream, dst_stream);
+		bb_fclose_nonstdin(src_stream);
+		return(ret);
 	}
 	bb_error_msg_and_die("No `begin' line");
 }

 ------------------------------------------------------------------------
r16208 | vda | 2006-09-23 13:49:09 -0400 (Sat, 23 Sep 2006) | 3 lines
Changed paths:
   M /trunk/busybox/libbb/xconnect.c
   M /trunk/busybox/networking/wget.c

wget: fix bug where wget creates null file if there is no remote one.
add O_LARGEFILE support (not run tested :).

 ------------------------------------------------------------------------

Index: networking/wget.c
===================================================================
--- networking/wget.c	(revision 16207)
+++ networking/wget.c	(revision 16208)
@@ -9,7 +9,6 @@
 #include "busybox.h"
 #include 
 
-
 struct host_info {
 	char *host;
 	int port;
@@ -39,14 +38,6 @@
 static void progressmeter(int flag) {}
 #endif
 
-static void close_and_delete_outfile(FILE* output, char *fname_out, int do_continue)
-{
-	if (output != stdout && do_continue == 0) {
-		fclose(output);
-		unlink(fname_out);
-	}
-}
-
 /* Read NMEMB elements of SIZE bytes into PTR from STREAM.  Returns the
  * number of elements read, and a short count if an eof or non-interrupt
  * error is encountered.  */
@@ -62,21 +53,6 @@
 	return ret;
 }
 
-/* Write NMEMB elements of SIZE bytes from PTR to STREAM.  Returns the
- * number of elements written, and a short count if an eof or non-interrupt
- * error is encountered.  */
-static size_t safe_fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream)
-{
-	size_t ret = 0;
-
-	do {
-		clearerr(stream);
-		ret += fwrite((char *)ptr + (ret * size), size, nmemb - ret, stream);
-	} while (ret < nmemb && ferror(stream) && errno == EINTR);
-
-	return ret;
-}
-
 /* Read a line or SIZE - 1 bytes into S, whichever is less, from STREAM.
  * Returns S, or NULL if an eof or non-interrupt error is encountered.  */
 static char *safe_fgets(char *s, int size, FILE *stream)
@@ -91,11 +67,6 @@
 	return ret;
 }
 
-#define close_delete_and_die(s...) { \
-	close_and_delete_outfile(output, fname_out, do_continue); \
-	bb_error_msg_and_die(s); }
-
-
 #ifdef CONFIG_FEATURE_WGET_AUTHENTICATION
 /*
  *  Base64-encode character string and return the string.
@@ -138,7 +109,6 @@
 	char *proxy = 0;
 	char *dir_prefix=NULL;
 	char *s, buf[512];
-	struct stat sbuf;
 	char extra_headers[1024];
 	char *extra_headers_ptr = extra_headers;
 	int extra_headers_left = sizeof(extra_headers);
@@ -150,9 +120,9 @@
 	FILE *dfp = NULL;		/* socket to ftp server (data)	    */
 	char *fname_out = NULL;		/* where to direct output (-O)	    */
 	int do_continue = 0;		/* continue a prev transfer (-c)    */
-	long beg_range = 0L;		/*   range at which continue begins */
+	off64_t beg_range = 0;		/*   range at which continue begins */
 	int got_clen = 0;		/* got content-length: from server  */
-	FILE *output;			/* socket to web server		    */
+	int output_fd = -1;
 	int quiet_flag = FALSE;		/* Be verry, verry quiet...	    */
 	int use_proxy = 1;		/* Use proxies if env vars are set  */
 	char *proxy_flag = "on";	/* Use proxies if env vars are set  */
@@ -221,7 +191,7 @@
 #endif
 				bb_get_last_path_component(target.path);
 		}
-		if (fname_out == NULL || strlen(fname_out) < 1) {
+		if (!fname_out || !fname_out[0]) {
 			fname_out =
 #ifdef CONFIG_FEATURE_WGET_STATUSBAR
 				curfile =
@@ -238,29 +208,24 @@
 	if (do_continue && !fname_out)
 		bb_error_msg_and_die("cannot specify continue (-c) without a filename (-O)");
 
-
 	/*
-	 * Open the output file stream.
+	 * Determine where to start transfer.
 	 */
-	if (strcmp(fname_out, "-") == 0) {
-		output = stdout;
+	if (!strcmp(fname_out, "-")) {
+		output_fd = 1;
 		quiet_flag = TRUE;
-	} else {
-		output = xfopen(fname_out, (do_continue ? "a" : "w"));
+		do_continue = 0;
+	} else if (do_continue) {
+		output_fd = open(fname_out, O_WRONLY|O_LARGEFILE);
+		if (output_fd >= 0) {
+			beg_range = lseek64(output_fd, 0, SEEK_END);
+			if (beg_range == (off64_t)-1)
+				bb_perror_msg_and_die("lseek64");
+		}
+		/* File doesn't exist. We do not create file here yet.
+		   We are not sure it exists on remove side */
 	}
 
-	/*
-	 * Determine where to start transfer.
-	 */
-	if (do_continue) {
-		if (fstat(fileno(output), &sbuf) < 0)
-			bb_perror_msg_and_die("fstat");
-		if (sbuf.st_size > 0)
-			beg_range = sbuf.st_size;
-		else
-			do_continue = 0;
-	}
-
 	/* We want to do exactly _one_ DNS lookup, since some
 	 * sites (i.e. ftp.us.debian.org) use round-robin DNS
 	 * and we want to connect to only one IP... */
@@ -279,7 +244,7 @@
 			got_clen = chunked = 0;
 
 			if (!--try)
-				close_delete_and_die("too many redirections");
+				bb_error_msg_and_die("too many redirections");
 
 			/*
 			 * Open socket to http server
@@ -317,8 +282,8 @@
 			}
 #endif
 
-			if (do_continue)
-				fprintf(sfp, "Range: bytes=%ld-\r\n", beg_range);
+			if (beg_range)
+				fprintf(sfp, "Range: bytes=%lld-\r\n", (long long)beg_range);
 			if(extra_headers_left < sizeof(extra_headers))
 				fputs(extra_headers,sfp);
 			fprintf(sfp,"Connection: close\r\n\r\n");
@@ -328,7 +293,7 @@
 			*/
 read_response:
 			if (fgets(buf, sizeof(buf), sfp) == NULL)
-				close_delete_and_die("no response from server");
+				bb_error_msg_and_die("no response from server");
 
 			for (s = buf ; *s != '\0' && !isspace(*s) ; ++s)
 				;
@@ -340,9 +305,6 @@
 					while (gethdr(buf, sizeof(buf), sfp, &n) != NULL);
 					goto read_response;
 				case 200:
-					if (do_continue && output != stdout)
-						output = freopen(fname_out, "w", output);
-					do_continue = 0;
 					break;
 				case 300:	/* redirection */
 				case 301:
@@ -350,12 +312,12 @@
 				case 303:
 					break;
 				case 206:
-					if (do_continue)
+					if (beg_range)
 						break;
 					/*FALLTHRU*/
 				default:
 					chomp(buf);
-					close_delete_and_die("server returned error %d: %s", atoi(s), buf);
+					bb_error_msg_and_die("server returned error %d: %s", atoi(s), buf);
 			}
 
 			/*
@@ -365,7 +327,7 @@
 				if (strcasecmp(buf, "content-length") == 0) {
 					unsigned long value;
 					if (safe_strtoul(s, &value)) {
-						close_delete_and_die("content-length %s is garbage", s);
+						bb_error_msg_and_die("content-length %s is garbage", s);
 					}
 					filesize = value;
 					got_clen = 1;
@@ -375,7 +337,7 @@
 					if (strcasecmp(s, "chunked") == 0) {
 						chunked = got_clen = 1;
 					} else {
-						close_delete_and_die("server wants to do %s transfer encoding", s);
+						bb_error_msg_and_die("server wants to do %s transfer encoding", s);
 					}
 				}
 				if (strcasecmp(buf, "location") == 0) {
@@ -407,7 +369,7 @@
 
 		sfp = open_socket(&s_in);
 		if (ftpcmd(NULL, NULL, sfp, buf) != 220)
-			close_delete_and_die("%s", buf+4);
+			bb_error_msg_and_die("%s", buf+4);
 
 		/*
 		 * Splitting username:password pair,
@@ -424,7 +386,7 @@
 					break;
 				/* FALLTHRU (failed login) */
 			default:
-				close_delete_and_die("ftp login: %s", buf+4);
+				bb_error_msg_and_die("ftp login: %s", buf+4);
 		}
 
 		ftpcmd("TYPE I", NULL, sfp, buf);
@@ -435,7 +397,7 @@
 		if (ftpcmd("SIZE ", target.path, sfp, buf) == 213) {
 			unsigned long value;
 			if (safe_strtoul(buf+4, &value)) {
-				close_delete_and_die("SIZE value is garbage");
+				bb_error_msg_and_die("SIZE value is garbage");
 			}
 			filesize = value;
 			got_clen = 1;
@@ -445,7 +407,7 @@
 		 * Entering passive mode
 		 */
 		if (ftpcmd("PASV", NULL, sfp, buf) !=  227)
-			close_delete_and_die("PASV: %s", buf+4);
+			bb_error_msg_and_die("PASV: %s", buf+4);
 		s = strrchr(buf, ',');
 		*s = 0;
 		port = atoi(s+1);
@@ -454,18 +416,14 @@
 		s_in.sin_port = htons(port);
 		dfp = open_socket(&s_in);
 
-		if (do_continue) {
-			sprintf(buf, "REST %ld", beg_range);
-			if (ftpcmd(buf, NULL, sfp, buf) != 350) {
-				if (output != stdout)
-					output = freopen(fname_out, "w", output);
-				do_continue = 0;
-			} else
+		if (beg_range) {
+			sprintf(buf, "REST %lld", (long long)beg_range);
+			if (ftpcmd(buf, NULL, sfp, buf) == 350)
 				filesize -= beg_range;
 		}
 
 		if (ftpcmd("RETR ", target.path, sfp, buf) > 150)
-			close_delete_and_die("RETR: %s", buf+4);
+			bb_error_msg_and_die("RETR: %s", buf+4);
 	}
 
 
@@ -488,7 +446,9 @@
 			n = safe_fread(buf, 1, rdsz, dfp);
 			if (n <= 0)
 				break;
-			if (safe_fwrite(buf, 1, n, output) != n) {
+			if (output_fd < 0)
+				output_fd = xopen3(fname_out, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_LARGEFILE, 0666);
+			if (full_write(output_fd, buf, n) != n) {
 				bb_perror_msg_and_die(bb_msg_write_error);
 			}
 #ifdef CONFIG_FEATURE_WGET_STATUSBAR
@@ -526,7 +486,7 @@
 }
 
 
-void parse_url(char *url, struct host_info *h)
+static void parse_url(char *url, struct host_info *h)
 {
 	char *cp, *sp, *up, *pp;
 
@@ -581,7 +541,7 @@
 }
 
 
-FILE *open_socket(struct sockaddr_in *s_in)
+static FILE *open_socket(struct sockaddr_in *s_in)
 {
 	FILE *fp;
 
@@ -593,7 +553,7 @@
 }
 
 
-char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc)
+static char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc)
 {
 	char *s, *hdrval;
 	int c;
Index: libbb/xconnect.c
===================================================================
--- libbb/xconnect.c	(revision 16207)
+++ libbb/xconnect.c	(revision 16208)
@@ -55,7 +55,7 @@
 	if (connect(s, (struct sockaddr *)s_addr, sizeof(struct sockaddr_in)) < 0)
 	{
 		if (ENABLE_FEATURE_CLEAN_UP) close(s);
-		bb_perror_msg_and_die("Unable to connect to remote host (%s)",
+		bb_perror_msg_and_die("unable to connect to remote host (%s)",
 				inet_ntoa(s_addr->sin_addr));
 	}
 	return s;

 ------------------------------------------------------------------------
r16207 | vda | 2006-09-23 12:34:39 -0400 (Sat, 23 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/applets/applets.c

applets.c: fix indentation

 ------------------------------------------------------------------------

Index: applets/applets.c
===================================================================
--- applets/applets.c	(revision 16206)
+++ applets/applets.c	(revision 16207)
@@ -50,33 +50,33 @@
 /* applets [] is const, so we have to define this "override" structure */
 static struct BB_suid_config
 {
-  struct BB_applet *m_applet;
+	struct BB_applet *m_applet;
 
-  uid_t m_uid;
-  gid_t m_gid;
-  mode_t m_mode;
+	uid_t m_uid;
+	gid_t m_gid;
+	mode_t m_mode;
 
-  struct BB_suid_config *m_next;
+	struct BB_suid_config *m_next;
 } *suid_config;
 
 static int suid_cfg_readable;
 
 /* check if u is member of group g */
-static int ingroup (uid_t u, gid_t g)
+static int ingroup(uid_t u, gid_t g)
 {
-  struct group *grp = getgrgid (g);
+	struct group *grp = getgrgid(g);
 
-  if (grp) {
-	char **mem;
+	if (grp) {
+		char **mem;
 
-	for (mem = grp->gr_mem; *mem; mem++) {
-	  struct passwd *pwd = getpwnam (*mem);
+		for (mem = grp->gr_mem; *mem; mem++) {
+			struct passwd *pwd = getpwnam(*mem);
 
-	  if (pwd && (pwd->pw_uid == u))
-		return 1;
+			if (pwd && (pwd->pw_uid == u))
+				return 1;
+		}
 	}
-  }
-  return 0;
+	return 0;
 }
 
 /* This should probably be a libbb routine.  In that case,
@@ -320,58 +320,58 @@
 #ifdef CONFIG_FEATURE_SUID
 static void check_suid (struct BB_applet *applet)
 {
-  uid_t ruid = getuid ();               /* real [ug]id */
-  uid_t rgid = getgid ();
+	uid_t ruid = getuid ();               /* real [ug]id */
+	uid_t rgid = getgid ();
 
 #ifdef CONFIG_FEATURE_SUID_CONFIG
-  if (suid_cfg_readable) {
-	struct BB_suid_config *sct;
+	if (suid_cfg_readable) {
+		struct BB_suid_config *sct;
 
-	for (sct = suid_config; sct; sct = sct->m_next) {
-	  if (sct->m_applet == applet)
-		break;
-	}
-	if (sct) {
-	  mode_t m = sct->m_mode;
+		for (sct = suid_config; sct; sct = sct->m_next) {
+			if (sct->m_applet == applet)
+				break;
+		}
+		if (sct) {
+			mode_t m = sct->m_mode;
 
-	  if (sct->m_uid == ruid)       /* same uid */
-		m >>= 6;
-	  else if ((sct->m_gid == rgid) || ingroup (ruid, sct->m_gid))  /* same group / in group */
-		m >>= 3;
+			if (sct->m_uid == ruid)       /* same uid */
+				m >>= 6;
+			else if ((sct->m_gid == rgid) || ingroup (ruid, sct->m_gid))  /* same group / in group */
+				m >>= 3;
 
-	  if (!(m & S_IXOTH))           /* is x bit not set ? */
-		bb_error_msg_and_die ("You have no permission to run this applet!");
+			if (!(m & S_IXOTH))           /* is x bit not set ? */
+				bb_error_msg_and_die ("You have no permission to run this applet!");
 
-	  if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {     /* *both* have to be set for sgid */
-		xsetgid(sct->m_gid);
-	  } else xsetgid(rgid);                /* no sgid -> drop */
+			if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {     /* *both* have to be set for sgid */
+				xsetgid(sct->m_gid);
+			} else xsetgid(rgid);                /* no sgid -> drop */
 
-	  if (sct->m_mode & S_ISUID) xsetuid(sct->m_uid);
-	  else xsetuid(ruid);                  /* no suid -> drop */
+			if (sct->m_mode & S_ISUID) xsetuid(sct->m_uid);
+			else xsetuid(ruid);                  /* no suid -> drop */
+		} else {
+			/* default: drop all privileges */
+			xsetgid(rgid);
+			xsetuid(ruid);
+		}
+		return;
 	} else {
-		/* default: drop all privileges */
-	  xsetgid(rgid);
-	  xsetuid(ruid);
-	}
-	return;
-  } else {
 #ifndef CONFIG_FEATURE_SUID_CONFIG_QUIET
-	static int onetime = 0;
+		static int onetime = 0;
 
-	if (!onetime) {
-	  onetime = 1;
-	  fprintf (stderr, "Using fallback suid method\n");
+		if (!onetime) {
+			onetime = 1;
+			fprintf (stderr, "Using fallback suid method\n");
+		}
+#endif
 	}
 #endif
-  }
-#endif
 
-  if (applet->need_suid == _BB_SUID_ALWAYS) {
-	if (geteuid()) bb_error_msg_and_die("Applet requires root privileges!");
-  } else if (applet->need_suid == _BB_SUID_NEVER) {
-	xsetgid(rgid);                          /* drop all privileges */
-	xsetuid(ruid);
-  }
+	if (applet->need_suid == _BB_SUID_ALWAYS) {
+		if (geteuid()) bb_error_msg_and_die("Applet requires root privileges!");
+	} else if (applet->need_suid == _BB_SUID_NEVER) {
+		xsetgid(rgid);                          /* drop all privileges */
+		xsetuid(ruid);
+	}
 }
 #else
 #define check_suid(x)
@@ -426,7 +426,7 @@
 #define unpack_usage_messages() usage_messages
 #endif /* ENABLE_FEATURE_COMPRESS_USAGE */
 
-void bb_show_usage (void)
+void bb_show_usage(void)
 {
 	if (ENABLE_SHOW_USAGE) {
 		const char *format_string;
@@ -443,22 +443,22 @@
 			applet_using->name, usage_string);
 	}
 
-  exit (bb_default_error_retval);
+	exit (bb_default_error_retval);
 }
 
 static int applet_name_compare(const void *name, const void *vapplet)
 {
-  const struct BB_applet *applet = vapplet;
+	const struct BB_applet *applet = vapplet;
 
-  return strcmp(name, applet->name);
+	return strcmp(name, applet->name);
 }
 
 extern const size_t NUM_APPLETS;
 
 struct BB_applet *find_applet_by_name(const char *name)
 {
-  return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
-				  applet_name_compare);
+	return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
+				applet_name_compare);
 }
 
 void run_applet_by_name(const char *name, int argc, char **argv)

 ------------------------------------------------------------------------
r16206 | vda | 2006-09-23 12:01:09 -0400 (Sat, 23 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/coreutils/printf.c
   M /trunk/busybox/libbb/xgetcwd.c
   M /trunk/busybox/miscutils/runlevel.c

remove unneeded #includes, fix indentation

 ------------------------------------------------------------------------

Index: coreutils/printf.c
===================================================================
--- coreutils/printf.c	(revision 16205)
+++ coreutils/printf.c	(revision 16206)
@@ -38,37 +38,30 @@
 
 //   19990508 Busy Boxed! Dave Cinege
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include "busybox.h"
 
-static int print_formatted (char *format, int argc, char **argv);
-static void print_direc (char *start, size_t length,
+static int print_formatted(char *format, int argc, char **argv);
+static void print_direc(char *start, size_t length,
 			int field_width, int precision, char *argument);
 
 typedef int (*converter)(char *arg, void *result);
+
 static void multiconvert(char *arg, void *result, converter convert)
 {
 	char s[16];
 	if (*arg == '"' || *arg == '\'') {
-		sprintf(s,"%d",(unsigned)*(++arg));
-		arg=s;
+		sprintf(s, "%d", (unsigned)arg[1]);
+		arg = s;
 	}
-	if(convert(arg,result)) fprintf(stderr, "%s", arg);
+	if (convert(arg, result))
+		fputs(arg, stderr);
 }
 
 static unsigned long xstrtoul(char *arg)
 {
 	unsigned long result;
 
-	multiconvert(arg,&result, (converter)safe_strtoul);
+	multiconvert(arg, &result, (converter)safe_strtoul);
 	return result;
 }
 
@@ -104,7 +97,7 @@
 	char *format;
 	int args_used;
 
-	if (argc <= 1 || **(argv + 1) == '-') {
+	if (argc <= 1 || argv[1][0] == '-') {
 		bb_show_usage();
 	}
 
@@ -119,9 +112,8 @@
 	}
 	while (args_used > 0 && argc > 0);
 
-/*
-  if (argc > 0)
-    fprintf(stderr, "excess args ignored");
+/*	if (argc > 0)
+		fprintf(stderr, "excess args ignored");
 */
 
 	return EXIT_SUCCESS;
@@ -199,9 +191,9 @@
 				++direc_length;
 			}
 			/*
-			   if (!strchr ("diouxXfeEgGcs", *f))
-			   fprintf(stderr, "%%%c: invalid directive", *f);
-			 */
+			if (!strchr ("diouxXfeEgGcs", *f))
+			fprintf(stderr, "%%%c: invalid directive", *f);
+			*/
 			++direc_length;
 			if (argc > 0) {
 				print_direc(direc_start, direc_length, field_width,
@@ -232,7 +224,7 @@
 print_direc(char *start, size_t length, int field_width, int precision,
 			char *argument)
 {
-	char *p;					/* Null-terminated copy of % directive. */
+	char *p;		/* Null-terminated copy of % directive. */
 
 	p = xmalloc((unsigned) (length + 1));
 	strncpy(p, start, length);
Index: libbb/xgetcwd.c
===================================================================
--- libbb/xgetcwd.c	(revision 16205)
+++ libbb/xgetcwd.c	(revision 16206)
@@ -7,11 +7,6 @@
  * Special function for busybox written by Vladimir Oleynik 
 */
 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include "libbb.h"
 
 /* Amount to increase buffer size by in each try. */
@@ -23,27 +18,27 @@
 */
 
 char *
-xgetcwd (char *cwd)
+xgetcwd(char *cwd)
 {
-  char *ret;
-  unsigned path_max;
+	char *ret;
+	unsigned path_max;
 
-  path_max = (unsigned) PATH_MAX;
-  path_max += 2;                /* The getcwd docs say to do this. */
+	path_max = (unsigned) PATH_MAX;
+	path_max += 2;                /* The getcwd docs say to do this. */
 
-  if(cwd==0)
-	cwd = xmalloc (path_max);
+	if (cwd==0)
+		cwd = xmalloc(path_max);
 
-  while ((ret = getcwd (cwd, path_max)) == NULL && errno == ERANGE) {
-      path_max += PATH_INCR;
-      cwd = xrealloc (cwd, path_max);
-  }
+	while ((ret = getcwd(cwd, path_max)) == NULL && errno == ERANGE) {
+		path_max += PATH_INCR;
+		cwd = xrealloc(cwd, path_max);
+	}
 
-  if (ret == NULL) {
-      free (cwd);
-      bb_perror_msg("getcwd()");
-      return NULL;
-  }
+	if (ret == NULL) {
+		free(cwd);
+		bb_perror_msg("getcwd");
+		return NULL;
+	}
 
-  return cwd;
+	return cwd;
 }
Index: miscutils/runlevel.c
===================================================================
--- miscutils/runlevel.c	(revision 16205)
+++ miscutils/runlevel.c	(revision 16206)
@@ -20,24 +20,23 @@
 
 int runlevel_main(int argc, char *argv[])
 {
-  struct utmp *ut;
-  char prev;
+	struct utmp *ut;
+	char prev;
 
-  if (argc > 1) utmpname(argv[1]);
+	if (argc > 1) utmpname(argv[1]);
 
-  setutent();
-  while ((ut = getutent()) != NULL) {
-	if (ut->ut_type == RUN_LVL) {
-		prev = ut->ut_pid / 256;
-		if (prev == 0) prev = 'N';
-		printf("%c %c\n", prev, ut->ut_pid % 256);
-		endutent();
-		return (0);
+	setutent();
+	while ((ut = getutent()) != NULL) {
+		if (ut->ut_type == RUN_LVL) {
+			prev = ut->ut_pid / 256;
+			if (prev == 0) prev = 'N';
+			printf("%c %c\n", prev, ut->ut_pid % 256);
+			endutent();
+			return 0;
+		}
 	}
-  }
 
-  printf("unknown\n");
-  endutent();
-  return (1);
+	puts("unknown");
+	endutent();
+	return 1;
 }
-

 ------------------------------------------------------------------------
r16205 | vda | 2006-09-23 11:58:01 -0400 (Sat, 23 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/networking/inetd.c

inetd: deindent main loop, other readability enhancements

 ------------------------------------------------------------------------

Index: networking/inetd.c
===================================================================
--- networking/inetd.c	(revision 16204)
+++ networking/inetd.c	(revision 16205)
@@ -183,8 +183,7 @@
 # define INETD_SETPROCTITLE
 #endif
 
-typedef struct servtab
-{
+typedef struct servtab {
 	char *se_hostaddr;                    /* host address to listen on */
 	char *se_service;                     /* name of service */
 	int se_socktype;                      /* type of socket to use */
@@ -209,8 +208,7 @@
 #define MAXARGV 20
 	char *se_argv[MAXARGV + 1];           /* program arguments */
 	int se_fd;                            /* open descriptor */
-	union
-	{
+	union {
 		struct sockaddr se_un_ctrladdr;
 		struct sockaddr_in se_un_ctrladdr_in;
 #ifdef CONFIG_FEATURE_IPV6
@@ -232,8 +230,7 @@
 static servtab_t *servtab;
 
 #ifdef INETD_FEATURE_ENABLED
-struct builtin
-{
+struct builtin {
 	const char *bi_service;               /* internally provided service name */
 	int bi_socktype;                      /* type of socket supported */
 	short bi_fork;                        /* 1 if should fork before call */
@@ -427,7 +424,8 @@
 	int on = 1;
 	int r;
 
-	if ((sep->se_fd = socket(sep->se_family, sep->se_socktype, 0)) < 0) {
+	sep->se_fd = socket(sep->se_family, sep->se_socktype, 0);
+	if (sep->se_fd < 0) {
 		bb_perror_msg("%s/%s: socket", sep->se_service, sep->se_proto);
 		return;
 	}
@@ -1355,7 +1353,7 @@
 		}
 
 		readable = allsock;
-		n = select(maxsock + 1, &readable, NULL, NULL, NULL)
+		n = select(maxsock + 1, &readable, NULL, NULL, NULL);
 		if (n <= 0) {
 			if (n < 0 && errno != EINTR) {
 				bb_perror_msg("select");
@@ -1363,154 +1361,154 @@
 			}
 			continue;
 		}
+
 		for (sep = servtab; n && sep; sep = sep->se_next) {
-			// TODO: undo this unholy mess
-			if (sep->se_fd != -1 && FD_ISSET(sep->se_fd, &readable)) {
-				n--;
-				if (!sep->se_wait && sep->se_socktype == SOCK_STREAM) {
-					ctrl = accept(sep->se_fd, NULL, NULL);
-					if (ctrl < 0) {
-						if (errno == EINTR)
-							continue;
-						bb_perror_msg("accept (for %s)", sep->se_service);
+			if (sep->se_fd == -1 || !FD_ISSET(sep->se_fd, &readable))
+				continue;
+
+			n--;
+			if (!sep->se_wait && sep->se_socktype == SOCK_STREAM) {
+				ctrl = accept(sep->se_fd, NULL, NULL);
+				if (ctrl < 0) {
+					if (errno == EINTR)
 						continue;
+					bb_perror_msg("accept (for %s)", sep->se_service);
+					continue;
+				}
+				if (sep->se_family == AF_INET && sep->se_socktype == SOCK_STREAM) {
+					struct sockaddr_in peer;
+					socklen_t plen = sizeof(peer);
+
+					if (getpeername(ctrl, (struct sockaddr *) &peer, &plen) < 0) {
+						bb_error_msg("could not getpeername");
+						close(ctrl);
+						continue;
 					}
-					if (sep->se_family == AF_INET && sep->se_socktype == SOCK_STREAM) {
-						struct sockaddr_in peer;
-						socklen_t plen = sizeof(peer);
+					if (ntohs(peer.sin_port) == 20) {
+						/* XXX ftp bounce */
+						close(ctrl);
+						continue;
+					}
+				}
+			} else
+				ctrl = sep->se_fd;
 
-						if (getpeername(ctrl, (struct sockaddr *) &peer, &plen) < 0) {
-							bb_error_msg("could not getpeername");
+			Block_Using_Signals(omask);
+			pid = 0;
+#ifdef INETD_FEATURE_ENABLED
+			if (sep->se_bi == 0 || sep->se_bi->bi_fork)
+#endif
+			{
+				if (sep->se_count++ == 0)
+					(void) gettimeofday(&sep->se_time, NULL);
+				else if (toomany > 0 && sep->se_count >= sep->se_max) {
+					struct timeval now;
+
+					(void) gettimeofday(&now, NULL);
+					if (now.tv_sec - sep->se_time.tv_sec > CNT_INTVL) {
+						sep->se_time = now;
+						sep->se_count = 1;
+					} else {
+						if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
 							close(ctrl);
+						if (sep->se_family == AF_INET &&
+							  ntohs(sep->se_ctrladdr_in.sin_port) >= IPPORT_RESERVED) {
+							/*
+							 * Cannot close it -- there are
+							 * thieves on the system.
+							 * Simply ignore the connection.
+							 */
+							--sep->se_count;
 							continue;
 						}
-						if (ntohs(peer.sin_port) == 20) {
-							/* XXX ftp bounce */
+						bb_error_msg("%s/%s server failing (looping), service terminated",
+							      sep->se_service, sep->se_proto);
+						if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
 							close(ctrl);
-							continue;
+						FD_CLR(sep->se_fd, &allsock);
+						(void) close(sep->se_fd);
+						sep->se_fd = -1;
+						sep->se_count = 0;
+						nsock--;
+						sigprocmask(SIG_UNBLOCK, &omask, NULL);
+						if (!timingout) {
+							timingout = 1;
+							alarm(RETRYTIME);
 						}
+						continue;
 					}
-				} else
-					ctrl = sep->se_fd;
-				Block_Using_Signals(omask);
-				pid = 0;
-#ifdef INETD_FEATURE_ENABLED
-				if (sep->se_bi == 0 || sep->se_bi->bi_fork)
-#endif
-				{
-					if (sep->se_count++ == 0)
-						(void) gettimeofday(&sep->se_time, NULL);
-					else if (toomany > 0 && sep->se_count >= sep->se_max) {
-						struct timeval now;
-
-						(void) gettimeofday(&now, NULL);
-						if (now.tv_sec - sep->se_time.tv_sec > CNT_INTVL) {
-							sep->se_time = now;
-							sep->se_count = 1;
-						} else {
-							if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
-								close(ctrl);
-							if (sep->se_family == AF_INET &&
-								  ntohs(sep->se_ctrladdr_in.sin_port) >= IPPORT_RESERVED) {
-								/*
-								 * Cannot close it -- there are
-								 * thieves on the system.
-								 * Simply ignore the connection.
-								 */
-								--sep->se_count;
-								continue;
-							}
-							bb_error_msg("%s/%s server failing (looping), service terminated",
-								      sep->se_service, sep->se_proto);
-							if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
-								close(ctrl);
-							FD_CLR(sep->se_fd, &allsock);
-							(void) close(sep->se_fd);
-							sep->se_fd = -1;
-							sep->se_count = 0;
-							nsock--;
-							sigprocmask(SIG_UNBLOCK, &omask, NULL);
-							if (!timingout) {
-								timingout = 1;
-								alarm(RETRYTIME);
-							}
-							continue;
-						}
-					}
-					pid = fork();
 				}
-				if (pid < 0) {
-					bb_perror_msg("fork");
-					if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
-						close(ctrl);
-					sigprocmask(SIG_UNBLOCK, &omask, NULL);
-					sleep(1);
-					continue;
-				}
-				if (pid && sep->se_wait) {
-					sep->se_wait = pid;
-					FD_CLR(sep->se_fd, &allsock);
-					nsock--;
-				}
+				pid = fork();
+			}
+			if (pid < 0) {
+				bb_perror_msg("fork");
+				if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
+					close(ctrl);
 				sigprocmask(SIG_UNBLOCK, &omask, NULL);
-				if (pid == 0) {
+				sleep(1);
+				continue;
+			}
+			if (pid && sep->se_wait) {
+				sep->se_wait = pid;
+				FD_CLR(sep->se_fd, &allsock);
+				nsock--;
+			}
+			sigprocmask(SIG_UNBLOCK, &omask, NULL);
+			if (pid == 0) {
 #ifdef INETD_FEATURE_ENABLED
-					if (sep->se_bi) {
-						(*sep->se_bi->bi_fn)(ctrl, sep);
-					} else
+				if (sep->se_bi) {
+					(*sep->se_bi->bi_fn)(ctrl, sep);
+				} else
 #endif
-						{
-						if ((pwd = getpwnam(sep->se_user)) == NULL) {
-							bb_error_msg("getpwnam: %s: no such user", sep->se_user);
-							if (sep->se_socktype != SOCK_STREAM)
-								recv(0, buf, sizeof(buf), 0);
+					{
+					pwd = getpwnam(sep->se_user);
+					if (pwd == NULL) {
+						bb_error_msg("getpwnam: %s: no such user", sep->se_user);
+						goto do_exit1;
+					}
+					if (setsid() < 0)
+						bb_perror_msg("%s: setsid", sep->se_service);
+					if (sep->se_group && (grp = getgrnam(sep->se_group)) == NULL) {
+						bb_error_msg("getgrnam: %s: no such group", sep->se_group);
+						goto do_exit1;
+					}
+					if (uid != 0) {
+						/* a user running private inetd */
+						if (uid != pwd->pw_uid)
 							_exit(1);
-						}
-						if (setsid() < 0)
-							bb_perror_msg("%s: setsid", sep->se_service);
-						if (sep->se_group && (grp = getgrnam(sep->se_group)) == NULL) {
-							bb_error_msg("getgrnam: %s: no such group", sep->se_group);
-							if (sep->se_socktype != SOCK_STREAM)
-								recv(0, buf, sizeof(buf), 0);
-							_exit(1);
-						}
-						if (uid != 0) {
-							/* a user running private inetd */
-							if (uid != pwd->pw_uid)
-								_exit(1);
-						} else if (pwd->pw_uid) {
-							if (sep->se_group)
-								pwd->pw_gid = grp->gr_gid;
-							xsetgid((gid_t) pwd->pw_gid);
-							initgroups(pwd->pw_name, pwd->pw_gid);
-							xsetuid((uid_t) pwd->pw_uid);
-						} else if (sep->se_group) {
-							xsetgid(grp->gr_gid);
-							setgroups(1, &grp->gr_gid);
-						}
-						dup2(ctrl, 0);
-						close(ctrl);
-						dup2(0, 1);
-						dup2(0, 2);
-						if (rlim_ofile.rlim_cur != rlim_ofile_cur)
-							if (setrlimit(RLIMIT_NOFILE, &rlim_ofile) < 0)
-								bb_perror_msg("setrlimit");
-						closelog();
-						for (tmpint = rlim_ofile_cur - 1; --tmpint > 2;)
-							(void) close(tmpint);
-						sigaction(SIGPIPE, &sapipe, NULL);
-						execv(sep->se_server, sep->se_argv);
-						if (sep->se_socktype != SOCK_STREAM)
-							recv(0, buf, sizeof(buf), 0);
-						bb_perror_msg("execv %s", sep->se_server);
-						_exit(1);
+					} else if (pwd->pw_uid) {
+						if (sep->se_group)
+							pwd->pw_gid = grp->gr_gid;
+						xsetgid((gid_t) pwd->pw_gid);
+						initgroups(pwd->pw_name, pwd->pw_gid);
+						xsetuid((uid_t) pwd->pw_uid);
+					} else if (sep->se_group) {
+						xsetgid(grp->gr_gid);
+						setgroups(1, &grp->gr_gid);
 					}
+					dup2(ctrl, 0);
+					if (ctrl) close(ctrl);
+					dup2(0, 1);
+					dup2(0, 2);
+					if (rlim_ofile.rlim_cur != rlim_ofile_cur)
+						if (setrlimit(RLIMIT_NOFILE, &rlim_ofile) < 0)
+							bb_perror_msg("setrlimit");
+					closelog();
+					for (tmpint = rlim_ofile_cur - 1; --tmpint > 2;)
+						(void) close(tmpint);
+					sigaction(SIGPIPE, &sapipe, NULL);
+					execv(sep->se_server, sep->se_argv);
+					bb_perror_msg("execv %s", sep->se_server);
+do_exit1:
+					if (sep->se_socktype != SOCK_STREAM)
+						recv(0, buf, sizeof(buf), 0);
+					_exit(1);
 				}
-				if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
-					close(ctrl);
 			}
-		}
-	}
+			if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
+				close(ctrl);
+		} /* for (sep = servtab...) */
+	} /* for(;;) */
 }
 
 /*
@@ -1542,8 +1540,12 @@
 	int i;
 
 	inetd_setproctitle(sep->se_service, s);
-	while ((i = read(s, buffer, sizeof(buffer))) > 0 &&
-				 write(s, buffer, i) > 0);
+	while (1) {
+		i = read(s, buffer, sizeof(buffer));
+		if (i <= 0) break;
+		/* FIXME: this isnt correct - safe_write()? */
+		if (write(s, buffer, i) <= 0) break;
+	}
 	exit(0);
 }
 
@@ -1577,9 +1579,11 @@
 	char buffer[BUFSIZE];
 
 	inetd_setproctitle(sep->se_service, s);
-	while ((errno = 0, read(s, buffer, sizeof(buffer)) > 0) ||
-				 errno == EINTR);
-	exit(0);
+	while (1) {
+		errno = 0;
+		if (read(s, buffer, sizeof(buffer)) <= 0 && errno != EINTR)
+			exit(0);
+	}
 }
 
 /* Discard service -- ignore data */
@@ -1629,8 +1633,10 @@
 
 	text[LINESIZ] = '\r';
 	text[LINESIZ + 1] = '\n';
-	for (rs = ring;;) {
-		if ((len = endring - rs) >= LINESIZ)
+	rs = ring;
+	for (;;) {
+		len = endring - rs;
+		if (len >= LINESIZ)
 			memmove(text, rs, LINESIZ);
 		else {
 			memmove(text, rs, len);

 ------------------------------------------------------------------------
r16204 | vda | 2006-09-23 11:53:01 -0400 (Sat, 23 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/util-linux/hexdump.c

hexdump: fixlet for my breakage

 ------------------------------------------------------------------------

Index: util-linux/hexdump.c
===================================================================
--- util-linux/hexdump.c	(revision 16203)
+++ util-linux/hexdump.c	(revision 16204)
@@ -60,7 +60,7 @@
 	bb_dump_length = -1;
 
 	while ((ch = getopt(argc, argv, hexdump_opts)) > 0) {
-		p = strchr(hexdump_opts, ch)
+		p = strchr(hexdump_opts, ch);
 		if (!p)
 			bb_show_usage();
 		if ((p - hexdump_opts) < 5) {

 ------------------------------------------------------------------------
r16203 | vda | 2006-09-23 11:18:38 -0400 (Sat, 23 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/networking/inetd.c

inetd: reformat with tabs for indentation

 ------------------------------------------------------------------------

Index: networking/inetd.c
===================================================================
--- networking/inetd.c	(revision 16202)
+++ networking/inetd.c	(revision 16203)
@@ -170,63 +170,63 @@
 
 /* Check unsupporting builtin */
 #if defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO || \
-	defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD || \
-	defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME || \
-	defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME || \
-	defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN
+		defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD || \
+		defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME || \
+		defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME || \
+		defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN
 # define INETD_FEATURE_ENABLED
 #endif
 
 #if defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO || \
-	defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD || \
-	defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN
+		defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD || \
+		defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN
 # define INETD_SETPROCTITLE
 #endif
 
 typedef struct servtab
 {
-  char *se_hostaddr;                    /* host address to listen on */
-  char *se_service;                     /* name of service */
-  int se_socktype;                      /* type of socket to use */
-  int se_family;                        /* address family */
-  char *se_proto;                       /* protocol used */
+	char *se_hostaddr;                    /* host address to listen on */
+	char *se_service;                     /* name of service */
+	int se_socktype;                      /* type of socket to use */
+	int se_family;                        /* address family */
+	char *se_proto;                       /* protocol used */
 #ifdef CONFIG_FEATURE_INETD_RPC
-  int se_rpcprog;                       /* rpc program number */
-  int se_rpcversl;                      /* rpc program lowest version */
-  int se_rpcversh;                      /* rpc program highest version */
+	int se_rpcprog;                       /* rpc program number */
+	int se_rpcversl;                      /* rpc program lowest version */
+	int se_rpcversh;                      /* rpc program highest version */
 #define isrpcservice(sep)       ((sep)->se_rpcversl != 0)
 #else
 #define isrpcservice(sep)       0
 #endif
-  pid_t se_wait;                        /* single threaded server */
-  short se_checked;                     /* looked at during merge */
-  char *se_user;                        /* user name to run as */
-  char *se_group;                       /* group name to run as */
+	pid_t se_wait;                        /* single threaded server */
+	short se_checked;                     /* looked at during merge */
+	char *se_user;                        /* user name to run as */
+	char *se_group;                       /* group name to run as */
 #ifdef INETD_FEATURE_ENABLED
-  const struct builtin *se_bi;                 /* if built-in, description */
+	const struct builtin *se_bi;          /* if built-in, description */
 #endif
-  char *se_server;                      /* server program */
+	char *se_server;                      /* server program */
 #define MAXARGV 20
-  char *se_argv[MAXARGV + 1];           /* program arguments */
-  int se_fd;                            /* open descriptor */
-  union
-  {
-	struct sockaddr se_un_ctrladdr;
-	struct sockaddr_in se_un_ctrladdr_in;
+	char *se_argv[MAXARGV + 1];           /* program arguments */
+	int se_fd;                            /* open descriptor */
+	union
+	{
+		struct sockaddr se_un_ctrladdr;
+		struct sockaddr_in se_un_ctrladdr_in;
 #ifdef CONFIG_FEATURE_IPV6
-	struct sockaddr_in6 se_un_ctrladdr_in6;
+		struct sockaddr_in6 se_un_ctrladdr_in6;
 #endif
-	struct sockaddr_un se_un_ctrladdr_un;
-  } se_un;                              /* bound address */
+		struct sockaddr_un se_un_ctrladdr_un;
+	} se_un;                              /* bound address */
 #define se_ctrladdr     se_un.se_un_ctrladdr
 #define se_ctrladdr_in  se_un.se_un_ctrladdr_in
 #define se_ctrladdr_in6 se_un.se_un_ctrladdr_in6
 #define se_ctrladdr_un  se_un.se_un_ctrladdr_un
-  int se_ctrladdr_size;
-  int se_max;                           /* max # of instances of this service */
-  int se_count;                         /* number started since se_time */
-  struct timeval se_time;               /* start of se_count */
-  struct servtab *se_next;
+	int se_ctrladdr_size;
+	int se_max;                           /* max # of instances of this service */
+	int se_count;                         /* number started since se_time */
+	struct timeval se_time;               /* start of se_count */
+	struct servtab *se_next;
 } servtab_t;
 
 static servtab_t *servtab;
@@ -234,66 +234,66 @@
 #ifdef INETD_FEATURE_ENABLED
 struct builtin
 {
-  const char *bi_service;               /* internally provided service name */
-  int bi_socktype;                      /* type of socket supported */
-  short bi_fork;                        /* 1 if should fork before call */
-  short bi_wait;                        /* 1 if should wait for child */
-  void (*bi_fn) (int, servtab_t *);
+	const char *bi_service;               /* internally provided service name */
+	int bi_socktype;                      /* type of socket supported */
+	short bi_fork;                        /* 1 if should fork before call */
+	short bi_wait;                        /* 1 if should wait for child */
+	void (*bi_fn) (int, servtab_t *);
 };
 
-	/* Echo received data */
+		/* Echo received data */
 #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO
-static void echo_stream (int, servtab_t *);
-static void echo_dg (int, servtab_t *);
+static void echo_stream(int, servtab_t *);
+static void echo_dg(int, servtab_t *);
 #endif
-	/* Internet /dev/null */
+		/* Internet /dev/null */
 #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD
-static void discard_stream (int, servtab_t *);
-static void discard_dg (int, servtab_t *);
+static void discard_stream(int, servtab_t *);
+static void discard_dg(int, servtab_t *);
 #endif
-	/* Return 32 bit time since 1900 */
+		/* Return 32 bit time since 1900 */
 #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME
-static void machtime_stream (int, servtab_t *);
-static void machtime_dg (int, servtab_t *);
+static void machtime_stream(int, servtab_t *);
+static void machtime_dg(int, servtab_t *);
 #endif
-	/* Return human-readable time */
+		/* Return human-readable time */
 #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME
-static void daytime_stream (int, servtab_t *);
-static void daytime_dg (int, servtab_t *);
+static void daytime_stream(int, servtab_t *);
+static void daytime_dg(int, servtab_t *);
 #endif
-	/* Familiar character generator */
+		/* Familiar character generator */
 #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN
-static void chargen_stream (int, servtab_t *);
-static void chargen_dg (int, servtab_t *);
+static void chargen_stream(int, servtab_t *);
+static void chargen_dg(int, servtab_t *);
 #endif
 
 static const struct builtin builtins[] = {
 #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO
-  /* Echo received data */
-  {"echo", SOCK_STREAM, 1, 0, echo_stream,},
-  {"echo", SOCK_DGRAM, 0, 0, echo_dg,},
+	/* Echo received data */
+	{"echo", SOCK_STREAM, 1, 0, echo_stream,},
+	{"echo", SOCK_DGRAM, 0, 0, echo_dg,},
 #endif
 #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD
-  /* Internet /dev/null */
-  {"discard", SOCK_STREAM, 1, 0, discard_stream,},
-  {"discard", SOCK_DGRAM, 0, 0, discard_dg,},
+	/* Internet /dev/null */
+	{"discard", SOCK_STREAM, 1, 0, discard_stream,},
+	{"discard", SOCK_DGRAM, 0, 0, discard_dg,},
 #endif
 #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME
-  /* Return 32 bit time since 1900 */
-  {"time", SOCK_STREAM, 0, 0, machtime_stream,},
-  {"time", SOCK_DGRAM, 0, 0, machtime_dg,},
+	/* Return 32 bit time since 1900 */
+	{"time", SOCK_STREAM, 0, 0, machtime_stream,},
+	{"time", SOCK_DGRAM, 0, 0, machtime_dg,},
 #endif
 #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME
-  /* Return human-readable time */
-  {"daytime", SOCK_STREAM, 0, 0, daytime_stream,},
-  {"daytime", SOCK_DGRAM, 0, 0, daytime_dg,},
+	/* Return human-readable time */
+	{"daytime", SOCK_STREAM, 0, 0, daytime_stream,},
+	{"daytime", SOCK_DGRAM, 0, 0, daytime_dg,},
 #endif
 #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN
-  /* Familiar character generator */
-  {"chargen", SOCK_STREAM, 1, 0, chargen_stream,},
-  {"chargen", SOCK_DGRAM, 0, 0, chargen_dg,},
+	/* Familiar character generator */
+	{"chargen", SOCK_STREAM, 1, 0, chargen_stream,},
+	{"chargen", SOCK_DGRAM, 0, 0, chargen_dg,},
 #endif
-  {NULL, 0, 0, 0, NULL}
+	{NULL, 0, 0, 0, NULL}
 };
 #endif /* INETD_FEATURE_ENABLED */
 
@@ -315,884 +315,884 @@
  * will return newly-allocated "" if called with NULL arg
  * TODO: audit whether this makes any real difference
  */
-static char *xxstrdup (char *cp)
+static char *xxstrdup(char *cp)
 {
-  return xstrdup (cp ? cp : "");
+	return xstrdup(cp ? cp : "");
 }
 
-static int setconfig (void)
+static int setconfig(void)
 {
-  free (defhost);
-  defhost = xstrdup ("*");
-  if (fconfig != NULL) {
-	fseek (fconfig, 0L, SEEK_SET);
-	return (1);
-  }
-  fconfig = fopen (CONFIG, "r");
-  return (fconfig != NULL);
+	free(defhost);
+	defhost = xstrdup("*");
+	if (fconfig != NULL) {
+		fseek(fconfig, 0L, SEEK_SET);
+		return 1;
+	}
+	fconfig = fopen(CONFIG, "r");
+	return (fconfig != NULL);
 }
 
-static void endconfig (void)
+static void endconfig(void)
 {
-  if (fconfig) {
-	(void) fclose (fconfig);
-	fconfig = NULL;
-  }
-  free (defhost);
-  defhost = 0;
+	if (fconfig) {
+		(void) fclose(fconfig);
+		fconfig = NULL;
+	}
+	free(defhost);
+	defhost = 0;
 }
 
 #ifdef CONFIG_FEATURE_INETD_RPC
-static void register_rpc (servtab_t *sep)
+static void register_rpc(servtab_t *sep)
 {
-  int n;
-  struct sockaddr_in ir_sin;
-  struct protoent *pp;
-  socklen_t size;
+	int n;
+	struct sockaddr_in ir_sin;
+	struct protoent *pp;
+	socklen_t size;
 
-  if ((pp = getprotobyname (sep->se_proto + 4)) == NULL) {
-	bb_perror_msg ("%s: getproto", sep->se_proto);
-	return;
-  }
-  size = sizeof ir_sin;
-  if (getsockname (sep->se_fd, (struct sockaddr *) &ir_sin, &size) < 0) {
-	bb_perror_msg ("%s/%s: getsockname",
-			sep->se_service, sep->se_proto);
-	return;
-  }
+	if ((pp = getprotobyname(sep->se_proto + 4)) == NULL) {
+		bb_perror_msg("%s: getproto", sep->se_proto);
+		return;
+	}
+	size = sizeof ir_sin;
+	if (getsockname(sep->se_fd, (struct sockaddr *) &ir_sin, &size) < 0) {
+		bb_perror_msg("%s/%s: getsockname",
+				sep->se_service, sep->se_proto);
+		return;
+	}
 
-  for (n = sep->se_rpcversl; n <= sep->se_rpcversh; n++) {
-	(void) pmap_unset (sep->se_rpcprog, n);
-	if (!pmap_set (sep->se_rpcprog, n, pp->p_proto, ntohs (ir_sin.sin_port)))
-	  bb_perror_msg ("%s %s: pmap_set: %u %u %u %u",
-			  sep->se_service, sep->se_proto,
-			  sep->se_rpcprog, n, pp->p_proto, ntohs (ir_sin.sin_port));
-  }
+	for (n = sep->se_rpcversl; n <= sep->se_rpcversh; n++) {
+		(void) pmap_unset(sep->se_rpcprog, n);
+		if (!pmap_set(sep->se_rpcprog, n, pp->p_proto, ntohs(ir_sin.sin_port)))
+			bb_perror_msg("%s %s: pmap_set: %u %u %u %u",
+					sep->se_service, sep->se_proto,
+					sep->se_rpcprog, n, pp->p_proto, ntohs(ir_sin.sin_port));
+	}
 }
 
-static void unregister_rpc (servtab_t *sep)
+static void unregister_rpc(servtab_t *sep)
 {
-  int n;
+	int n;
 
-  for (n = sep->se_rpcversl; n <= sep->se_rpcversh; n++) {
-	if (!pmap_unset (sep->se_rpcprog, n))
-	  bb_error_msg ("pmap_unset(%u, %u)", sep->se_rpcprog, n);
-  }
+	for (n = sep->se_rpcversl; n <= sep->se_rpcversh; n++) {
+		if (!pmap_unset(sep->se_rpcprog, n))
+			bb_error_msg("pmap_unset(%u, %u)", sep->se_rpcprog, n);
+	}
 }
 #endif /* CONFIG_FEATURE_INETD_RPC */
 
-static void freeconfig (servtab_t *cp)
+static void freeconfig(servtab_t *cp)
 {
-  int i;
+	int i;
 
-  free (cp->se_hostaddr);
-  free (cp->se_service);
-  free (cp->se_proto);
-  free (cp->se_user);
-  free (cp->se_group);
-  free (cp->se_server);
-  for (i = 0; i < MAXARGV; i++)
-	free (cp->se_argv[i]);
+	free(cp->se_hostaddr);
+	free(cp->se_service);
+	free(cp->se_proto);
+	free(cp->se_user);
+	free(cp->se_group);
+	free(cp->se_server);
+	for (i = 0; i < MAXARGV; i++)
+		free(cp->se_argv[i]);
 }
 
 static int bump_nofile (void)
 {
 #define FD_CHUNK        32
 
-  struct rlimit rl;
+	struct rlimit rl;
 
-  if (getrlimit (RLIMIT_NOFILE, &rl) < 0) {
-	bb_perror_msg ("getrlimit");
-	return -1;
-  }
-  rl.rlim_cur = MIN (rl.rlim_max, rl.rlim_cur + FD_CHUNK);
-  rl.rlim_cur = MIN (FD_SETSIZE, rl.rlim_cur + FD_CHUNK);
-  if (rl.rlim_cur <= rlim_ofile_cur) {
-	bb_error_msg ("bump_nofile: cannot extend file limit, max = %d",
-			(int) rl.rlim_cur);
-	return -1;
-  }
+	if (getrlimit (RLIMIT_NOFILE, &rl) < 0) {
+		bb_perror_msg("getrlimit");
+		return -1;
+	}
+	rl.rlim_cur = MIN(rl.rlim_max, rl.rlim_cur + FD_CHUNK);
+	rl.rlim_cur = MIN(FD_SETSIZE, rl.rlim_cur + FD_CHUNK);
+	if (rl.rlim_cur <= rlim_ofile_cur) {
+		bb_error_msg("bump_nofile: cannot extend file limit, max = %d",
+						(int) rl.rlim_cur);
+		return -1;
+	}
 
-  if (setrlimit (RLIMIT_NOFILE, &rl) < 0) {
-	bb_perror_msg ("setrlimit");
-	return -1;
-  }
+	if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
+		bb_perror_msg("setrlimit");
+		return -1;
+	}
 
-  rlim_ofile_cur = rl.rlim_cur;
-  return 0;
+	rlim_ofile_cur = rl.rlim_cur;
+	return 0;
 }
 
-static void setup (servtab_t *sep)
+static void setup(servtab_t *sep)
 {
-  int on = 1;
-  int r;
+	int on = 1;
+	int r;
 
-  if ((sep->se_fd = socket (sep->se_family, sep->se_socktype, 0)) < 0) {
-	bb_perror_msg ("%s/%s: socket", sep->se_service, sep->se_proto);
-	return;
-  }
+	if ((sep->se_fd = socket(sep->se_family, sep->se_socktype, 0)) < 0) {
+		bb_perror_msg("%s/%s: socket", sep->se_service, sep->se_proto);
+		return;
+	}
 #define turnon(fd, opt) \
-setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on))
-  if (turnon (sep->se_fd, SO_REUSEADDR) < 0)
-	bb_perror_msg ("setsockopt (SO_REUSEADDR)");
+setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof(on))
+	if (turnon(sep->se_fd, SO_REUSEADDR) < 0)
+		bb_perror_msg("setsockopt(SO_REUSEADDR)");
 #undef turnon
 
 #ifdef CONFIG_FEATURE_INETD_RPC
-  if (isrpcservice (sep)) {
-	struct passwd *pwd;
+	if (isrpcservice(sep)) {
+		struct passwd *pwd;
 
-	/*
-	 * for RPC services, attempt to use a reserved port
-	 * if they are going to be running as root.
-	 *
-	 * Also, zero out the port for all RPC services; let bind()
-	 * find one.
-	 */
-	sep->se_ctrladdr_in.sin_port = 0;
-	if (sep->se_user && (pwd = getpwnam (sep->se_user)) &&
-		pwd->pw_uid == 0 && uid == 0)
-	  r = bindresvport (sep->se_fd, &sep->se_ctrladdr_in);
-	else {
-	  r = bind (sep->se_fd, &sep->se_ctrladdr, sep->se_ctrladdr_size);
-	  if (r == 0) {
-		socklen_t len = sep->se_ctrladdr_size;
-		int saveerrno = errno;
+		/*
+		 * for RPC services, attempt to use a reserved port
+		 * if they are going to be running as root.
+		 *
+		 * Also, zero out the port for all RPC services; let bind()
+		 * find one.
+		 */
+		sep->se_ctrladdr_in.sin_port = 0;
+		if (sep->se_user && (pwd = getpwnam(sep->se_user)) &&
+				pwd->pw_uid == 0 && uid == 0)
+			r = bindresvport(sep->se_fd, &sep->se_ctrladdr_in);
+		else {
+			r = bind(sep->se_fd, &sep->se_ctrladdr, sep->se_ctrladdr_size);
+			if (r == 0) {
+				socklen_t len = sep->se_ctrladdr_size;
+				int saveerrno = errno;
 
-		/* update se_ctrladdr_in.sin_port */
-		r = getsockname (sep->se_fd, &sep->se_ctrladdr, &len);
-		if (r <= 0)
-		  errno = saveerrno;
-	  }
-	}
-  } else
+				/* update se_ctrladdr_in.sin_port */
+				r = getsockname(sep->se_fd, &sep->se_ctrladdr, &len);
+				if (r <= 0)
+					errno = saveerrno;
+			}
+		}
+	} else
 #endif
-	r = bind (sep->se_fd, &sep->se_ctrladdr, sep->se_ctrladdr_size);
-  if (r < 0) {
-	bb_perror_msg ("%s/%s (%d): bind",
-			sep->se_service, sep->se_proto, sep->se_ctrladdr.sa_family);
-	close (sep->se_fd);
-	sep->se_fd = -1;
-	if (!timingout) {
-	  timingout = 1;
-	  alarm (RETRYTIME);
+		r = bind(sep->se_fd, &sep->se_ctrladdr, sep->se_ctrladdr_size);
+	if (r < 0) {
+		bb_perror_msg("%s/%s (%d): bind",
+				sep->se_service, sep->se_proto, sep->se_ctrladdr.sa_family);
+		close(sep->se_fd);
+		sep->se_fd = -1;
+		if (!timingout) {
+			timingout = 1;
+			alarm(RETRYTIME);
+		}
+		return;
 	}
-	return;
-  }
-  if (sep->se_socktype == SOCK_STREAM)
-	listen (sep->se_fd, global_queuelen);
+	if (sep->se_socktype == SOCK_STREAM)
+		listen(sep->se_fd, global_queuelen);
 
-  FD_SET (sep->se_fd, &allsock);
-  nsock++;
-  if (sep->se_fd > maxsock) {
-	maxsock = sep->se_fd;
-	if ((rlim_t)maxsock > rlim_ofile_cur - FD_MARGIN)
-	  bump_nofile ();
-  }
+	FD_SET(sep->se_fd, &allsock);
+	nsock++;
+	if (sep->se_fd > maxsock) {
+		maxsock = sep->se_fd;
+		if ((rlim_t)maxsock > rlim_ofile_cur - FD_MARGIN)
+			bump_nofile();
+	}
 }
 
-static char *nextline (void)
+static char *nextline(void)
 {
-  char *cp;
-  FILE *fd = fconfig;
+	char *cp;
+	FILE *fd = fconfig;
 
-  if (fgets (line, sizeof (line), fd) == NULL)
-	return (NULL);
-  cp = strchr (line, '\n');
-  if (cp)
-	*cp = '\0';
-  return (line);
+	if (fgets(line, sizeof(line), fd) == NULL)
+		return NULL;
+	cp = strchr(line, '\n');
+	if (cp)
+		*cp = '\0';
+	return line;
 }
 
-static char *skip (char **cpp) /* int report; */
+static char *skip(char **cpp) /* int report; */
 {
-  char *cp = *cpp;
-  char *start;
+	char *cp = *cpp;
+	char *start;
 
 /* erp: */
-  if (*cpp == NULL) {
-	/* if (report) */
-	/* bb_error_msg ("syntax error in inetd config file"); */
-	return (NULL);
-  }
+	if (*cpp == NULL) {
+		/* if (report) */
+		/* bb_error_msg("syntax error in inetd config file"); */
+		return NULL;
+	}
 
 again:
-  while (*cp == ' ' || *cp == '\t')
-	cp++;
-  if (*cp == '\0') {
-	int c;
+	while (*cp == ' ' || *cp == '\t')
+		cp++;
+	if (*cp == '\0') {
+		int c;
 
-	c = getc (fconfig);
-	(void) ungetc (c, fconfig);
-	if (c == ' ' || c == '\t')
-	  if ((cp = nextline ()))
-		goto again;
-	*cpp = NULL;
+		c = getc(fconfig);
+		(void) ungetc(c, fconfig);
+		if (c == ' ' || c == '\t')
+			if ((cp = nextline()))
+				goto again;
+		*cpp = NULL;
+		/* goto erp; */
+		return NULL;
+	}
+	start = cp;
+	while (*cp && *cp != ' ' && *cp != '\t')
+		cp++;
+	if (*cp != '\0')
+		*cp++ = '\0';
+	/* if ((*cpp = cp) == NULL) */
 	/* goto erp; */
-	return (NULL);
-  }
-  start = cp;
-  while (*cp && *cp != ' ' && *cp != '\t')
-	cp++;
-  if (*cp != '\0')
-	*cp++ = '\0';
-  /* if ((*cpp = cp) == NULL) */
-  /* goto erp; */
 
-  *cpp = cp;
-  return (start);
+	*cpp = cp;
+	return start;
 }
 
 static servtab_t *new_servtab(void)
 {
-  return xmalloc (sizeof (servtab_t));
+	return xmalloc(sizeof(servtab_t));
 }
 
-static servtab_t *dupconfig (servtab_t *sep)
+static servtab_t *dupconfig(servtab_t *sep)
 {
-  servtab_t *newtab;
-  int argc;
+	servtab_t *newtab;
+	int argc;
 
-  newtab = new_servtab();
-  memset (newtab, 0, sizeof (servtab_t));
-  newtab->se_service = xstrdup (sep->se_service);
-  newtab->se_socktype = sep->se_socktype;
-  newtab->se_family = sep->se_family;
-  newtab->se_proto = xstrdup (sep->se_proto);
+	newtab = new_servtab();
+	memset(newtab, 0, sizeof(servtab_t));
+	newtab->se_service = xstrdup(sep->se_service);
+	newtab->se_socktype = sep->se_socktype;
+	newtab->se_family = sep->se_family;
+	newtab->se_proto = xstrdup(sep->se_proto);
 #ifdef CONFIG_FEATURE_INETD_RPC
-  newtab->se_rpcprog = sep->se_rpcprog;
-  newtab->se_rpcversl = sep->se_rpcversl;
-  newtab->se_rpcversh = sep->se_rpcversh;
+	newtab->se_rpcprog = sep->se_rpcprog;
+	newtab->se_rpcversl = sep->se_rpcversl;
+	newtab->se_rpcversh = sep->se_rpcversh;
 #endif
-  newtab->se_wait = sep->se_wait;
-  newtab->se_user = xstrdup (sep->se_user);
-  newtab->se_group = xstrdup (sep->se_group);
+	newtab->se_wait = sep->se_wait;
+	newtab->se_user = xstrdup(sep->se_user);
+	newtab->se_group = xstrdup(sep->se_group);
 #ifdef INETD_FEATURE_ENABLED
-  newtab->se_bi = sep->se_bi;
+	newtab->se_bi = sep->se_bi;
 #endif
-  newtab->se_server = xstrdup (sep->se_server);
+	newtab->se_server = xstrdup(sep->se_server);
 
-  for (argc = 0; argc <= MAXARGV; argc++)
-	newtab->se_argv[argc] = xstrdup (sep->se_argv[argc]);
-  newtab->se_max = sep->se_max;
+	for (argc = 0; argc <= MAXARGV; argc++)
+		newtab->se_argv[argc] = xstrdup(sep->se_argv[argc]);
+	newtab->se_max = sep->se_max;
 
-  return (newtab);
+	return newtab;
 }
 
-static servtab_t *getconfigent (void)
+static servtab_t *getconfigent(void)
 {
-  servtab_t *sep;
-  int argc;
-  char *cp, *arg;
-  char *hostdelim;
-  servtab_t *nsep;
-  servtab_t *psep;
+	servtab_t *sep;
+	int argc;
+	char *cp, *arg;
+	char *hostdelim;
+	servtab_t *nsep;
+	servtab_t *psep;
 
-  sep = new_servtab();
+	sep = new_servtab();
 
-  /* memset(sep, 0, sizeof *sep); */
+	/* memset(sep, 0, sizeof *sep); */
 more:
-  /* freeconfig(sep); */
+	/* freeconfig(sep); */
 
-  while ((cp = nextline ()) && *cp == '#');
-  if (cp == NULL) {
-	/* free(sep); */
-	return (NULL);
-  }
+	while ((cp = nextline()) && *cp == '#');
+	if (cp == NULL) {
+		/* free(sep); */
+		return NULL;
+	}
 
-  memset ((char *) sep, 0, sizeof *sep);
-  arg = skip (&cp);
-  if (arg == NULL) {
-	/* A blank line. */
-	goto more;
-  }
-
-  /* Check for a host name. */
-  hostdelim = strrchr (arg, ':');
-  if (hostdelim) {
-	*hostdelim = '\0';
-	sep->se_hostaddr = xstrdup (arg);
-	arg = hostdelim + 1;
-	/*
-	 * If the line is of the form `host:', then just change the
-	 * default host for the following lines.
-	 */
-	if (*arg == '\0') {
-	  arg = skip (&cp);
-	  if (cp == NULL) {
-		free (defhost);
-		defhost = sep->se_hostaddr;
+	memset((char *) sep, 0, sizeof *sep);
+	arg = skip(&cp);
+	if (arg == NULL) {
+		/* A blank line. */
 		goto more;
-	  }
 	}
-  } else
-	sep->se_hostaddr = xxstrdup (defhost);
 
-  sep->se_service = xxstrdup (arg);
-  arg = skip (&cp);
+	/* Check for a host name. */
+	hostdelim = strrchr(arg, ':');
+	if (hostdelim) {
+		*hostdelim = '\0';
+		sep->se_hostaddr = xstrdup(arg);
+		arg = hostdelim + 1;
+		/*
+		 * If the line is of the form `host:', then just change the
+		 * default host for the following lines.
+		 */
+		if (*arg == '\0') {
+			arg = skip(&cp);
+			if (cp == NULL) {
+				free(defhost);
+				defhost = sep->se_hostaddr;
+				goto more;
+			}
+		}
+	} else
+		sep->se_hostaddr = xxstrdup(defhost);
 
-  if (strcmp (arg, "stream") == 0)
-	sep->se_socktype = SOCK_STREAM;
-  else if (strcmp (arg, "dgram") == 0)
-	sep->se_socktype = SOCK_DGRAM;
-  else if (strcmp (arg, "rdm") == 0)
-	sep->se_socktype = SOCK_RDM;
-  else if (strcmp (arg, "seqpacket") == 0)
-	sep->se_socktype = SOCK_SEQPACKET;
-  else if (strcmp (arg, "raw") == 0)
-	sep->se_socktype = SOCK_RAW;
-  else
-	sep->se_socktype = -1;
+	sep->se_service = xxstrdup(arg);
+	arg = skip(&cp);
 
-  sep->se_proto = xxstrdup (skip (&cp));
+	if (strcmp(arg, "stream") == 0)
+		sep->se_socktype = SOCK_STREAM;
+	else if (strcmp(arg, "dgram") == 0)
+		sep->se_socktype = SOCK_DGRAM;
+	else if (strcmp(arg, "rdm") == 0)
+		sep->se_socktype = SOCK_RDM;
+	else if (strcmp(arg, "seqpacket") == 0)
+		sep->se_socktype = SOCK_SEQPACKET;
+	else if (strcmp(arg, "raw") == 0)
+		sep->se_socktype = SOCK_RAW;
+	else
+		sep->se_socktype = -1;
 
-  if (strcmp (sep->se_proto, "unix") == 0) {
-	sep->se_family = AF_UNIX;
-  } else {
-	sep->se_family = AF_INET;
-	if (sep->se_proto[strlen (sep->se_proto) - 1] == '6')
+	sep->se_proto = xxstrdup(skip(&cp));
+
+	if (strcmp(sep->se_proto, "unix") == 0) {
+		sep->se_family = AF_UNIX;
+	} else {
+		sep->se_family = AF_INET;
+		if (sep->se_proto[strlen(sep->se_proto) - 1] == '6')
 #ifdef CONFIG_FEATURE_IPV6
-	  sep->se_family = AF_INET6;
+			sep->se_family = AF_INET6;
 #else
-	  bb_error_msg ("%s: IPV6 not supported", sep->se_proto);
+			bb_error_msg("%s: IPV6 not supported", sep->se_proto);
 #endif
-	if (strncmp (sep->se_proto, "rpc/", 4) == 0) {
+		if (strncmp(sep->se_proto, "rpc/", 4) == 0) {
 #ifdef CONFIG_FEATURE_INETD_RPC
-	  char *p, *ccp;
-	  long l;
+			char *p, *ccp;
+			long l;
 
-	  p = strchr (sep->se_service, '/');
-	  if (p == 0) {
-		bb_error_msg ("%s: no rpc version", sep->se_service);
-		goto more;
-	  }
-	  *p++ = '\0';
-	  l = strtol (p, &ccp, 0);
-	  if (ccp == p || l < 0 || l > INT_MAX) {
-	  badafterall:
-		bb_error_msg ("%s/%s: bad rpc version", sep->se_service, p);
-		goto more;
-	  }
-	  sep->se_rpcversl = sep->se_rpcversh = l;
-	  if (*ccp == '-') {
-		p = ccp + 1;
-		l = strtol (p, &ccp, 0);
-		if (ccp == p || l < 0 || l > INT_MAX || l < sep->se_rpcversl || *ccp)
-		  goto badafterall;
-		sep->se_rpcversh = l;
-	  } else if (*ccp != '\0')
-		goto badafterall;
+			p = strchr(sep->se_service, '/');
+			if (p == 0) {
+				bb_error_msg("%s: no rpc version", sep->se_service);
+				goto more;
+			}
+			*p++ = '\0';
+			l = strtol(p, &ccp, 0);
+			if (ccp == p || l < 0 || l > INT_MAX) {
+			badafterall:
+				bb_error_msg("%s/%s: bad rpc version", sep->se_service, p);
+				goto more;
+			}
+			sep->se_rpcversl = sep->se_rpcversh = l;
+			if (*ccp == '-') {
+				p = ccp + 1;
+				l = strtol(p, &ccp, 0);
+				if (ccp == p || l < 0 || l > INT_MAX || l < sep->se_rpcversl || *ccp)
+					goto badafterall;
+				sep->se_rpcversh = l;
+			} else if (*ccp != '\0')
+				goto badafterall;
 #else
-	bb_error_msg ("%s: rpc services not supported", sep->se_service);
+		bb_error_msg("%s: rpc services not supported", sep->se_service);
 #endif
+		}
 	}
-  }
-  arg = skip (&cp);
-  if (arg == NULL)
-	goto more;
+	arg = skip(&cp);
+	if (arg == NULL)
+		goto more;
 
-  {
-	char *s = strchr (arg, '.');
-	if (s) {
-	  *s++ = '\0';
-	  sep->se_max = atoi (s);
-	} else
-	  sep->se_max = toomany;
-  }
-  sep->se_wait = strcmp (arg, "wait") == 0;
-  /* if ((arg = skip(&cp, 1)) == NULL) */
-  /* goto more; */
-  sep->se_user = xxstrdup (skip (&cp));
-  arg = strchr (sep->se_user, '.');
-  if (arg == NULL)
-	arg = strchr (sep->se_user, ':');
-  if (arg) {
-	*arg++ = '\0';
-	sep->se_group = xstrdup (arg);
-  }
-  /* if ((arg = skip(&cp, 1)) == NULL) */
-  /* goto more; */
+	{
+		char *s = strchr(arg, '.');
+		if (s) {
+			*s++ = '\0';
+			sep->se_max = atoi(s);
+		} else
+			sep->se_max = toomany;
+	}
+	sep->se_wait = strcmp(arg, "wait") == 0;
+	/* if ((arg = skip(&cp, 1)) == NULL) */
+	/* goto more; */
+	sep->se_user = xxstrdup(skip(&cp));
+	arg = strchr(sep->se_user, '.');
+	if (arg == NULL)
+		arg = strchr(sep->se_user, ':');
+	if (arg) {
+		*arg++ = '\0';
+		sep->se_group = xstrdup(arg);
+	}
+	/* if ((arg = skip(&cp, 1)) == NULL) */
+	/* goto more; */
 
-  sep->se_server = xxstrdup (skip (&cp));
-  if (strcmp (sep->se_server, "internal") == 0) {
+	sep->se_server = xxstrdup(skip(&cp));
+	if (strcmp(sep->se_server, "internal") == 0) {
 #ifdef INETD_FEATURE_ENABLED
-	const struct builtin *bi;
+		const struct builtin *bi;
 
-	for (bi = builtins; bi->bi_service; bi++)
-	  if (bi->bi_socktype == sep->se_socktype &&
-		  strcmp (bi->bi_service, sep->se_service) == 0)
-		break;
-	if (bi->bi_service == 0) {
-	  bb_error_msg ("internal service %s unknown", sep->se_service);
-	  goto more;
-	}
-	sep->se_bi = bi;
-	sep->se_wait = bi->bi_wait;
+		for (bi = builtins; bi->bi_service; bi++)
+			if (bi->bi_socktype == sep->se_socktype &&
+					strcmp(bi->bi_service, sep->se_service) == 0)
+				break;
+		if (bi->bi_service == 0) {
+			bb_error_msg("internal service %s unknown", sep->se_service);
+			goto more;
+		}
+		sep->se_bi = bi;
+		sep->se_wait = bi->bi_wait;
 #else
-	bb_perror_msg ("internal service %s unknown", sep->se_service);
-	goto more;
+		bb_perror_msg("internal service %s unknown", sep->se_service);
+		goto more;
 #endif
-  }
+	}
 #ifdef INETD_FEATURE_ENABLED
-    else
-	sep->se_bi = NULL;
+		else
+		sep->se_bi = NULL;
 #endif
-  argc = 0;
-  for (arg = skip (&cp); cp; arg = skip (&cp)) {
-	if (argc < MAXARGV)
-	  sep->se_argv[argc++] = xxstrdup (arg);
-  }
-  while (argc <= MAXARGV)
-	sep->se_argv[argc++] = NULL;
+	argc = 0;
+	for (arg = skip(&cp); cp; arg = skip(&cp)) {
+		if (argc < MAXARGV)
+			sep->se_argv[argc++] = xxstrdup(arg);
+	}
+	while (argc <= MAXARGV)
+		sep->se_argv[argc++] = NULL;
 
-  /*
-   * Now that we've processed the entire line, check if the hostname
-   * specifier was a comma separated list of hostnames. If so
-   * we'll make new entries for each address.
-   */
-  while ((hostdelim = strrchr (sep->se_hostaddr, ',')) != NULL) {
-	nsep = dupconfig (sep);
-
 	/*
-	 * NULL terminate the hostname field of the existing entry,
-	 * and make a dup for the new entry.
+	 * Now that we've processed the entire line, check if the hostname
+	 * specifier was a comma separated list of hostnames. If so
+	 * we'll make new entries for each address.
 	 */
-	*hostdelim++ = '\0';
-	nsep->se_hostaddr = xstrdup (hostdelim);
+	while ((hostdelim = strrchr(sep->se_hostaddr, ',')) != NULL) {
+		nsep = dupconfig(sep);
 
-	nsep->se_next = sep->se_next;
-	sep->se_next = nsep;
-  }
+		/*
+		 * NULL terminate the hostname field of the existing entry,
+		 * and make a dup for the new entry.
+		 */
+		*hostdelim++ = '\0';
+		nsep->se_hostaddr = xstrdup(hostdelim);
 
-  nsep = sep;
-  while (nsep != NULL) {
-	nsep->se_checked = 1;
-	if (nsep->se_family == AF_INET) {
-	  if (!strcmp (nsep->se_hostaddr, "*"))
-		nsep->se_ctrladdr_in.sin_addr.s_addr = INADDR_ANY;
-	  else if (!inet_aton (nsep->se_hostaddr, &nsep->se_ctrladdr_in.sin_addr)) {
-		struct hostent *hp;
+		nsep->se_next = sep->se_next;
+		sep->se_next = nsep;
+	}
 
-		hp = gethostbyname (nsep->se_hostaddr);
-		if (hp == 0) {
-		  bb_error_msg ("%s: unknown host", nsep->se_hostaddr);
-		  nsep->se_checked = 0;
-		  goto skip;
-		} else if (hp->h_addrtype != AF_INET) {
-		  bb_error_msg ("%s: address isn't an Internet "
-				  "address", nsep->se_hostaddr);
-		  nsep->se_checked = 0;
-		  goto skip;
-		} else {
-		  int i = 1;
+	nsep = sep;
+	while (nsep != NULL) {
+		nsep->se_checked = 1;
+		if (nsep->se_family == AF_INET) {
+			if (!strcmp(nsep->se_hostaddr, "*"))
+				nsep->se_ctrladdr_in.sin_addr.s_addr = INADDR_ANY;
+			else if (!inet_aton(nsep->se_hostaddr, &nsep->se_ctrladdr_in.sin_addr)) {
+				struct hostent *hp;
 
-		  memmove (&nsep->se_ctrladdr_in.sin_addr,
-				   hp->h_addr_list[0], sizeof (struct in_addr));
-		  while (hp->h_addr_list[i] != NULL) {
-			psep = dupconfig (nsep);
-			psep->se_hostaddr = xxstrdup (nsep->se_hostaddr);
-			psep->se_checked = 1;
-			memmove (&psep->se_ctrladdr_in.sin_addr,
-					 hp->h_addr_list[i], sizeof (struct in_addr));
-			psep->se_ctrladdr_size = sizeof (psep->se_ctrladdr_in);
-			i++;
-			/* Prepend to list, don't want to look up its */
-			/* hostname again. */
-			psep->se_next = sep;
-			sep = psep;
-		  }
+				hp = gethostbyname(nsep->se_hostaddr);
+				if (hp == 0) {
+					bb_error_msg("%s: unknown host", nsep->se_hostaddr);
+					nsep->se_checked = 0;
+					goto skip;
+				} else if (hp->h_addrtype != AF_INET) {
+					bb_error_msg("%s: address isn't an Internet "
+								  "address", nsep->se_hostaddr);
+					nsep->se_checked = 0;
+					goto skip;
+				} else {
+					int i = 1;
+
+					memmove(&nsep->se_ctrladdr_in.sin_addr,
+								   hp->h_addr_list[0], sizeof(struct in_addr));
+					while (hp->h_addr_list[i] != NULL) {
+						psep = dupconfig(nsep);
+						psep->se_hostaddr = xxstrdup(nsep->se_hostaddr);
+						psep->se_checked = 1;
+						memmove(&psep->se_ctrladdr_in.sin_addr,
+								     hp->h_addr_list[i], sizeof(struct in_addr));
+						psep->se_ctrladdr_size = sizeof(psep->se_ctrladdr_in);
+						i++;
+						/* Prepend to list, don't want to look up */
+						/* its hostname again. */
+						psep->se_next = sep;
+						sep = psep;
+					}
+				}
+			}
 		}
-	  }
+/* XXX BUG?: is this skip: label supposed to remain? */
+	skip:
+		nsep = nsep->se_next;
 	}
-/* XXX BUG?: is this skip: label supposed to remain? */
-  skip:
-	nsep = nsep->se_next;
-  }
 
-  /*
-   * Finally, free any entries which failed the gethostbyname
-   * check.
-   */
-  psep = NULL;
-  nsep = sep;
-  while (nsep != NULL) {
-	servtab_t *tsep;
+	/*
+	 * Finally, free any entries which failed the gethostbyname
+	 * check.
+	 */
+	psep = NULL;
+	nsep = sep;
+	while (nsep != NULL) {
+		servtab_t *tsep;
 
-	if (nsep->se_checked == 0) {
-	  tsep = nsep;
-	  if (psep == NULL) {
-		sep = nsep->se_next;
-		nsep = sep;
-	  } else {
-		nsep = nsep->se_next;
-		psep->se_next = nsep;
-	  }
-	  freeconfig (tsep);
-	} else {
-	  nsep->se_checked = 0;
-	  psep = nsep;
-	  nsep = nsep->se_next;
+		if (nsep->se_checked == 0) {
+			tsep = nsep;
+			if (psep == NULL) {
+				sep = nsep->se_next;
+				nsep = sep;
+			} else {
+				nsep = nsep->se_next;
+				psep->se_next = nsep;
+			}
+			freeconfig(tsep);
+		} else {
+			nsep->se_checked = 0;
+			psep = nsep;
+			nsep = nsep->se_next;
+		}
 	}
-  }
 
-  return (sep);
+	return sep;
 }
 
-#define Block_Using_Signals(m) do {     sigemptyset(&m); \
-					sigaddset(&m, SIGCHLD); \
-					sigaddset(&m, SIGHUP); \
-					sigaddset(&m, SIGALRM); \
-					sigprocmask(SIG_BLOCK, &m, NULL); \
-				} while(0)
+#define Block_Using_Signals(m) do { \
+	sigemptyset(&m); \
+	sigaddset(&m, SIGCHLD); \
+	sigaddset(&m, SIGHUP); \
+	sigaddset(&m, SIGALRM); \
+	sigprocmask(SIG_BLOCK, &m, NULL); \
+} while(0)
 
-
-static servtab_t *enter (servtab_t *cp)
+static servtab_t *enter(servtab_t *cp)
 {
-  servtab_t *sep;
-  sigset_t omask;
+	servtab_t *sep;
+	sigset_t omask;
 
-  sep = new_servtab();
-  *sep = *cp;
-  sep->se_fd = -1;
+	sep = new_servtab();
+	*sep = *cp;
+	sep->se_fd = -1;
 #ifdef CONFIG_FEATURE_INETD_RPC
-  sep->se_rpcprog = -1;
+	sep->se_rpcprog = -1;
 #endif
-  Block_Using_Signals(omask);
-  sep->se_next = servtab;
-  servtab = sep;
-  sigprocmask(SIG_UNBLOCK, &omask, NULL);
-  return (sep);
+	Block_Using_Signals(omask);
+	sep->se_next = servtab;
+	servtab = sep;
+	sigprocmask(SIG_UNBLOCK, &omask, NULL);
+	return sep;
 }
 
-static int matchconf (servtab_t *old, servtab_t *new)
+static int matchconf(servtab_t *old, servtab_t *new)
 {
-  if (strcmp (old->se_service, new->se_service) != 0)
-	return (0);
+	if (strcmp(old->se_service, new->se_service) != 0)
+		return 0;
 
-  if (strcmp (old->se_hostaddr, new->se_hostaddr) != 0)
-	return (0);
+	if (strcmp(old->se_hostaddr, new->se_hostaddr) != 0)
+		return 0;
 
-  if (strcmp (old->se_proto, new->se_proto) != 0)
-	return (0);
+	if (strcmp(old->se_proto, new->se_proto) != 0)
+		return 0;
 
-  /*
-   * If the new servtab is bound to a specific address, check that the
-   * old servtab is bound to the same entry. If the new service is not
-   * bound to a specific address then the check of se_hostaddr above
-   * is sufficient.
-   */
+	/*
+	 * If the new servtab is bound to a specific address, check that the
+	 * old servtab is bound to the same entry. If the new service is not
+	 * bound to a specific address then the check of se_hostaddr above
+	 * is sufficient.
+	 */
 
-  if (old->se_family == AF_INET && new->se_family == AF_INET &&
-	  memcmp (&old->se_ctrladdr_in.sin_addr,
-			  &new->se_ctrladdr_in.sin_addr,
-			  sizeof (new->se_ctrladdr_in.sin_addr)) != 0)
-	return (0);
+	if (old->se_family == AF_INET && new->se_family == AF_INET &&
+			memcmp(&old->se_ctrladdr_in.sin_addr,
+					&new->se_ctrladdr_in.sin_addr,
+					sizeof(new->se_ctrladdr_in.sin_addr)) != 0)
+		return 0;
 
 #ifdef CONFIG_FEATURE_IPV6
-  if (old->se_family == AF_INET6 && new->se_family == AF_INET6 &&
-	  memcmp (&old->se_ctrladdr_in6.sin6_addr,
-			  &new->se_ctrladdr_in6.sin6_addr,
-			  sizeof (new->se_ctrladdr_in6.sin6_addr)) != 0)
-	return (0);
+	if (old->se_family == AF_INET6 && new->se_family == AF_INET6 &&
+			memcmp(&old->se_ctrladdr_in6.sin6_addr,
+					&new->se_ctrladdr_in6.sin6_addr,
+					sizeof(new->se_ctrladdr_in6.sin6_addr)) != 0)
+		return 0;
 #endif
-  return (1);
+	return 1;
 }
 
-static void config (int sig ATTRIBUTE_UNUSED)
+static void config(int sig ATTRIBUTE_UNUSED)
 {
-  servtab_t *sep, *cp, **sepp;
-  sigset_t omask;
-  size_t n;
-  char protoname[10];
+	servtab_t *sep, *cp, **sepp;
+	sigset_t omask;
+	size_t n;
+	char protoname[10];
 
-  if (!setconfig ()) {
-	bb_perror_msg ("%s", CONFIG);
-	return;
-  }
-  for (sep = servtab; sep; sep = sep->se_next)
-	sep->se_checked = 0;
-  cp = getconfigent ();
-  while (cp != NULL) {
+	if (!setconfig()) {
+		bb_perror_msg("%s", CONFIG);
+		return;
+	}
 	for (sep = servtab; sep; sep = sep->se_next)
-	  if (matchconf (sep, cp))
-		break;
+		sep->se_checked = 0;
+	cp = getconfigent();
+	while (cp != NULL) {
+		for (sep = servtab; sep; sep = sep->se_next)
+			if (matchconf(sep, cp))
+				break;
 
-	if (sep != 0) {
-	  int i;
+		if (sep != 0) {
+			int i;
 
 #define SWAP(type, a, b) do {type c=(type)a; a=(type)b; b=(type)c;} while (0)
 
-	  Block_Using_Signals(omask);
-	  /*
-	   * sep->se_wait may be holding the pid of a daemon
-	   * that we're waiting for.  If so, don't overwrite
-	   * it unless the config file explicitly says don't
-	   * wait.
-	   */
-	  if (
+			Block_Using_Signals(omask);
+			/*
+			 * sep->se_wait may be holding the pid of a daemon
+			 * that we're waiting for.  If so, don't overwrite
+			 * it unless the config file explicitly says don't
+			 * wait.
+			 */
+			if (
 #ifdef INETD_FEATURE_ENABLED
-		   cp->se_bi == 0 &&
+					 cp->se_bi == 0 &&
 #endif
-		(sep->se_wait == 1 || cp->se_wait == 0))
-		sep->se_wait = cp->se_wait;
-	  SWAP (int, cp->se_max, sep->se_max);
-	  SWAP (char *, sep->se_user, cp->se_user);
-	  SWAP (char *, sep->se_group, cp->se_group);
-	  SWAP (char *, sep->se_server, cp->se_server);
-	  for (i = 0; i < MAXARGV; i++)
-		SWAP (char *, sep->se_argv[i], cp->se_argv[i]);
+				(sep->se_wait == 1 || cp->se_wait == 0))
+				sep->se_wait = cp->se_wait;
+			SWAP(int, cp->se_max, sep->se_max);
+			SWAP(char *, sep->se_user, cp->se_user);
+			SWAP(char *, sep->se_group, cp->se_group);
+			SWAP(char *, sep->se_server, cp->se_server);
+			for (i = 0; i < MAXARGV; i++)
+				SWAP(char *, sep->se_argv[i], cp->se_argv[i]);
 #undef SWAP
 
 #ifdef CONFIG_FEATURE_INETD_RPC
-	  if (isrpcservice (sep))
-		unregister_rpc (sep);
-	  sep->se_rpcversl = cp->se_rpcversl;
-	  sep->se_rpcversh = cp->se_rpcversh;
+			if (isrpcservice(sep))
+				unregister_rpc(sep);
+			sep->se_rpcversl = cp->se_rpcversl;
+			sep->se_rpcversh = cp->se_rpcversh;
 #endif
-	  sigprocmask(SIG_UNBLOCK, &omask, NULL);
-	  freeconfig (cp);
-	} else {
-	  sep = enter (cp);
-	}
-	sep->se_checked = 1;
+			sigprocmask(SIG_UNBLOCK, &omask, NULL);
+			freeconfig(cp);
+		} else {
+			sep = enter(cp);
+		}
+		sep->se_checked = 1;
 
-	switch (sep->se_family) {
-	case AF_UNIX:
-	  if (sep->se_fd != -1)
-		break;
-	  (void) unlink (sep->se_service);
-	  n = strlen (sep->se_service);
-	  if (n > sizeof sep->se_ctrladdr_un.sun_path - 1)
-		n = sizeof sep->se_ctrladdr_un.sun_path - 1;
-	  safe_strncpy (sep->se_ctrladdr_un.sun_path, sep->se_service, n + 1);
-	  sep->se_ctrladdr_un.sun_family = AF_UNIX;
-	  sep->se_ctrladdr_size = n + sizeof sep->se_ctrladdr_un.sun_family;
-	  setup (sep);
-	  break;
-	case AF_INET:
-	  sep->se_ctrladdr_in.sin_family = AF_INET;
-	  /* se_ctrladdr_in was set in getconfigent */
-	  sep->se_ctrladdr_size = sizeof sep->se_ctrladdr_in;
+		switch (sep->se_family) {
+		case AF_UNIX:
+			if (sep->se_fd != -1)
+				break;
+			(void) unlink(sep->se_service);
+			n = strlen(sep->se_service);
+			if (n > sizeof sep->se_ctrladdr_un.sun_path - 1)
+				n = sizeof sep->se_ctrladdr_un.sun_path - 1;
+			safe_strncpy(sep->se_ctrladdr_un.sun_path, sep->se_service, n + 1);
+			sep->se_ctrladdr_un.sun_family = AF_UNIX;
+			sep->se_ctrladdr_size = n + sizeof sep->se_ctrladdr_un.sun_family;
+			setup(sep);
+			break;
+		case AF_INET:
+			sep->se_ctrladdr_in.sin_family = AF_INET;
+			/* se_ctrladdr_in was set in getconfigent */
+			sep->se_ctrladdr_size = sizeof sep->se_ctrladdr_in;
 
 #ifdef CONFIG_FEATURE_INETD_RPC
-	  if (isrpcservice (sep)) {
-		struct rpcent *rp;
+			if (isrpcservice(sep)) {
+				struct rpcent *rp;
 
-		sep->se_rpcprog = atoi (sep->se_service);
-		if (sep->se_rpcprog == 0) {
-		  rp = getrpcbyname (sep->se_service);
-		  if (rp == 0) {
-			bb_error_msg ("%s: unknown rpc service", sep->se_service);
-			goto serv_unknown;
-		  }
-		  sep->se_rpcprog = rp->r_number;
-		}
-		if (sep->se_fd == -1)
-		  setup (sep);
-		if (sep->se_fd != -1)
-		  register_rpc (sep);
-	  } else
+				sep->se_rpcprog = atoi(sep->se_service);
+				if (sep->se_rpcprog == 0) {
+					rp = getrpcbyname(sep->se_service);
+					if (rp == 0) {
+						bb_error_msg("%s: unknown rpc service", sep->se_service);
+						goto serv_unknown;
+					}
+					sep->se_rpcprog = rp->r_number;
+				}
+				if (sep->se_fd == -1)
+					setup(sep);
+				if (sep->se_fd != -1)
+					register_rpc(sep);
+			} else
 #endif
-	     {
-		u_short port = htons (atoi (sep->se_service));
+				 {
+				u_short port = htons(atoi(sep->se_service));
 
-		if (!port) {
-		   /*XXX*/ strncpy (protoname, sep->se_proto, sizeof (protoname));
-		  if (isdigit (protoname[strlen (protoname) - 1]))
-			protoname[strlen (protoname) - 1] = '\0';
-		  sp = getservbyname (sep->se_service, protoname);
-		  if (sp == 0) {
-			bb_error_msg ("%s/%s: unknown service",
-				sep->se_service, sep->se_proto);
-			goto serv_unknown;
-		  }
-		  port = sp->s_port;
-		}
-		if (port != sep->se_ctrladdr_in.sin_port) {
-		  sep->se_ctrladdr_in.sin_port = port;
-		  if (sep->se_fd != -1) {
-			FD_CLR (sep->se_fd, &allsock);
-			nsock--;
-			(void) close (sep->se_fd);
-		  }
-		  sep->se_fd = -1;
-		}
-		if (sep->se_fd == -1)
-		  setup (sep);
-	  }
-	  break;
+				if (!port) {
+					 /*XXX*/ strncpy(protoname, sep->se_proto, sizeof(protoname));
+					if (isdigit(protoname[strlen(protoname) - 1]))
+						protoname[strlen(protoname) - 1] = '\0';
+					sp = getservbyname(sep->se_service, protoname);
+					if (sp == 0) {
+						bb_error_msg("%s/%s: unknown service",
+								sep->se_service, sep->se_proto);
+						goto serv_unknown;
+					}
+					port = sp->s_port;
+				}
+				if (port != sep->se_ctrladdr_in.sin_port) {
+					sep->se_ctrladdr_in.sin_port = port;
+					if (sep->se_fd != -1) {
+						FD_CLR(sep->se_fd, &allsock);
+						nsock--;
+						(void) close(sep->se_fd);
+					}
+					sep->se_fd = -1;
+				}
+				if (sep->se_fd == -1)
+					setup(sep);
+			}
+			break;
 #ifdef CONFIG_FEATURE_IPV6
-	case AF_INET6:
-	  sep->se_ctrladdr_in6.sin6_family = AF_INET6;
-	  /* se_ctrladdr_in was set in getconfigent */
-	  sep->se_ctrladdr_size = sizeof sep->se_ctrladdr_in6;
+		case AF_INET6:
+			sep->se_ctrladdr_in6.sin6_family = AF_INET6;
+			/* se_ctrladdr_in was set in getconfigent */
+			sep->se_ctrladdr_size = sizeof sep->se_ctrladdr_in6;
 
 #ifdef CONFIG_FEATURE_INETD_RPC
-	  if (isrpcservice (sep)) {
-		struct rpcent *rp;
+			if (isrpcservice(sep)) {
+				struct rpcent *rp;
 
-		sep->se_rpcprog = atoi (sep->se_service);
-		if (sep->se_rpcprog == 0) {
-		  rp = getrpcbyname (sep->se_service);
-		  if (rp == 0) {
-			bb_error_msg ("%s: unknown rpc service", sep->se_service);
-			goto serv_unknown;
-		  }
-		  sep->se_rpcprog = rp->r_number;
-		}
-		if (sep->se_fd == -1)
-		  setup (sep);
-		if (sep->se_fd != -1)
-		  register_rpc (sep);
-	  } else
+				sep->se_rpcprog = atoi(sep->se_service);
+				if (sep->se_rpcprog == 0) {
+					rp = getrpcbyname(sep->se_service);
+					if (rp == 0) {
+						bb_error_msg("%s: unknown rpc service", sep->se_service);
+						goto serv_unknown;
+					}
+					sep->se_rpcprog = rp->r_number;
+				}
+				if (sep->se_fd == -1)
+					setup(sep);
+				if (sep->se_fd != -1)
+					register_rpc(sep);
+			} else
 #endif
-		{
-		u_short port = htons (atoi (sep->se_service));
+				{
+				u_short port = htons(atoi(sep->se_service));
 
-		if (!port) {
-		   /*XXX*/ strncpy (protoname, sep->se_proto, sizeof (protoname));
-		  if (isdigit (protoname[strlen (protoname) - 1]))
-			protoname[strlen (protoname) - 1] = '\0';
-		  sp = getservbyname (sep->se_service, protoname);
-		  if (sp == 0) {
-			bb_error_msg ("%s/%s: unknown service",
-				sep->se_service, sep->se_proto);
-			goto serv_unknown;
-		  }
-		  port = sp->s_port;
+				if (!port) {
+					 /*XXX*/ strncpy(protoname, sep->se_proto, sizeof(protoname));
+					if (isdigit(protoname[strlen(protoname) - 1]))
+						protoname[strlen(protoname) - 1] = '\0';
+					sp = getservbyname(sep->se_service, protoname);
+					if (sp == 0) {
+						bb_error_msg("%s/%s: unknown service",
+								sep->se_service, sep->se_proto);
+						goto serv_unknown;
+					}
+					port = sp->s_port;
+				}
+				if (port != sep->se_ctrladdr_in6.sin6_port) {
+					sep->se_ctrladdr_in6.sin6_port = port;
+					if (sep->se_fd != -1) {
+						FD_CLR(sep->se_fd, &allsock);
+						nsock--;
+						(void) close(sep->se_fd);
+					}
+					sep->se_fd = -1;
+				}
+				if (sep->se_fd == -1)
+					setup(sep);
+			}
+			break;
+#endif /* CONFIG_FEATURE_IPV6 */
 		}
-		if (port != sep->se_ctrladdr_in6.sin6_port) {
-		  sep->se_ctrladdr_in6.sin6_port = port;
-		  if (sep->se_fd != -1) {
-			FD_CLR (sep->se_fd, &allsock);
+	serv_unknown:
+		if (cp->se_next != NULL) {
+			servtab_t *tmp = cp;
+
+			cp = cp->se_next;
+			free(tmp);
+		} else {
+			free(cp);
+			cp = getconfigent();
+		}
+	}
+	endconfig();
+	/*
+	 * Purge anything not looked at above.
+	 */
+	Block_Using_Signals(omask);
+	sepp = &servtab;
+	while ((sep = *sepp)) {
+		if (sep->se_checked) {
+			sepp = &sep->se_next;
+			continue;
+		}
+		*sepp = sep->se_next;
+		if (sep->se_fd != -1) {
+			FD_CLR(sep->se_fd, &allsock);
 			nsock--;
-			(void) close (sep->se_fd);
-		  }
-		  sep->se_fd = -1;
+			(void) close(sep->se_fd);
 		}
-		if (sep->se_fd == -1)
-		  setup (sep);
-	  }
-	  break;
-#endif /* CONFIG_FEATURE_IPV6 */
-	}
-  serv_unknown:
-	if (cp->se_next != NULL) {
-	  servtab_t *tmp = cp;
-
-	  cp = cp->se_next;
-	  free (tmp);
-	} else {
-	  free (cp);
-	  cp = getconfigent ();
-	}
-  }
-  endconfig ();
-  /*
-   * Purge anything not looked at above.
-   */
-  Block_Using_Signals(omask);
-  sepp = &servtab;
-  while ((sep = *sepp)) {
-	if (sep->se_checked) {
-	  sepp = &sep->se_next;
-	  continue;
-	}
-	*sepp = sep->se_next;
-	if (sep->se_fd != -1) {
-	  FD_CLR (sep->se_fd, &allsock);
-	  nsock--;
-	  (void) close (sep->se_fd);
-	}
 #ifdef CONFIG_FEATURE_INETD_RPC
-	if (isrpcservice (sep))
-	  unregister_rpc (sep);
+		if (isrpcservice(sep))
+			unregister_rpc(sep);
 #endif
-	if (sep->se_family == AF_UNIX)
-	  (void) unlink (sep->se_service);
-	freeconfig (sep);
-	free (sep);
-  }
-  sigprocmask(SIG_UNBLOCK, &omask, NULL);
+		if (sep->se_family == AF_UNIX)
+			(void) unlink(sep->se_service);
+		freeconfig(sep);
+		free(sep);
+	}
+	sigprocmask(SIG_UNBLOCK, &omask, NULL);
 }
 
 
-static void reapchild (int sig ATTRIBUTE_UNUSED)
+static void reapchild(int sig ATTRIBUTE_UNUSED)
 {
-  pid_t pid;
-  int save_errno = errno, status;
-  servtab_t *sep;
+	pid_t pid;
+	int save_errno = errno, status;
+	servtab_t *sep;
 
-  for (;;) {
-	pid = wait3 (&status, WNOHANG, NULL);
-	if (pid <= 0)
-	  break;
-	for (sep = servtab; sep; sep = sep->se_next)
-	  if (sep->se_wait == pid) {
-		if (WIFEXITED (status) && WEXITSTATUS (status))
-		  bb_error_msg("%s: exit status 0x%x",
-				  sep->se_server, WEXITSTATUS (status));
-		else if (WIFSIGNALED (status))
-		  bb_error_msg("%s: exit signal 0x%x",
-				  sep->se_server, WTERMSIG (status));
-		sep->se_wait = 1;
-		FD_SET (sep->se_fd, &allsock);
-		nsock++;
-	  }
-  }
-  errno = save_errno;
+	for (;;) {
+		pid = wait3(&status, WNOHANG, NULL);
+		if (pid <= 0)
+			break;
+		for (sep = servtab; sep; sep = sep->se_next)
+			if (sep->se_wait == pid) {
+				if (WIFEXITED(status) && WEXITSTATUS(status))
+					bb_error_msg("%s: exit status 0x%x",
+							sep->se_server, WEXITSTATUS(status));
+				else if (WIFSIGNALED(status))
+					bb_error_msg("%s: exit signal 0x%x",
+							sep->se_server, WTERMSIG(status));
+				sep->se_wait = 1;
+				FD_SET(sep->se_fd, &allsock);
+				nsock++;
+			}
+	}
+	errno = save_errno;
 }
 
-static void retry (int sig ATTRIBUTE_UNUSED)
+static void retry(int sig ATTRIBUTE_UNUSED)
 {
-  servtab_t *sep;
+	servtab_t *sep;
 
-  timingout = 0;
-  for (sep = servtab; sep; sep = sep->se_next) {
-	if (sep->se_fd == -1) {
-	  switch (sep->se_family) {
-	  case AF_UNIX:
-	  case AF_INET:
+	timingout = 0;
+	for (sep = servtab; sep; sep = sep->se_next) {
+		if (sep->se_fd == -1) {
+			switch (sep->se_family) {
+			case AF_UNIX:
+			case AF_INET:
 #ifdef CONFIG_FEATURE_IPV6
-	  case AF_INET6:
+			case AF_INET6:
 #endif
-		setup (sep);
+				setup(sep);
 #ifdef CONFIG_FEATURE_INETD_RPC
-		if (sep->se_fd != -1 && isrpcservice (sep))
-		  register_rpc (sep);
+				if (sep->se_fd != -1 && isrpcservice(sep))
+					register_rpc(sep);
 #endif
-		break;
-	  }
+				break;
+			}
+		}
 	}
-  }
 }
 
-static void goaway (int sig ATTRIBUTE_UNUSED)
+static void goaway(int sig ATTRIBUTE_UNUSED)
 {
-  servtab_t *sep;
+	servtab_t *sep;
 
-  /* XXX signal race walking sep list */
-  for (sep = servtab; sep; sep = sep->se_next) {
-	if (sep->se_fd == -1)
-	  continue;
+	/* XXX signal race walking sep list */
+	for (sep = servtab; sep; sep = sep->se_next) {
+		if (sep->se_fd == -1)
+			continue;
 
-	switch (sep->se_family) {
-	case AF_UNIX:
-	  (void) unlink (sep->se_service);
-	  break;
-	case AF_INET:
+		switch (sep->se_family) {
+		case AF_UNIX:
+			(void) unlink(sep->se_service);
+			break;
+		case AF_INET:
 #ifdef CONFIG_FEATURE_IPV6
-	case AF_INET6:
+		case AF_INET6:
 #endif
 #ifdef CONFIG_FEATURE_INETD_RPC
-	  if (sep->se_wait == 1 && isrpcservice (sep))
-		unregister_rpc (sep);   /* XXX signal race */
+			if (sep->se_wait == 1 && isrpcservice(sep))
+				unregister_rpc(sep);   /* XXX signal race */
 #endif
-	  break;
+			break;
+		}
+		(void) close(sep->se_fd);
 	}
-	(void) close (sep->se_fd);
-  }
-  (void) unlink (_PATH_INETDPID);
-  exit (0);
+	(void) unlink(_PATH_INETDPID);
+	exit(0);
 }
 
 
@@ -1201,314 +1201,316 @@
 static char *LastArg;
 
 static void
-inetd_setproctitle (char *a, int s)
+inetd_setproctitle(char *a, int s)
 {
-  socklen_t size;
-  char *cp;
-  struct sockaddr_in prt_sin;
-  char buf[80];
+	socklen_t size;
+	char *cp;
+	struct sockaddr_in prt_sin;
+	char buf[80];
 
-  cp = Argv[0];
-  size = sizeof (prt_sin);
-  (void) snprintf (buf, sizeof buf, "-%s", a);
-  if (getpeername (s, (struct sockaddr *) &prt_sin, &size) == 0) {
-	char *sa = inet_ntoa (prt_sin.sin_addr);
+	cp = Argv[0];
+	size = sizeof(prt_sin);
+	(void) snprintf(buf, sizeof buf, "-%s", a);
+	if (getpeername(s, (struct sockaddr *) &prt_sin, &size) == 0) {
+		char *sa = inet_ntoa(prt_sin.sin_addr);
 
-	buf[sizeof (buf) - 1 - strlen (sa) - 3] = '\0';
-	strcat (buf, " [");
-	strcat (buf, sa);
-	strcat (buf, "]");
-  }
-  strncpy (cp, buf, LastArg - cp);
-  cp += strlen (cp);
-  while (cp < LastArg)
-	*cp++ = ' ';
+		buf[sizeof(buf) - 1 - strlen(sa) - 3] = '\0';
+		strcat(buf, " [");
+		strcat(buf, sa);
+		strcat(buf, "]");
+	}
+	strncpy(cp, buf, LastArg - cp);
+	cp += strlen(cp);
+	while (cp < LastArg)
+		*cp++ = ' ';
 }
 #endif
 
 
 int
-inetd_main (int argc, char *argv[])
+inetd_main(int argc, char *argv[])
 {
-  servtab_t *sep;
-  struct passwd *pwd;
-  struct group *grp = NULL;
-  int tmpint;
-  struct sigaction sa, sapipe;
-  int opt;
-  pid_t pid;
-  char buf[50];
-  char *stoomany;
-  sigset_t omask, wait_mask;
+	servtab_t *sep;
+	struct passwd *pwd;
+	struct group *grp = NULL;
+	int tmpint;
+	struct sigaction sa, sapipe;
+	int opt;
+	pid_t pid;
+	char buf[50];
+	char *stoomany;
+	sigset_t omask, wait_mask;
 
 #ifdef INETD_SETPROCTITLE
-  extern char **environ;
-  char **envp = environ;
+	extern char **environ;
+	char **envp = environ;
 
-  Argv = argv;
-  if (envp == 0 || *envp == 0)
-	envp = argv;
-  while (*envp)
-	envp++;
-  LastArg = envp[-1] + strlen (envp[-1]);
+	Argv = argv;
+	if (envp == 0 || *envp == 0)
+		envp = argv;
+	while (*envp)
+		envp++;
+	LastArg = envp[-1] + strlen(envp[-1]);
 #endif
 
-  openlog (bb_applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
+	openlog(bb_applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
 
-  opt = bb_getopt_ulflags (argc, argv, "R:f", &stoomany);
-  if(opt & 1) {
-	char *e;
+	opt = bb_getopt_ulflags(argc, argv, "R:f", &stoomany);
+	if(opt & 1) {
+		char *e;
 
-	toomany = strtoul (stoomany, &e, 0);
-	if (!(toomany >= 0 && *e == '\0')) {
-		toomany = TOOMANY;
-		bb_perror_msg ("-R %s: bad value for service invocation rate", stoomany);
+		toomany = strtoul(stoomany, &e, 0);
+		if (!(toomany >= 0 && *e == '\0')) {
+				toomany = TOOMANY;
+				bb_perror_msg("-R %s: bad value for service invocation rate", stoomany);
+		}
 	}
-  }
-  argc -= optind;
-  argv += optind;
+	argc -= optind;
+	argv += optind;
 
-  uid = getuid ();
-  if (uid != 0)
-	CONFIG = NULL;
-  if (argc > 0)
-	CONFIG = argv[0];
-  if (CONFIG == NULL)
-	bb_error_msg_and_die ("non-root must specify a config file");
+	uid = getuid();
+	if (uid != 0)
+		CONFIG = NULL;
+	if (argc > 0)
+		CONFIG = argv[0];
+	if (CONFIG == NULL)
+		bb_error_msg_and_die("non-root must specify a config file");
 
-  if (!(opt & 2)) {
+	if (!(opt & 2)) {
 #ifdef BB_NOMMU
-	/* reexec for vfork() do continue parent */
-	vfork_daemon_rexec (0, 0, argc, argv, "-f");
+		/* reexec for vfork() do continue parent */
+		vfork_daemon_rexec(0, 0, argc, argv, "-f");
 #else
-	xdaemon (0, 0);
+		xdaemon(0, 0);
 #endif
-  } else {
-	setsid ();
-  }
-  logmode = LOGMODE_SYSLOG;
+	} else {
+		setsid();
+	}
+	logmode = LOGMODE_SYSLOG;
 
-  if (uid == 0) {
-	gid_t gid = getgid ();
+	if (uid == 0) {
+		gid_t gid = getgid();
 
-	/* If run by hand, ensure groups vector gets trashed */
-	setgroups (1, &gid);
-  }
+		/* If run by hand, ensure groups vector gets trashed */
+		setgroups(1, &gid);
+	}
 
-  {
-	FILE *fp;
+	{
+		FILE *fp = fopen(_PATH_INETDPID, "w");
 
-	if ((fp = fopen (_PATH_INETDPID, "w")) != NULL) {
-		fprintf (fp, "%u\n", getpid ());
-		(void) fclose (fp);
+		if (fp != NULL) {
+			fprintf(fp, "%u\n", getpid());
+			(void) fclose(fp);
+		}
 	}
-  }
 
-  if (getrlimit (RLIMIT_NOFILE, &rlim_ofile) < 0) {
-	bb_perror_msg ("getrlimit");
-  } else {
-	rlim_ofile_cur = rlim_ofile.rlim_cur;
-	if (rlim_ofile_cur == RLIM_INFINITY)    /* ! */
-	  rlim_ofile_cur = OPEN_MAX;
-  }
+	if (getrlimit(RLIMIT_NOFILE, &rlim_ofile) < 0) {
+		bb_perror_msg("getrlimit");
+	} else {
+		rlim_ofile_cur = rlim_ofile.rlim_cur;
+		if (rlim_ofile_cur == RLIM_INFINITY)    /* ! */
+			rlim_ofile_cur = OPEN_MAX;
+	}
 
-  memset ((char *) &sa, 0, sizeof (sa));
-  sigemptyset (&sa.sa_mask);
-  sigaddset (&sa.sa_mask, SIGALRM);
-  sigaddset (&sa.sa_mask, SIGCHLD);
-  sigaddset (&sa.sa_mask, SIGHUP);
-  sa.sa_handler = retry;
-  sigaction (SIGALRM, &sa, NULL);
-  /* doconfig(); */
-  config (SIGHUP);
-  sa.sa_handler = config;
-  sigaction (SIGHUP, &sa, NULL);
-  sa.sa_handler = reapchild;
-  sigaction (SIGCHLD, &sa, NULL);
-  sa.sa_handler = goaway;
-  sigaction (SIGTERM, &sa, NULL);
-  sa.sa_handler = goaway;
-  sigaction (SIGINT, &sa, NULL);
-  sa.sa_handler = SIG_IGN;
-  sigaction (SIGPIPE, &sa, &sapipe);
-  memset(&wait_mask, 0, sizeof(wait_mask));
-  {
-	/* space for daemons to overwrite environment for ps */
+	memset((char *) &sa, 0, sizeof(sa));
+	sigemptyset(&sa.sa_mask);
+	sigaddset(&sa.sa_mask, SIGALRM);
+	sigaddset(&sa.sa_mask, SIGCHLD);
+	sigaddset(&sa.sa_mask, SIGHUP);
+	sa.sa_handler = retry;
+	sigaction(SIGALRM, &sa, NULL);
+	/* doconfig(); */
+	config(SIGHUP);
+	sa.sa_handler = config;
+	sigaction(SIGHUP, &sa, NULL);
+	sa.sa_handler = reapchild;
+	sigaction(SIGCHLD, &sa, NULL);
+	sa.sa_handler = goaway;
+	sigaction(SIGTERM, &sa, NULL);
+	sa.sa_handler = goaway;
+	sigaction(SIGINT, &sa, NULL);
+	sa.sa_handler = SIG_IGN;
+	sigaction(SIGPIPE, &sa, &sapipe);
+	memset(&wait_mask, 0, sizeof(wait_mask));
+	{
+		/* space for daemons to overwrite environment for ps */
 #define DUMMYSIZE       100
-	char dummy[DUMMYSIZE];
+		char dummy[DUMMYSIZE];
 
-	(void) memset (dummy, 'x', DUMMYSIZE - 1);
-	dummy[DUMMYSIZE - 1] = '\0';
+		(void) memset(dummy, 'x', DUMMYSIZE - 1);
+		dummy[DUMMYSIZE - 1] = '\0';
 
-	(void) setenv ("inetd_dummy", dummy, 1);
-  }
+		(void) setenv("inetd_dummy", dummy, 1);
+	}
 
-  for (;;) {
-	int n, ctrl = -1;
-	fd_set readable;
+	for (;;) {
+		int n, ctrl = -1;
+		fd_set readable;
 
-	if (nsock == 0) {
-	  Block_Using_Signals(omask);
-	  while (nsock == 0)
-		sigsuspend (&wait_mask);
-	  sigprocmask(SIG_UNBLOCK, &omask, NULL);
-	}
+		if (nsock == 0) {
+			Block_Using_Signals(omask);
+			while (nsock == 0)
+				sigsuspend(&wait_mask);
+			sigprocmask(SIG_UNBLOCK, &omask, NULL);
+		}
 
-	readable = allsock;
-	if ((n = select (maxsock + 1, &readable, NULL, NULL, NULL)) <= 0) {
-	  if (n < 0 && errno != EINTR) {
-		bb_perror_msg("select");
-		sleep (1);
-	  }
-	  continue;
-	}
-	for (sep = servtab; n && sep; sep = sep->se_next)
-	  if (sep->se_fd != -1 && FD_ISSET (sep->se_fd, &readable)) {
-		n--;
-		if (!sep->se_wait && sep->se_socktype == SOCK_STREAM) {
-		  ctrl = accept (sep->se_fd, NULL, NULL);
-		  if (ctrl < 0) {
-			if (errno == EINTR)
-			  continue;
-			bb_perror_msg("accept (for %s)", sep->se_service);
+		readable = allsock;
+		n = select(maxsock + 1, &readable, NULL, NULL, NULL)
+		if (n <= 0) {
+			if (n < 0 && errno != EINTR) {
+				bb_perror_msg("select");
+				sleep(1);
+			}
 			continue;
-		  }
-		  if (sep->se_family == AF_INET && sep->se_socktype == SOCK_STREAM) {
-			struct sockaddr_in peer;
-			socklen_t plen = sizeof (peer);
+		}
+		for (sep = servtab; n && sep; sep = sep->se_next) {
+			// TODO: undo this unholy mess
+			if (sep->se_fd != -1 && FD_ISSET(sep->se_fd, &readable)) {
+				n--;
+				if (!sep->se_wait && sep->se_socktype == SOCK_STREAM) {
+					ctrl = accept(sep->se_fd, NULL, NULL);
+					if (ctrl < 0) {
+						if (errno == EINTR)
+							continue;
+						bb_perror_msg("accept (for %s)", sep->se_service);
+						continue;
+					}
+					if (sep->se_family == AF_INET && sep->se_socktype == SOCK_STREAM) {
+						struct sockaddr_in peer;
+						socklen_t plen = sizeof(peer);
 
-			if (getpeername (ctrl, (struct sockaddr *) &peer, &plen) < 0) {
-			  bb_error_msg("could not getpeername");
-			  close (ctrl);
-			  continue;
-			}
-			if (ntohs (peer.sin_port) == 20) {
-			  /* XXX ftp bounce */
-			  close (ctrl);
-			  continue;
-			}
-		  }
-		} else
-		  ctrl = sep->se_fd;
-		Block_Using_Signals(omask);
-		pid = 0;
+						if (getpeername(ctrl, (struct sockaddr *) &peer, &plen) < 0) {
+							bb_error_msg("could not getpeername");
+							close(ctrl);
+							continue;
+						}
+						if (ntohs(peer.sin_port) == 20) {
+							/* XXX ftp bounce */
+							close(ctrl);
+							continue;
+						}
+					}
+				} else
+					ctrl = sep->se_fd;
+				Block_Using_Signals(omask);
+				pid = 0;
 #ifdef INETD_FEATURE_ENABLED
-		if (sep->se_bi == 0 || sep->se_bi->bi_fork)
+				if (sep->se_bi == 0 || sep->se_bi->bi_fork)
 #endif
-		{
-		  if (sep->se_count++ == 0)
-			(void) gettimeofday (&sep->se_time, NULL);
-		  else if (toomany > 0 && sep->se_count >= sep->se_max) {
-			struct timeval now;
+				{
+					if (sep->se_count++ == 0)
+						(void) gettimeofday(&sep->se_time, NULL);
+					else if (toomany > 0 && sep->se_count >= sep->se_max) {
+						struct timeval now;
 
-			(void) gettimeofday (&now, NULL);
-			if (now.tv_sec - sep->se_time.tv_sec > CNT_INTVL) {
-			  sep->se_time = now;
-			  sep->se_count = 1;
-			} else {
-			  if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
-				close (ctrl);
-			  if (sep->se_family == AF_INET &&
-				  ntohs (sep->se_ctrladdr_in.sin_port) >= IPPORT_RESERVED) {
-				/*
-				 * Cannot close it -- there are
-				 * thieves on the system.
-				 * Simply ignore the connection.
-				 */
-				--sep->se_count;
-				continue;
-			  }
-			  bb_error_msg ("%s/%s server failing (looping), service terminated",
-					  sep->se_service, sep->se_proto);
-			  if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
-				close (ctrl);
-			  FD_CLR (sep->se_fd, &allsock);
-			  (void) close (sep->se_fd);
-			  sep->se_fd = -1;
-			  sep->se_count = 0;
-			  nsock--;
-			  sigprocmask(SIG_UNBLOCK, &omask, NULL);
-			  if (!timingout) {
-				timingout = 1;
-				alarm (RETRYTIME);
-			  }
-			  continue;
-			}
-		  }
-		  pid = fork ();
-		}
-		if (pid < 0) {
-		  bb_perror_msg ("fork");
-		  if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
-			close (ctrl);
-		  sigprocmask(SIG_UNBLOCK, &omask, NULL);
-		  sleep (1);
-		  continue;
-		}
-		if (pid && sep->se_wait) {
-		  sep->se_wait = pid;
-		  FD_CLR (sep->se_fd, &allsock);
-		  nsock--;
-		}
-		sigprocmask(SIG_UNBLOCK, &omask, NULL);
-		if (pid == 0) {
+						(void) gettimeofday(&now, NULL);
+						if (now.tv_sec - sep->se_time.tv_sec > CNT_INTVL) {
+							sep->se_time = now;
+							sep->se_count = 1;
+						} else {
+							if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
+								close(ctrl);
+							if (sep->se_family == AF_INET &&
+								  ntohs(sep->se_ctrladdr_in.sin_port) >= IPPORT_RESERVED) {
+								/*
+								 * Cannot close it -- there are
+								 * thieves on the system.
+								 * Simply ignore the connection.
+								 */
+								--sep->se_count;
+								continue;
+							}
+							bb_error_msg("%s/%s server failing (looping), service terminated",
+								      sep->se_service, sep->se_proto);
+							if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
+								close(ctrl);
+							FD_CLR(sep->se_fd, &allsock);
+							(void) close(sep->se_fd);
+							sep->se_fd = -1;
+							sep->se_count = 0;
+							nsock--;
+							sigprocmask(SIG_UNBLOCK, &omask, NULL);
+							if (!timingout) {
+								timingout = 1;
+								alarm(RETRYTIME);
+							}
+							continue;
+						}
+					}
+					pid = fork();
+				}
+				if (pid < 0) {
+					bb_perror_msg("fork");
+					if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
+						close(ctrl);
+					sigprocmask(SIG_UNBLOCK, &omask, NULL);
+					sleep(1);
+					continue;
+				}
+				if (pid && sep->se_wait) {
+					sep->se_wait = pid;
+					FD_CLR(sep->se_fd, &allsock);
+					nsock--;
+				}
+				sigprocmask(SIG_UNBLOCK, &omask, NULL);
+				if (pid == 0) {
 #ifdef INETD_FEATURE_ENABLED
-		  if (sep->se_bi) {
-			(*sep->se_bi->bi_fn) (ctrl, sep);
-		  } else
+					if (sep->se_bi) {
+						(*sep->se_bi->bi_fn)(ctrl, sep);
+					} else
 #endif
-			{
-			if ((pwd = getpwnam (sep->se_user)) == NULL) {
-			  bb_error_msg ("getpwnam: %s: no such user", sep->se_user);
-			  if (sep->se_socktype != SOCK_STREAM)
-				recv (0, buf, sizeof (buf), 0);
-			  _exit (1);
+						{
+						if ((pwd = getpwnam(sep->se_user)) == NULL) {
+							bb_error_msg("getpwnam: %s: no such user", sep->se_user);
+							if (sep->se_socktype != SOCK_STREAM)
+								recv(0, buf, sizeof(buf), 0);
+							_exit(1);
+						}
+						if (setsid() < 0)
+							bb_perror_msg("%s: setsid", sep->se_service);
+						if (sep->se_group && (grp = getgrnam(sep->se_group)) == NULL) {
+							bb_error_msg("getgrnam: %s: no such group", sep->se_group);
+							if (sep->se_socktype != SOCK_STREAM)
+								recv(0, buf, sizeof(buf), 0);
+							_exit(1);
+						}
+						if (uid != 0) {
+							/* a user running private inetd */
+							if (uid != pwd->pw_uid)
+								_exit(1);
+						} else if (pwd->pw_uid) {
+							if (sep->se_group)
+								pwd->pw_gid = grp->gr_gid;
+							xsetgid((gid_t) pwd->pw_gid);
+							initgroups(pwd->pw_name, pwd->pw_gid);
+							xsetuid((uid_t) pwd->pw_uid);
+						} else if (sep->se_group) {
+							xsetgid(grp->gr_gid);
+							setgroups(1, &grp->gr_gid);
+						}
+						dup2(ctrl, 0);
+						close(ctrl);
+						dup2(0, 1);
+						dup2(0, 2);
+						if (rlim_ofile.rlim_cur != rlim_ofile_cur)
+							if (setrlimit(RLIMIT_NOFILE, &rlim_ofile) < 0)
+								bb_perror_msg("setrlimit");
+						closelog();
+						for (tmpint = rlim_ofile_cur - 1; --tmpint > 2;)
+							(void) close(tmpint);
+						sigaction(SIGPIPE, &sapipe, NULL);
+						execv(sep->se_server, sep->se_argv);
+						if (sep->se_socktype != SOCK_STREAM)
+							recv(0, buf, sizeof(buf), 0);
+						bb_perror_msg("execv %s", sep->se_server);
+						_exit(1);
+					}
+				}
+				if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
+					close(ctrl);
 			}
-			if (setsid () < 0)
-			  bb_perror_msg ("%s: setsid", sep->se_service);
-			if (sep->se_group && (grp = getgrnam (sep->se_group)) == NULL) {
-			  bb_error_msg ("getgrnam: %s: no such group", sep->se_group);
-			  if (sep->se_socktype != SOCK_STREAM)
-				recv (0, buf, sizeof (buf), 0);
-			  _exit (1);
-			}
-			if (uid != 0) {
-			  /* a user running private inetd */
-			  if (uid != pwd->pw_uid)
-				_exit (1);
-			} else if (pwd->pw_uid) {
-			  if (sep->se_group) {
-				pwd->pw_gid = grp->gr_gid;
-			  }
-			  xsetgid ((gid_t) pwd->pw_gid);
-			  initgroups (pwd->pw_name, pwd->pw_gid);
-			  xsetuid((uid_t) pwd->pw_uid);
-			} else if (sep->se_group) {
-			  xsetgid(grp->gr_gid);
-			  setgroups (1, &grp->gr_gid);
-			}
-			dup2 (ctrl, 0);
-			close (ctrl);
-			dup2 (0, 1);
-			dup2 (0, 2);
-			if (rlim_ofile.rlim_cur != rlim_ofile_cur)
-			  if (setrlimit (RLIMIT_NOFILE, &rlim_ofile) < 0)
-				bb_perror_msg ("setrlimit");
-			closelog ();
-			for (tmpint = rlim_ofile_cur - 1; --tmpint > 2;)
-			  (void) close (tmpint);
-			sigaction (SIGPIPE, &sapipe, NULL);
-			execv (sep->se_server, sep->se_argv);
-			if (sep->se_socktype != SOCK_STREAM)
-			  recv (0, buf, sizeof (buf), 0);
-			bb_perror_msg ("execv %s", sep->se_server);
-			_exit (1);
-		  }
 		}
-		if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
-		  close (ctrl);
-	  }
-  }
+	}
 }
 
 /*
@@ -1517,16 +1519,16 @@
 #define BUFSIZE 4096
 
 #if defined(CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO) || \
-    defined(CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN) || \
-    defined(CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME)
-static int dg_badinput (struct sockaddr_in *dg_sin)
+		defined(CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN) || \
+		defined(CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME)
+static int dg_badinput(struct sockaddr_in *dg_sin)
 {
-  if (ntohs (dg_sin->sin_port) < IPPORT_RESERVED)
-	return (1);
-  if (dg_sin->sin_addr.s_addr == htonl (INADDR_BROADCAST))
-	return (1);
-  /* XXX compare against broadcast addresses in SIOCGIFCONF list? */
-  return (0);
+	if (ntohs(dg_sin->sin_port) < IPPORT_RESERVED)
+		return 1;
+	if (dg_sin->sin_addr.s_addr == htonl(INADDR_BROADCAST))
+		return 1;
+	/* XXX compare against broadcast addresses in SIOCGIFCONF list? */
+	return 0;
 }
 #endif
 
@@ -1534,34 +1536,35 @@
 /* Echo service -- echo data back */
 /* ARGSUSED */
 static void
-echo_stream (int s, servtab_t *sep)
+echo_stream(int s, servtab_t *sep)
 {
-  char buffer[BUFSIZE];
-  int i;
+	char buffer[BUFSIZE];
+	int i;
 
-  inetd_setproctitle (sep->se_service, s);
-  while ((i = read (s, buffer, sizeof (buffer))) > 0 &&
-		 write (s, buffer, i) > 0);
-  exit (0);
+	inetd_setproctitle(sep->se_service, s);
+	while ((i = read(s, buffer, sizeof(buffer))) > 0 &&
+				 write(s, buffer, i) > 0);
+	exit(0);
 }
 
 /* Echo service -- echo data back */
 /* ARGSUSED */
 static void
-echo_dg (int s, servtab_t *sep ATTRIBUTE_UNUSED)
+echo_dg(int s, servtab_t *sep ATTRIBUTE_UNUSED)
 {
-  char buffer[BUFSIZE];
-  int i;
-  socklen_t size;
-  /* struct sockaddr_storage ss; */
-  struct sockaddr sa;
+	char buffer[BUFSIZE];
+	int i;
+	socklen_t size;
+	/* struct sockaddr_storage ss; */
+	struct sockaddr sa;
 
-  size = sizeof (sa);
-  if ((i = recvfrom (s, buffer, sizeof (buffer), 0, &sa, &size)) < 0)
-	return;
-  if (dg_badinput ((struct sockaddr_in *) &sa))
-	return;
-  (void) sendto (s, buffer, i, 0, &sa, sizeof (sa));
+	size = sizeof(sa);
+	i = recvfrom(s, buffer, sizeof(buffer), 0, &sa, &size);
+	if (i < 0)
+		return;
+	if (dg_badinput((struct sockaddr_in *) &sa))
+		return;
+	(void) sendto(s, buffer, i, 0, &sa, sizeof(sa));
 }
 #endif  /* CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO */
 
@@ -1569,24 +1572,24 @@
 /* Discard service -- ignore data */
 /* ARGSUSED */
 static void
-discard_stream (int s, servtab_t *sep)
+discard_stream(int s, servtab_t *sep)
 {
-  char buffer[BUFSIZE];
+	char buffer[BUFSIZE];
 
-  inetd_setproctitle (sep->se_service, s);
-  while ((errno = 0, read (s, buffer, sizeof (buffer)) > 0) ||
-		 errno == EINTR);
-  exit (0);
+	inetd_setproctitle(sep->se_service, s);
+	while ((errno = 0, read(s, buffer, sizeof(buffer)) > 0) ||
+				 errno == EINTR);
+	exit(0);
 }
 
 /* Discard service -- ignore data */
 /* ARGSUSED */
 static void
-discard_dg (int s, servtab_t *sep ATTRIBUTE_UNUSED)
+discard_dg(int s, servtab_t *sep ATTRIBUTE_UNUSED)
 {
-  char buffer[BUFSIZE];
+	char buffer[BUFSIZE];
 
-  (void) read (s, buffer, sizeof (buffer));
+	(void) read(s, buffer, sizeof(buffer));
 }
 #endif /* CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD */
 
@@ -1597,84 +1600,84 @@
 static char *endring;
 
 static void
-initring (void)
+initring(void)
 {
-  int i;
+	int i;
 
-  endring = ring;
+	endring = ring;
 
-  for (i = 0; i <= 128; ++i)
-	if (isprint (i))
-	  *endring++ = i;
+	for (i = 0; i <= 128; ++i)
+		if (isprint(i))
+			*endring++ = i;
 }
 
 /* Character generator */
 /* ARGSUSED */
 static void
-chargen_stream (int s, servtab_t *sep)
+chargen_stream(int s, servtab_t *sep)
 {
-  char *rs;
-  int len;
-  char text[LINESIZ + 2];
+	char *rs;
+	int len;
+	char text[LINESIZ + 2];
 
-  inetd_setproctitle (sep->se_service, s);
+	inetd_setproctitle(sep->se_service, s);
 
-  if (!endring) {
-	initring ();
-	rs = ring;
-  }
+	if (!endring) {
+		initring();
+		rs = ring;
+	}
 
-  text[LINESIZ] = '\r';
-  text[LINESIZ + 1] = '\n';
-  for (rs = ring;;) {
-	if ((len = endring - rs) >= LINESIZ)
-	  memmove (text, rs, LINESIZ);
-	else {
-	  memmove (text, rs, len);
-	  memmove (text + len, ring, LINESIZ - len);
+	text[LINESIZ] = '\r';
+	text[LINESIZ + 1] = '\n';
+	for (rs = ring;;) {
+		if ((len = endring - rs) >= LINESIZ)
+			memmove(text, rs, LINESIZ);
+		else {
+			memmove(text, rs, len);
+			memmove(text + len, ring, LINESIZ - len);
+		}
+		if (++rs == endring)
+			rs = ring;
+		if (write(s, text, sizeof(text)) != sizeof(text))
+			break;
 	}
-	if (++rs == endring)
-	  rs = ring;
-	if (write (s, text, sizeof (text)) != sizeof (text))
-	  break;
-  }
-  exit (0);
+	exit(0);
 }
 
 /* Character generator */
 /* ARGSUSED */
 static void
-chargen_dg (int s, servtab_t *sep ATTRIBUTE_UNUSED)
+chargen_dg(int s, servtab_t *sep ATTRIBUTE_UNUSED)
 {
-  /* struct sockaddr_storage ss; */
-  struct sockaddr sa;
-  static char *rs;
-  int len;
-  char text[LINESIZ + 2];
-  socklen_t size;
+	/* struct sockaddr_storage ss; */
+	struct sockaddr sa;
+	static char *rs;
+	int len;
+	char text[LINESIZ + 2];
+	socklen_t size;
 
-  if (endring == 0) {
-	initring ();
-	rs = ring;
-  }
+	if (endring == 0) {
+		initring();
+		rs = ring;
+	}
 
-  size = sizeof (sa);
-  if (recvfrom (s, text, sizeof (text), 0, &sa, &size) < 0)
-	return;
-  if (dg_badinput ((struct sockaddr_in *) &sa))
-	return;
+	size = sizeof(sa);
+	if (recvfrom(s, text, sizeof(text), 0, &sa, &size) < 0)
+		return;
+	if (dg_badinput((struct sockaddr_in *) &sa))
+		return;
 
-  if ((len = endring - rs) >= LINESIZ)
-	memmove (text, rs, LINESIZ);
-  else {
-	memmove (text, rs, len);
-	memmove (text + len, ring, LINESIZ - len);
-  }
-  if (++rs == endring)
-	rs = ring;
-  text[LINESIZ] = '\r';
-  text[LINESIZ + 1] = '\n';
-  (void) sendto (s, text, sizeof (text), 0, &sa, sizeof (sa));
+	if ((len = endring - rs) >= LINESIZ)
+		memmove(text, rs, LINESIZ);
+	else {
+		memmove(text, rs, len);
+		memmove(text + len, ring, LINESIZ - len);
+	}
+	if (++rs == endring)
+		rs = ring;
+	text[LINESIZ] = '\r';
+	text[LINESIZ + 1] = '\n';
+	(void) sendto(s, text, sizeof(text), 0, &sa, sizeof(sa));
 }
 #endif /* CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN */
 
@@ -1688,47 +1691,47 @@
  * some seventy years Bell Labs was asleep.
  */
 
-static u_int machtime (void)
+static u_int machtime(void)
 {
-  struct timeval tv;
+	struct timeval tv;
 
-  if (gettimeofday (&tv, NULL) < 0) {
-	fprintf (stderr, "Unable to get time of day\n");
-	return (0L);
-  }
-  return (htonl ((u_int) tv.tv_sec + 2208988800UL));
+	if (gettimeofday(&tv, NULL) < 0) {
+		fprintf(stderr, "Unable to get time of day\n");
+		return 0L;
+	}
+	return htonl((u_int) tv.tv_sec + 2208988800UL);
 }
 
 /* ARGSUSED */
 static void
-machtime_stream (int s, servtab_t *sep ATTRIBUTE_UNUSED)
+machtime_stream(int s, servtab_t *sep ATTRIBUTE_UNUSED)
 {
-  u_int result;
+	u_int result;
 
-  result = machtime ();
-  (void) write (s, (char *) &result, sizeof (result));
+	result = machtime();
+	(void) write(s, (char *) &result, sizeof(result));
 }
 
 /* ARGSUSED */
 static void
-machtime_dg (int s, servtab_t *sep ATTRIBUTE_UNUSED)
+machtime_dg(int s, servtab_t *sep ATTRIBUTE_UNUSED)
 {
-  u_int result;
-  /* struct sockaddr_storage ss; */
-  struct sockaddr sa;
-  struct sockaddr_in *dg_sin;
-  socklen_t size;
+	u_int result;
+	/* struct sockaddr_storage ss; */
+	struct sockaddr sa;
+	struct sockaddr_in *dg_sin;
+	socklen_t size;
 
-  size = sizeof (sa);
-  if (recvfrom (s, (char *) &result, sizeof (result), 0, &sa, &size) < 0)
-	return;
-  /* if (dg_badinput((struct sockaddr *)&ss)) */
-  dg_sin = (struct sockaddr_in *) &sa;
-  if (dg_sin->sin_addr.s_addr == htonl (INADDR_BROADCAST) ||
-	  ntohs (dg_sin->sin_port) < IPPORT_RESERVED / 2)
-	return;
-  result = machtime ();
-  (void) sendto (s, (char *) &result, sizeof (result), 0, &sa, sizeof (sa));
+	size = sizeof(sa);
+	if (recvfrom(s, (char *) &result, sizeof(result), 0, &sa, &size) < 0)
+		return;
+	/* if (dg_badinput((struct sockaddr *)&ss)) */
+	dg_sin = (struct sockaddr_in *) &sa;
+	if (dg_sin->sin_addr.s_addr == htonl(INADDR_BROADCAST) ||
+			ntohs(dg_sin->sin_port) < IPPORT_RESERVED / 2)
+		return;
+	result = machtime();
+	(void) sendto(s, (char *) &result, sizeof(result), 0, &sa, sizeof(sa));
 }
 #endif /* CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME */
 
@@ -1736,36 +1739,36 @@
 #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME
 /* Return human-readable time of day */
 /* ARGSUSED */
-static void daytime_stream (int s, servtab_t *sep ATTRIBUTE_UNUSED)
+static void daytime_stream(int s, servtab_t *sep ATTRIBUTE_UNUSED)
 {
-  char buffer[256];
-  time_t t;
+	char buffer[256];
+	time_t t;
 
-  t = time (NULL);
+	t = time(NULL);
 
-  (void) sprintf (buffer, "%.24s\r\n", ctime (&t));
-  (void) write (s, buffer, strlen (buffer));
+	(void) sprintf(buffer, "%.24s\r\n", ctime(&t));
+	(void) write(s, buffer, strlen(buffer));
 }
 
 /* Return human-readable time of day */
 /* ARGSUSED */
 void
-daytime_dg (int s, servtab_t *sep ATTRIBUTE_UNUSED)
+daytime_dg(int s, servtab_t *sep ATTRIBUTE_UNUSED)
 {
-  char buffer[256];
-  time_t t;
-  /* struct sockaddr_storage ss; */
-  struct sockaddr sa;
-  socklen_t size;
+	char buffer[256];
+	time_t t;
+	/* struct sockaddr_storage ss; */
+	struct sockaddr sa;
+	socklen_t size;
 
-  t = time ((time_t *) 0);
+	t = time(NULL);
 
-  size = sizeof (sa);
-  if (recvfrom (s, buffer, sizeof (buffer), 0, &sa, &size) < 0)
-	return;
-  if (dg_badinput ((struct sockaddr_in *) &sa))
-	return;
-  (void) sprintf (buffer, "%.24s\r\n", ctime (&t));
-  (void) sendto (s, buffer, strlen (buffer), 0, &sa, sizeof (sa));
+	size = sizeof(sa);
+	if (recvfrom(s, buffer, sizeof(buffer), 0, &sa, &size) < 0)
+		return;
+	if (dg_badinput((struct sockaddr_in *) &sa))
+		return;
+	(void) sprintf(buffer, "%.24s\r\n", ctime(&t));
+	(void) sendto(s, buffer, strlen(buffer), 0, &sa, sizeof(sa));
 }
 #endif /* CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME */

 ------------------------------------------------------------------------
r16202 | vda | 2006-09-23 09:31:46 -0400 (Sat, 23 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/util-linux/hexdump.c

hexdump: deindent, almost fits into 80 columns now

 ------------------------------------------------------------------------

Index: util-linux/hexdump.c
===================================================================
--- util-linux/hexdump.c	(revision 16201)
+++ util-linux/hexdump.c	(revision 16202)
@@ -33,11 +33,11 @@
 }
 
 static const char * const add_strings[] = {
-			"\"%07.7_ax \" 16/1 \"%03o \" \"\\n\"",		/* b */
-			"\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\"",		/* c */
-			"\"%07.7_ax \" 8/2 \"  %05u \" \"\\n\"",	/* d */
-			"\"%07.7_ax \" 8/2 \" %06o \" \"\\n\"",		/* o */
-			"\"%07.7_ax \" 8/2 \"   %04x \" \"\\n\"",	/* x */
+	"\"%07.7_ax \" 16/1 \"%03o \" \"\\n\"",		/* b */
+	"\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\"",		/* c */
+	"\"%07.7_ax \" 8/2 \"  %05u \" \"\\n\"",	/* d */
+	"\"%07.7_ax \" 8/2 \" %06o \" \"\\n\"",		/* o */
+	"\"%07.7_ax \" 8/2 \"   %04x \" \"\\n\"",	/* x */
 };
 
 static const char add_first[] = "\"%07.7_Ax\n\"";
@@ -53,7 +53,6 @@
 
 int hexdump_main(int argc, char **argv)
 {
-//	register FS *tfs;
 	const char *p;
 	int ch;
 
@@ -61,34 +60,33 @@
 	bb_dump_length = -1;
 
 	while ((ch = getopt(argc, argv, hexdump_opts)) > 0) {
-		if ((p = strchr(hexdump_opts, ch)) != NULL) {
-			if ((p - hexdump_opts) < 5) {
-				bb_dump_add(add_first);
-				bb_dump_add(add_strings[(int)(p - hexdump_opts)]);
-			} else if (ch == 'C') {
-				bb_dump_add("\"%08.8_Ax\n\"");
-				bb_dump_add("\"%08.8_ax  \" 8/1 \"%02x \" \"  \" 8/1 \"%02x \" ");
-				bb_dump_add("\"  |\" 16/1 \"%_p\" \"|\\n\"");
-			} else {
-				/* Sae a little bit of space below by omitting the 'else's. */
-				if (ch == 'e') {
-					bb_dump_add(optarg);
-				} /* else */
-				if (ch == 'f') {
-					bb_dump_addfile(optarg);
-				} /* else */
-				if (ch == 'n') {
-					bb_dump_length = bb_xgetularg10_bnd(optarg, 0, INT_MAX);
-				} /* else */
-				if (ch == 's') {
-					bb_dump_skip = bb_xgetularg_bnd_sfx(optarg, 10, 0, LONG_MAX, suffixes);
-				} /* else */
-				if (ch == 'v') {
-					bb_dump_vflag = ALL;
-				}
-			}
-		} else {
+		p = strchr(hexdump_opts, ch)
+		if (!p)
 			bb_show_usage();
+		if ((p - hexdump_opts) < 5) {
+			bb_dump_add(add_first);
+			bb_dump_add(add_strings[(int)(p - hexdump_opts)]);
+		} else if (ch == 'C') {
+			bb_dump_add("\"%08.8_Ax\n\"");
+			bb_dump_add("\"%08.8_ax  \" 8/1 \"%02x \" \"  \" 8/1 \"%02x \" ");
+			bb_dump_add("\"  |\" 16/1 \"%_p\" \"|\\n\"");
+		} else {
+			/* Save a little bit of space below by omitting the 'else's. */
+			if (ch == 'e') {
+				bb_dump_add(optarg);
+			} /* else */
+			if (ch == 'f') {
+				bb_dump_addfile(optarg);
+			} /* else */
+			if (ch == 'n') {
+				bb_dump_length = bb_xgetularg10_bnd(optarg, 0, INT_MAX);
+			} /* else */
+			if (ch == 's') {
+				bb_dump_skip = bb_xgetularg_bnd_sfx(optarg, 10, 0, LONG_MAX, suffixes);
+			} /* else */
+			if (ch == 'v') {
+				bb_dump_vflag = ALL;
+			}
 		}
 	}
 
@@ -99,5 +97,5 @@
 
 	argv += optind;
 
-	return(bb_dump_dump(argv));
+	return bb_dump_dump(argv);
 }

 ------------------------------------------------------------------------
r16201 | vda | 2006-09-23 09:11:49 -0400 (Sat, 23 Sep 2006) | 3 lines
Changed paths:
   M /trunk/busybox/libbb/correct_password.c
   M /trunk/busybox/loginutils/su.c
   M /trunk/busybox/loginutils/vlock.c

correct_password: undo whitespace damage.
vlock + correct_password: fix incorrect line breaks in messages.

 ------------------------------------------------------------------------

Index: libbb/correct_password.c
===================================================================
--- libbb/correct_password.c	(revision 16200)
+++ libbb/correct_password.c	(revision 16201)
@@ -28,50 +28,38 @@
  * SUCH DAMAGE.
  */
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
 #include "libbb.h"
 
-
-
 /* Ask the user for a password.
    Return 1 if the user gives the correct password for entry PW,
    0 if not.  Return 1 without asking for a password if run by UID 0
    or if PW has an empty password.  */
 
-int correct_password ( const struct passwd *pw )
+int correct_password(const struct passwd *pw)
 {
 	char *unencrypted, *encrypted, *correct;
 
 #ifdef CONFIG_FEATURE_SHADOWPASSWDS
-	if (( strcmp ( pw-> pw_passwd, "x" ) == 0 ) || ( strcmp ( pw-> pw_passwd, "*" ) == 0 )) {
-		struct spwd *sp = getspnam ( pw-> pw_name );
+	if (!strcmp(pw->pw_passwd, "x") || !strcmp(pw->pw_passwd, "*")) {
+		struct spwd *sp = getspnam(pw->pw_name);
 
-		if ( !sp )
-			bb_error_msg_and_die ( "\nno valid shadow password" );
+		if (!sp)
+			bb_error_msg_and_die("no valid shadow password");
 
-		correct = sp-> sp_pwdp;
+		correct = sp->sp_pwdp;
 	}
 	else
 #endif
-		correct = pw-> pw_passwd;
+		correct = pw->pw_passwd;
 
-	if ( correct == 0 || correct[0] == '\0' )
+	if (!correct || correct[0] == '\0')
 		return 1;
 
-	unencrypted = bb_askpass ( 0, "Password: " );
-	if ( !unencrypted )
-	{
+	unencrypted = bb_askpass(0, "Password: ");
+	if (!unencrypted) {
 		return 0;
 	}
-	encrypted = crypt ( unencrypted, correct );
-	memset ( unencrypted, 0, strlen ( unencrypted ));
-	return ( strcmp ( encrypted, correct ) == 0 ) ? 1 : 0;
+	encrypted = crypt(unencrypted, correct);
+	memset(unencrypted, 0, strlen(unencrypted));
+	return (!strcmp(encrypted, correct)) ? 1 : 0;
 }
Index: loginutils/vlock.c
===================================================================
--- loginutils/vlock.c	(revision 16200)
+++ loginutils/vlock.c	(revision 16201)
@@ -108,13 +108,12 @@
 	tcsetattr(STDIN_FILENO, TCSANOW, &term);
 
 	do {
-		printf("Virtual Console%s locked.\n%s's ", (o_lock_all) ? "s" : "", pw->pw_name);
-		fflush(stdout);
-		if (correct_password (pw)) {
+		printf("Virtual Console%s locked. Enter %s's password to unlock\n", (o_lock_all) ? "s" : "", pw->pw_name);
+		if (correct_password(pw)) {
 			break;
 		}
 		bb_do_delay(FAIL_DELAY);
-		puts("Password incorrect.");
+		puts("Password incorrect");
 	} while (1);
 	restore_terminal();
 	return 0;
Index: loginutils/su.c
===================================================================
--- loginutils/su.c	(revision 16200)
+++ loginutils/su.c	(revision 16201)
@@ -45,7 +45,7 @@
 	}
 
 	pw = getpwnam(opt_username);
-	if (!pw) bb_error_msg_and_die("Unknown id: %s", opt_username);
+	if (!pw) bb_error_msg_and_die("unknown id: %s", opt_username);
 
 	/* Make sure pw->pw_shell is non-NULL.  It may be NULL when NEW_USER
 	   is a username that is retrieved via NIS (YP), but that doesn't have

 ------------------------------------------------------------------------
r16200 | vda | 2006-09-23 08:49:01 -0400 (Sat, 23 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/networking/ifupdown.c

ifupdown: getopt_ulflags'ification.

 ------------------------------------------------------------------------

Index: networking/ifupdown.c
===================================================================
--- networking/ifupdown.c	(revision 16199)
+++ networking/ifupdown.c	(revision 16200)
@@ -91,8 +91,21 @@
 	struct mapping_defn_t *mappings;
 };
 
-static char no_act = 0;
-static char verbose = 0;
+static unsigned option_mask;
+#define OPTION_STR "anvf" USE_FEATURE_IFUPDOWN_MAPPING("m") "i:"
+enum {
+	OPT_do_all = 0x1,
+	OPT_no_act = 0x2,
+	OPT_verbose = 0x4,
+	OPT_force = 0x8,
+	OPT_no_mappings = 0x10,
+};
+#define DO_ALL (option_mask & OPT_do_all)
+#define NO_ACT (option_mask & OPT_no_act)
+#define VERBOSE (option_mask & OPT_verbose)
+#define FORCE (option_mask & OPT_force)
+#define NO_MAPPINGS (option_mask & OPT_no_mappings)
+
 static char **__myenviron = NULL;
 
 #if ENABLE_FEATURE_IFUPDOWN_IPV4 || ENABLE_FEATURE_IFUPDOWN_IPV6
@@ -875,10 +888,10 @@
 
 static int doit(char *str)
 {
-	if (verbose || no_act) {
+	if (option_mask & (OPT_no_act|OPT_verbose)) {
 		printf("%s\n", str);
 	}
-	if (!no_act) {
+	if (!(option_mask & OPT_no_act)) {
 		pid_t child;
 		int status;
 
@@ -895,7 +908,7 @@
 			return 0;
 		}
 	}
-	return (1);
+	return 1;
 }
 
 static int execute_all(struct interface_defn_t *ifd, const char *opt)
@@ -1070,12 +1083,6 @@
 	llist_t *target_list = NULL;
 	const char *interfaces = "/etc/network/interfaces";
 	const char *statefile = "/var/run/ifstate";
-
-#ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING
-	int run_mappings = 1;
-#endif
-	int do_all = 0;
-	int force = 0;
 	int any_failures = 0;
 	int i;
 
@@ -1087,48 +1094,11 @@
 		cmds = iface_down;
 	}
 
-#ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING
-	while ((i = getopt(argc, argv, "i:hvnamf")) != -1)
-#else
-		while ((i = getopt(argc, argv, "i:hvnaf")) != -1)
-#endif
-		{
-			switch (i) {
-				case 'i':	/* interfaces */
-					interfaces = optarg;
-					break;
-				case 'v':	/* verbose */
-					verbose = 1;
-					break;
-				case 'a':	/* all */
-					do_all = 1;
-					break;
-				case 'n':	/* no-act */
-					no_act = 1;
-					break;
-#ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING
-				case 'm':	/* no-mappings */
-					run_mappings = 0;
-					break;
-#endif
-				case 'f':	/* force */
-					force = 1;
-					break;
-				default:
-					bb_show_usage();
-					break;
-			}
-		}
-
+	option_mask = bb_getopt_ulflags(argc, argv, OPTION_STR, &interfaces);
 	if (argc - optind > 0) {
-		if (do_all) {
-			bb_show_usage();
-		}
-	} else {
-		if (!do_all) {
-			bb_show_usage();
-		}
-	}
+		if (DO_ALL) bb_show_usage();
+	} else
+		if (!DO_ALL) bb_show_usage();
 
 	debug_noise("reading %s file:\n", interfaces);
 	defn = read_interfaces(interfaces);
@@ -1139,7 +1109,7 @@
 	}
 
 	/* Create a list of interfaces to work on */
-	if (do_all) {
+	if (DO_ALL) {
 		if (cmds == iface_up) {
 			target_list = defn->autointerfaces;
 		} else {
@@ -1177,7 +1147,7 @@
 			liface = xstrdup(iface);
 		}
 
-		if (!force) {
+		if (!FORCE) {
 			const llist_t *iface_state = find_iface_state(state_list, iface);
 
 			if (cmds == iface_up) {
@@ -1196,7 +1166,7 @@
 		}
 
 #ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING
-		if ((cmds == iface_up) && run_mappings) {
+		if ((cmds == iface_up) && !NO_MAPPINGS) {
 			struct mapping_defn_t *currmap;
 
 			for (currmap = defn->mappings; currmap; currmap = currmap->next) {
@@ -1204,7 +1174,7 @@
 				for (i = 0; i < currmap->n_matches; i++) {
 					if (fnmatch(currmap->match[i], liface, 0) != 0)
 						continue;
-					if (verbose) {
+					if (VERBOSE) {
 						printf("Running mapping script %s on %s\n", currmap->script, liface);
 					}
 					liface = run_mapping(iface, currmap);
@@ -1240,11 +1210,11 @@
 			}
 			iface_list = iface_list->link;
 		}
-		if (verbose) {
+		if (VERBOSE) {
 			printf("\n");
 		}
 
-		if (!okay && !force) {
+		if (!okay && !FORCE) {
 			bb_error_msg("Ignoring unknown interface %s", liface);
 			any_failures += 1;
 		} else {
@@ -1266,7 +1236,7 @@
 	}
 
 	/* Actually write the new state */
-	if (!no_act) {
+	if (!NO_ACT) {
 		FILE *state_fp = NULL;
 
 		state_fp = xfopen(statefile, "w");

 ------------------------------------------------------------------------
r16199 | vda | 2006-09-23 08:46:30 -0400 (Sat, 23 Sep 2006) | 3 lines
Changed paths:
   M /trunk/busybox/networking/arping.c

arping: fix bug (getopt_ulflags and optarg don't mix),
remove unreachable error path.

 ------------------------------------------------------------------------

Index: networking/arping.c
===================================================================
--- networking/arping.c	(revision 16198)
+++ networking/arping.c	(revision 16199)
@@ -260,35 +260,32 @@
 	char *target;
 
 	s = xsocket(PF_PACKET, SOCK_DGRAM, 0);
-	ifindex = errno;
 
 	// Drop suid root privileges
 	xsetuid(getuid());
 
 	{
 		unsigned long opt;
-		char *_count, *_timeout, *_device;
+		char *_count, *_timeout;
 
 		/* Dad also sets quit_on_reply.
 		 * Advert also sets unsolicited.
 		 */
 		bb_opt_complementally = "Df:AU";
 		opt = bb_getopt_ulflags(argc, argv, "DUAqfbc:w:i:s:",
-						&_count, &_timeout, &_device);
-		cfg |= opt & 63; /* set respective flags */
-		if (opt & 64) /* count */
+					&_count, &_timeout, &device, &source);
+		cfg |= opt & 0x3f; /* set respective flags */
+		if (opt & 0x40) /* -c: count */
 			count = atoi(_count);
-		if (opt & 128) /* timeout */
+		if (opt & 0x80) /* -w: timeout */
 			timeout = atoi(_timeout);
-		if (opt & 256) { /* interface */
-			if (strlen(_device) > IF_NAMESIZE) {
-				bb_error_msg_and_die("Interface name `%s' must be less than %d",
-								_device, IF_NAMESIZE);
+		if (opt & 0x100) { /* -i: interface */
+			if (strlen(device) > IF_NAMESIZE) {
+				bb_error_msg_and_die("interface name '%s' is too long",
+								device);
 			}
-			device = _device;
 		}
-		if (opt & 512) /* source */
-			source = optarg;
+		//if (opt & 0x200) /* -s: source */
 	}
 	argc -= optind;
 	argv += optind;
@@ -298,11 +295,6 @@
 
 	target = *argv;
 
-
-	if (s < 0) {
-		bb_default_error_retval = ifindex;
-		bb_perror_msg_and_die("socket");
-	}
 	bb_default_error_retval = 2;
 
 	{
@@ -311,7 +303,7 @@
 		memset(&ifr, 0, sizeof(ifr));
 		strncpy(ifr.ifr_name, device, IFNAMSIZ - 1);
 		if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
-			bb_error_msg_and_die("Interface %s not found", device);
+			bb_error_msg_and_die("interface %s not found", device);
 		}
 		ifindex = ifr.ifr_ifindex;
 
@@ -319,10 +311,10 @@
 			bb_error_msg_and_die("SIOCGIFFLAGS");
 		}
 		if (!(ifr.ifr_flags & IFF_UP)) {
-			bb_error_msg_and_die("Interface %s is down", device);
+			bb_error_msg_and_die("interface %s is down", device);
 		}
 		if (ifr.ifr_flags & (IFF_NOARP | IFF_LOOPBACK)) {
-			bb_error_msg("Interface %s is not ARPable", device);
+			bb_error_msg("interface %s is not ARPable", device);
 			exit(cfg&dad ? 0 : 2);
 		}
 	}
@@ -352,7 +344,7 @@
 			if (setsockopt
 				(probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device,
 				 strlen(device) + 1) == -1)
-				bb_error_msg("WARNING: interface %s is ignored", device);
+				bb_error_msg("warning: interface %s is ignored", device);
 		}
 		memset(&saddr, 0, sizeof(saddr));
 		saddr.sin_family = AF_INET;
@@ -371,7 +363,7 @@
 			if (setsockopt
 				(probe_fd, SOL_SOCKET, SO_DONTROUTE, (char *) &on,
 				 sizeof(on)) == -1)
-				bb_perror_msg("WARNING: setsockopt(SO_DONTROUTE)");
+				bb_perror_msg("warning: setsockopt(SO_DONTROUTE)");
 			if (connect(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr))
 				== -1) {
 				bb_error_msg_and_die("connect");
@@ -440,7 +432,7 @@
 
 		if ((cc = recvfrom(s, packet, 4096, 0,
 						   (struct sockaddr *) &from, &alen)) < 0) {
-			perror("recvfrom");
+			bb_perror_msg("recvfrom");
 			continue;
 		}
 		sigemptyset(&sset);

 ------------------------------------------------------------------------
r16198 | vda | 2006-09-23 08:32:58 -0400 (Sat, 23 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/modutils/insmod.c

insmod: getopt_ulflags'isation

 ------------------------------------------------------------------------

Index: modutils/insmod.c
===================================================================
--- modutils/insmod.c	(revision 16197)
+++ modutils/insmod.c	(revision 16198)
@@ -693,13 +693,37 @@
 
 /*======================================================================*/
 
-static int flag_force_load = 0;
-static int flag_autoclean = 0;
-static int flag_verbose = 0;
-static int flag_quiet = 0;
-static int flag_export = 1;
+static unsigned option_mask;
+#define OPTION_STR "sLo:fkvqx" USE_FEATURE_INSMOD_LOAD_MAP("m")
+enum {
+	OPT_s = 0x1, // -s /* log to syslog */
+		/* Not supported but kernel needs this for request_module(),
+		   as this calls: modprobe -k -s -- 
+		   so silently ignore this flag */
+	OPT_L = 0x2, // -L /* Stub warning */
+		/* Compatibility with modprobe.
+		   In theory, this does locking, but we don't do
+		   that.  So be careful and plan your life around not
+		   loading the same module 50 times concurrently. */
+	OPT_o = 0x4, // -o /* name the output module */
+	OPT_f = 0x8, // -f /* force loading */
+	OPT_k = 0x10, // -k /* module loaded by kerneld, auto-cleanable */
+	OPT_v = 0x20, // -v /* verbose output */
+	OPT_q = 0x40, // -q /* silent */
+	OPT_x = 0x80, // -x /* do not export externs */
+	OPT_m = 0x100, // -m /* print module load map */
+};
+#define flag_force_load (option_mask & OPT_f)
+#define flag_autoclean (option_mask & OPT_k)
+#define flag_verbose (option_mask & OPT_v)
+#define flag_quiet (option_mask & OPT_q)
+#define flag_noexport (option_mask & OPT_x)
+#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP
+#define flag_print_load_map (option_mask & OPT_m)
+#else
+#define flag_print_load_map 0
+#endif
 
-
 /*======================================================================*/
 
 #if defined(CONFIG_USE_LIST)
@@ -2851,7 +2875,7 @@
 			}
 	}
 
-	if (flag_export && !obj_find_section(f, "__ksymtab")) {
+	if (!flag_noexport && !obj_find_section(f, "__ksymtab")) {
 		size_t nsyms;
 		int *loaded;
 
@@ -3764,7 +3788,7 @@
 	 * are not to be exported.  otherwise leave ksymtab alone for now, the
 	 * "export all symbols" compatibility code will export these symbols later.
 	 */
-	use_ksymtab =  obj_find_section(f, "__ksymtab") || !flag_export;
+	use_ksymtab = obj_find_section(f, "__ksymtab") || flag_noexport;
 
 	if ((sec = obj_find_section(f, ".this"))) {
 		/* tag the module header with the object name, last modified
@@ -3928,12 +3952,13 @@
 	}
 #endif
 }
-
+#else /* !CONFIG_FEATURE_INSMOD_LOAD_MAP */
+void print_load_map(struct obj_file *f);
 #endif
 
 int insmod_main( int argc, char **argv)
 {
-	int opt;
+	char *opt_o;
 	int len;
 	int k_crcs;
 	char *tmp, *tmp1;
@@ -3954,60 +3979,15 @@
 #else
 	FILE *fp;
 #endif
-#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP
-	int flag_print_load_map = 0;
-#endif
 	int k_version = 0;
 	struct utsname myuname;
 
 	/* Parse any options */
-#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP
-	while ((opt = getopt(argc, argv, "fkqsvxmLo:")) > 0)
-#else
-	while ((opt = getopt(argc, argv, "fkqsvxLo:")) > 0)
-#endif
-		{
-			switch (opt) {
-				case 'f':			/* force loading */
-					flag_force_load = 1;
-					break;
-				case 'k':			/* module loaded by kerneld, auto-cleanable */
-					flag_autoclean = 1;
-					break;
-				case 's':			/* log to syslog */
-					/* log to syslog -- not supported              */
-					/* but kernel needs this for request_module(), */
-					/* as this calls: modprobe -k -s --    */
-					/* so silently ignore this flag                */
-					break;
-				case 'v':			/* verbose output */
-					flag_verbose = 1;
-					break;
-				case 'q':			/* silent */
-					flag_quiet = 1;
-					break;
-				case 'x':			/* do not export externs */
-					flag_export = 0;
-					break;
-				case 'o':			/* name the output module */
-					free(m_name);
-					m_name = xstrdup(optarg);
-					break;
-				case 'L':			/* Stub warning */
-					/* This is needed for compatibility with modprobe.
-					 * In theory, this does locking, but we don't do
-					 * that.  So be careful and plan your life around not
-					 * loading the same module 50 times concurrently. */
-					break;
-#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP
-				case 'm':			/* print module load map */
-					flag_print_load_map = 1;
-					break;
-#endif
-				default:
-					bb_show_usage();
-			}
-		}
+	option_mask = bb_getopt_ulflags(argc, argv, OPTION_STR,	&opt_o);
+	if (option_mask & OPT_o) { // -o /* name the output module */
+		free(m_name);
+		m_name = xstrdup(opt_o);
+	}
 
 	if (argv[optind] == NULL) {
 		bb_show_usage();
@@ -4248,10 +4228,8 @@
 		goto out;
 	}
 
-#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP
 	if(flag_print_load_map)
 		print_load_map(f);
-#endif
 
 	exit_status = EXIT_SUCCESS;
 

 ------------------------------------------------------------------------
r16197 | vda | 2006-09-23 08:30:03 -0400 (Sat, 23 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/loginutils/passwd.c

passwd: getopt_ulflags'isation

 ------------------------------------------------------------------------

Index: loginutils/passwd.c
===================================================================
--- loginutils/passwd.c	(revision 16196)
+++ loginutils/passwd.c	(revision 16197)
@@ -46,7 +46,8 @@
 		snprintf(filename, sizeof filename, "%s", bb_path_passwd_file);
 	}
 
-	if (((fp = fopen(filename, "r+")) == 0) || (fstat(fileno(fp), &sb))) {
+	fp = fopen(filename, "r+");
+	if (fp == 0 || fstat(fileno(fp), &sb)) {
 		/* return 0; */
 		return 1;
 	}
@@ -57,7 +58,7 @@
 	lock.l_start = 0;
 	lock.l_len = 0;
 	if (fcntl(fileno(fp), F_SETLK, &lock) < 0) {
-		fprintf(stderr, "%s: %s\n", filename, strerror(errno));
+		bb_perror_msg("%s", filename);
 		return 1;
 	}
 	lock.l_type = F_UNLCK;
@@ -126,88 +127,76 @@
 
 int passwd_main(int argc, char **argv)
 {
+	enum {
+		OPT_algo = 0x1, /* -a - password algorithm */
+		OPT_lock = 0x2, /* -l - lock account */
+		OPT_unlock = 0x4, /* -u - unlock account */
+		OPT_delete = 0x8, /* -d - delete password */
+		OPT_lud = 0xe,
+	};
+	unsigned long opt;
+	char *opt_a;
 	int amroot;
 	char *cp;
 	char *np;
 	char *name;
 	char *myname;
-	int flag;
-	int algo = 1;				/* -a - password algorithm */
-	int lflg = 0;				/* -l - lock account */
-	int uflg = 0;				/* -u - unlock account */
-	int dflg = 0;				/* -d - delete password */
+	int algo = 1;
 	const struct passwd *pw;
 
 	amroot = (getuid() == 0);
 	openlog("passwd", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH);
-	while ((flag = getopt(argc, argv, "a:dlu")) != EOF) {
-		switch (flag) {
-		case 'a':
-			algo = get_algo(optarg);
-			break;
-		case 'd':
-			dflg++;
-			break;
-		case 'l':
-			lflg++;
-			break;
-		case 'u':
-			uflg++;
-			break;
-		default:
-			bb_show_usage();
-		}
-	}
-	myname = (char *) xstrdup(bb_getpwuid(NULL, getuid(), -1));
-	/* exits on error */
-	if (optind < argc) {
-		name = argv[optind];
-	} else {
-		name = myname;
-	}
-	if ((lflg || uflg || dflg) && (optind >= argc || !amroot)) {
+	opt = bb_getopt_ulflags(argc, argv, "a:lud", &opt_a);
+	argc -= optind;
+	argv += optind;
+	if (opt & OPT_algo) algo = get_algo(opt_a); // -a
+	if ((opt & OPT_lud) && (!argc || !amroot))
 		bb_show_usage();
-	}
+
+	myname = xstrdup(bb_getpwuid(NULL, getuid(), -1));
+	name = myname;
+	if (argc) name = argv[0];
+
 	pw = getpwnam(name);
 	if (!pw) {
-		bb_error_msg_and_die("Unknown user %s", name);
+		bb_error_msg_and_die("unknown user %s", name);
 	}
 	if (!amroot && pw->pw_uid != getuid()) {
-		syslog(LOG_WARNING, "can't change pwd for `%s'", name);
-		bb_error_msg_and_die("Permission denied.");
+		syslog(LOG_WARNING, "can't change pwd for '%s'", name);
+		bb_error_msg_and_die("permission denied");
 	}
 	if (ENABLE_FEATURE_SHADOWPASSWDS) {
 		struct spwd *sp = getspnam(name);
-		if (!sp) bb_error_msg_and_die("Unknown user %s", name);
+		if (!sp) bb_error_msg_and_die("unknown user %s", name);
 		cp = sp->sp_pwdp;
 	} else cp = pw->pw_passwd;
 
 	np = name;
 	safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd));
-	if (!(dflg || lflg || uflg)) {
+	if (!(opt & OPT_lud)) {
 		if (!amroot) {
 			if (cp[0] == '!') {
-				syslog(LOG_WARNING, "password locked for `%s'", np);
-				bb_error_msg_and_die( "The password for `%s' cannot be changed.", np);
+				syslog(LOG_WARNING, "password locked for '%s'", np);
+				bb_error_msg_and_die("the password for %s cannot be changed", np);
 			}
 		}
 		printf("Changing password for %s\n", name);
 		if (new_password(pw, amroot, algo)) {
-			bb_error_msg_and_die( "The password for %s is unchanged.", name);
+			bb_error_msg_and_die("the password for %s is unchanged", name);
 		}
-	} else if (lflg) {
+	} else if (opt & OPT_lock) {
 		if (crypt_passwd[0] != '!') {
 			memmove(&crypt_passwd[1], crypt_passwd,
 					sizeof crypt_passwd - 1);
 			crypt_passwd[sizeof crypt_passwd - 1] = '\0';
 			crypt_passwd[0] = '!';
 		}
-	} else if (uflg) {
+	} else if (opt & OPT_unlock) {
 		if (crypt_passwd[0] == '!') {
 			memmove(crypt_passwd, &crypt_passwd[1],
 					sizeof crypt_passwd - 1);
 		}
-	} else if (dflg) {
+	} else if (opt & OPT_delete) {
 		crypt_passwd[0] = '\0';
 	}
 	set_filesize_limit(30000);
@@ -217,15 +206,15 @@
 	umask(077);
 	xsetuid(0);
 	if (!update_passwd(pw, crypt_passwd)) {
-		syslog(LOG_INFO, "password for `%s' changed by user `%s'", name,
-			   myname);
-		printf("Password changed.\n");
+		syslog(LOG_INFO, "password for '%s' changed by user '%s'", name,
+				myname);
+		puts("Password changed");
 	} else {
-		syslog(LOG_WARNING, "an error occurred updating the password file");
-		bb_error_msg_and_die("An error occurred updating the password file.");
+		syslog(LOG_WARNING, "cannot update password file");
+		bb_error_msg_and_die("cannot update password file");
 	}
 	if (ENABLE_FEATURE_CLEAN_UP) free(myname);
-	return (0);
+	return 0;
 }
 
 
@@ -309,16 +298,17 @@
 	char pass[200];
 
 	if (!amroot && crypt_passwd[0]) {
-		if (!(clear = bb_askpass(0, "Old password:"))) {
+		clear = bb_askpass(0, "Old password:");
+		if (!clear) {
 			/* return -1; */
 			return 1;
 		}
 		cipher = pw_encrypt(clear, crypt_passwd);
 		if (strcmp(cipher, crypt_passwd) != 0) {
-			syslog(LOG_WARNING, "incorrect password for `%s'",
+			syslog(LOG_WARNING, "incorrect password for '%s'",
 				   pw->pw_name);
 			bb_do_delay(FAIL_DELAY);
-			fprintf(stderr, "Incorrect password.\n");
+			puts("Incorrect password");
 			/* return -1; */
 			return 1;
 		}
@@ -328,10 +318,10 @@
 	} else {
 		orig[0] = '\0';
 	}
-	if (! (cp=bb_askpass(0, "Enter the new password (minimum of 5, maximum of 8 characters)\n"
-					  "Please use a combination of upper and lower case letters and numbers.\n"
-					  "Enter new password: ")))
-	{
+	cp = bb_askpass(0, "Enter the new password (minimum of 5, maximum of 8 characters).\n"
+	                   "Please use a combination of upper and lower case letters and numbers.\n"
+	                   "Enter new password: ");
+	if (!cp ) {
 		memset(orig, 0, sizeof orig);
 		/* return -1; */
 		return 1;
@@ -341,19 +331,20 @@
 	/* if (!obscure(orig, pass, pw)) { */
 	if (obscure(orig, pass, pw)) {
 		if (amroot) {
-			printf("\nWarning: weak password (continuing).\n");
+			puts("\nWarning: weak password (continuing)");
 		} else {
 			/* return -1; */
 			return 1;
 		}
 	}
-	if (!(cp = bb_askpass(0, "Re-enter new password: "))) {
+	cp = bb_askpass(0, "Re-enter new password: ");
+	if (!cp) {
 		memset(orig, 0, sizeof orig);
 		/* return -1; */
 		return 1;
 	}
 	if (strcmp(cp, pass)) {
-		fprintf(stderr, "Passwords do not match.\n");
+		puts("Passwords do not match");
 		/* return -1; */
 		return 1;
 	}

 ------------------------------------------------------------------------
r16196 | vda | 2006-09-23 08:22:11 -0400 (Sat, 23 Sep 2006) | 4 lines
Changed paths:
   M /trunk/busybox/archival/tar.c
   M /trunk/busybox/libbb/bb_askpass.c
   M /trunk/busybox/libbb/getopt_ulflags.c
   M /trunk/busybox/miscutils/hdparm.c

bb_askpass: shorten static password buffer. 256 is way too large.
simplify code a bit.


 ------------------------------------------------------------------------

Index: archival/tar.c
===================================================================
--- archival/tar.c	(revision 16195)
+++ archival/tar.c	(revision 16196)
@@ -715,7 +715,7 @@
 		if ((tar_handle->action_header == header_list) ||
 			(tar_handle->action_header == header_verbose_list))
 		{
-				tar_handle->action_header = header_verbose_list;
+			tar_handle->action_header = header_verbose_list;
 		} else tar_handle->action_header = header_list;
 	}
 	if((opt & CTX_EXTRACT) && tar_handle->action_data != data_extract_to_stdout)
Index: libbb/bb_askpass.c
===================================================================
--- libbb/bb_askpass.c	(revision 16195)
+++ libbb/bb_askpass.c	(revision 16196)
@@ -17,9 +17,7 @@
 #include 
 
 #include "libbb.h"
-#define PWD_BUFFER_SIZE 256
 
-
 /* do nothing signal handler */
 static void askpass_timeout(int ATTRIBUTE_UNUSED ignore)
 {
@@ -27,18 +25,17 @@
 
 char *bb_askpass(int timeout, const char * prompt)
 {
+	static char passwd[64];
+
 	char *ret;
-	int i, size;
+	int i;
 	struct sigaction sa;
 	struct termios old, new;
-	static char passwd[PWD_BUFFER_SIZE];
 
 	tcgetattr(STDIN_FILENO, &old);
 	tcflush(STDIN_FILENO, TCIFLUSH);
 
-	size = sizeof(passwd);
-	ret = passwd;
-	memset(passwd, 0, size);
+	memset(passwd, 0, sizeof(passwd));
 
 	fputs(prompt, stdout);
 	fflush(stdout);
@@ -55,15 +52,16 @@
 		alarm(timeout);
 	}
 
-	if (read(STDIN_FILENO, passwd, size-1) <= 0) {
-		ret = NULL;
-	} else {
-		for(i = 0; i < size && passwd[i]; i++) {
-			if (passwd[i]== '\r' || passwd[i] == '\n') {
-				passwd[i]= 0;
-				break;
-			}
-		}
+	ret = NULL;
+	if (read(STDIN_FILENO, passwd, sizeof(passwd)-1) > 0) {
+		ret = passwd;
+		i = 0;
+		/* Last byte is guaranteed to be 0
+		   (read did not overwrite it) */
+		do {
+			if (passwd[i] == '\r' || passwd[i] == '\n')
+				passwd[i] = 0;
+		} while (passwd[i++]);
 	}
 
 	if (timeout) {
@@ -71,8 +69,7 @@
 	}
 
 	tcsetattr(STDIN_FILENO, TCSANOW, &old);
-	fputs("\n", stdout);
+	puts("");
 	fflush(stdout);
 	return ret;
 }
-
Index: libbb/getopt_ulflags.c
===================================================================
--- libbb/getopt_ulflags.c	(revision 16195)
+++ libbb/getopt_ulflags.c	(revision 16196)
@@ -104,7 +104,6 @@
 	if they are not specifed on the command line.  For example:
 
 	bb_opt_complementally = "abc";
-
 	flags = bb_getopt_ulflags(argc, argv, "abcd")
 
 	If getopt() finds "-a" on the command line, then
@@ -120,7 +119,6 @@
 	int w_counter = 0;
 	bb_opt_complementally = "ww";
 	bb_getopt_ulflags(argc, argv, "w", &w_counter);
-
 	if(w_counter)
 		width = (w_counter == 1) ? 132 : INT_MAX;
 	else
@@ -128,6 +126,7 @@
 
 	w_counter is a pointer to an integer. It has to be passed to
 	bb_getopt_ulflags() after all other option argument sinks.
+
 	For example: accept multiple -v to indicate the level of verbosity
 	and for each -b optarg, add optarg to my_b. Finally, if b is given,
 	turn off c and vice versa:
@@ -136,8 +135,8 @@
 	int verbose_level = 0;
 	bb_opt_complementally = "vv:b::b-c:c-b";
 	f = bb_getopt_ulflags(argc, argv, "vb:c", &my_b, &verbose_level);
-	if((f & 2))     // -c after -b unsets -b flag
-		while(my_b) { dosomething_with(my_b->data) ; my_b = my_b->link; }
+	if(f & 2)       // -c after -b unsets -b flag
+		while(my_b) { dosomething_with(my_b->data); my_b = my_b->link; }
 	if(my_b)        // but llist is stored if -b is specified
 		free_llist(my_b);
 	if(verbose_level) bb_printf("verbose level is %d\n", verbose_level);
@@ -237,7 +236,7 @@
 
  "--"   A double dash at the beginning of bb_opt_complementally means the
 	argv[1] string should always be treated as options, even if it isn't
-	prefixed with a "-".  This is to support the special syntax in applets
+	prefixed with a "-".  This is useful for special syntax in applets
 	such as "ar" and "tar":
 	tar xvf foo.tar
 
Index: miscutils/hdparm.c
===================================================================
--- miscutils/hdparm.c	(revision 16195)
+++ miscutils/hdparm.c	(revision 16196)
@@ -2058,13 +2058,13 @@
 /* busybox specific stuff */
 static void parse_opts(unsigned long *get, unsigned long *set, unsigned long *value, int min, int max)
 {
-		if (get) {
-			*get = 1;
-		}
-		if (optarg) {
-			*set = 1;
-			*value = bb_xgetlarg(optarg, 10, min, max);
-		}
+	if (get) {
+		*get = 1;
+	}
+	if (optarg) {
+		*set = 1;
+		*value = bb_xgetlarg(optarg, 10, min, max);
+	}
 }
 
 static void parse_xfermode(int flag, unsigned long *get, unsigned long *set, int *value)

 ------------------------------------------------------------------------
r16192 | landley | 2006-09-22 15:11:59 -0400 (Fri, 22 Sep 2006) | 3 lines
Changed paths:
   M /trunk/busybox/coreutils/uudecode.c

Follow-up to 16172: this also doesn't produce a warning for me on gcc 4.1,
without having to feed the compiler nonsense.

 ------------------------------------------------------------------------

Index: coreutils/uudecode.c
===================================================================
--- coreutils/uudecode.c	(revision 16191)
+++ coreutils/uudecode.c	(revision 16192)
@@ -125,7 +125,6 @@
 
 int uudecode_main(int argc, char **argv)
 {
-	int (*decode_fn_ptr)(FILE * src, FILE * dst) = read_stduu; /* silence gcc */
 	FILE *src_stream;
 	char *outname = NULL;
 	char *line;
@@ -142,6 +141,7 @@
 
 	/* Search for the start of the encoding */
 	while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL) {
+		int (*decode_fn_ptr)(FILE * src, FILE * dst);
 		char *line_ptr = NULL;
 
 		if (strncmp(line, "begin-base64 ", 13) == 0) {

 ------------------------------------------------------------------------
r16191 | landley | 2006-09-22 14:47:45 -0400 (Fri, 22 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/console-tools/Config.in
   M /trunk/busybox/console-tools/Makefile.in
   M /trunk/busybox/console-tools/resize.c
   M /trunk/busybox/include/applets.h
   M /trunk/busybox/include/usage.h

"I'll think about it" != "apply it now".  It means I need to think about it.

 ------------------------------------------------------------------------

Index: console-tools/Makefile.in
===================================================================
--- console-tools/Makefile.in	(revision 16190)
+++ console-tools/Makefile.in	(revision 16191)
@@ -20,7 +20,6 @@
 CONSOLETOOLS-$(CONFIG_LOADKMAP)	+= loadkmap.o
 CONSOLETOOLS-$(CONFIG_OPENVT)	+= openvt.o
 CONSOLETOOLS-$(CONFIG_RESET)	+= reset.o
-CONSOLETOOLS-$(CONFIG_APP_RESIZE)	+= resize.o
 CONSOLETOOLS-$(CONFIG_SETKEYCODES)	+= setkeycodes.o
 CONSOLETOOLS-$(CONFIG_SETLOGCONS)	+= setlogcons.o
 
Index: console-tools/resize.c
===================================================================
--- console-tools/resize.c	(revision 16190)
+++ console-tools/resize.c	(revision 16191)
@@ -1,38 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * resize - set terminal width and height.
- *
- * Copyright 2006 Bernhard Fischer
- *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
- */
-/* no options, no getopt */
-#include "busybox.h"
-
-int resize_main(int argc, char **argv)
-{
-	struct termios old, new;
-	struct winsize w = {0,0,0,0};
-	int ret;
-
-	tcgetattr(STDOUT_FILENO, &old); /* fiddle echo */
-	new = old;
-	new.c_cflag |= (CLOCAL | CREAD);
-	new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
-	tcsetattr(STDOUT_FILENO, TCSANOW, &new);
-	/* save_cursor_pos 7
-	 * scroll_whole_screen [r
-	 * put_cursor_waaaay_off [$x;$yH
-	 * get_cursor_pos [6n
-	 * restore_cursor_pos 8
-	 */
-	printf("\0337\033[r\033[999;999H\033[6n");
-	scanf("\033[%hu;%huR", &w.ws_row, &w.ws_col);
-	ret = ioctl(STDOUT_FILENO, TIOCSWINSZ, &w);
-	printf("\0338");
-	tcsetattr(STDOUT_FILENO, TCSANOW, &old);
-	if (ENABLE_FEATURE_RESIZE_PRINT)
-		printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;",
-			w.ws_col, w.ws_row);
-	return ret;
-}
Index: console-tools/Config.in
===================================================================
--- console-tools/Config.in	(revision 16190)
+++ console-tools/Config.in	(revision 16191)
@@ -58,23 +58,6 @@
 	  This program is used to reset the terminal screen, if it
 	  gets messed up.
 
-config CONFIG_APP_RESIZE
-	bool "resize"
-	default n
-	help
-	  This program is used to (re)set the width and height of your current
-	  terminal.
-
-config CONFIG_FEATURE_RESIZE_PRINT
-	bool "print environment variables"
-	default n
-	depends on CONFIG_APP_RESIZE
-	help
-	  Prints the newly set size (number of columns and rows) of
-	  the terminal.
-	  E.g.:
-	  COLUMNS=80;LINES=44;export COLUMNS LINES;
-
 config CONFIG_SETCONSOLE
 	bool "setconsole"
 	default n
Index: include/usage.h
===================================================================
--- include/usage.h	(revision 16190)
+++ include/usage.h	(revision 16191)
@@ -2455,11 +2455,6 @@
 #define reset_full_usage \
 	"Resets the screen."
 
-#define resize_trivial_usage \
-	""
-#define resize_full_usage \
-	"Resizes the screen."
-
 #define rm_trivial_usage \
 	"[OPTION]... FILE..."
 #define rm_full_usage \
Index: include/applets.h
===================================================================
--- include/applets.h	(revision 16190)
+++ include/applets.h	(revision 16191)
@@ -58,6 +58,7 @@
 USE_AWK(APPLET(awk, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
 USE_BASENAME(APPLET(basename, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
 USE_BBCONFIG(APPLET(bbconfig, _BB_DIR_BIN, _BB_SUID_NEVER))
+//USE_BBSH(APPLET(bbsh, _BB_DIR_BIN, _BB_SUID_NEVER))
 USE_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
 /* Always enabled. */
 APPLET_NOUSAGE(busybox, busybox, _BB_DIR_BIN, _BB_SUID_MAYBE)
@@ -226,7 +227,6 @@
 USE_HALT(APPLET_ODDNAME(reboot, halt, _BB_DIR_SBIN, _BB_SUID_NEVER, reboot))
 USE_RENICE(APPLET(renice, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
 USE_RESET(APPLET(reset, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
-USE_APP_RESIZE(APPLET(resize, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
 USE_RM(APPLET(rm, _BB_DIR_BIN, _BB_SUID_NEVER))
 USE_RMDIR(APPLET(rmdir, _BB_DIR_BIN, _BB_SUID_NEVER))
 USE_RMMOD(APPLET(rmmod, _BB_DIR_SBIN, _BB_SUID_NEVER))

 ------------------------------------------------------------------------
r16188 | vda | 2006-09-22 12:02:40 -0400 (Fri, 22 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/networking/netstat.c

netstat: getopt_ulflags'isation

 ------------------------------------------------------------------------

Index: networking/netstat.c
===================================================================
--- networking/netstat.c	(revision 16187)
+++ networking/netstat.c	(revision 16188)
@@ -18,16 +18,17 @@
 extern void displayroutes(int noresolve, int netstatfmt);
 #endif
 
-#define NETSTAT_CONNECTED	0x01
-#define NETSTAT_LISTENING	0x02
-#define NETSTAT_NUMERIC		0x04
-#define NETSTAT_TCP			0x10
-#define NETSTAT_UDP			0x20
-#define NETSTAT_RAW			0x40
-#define NETSTAT_UNIX		0x80
+#define NETSTAT_CONNECTED       0x01
+#define NETSTAT_LISTENING       0x02
+#define NETSTAT_NUMERIC         0x04
+/* Must match getopt_ulflags option string */
+#define NETSTAT_TCP             0x10
+#define NETSTAT_UDP             0x20
+#define NETSTAT_RAW             0x40
+#define NETSTAT_UNIX            0x80
+#define NETSTAT_ALLPROTO (NETSTAT_TCP|NETSTAT_UDP|NETSTAT_RAW|NETSTAT_UNIX)
 
-static int flags = NETSTAT_CONNECTED |
-			NETSTAT_TCP | NETSTAT_UDP | NETSTAT_RAW | NETSTAT_UNIX;
+static int flags = NETSTAT_CONNECTED | NETSTAT_ALLPROTO;
 
 #define PROGNAME_WIDTHs PROGNAME_WIDTH1(PROGNAME_WIDTH)
 #define PROGNAME_WIDTH1(s) PROGNAME_WIDTH2(s)
@@ -165,7 +166,7 @@
 	}
 
 	if (num < 10) {
-		bb_error_msg("warning, got bogus tcp line.");
+		bb_error_msg("warning, got bogus tcp line");
 		return;
 	}
 	state_str = tcp_state[state];
@@ -236,7 +237,7 @@
 	}
 
 	if (num < 10) {
-		bb_error_msg("warning, got bogus udp line.");
+		bb_error_msg("warning, got bogus udp line");
 		return;
 	}
 	switch (state) {
@@ -330,7 +331,7 @@
 	}
 
 	if (num < 10) {
-		bb_error_msg("warning, got bogus raw line.");
+		bb_error_msg("warning, got bogus raw line");
 		return;
 	}
 	state_str=itoa(state);
@@ -383,7 +384,7 @@
 	num = sscanf(line, "%p: %lX %lX %lX %X %X %d %s",
 				 &d, &refcnt, &proto, &unix_flags, &type, &state, &inode, path);
 	if (num < 6) {
-		bb_error_msg("warning, got bogus unix line.");
+		bb_error_msg("warning, got bogus unix line");
 		return;
 	}
 	if (!(has & HAS_INODE))
@@ -504,7 +505,7 @@
 		if (errno != ENOENT) {
 			perror(file);
 		} else {
-		bb_error_msg("no support for `%s' on this system.", name);
+		bb_error_msg("no support for `%s' on this system", name);
 		}
 	} else {
 		do {
@@ -521,69 +522,53 @@
 
 int netstat_main(int argc, char **argv)
 {
-	int opt;
-	int new_flags=0;
-	int showroute = 0, extended = 0;
+	enum {
+		OPT_extended = 0x4,
+		OPT_showroute = 0x100,
+	};
+	unsigned long opt;
 #ifdef CONFIG_FEATURE_IPV6
-	int inet=1;
-	int inet6=1;
+	int inet = 1;
+	int inet6 = 1;
 #else
 # define inet 1
 # define inet6 0
 #endif
-	while ((opt = getopt(argc, argv, "laenrtuwx")) != -1)
-		switch (opt) {
-		case 'l':
-			flags &= ~NETSTAT_CONNECTED;
-			flags |= NETSTAT_LISTENING;
-			break;
-		case 'a':
-			flags |= NETSTAT_LISTENING | NETSTAT_CONNECTED;
-			break;
-		case 'n':
-			flags |= NETSTAT_NUMERIC;
-			break;
-		case 'r':
-			showroute = 1;
-			break;
-		case 'e':
-			extended = 1;
-			break;
-		case 't':
-			new_flags |= NETSTAT_TCP;
-			break;
-		case 'u':
-			new_flags |= NETSTAT_UDP;
-			break;
-		case 'w':
-			new_flags |= NETSTAT_RAW;
-			break;
-		case 'x':
-			new_flags |= NETSTAT_UNIX;
-			break;
-		default:
-			bb_show_usage();
-		}
-	if ( showroute ) {
+
+	/* Option string must match NETSTAT_xxx constants */
+	opt = bb_getopt_ulflags(argc, argv, "laentuwxr");
+	if (opt & 0x1) { // -l
+		flags &= ~NETSTAT_CONNECTED;
+		flags |= NETSTAT_LISTENING;
+	}
+	if (opt & 0x2) flags |= NETSTAT_LISTENING | NETSTAT_CONNECTED; // -a
+	//if (opt & 0x4) // -e
+	if (opt & 0x8) flags |= NETSTAT_NUMERIC; // -n
+	//if (opt & 0x10) // -t: NETSTAT_TCP
+	//if (opt & 0x20) // -u: NETSTAT_UDP
+	//if (opt & 0x40) // -w: NETSTAT_RAW
+	//if (opt & 0x80) // -x: NETSTAT_UNIX
+	if (opt & OPT_showroute) { // -r
 #ifdef CONFIG_ROUTE
-		displayroutes ( flags & NETSTAT_NUMERIC, !extended );
+		displayroutes(flags & NETSTAT_NUMERIC, !(opt & OPT_extended));
 		return 0;
 #else
-		bb_error_msg_and_die( "-r (display routing table) is not compiled in." );
+		bb_error_msg_and_die("-r (display routing table) is not compiled in");
 #endif
 	}
 
-	if (new_flags) {
-		flags &= ~(NETSTAT_TCP|NETSTAT_UDP|NETSTAT_RAW|NETSTAT_UNIX);
-		flags |= new_flags;
+	opt &= NETSTAT_ALLPROTO;
+	if (opt) {
+		flags &= ~NETSTAT_ALLPROTO;
+		flags |= opt;
 	}
-	if (flags&(NETSTAT_TCP|NETSTAT_UDP|NETSTAT_RAW)) {
+	if (flags & (NETSTAT_TCP|NETSTAT_UDP|NETSTAT_RAW)) {
 		printf("Active Internet connections ");	/* xxx */
 
 		if ((flags&(NETSTAT_LISTENING|NETSTAT_CONNECTED))==(NETSTAT_LISTENING|NETSTAT_CONNECTED))
 			printf("(servers and established)");
 		else {
-			if (flags&NETSTAT_LISTENING)
+			if (flags & NETSTAT_LISTENING)
 				printf("(only servers)");
 			else
 				printf("(w/o servers)");

 ------------------------------------------------------------------------
r16187 | vda | 2006-09-22 11:13:38 -0400 (Fri, 22 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/archival/gzip.c

gzip: getopt_ulflags'isation

 ------------------------------------------------------------------------

Index: archival/gzip.c
===================================================================
--- archival/gzip.c	(revision 16186)
+++ archival/gzip.c	(revision 16187)
@@ -1122,44 +1122,36 @@
 /* ======================================================================== */
 int gzip_main(int argc, char **argv)
 {
+	enum {
+		OPT_tostdout = 0x1,
+		OPT_force = 0x2,
+	};
+
+	unsigned long opt;
 	int result;
 	int inFileNum;
 	int outFileNum;
 	struct stat statBuf;
 	char *delFileName;
-	int tostdout = 0;
-	int force = 0;
-	int opt;
 
-	while ((opt = getopt(argc, argv, "cf123456789dq")) != -1) {
-		switch (opt) {
-		case 'c':
-			tostdout = 1;
-			break;
-		case 'f':
-			force = 1;
-			break;
-			/* Ignore 1-9 (compression level) options */
-		case '1':
-		case '2':
-		case '3':
-		case '4':
-		case '5':
-		case '6':
-		case '7':
-		case '8':
-		case '9':
-			break;
-		case 'q':
-			break;
-#ifdef CONFIG_GUNZIP
-		case 'd':
-			optind = 1;
-			return gunzip_main(argc, argv);
-#endif
-		default:
-			bb_show_usage();
-		}
+	opt = bb_getopt_ulflags(argc, argv, "cf123456789q" USE_GUNZIP("d"));
+	//if (opt & 0x1) // -c
+	//if (opt & 0x2) // -f
+	/* Ignore 1-9 (compression level) options */
+	//if (opt & 0x4) // -1
+	//if (opt & 0x8) // -2
+	//if (opt & 0x10) // -3
+	//if (opt & 0x20) // -4
+	//if (opt & 0x40) // -5
+	//if (opt & 0x80) // -6
+	//if (opt & 0x100) // -7
+	//if (opt & 0x200) // -8
+	//if (opt & 0x400) // -9
+	//if (opt & 0x800) // -q
+	if (ENABLE_GUNZIP && (opt & 0x1000)) { // -d
+		/* FIXME: bb_getopt_ulflags should not depend on optind */
+		optind = 1;
+		return gunzip_main(argc, argv);
 	}
 
 	foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
@@ -1211,7 +1203,7 @@
 					bb_perror_msg_and_die("%s", argv[i]);
 				time_stamp = statBuf.st_ctime;
 
-				if (!tostdout) {
+				if (!(opt & OPT_tostdout)) {
 					path = xasprintf("%s.gz", argv[i]);
 
 					/* Open output file */
@@ -1233,7 +1225,7 @@
 					outFileNum = STDOUT_FILENO;
 			}
 
-			if (path == NULL && isatty(outFileNum) && force == 0) {
+			if (path == NULL && isatty(outFileNum) && !(opt & OPT_force)) {
 				bb_error_msg
 					("compressed data not written to a terminal. Use -f to force compression.");
 				free(path);

 ------------------------------------------------------------------------
r16186 | vda | 2006-09-22 10:53:41 -0400 (Fri, 22 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/libbb/verror_msg.c
   M /trunk/busybox/util-linux/losetup.c

losetup: getopt_ulflags'ification + small fix for perror_nomsg

 ------------------------------------------------------------------------

Index: libbb/verror_msg.c
===================================================================
--- libbb/verror_msg.c	(revision 16185)
+++ libbb/verror_msg.c	(revision 16186)
@@ -27,7 +27,9 @@
 		if (!strerr)
 			fputs(msg_eol, stderr);
 		else
-			fprintf(stderr, ": %s%s", strerr, msg_eol);
+			fprintf(stderr, "%s%s%s",
+					s ? ": " : "",
+					strerr, msg_eol);
 	}
 	if (ENABLE_FEATURE_SYSLOG && (logmode & LOGMODE_SYSLOG)) {
 		if (!strerr)
Index: util-linux/losetup.c
===================================================================
--- util-linux/losetup.c	(revision 16185)
+++ util-linux/losetup.c	(revision 16186)
@@ -12,39 +12,41 @@
 
 #include "busybox.h"
 
-int losetup_main (int argc, char **argv)
+int losetup_main(int argc, char **argv)
 {
-  int offset = 0;
+	unsigned long opt;
+	char *opt_o;
+	int offset = 0;
 
-  /* This will need a "while(getopt()!=-1)" loop when we can have more than
-     one option, but for now we can't. */
-  switch(getopt(argc,argv, "do:")) {
-    case 'd':
-      /* detach takes exactly one argument */
-      if(optind+1!=argc) bb_show_usage();
-      if(!del_loop(argv[optind])) return EXIT_SUCCESS;
-die_failed:
-      bb_perror_msg_and_die("%s",argv[optind]);
+	opt = bb_getopt_ulflags(argc, argv, "do:", &opt_o);
+	argc -= optind;
+	argv += optind;
 
-    case 'o':
-      offset = bb_xparse_number (optarg, NULL);
-      /* Fall through to do the losetup */
-    case -1:
-      /* losetup takes two argument:, loop_device and file */
-      if(optind+2==argc) {
-	if(set_loop(&argv[optind], argv[optind + 1], offset)>=0)
-	  return EXIT_SUCCESS;
-	else goto die_failed;
-      }
-      if(optind+1==argc) {
-	char *s=query_loop(argv[optind]);
-	if (!s) goto die_failed;
-	printf("%s: %s\n",argv[optind],s);
-	if(ENABLE_FEATURE_CLEAN_UP) free(s);
+	if (opt == 0x3) bb_show_usage(); // -d and -o (illegal)
+
+	if (opt == 0x1) { // -d
+		/* detach takes exactly one argument */
+		if (argc != 1)
+			bb_show_usage();
+		if (!del_loop(argv[0]))
+			return EXIT_SUCCESS;
+		bb_perror_nomsg_and_die();
+	}
+
+	if (opt == 0x2) // -o
+		offset = bb_xparse_number(opt_o, NULL);
+
+	/* -o or no option */
+
+	if (argc == 2) {
+		if (set_loop(&argv[0], argv[1], offset) < 0)
+			bb_perror_nomsg_and_die();
+	} else if (argc == 1) {
+		char *s = query_loop(argv[0]);
+		if (!s) bb_perror_nomsg_and_die();
+		printf("%s: %s\n", argv[0], s);
+		if (ENABLE_FEATURE_CLEAN_UP) free(s);
+	} else
+		bb_show_usage();
 	return EXIT_SUCCESS;
-      }
-      break;
-  }
-  bb_show_usage();
-  return EXIT_FAILURE;
 }

 ------------------------------------------------------------------------
r16185 | vda | 2006-09-22 05:02:30 -0400 (Fri, 22 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/editors/awk.c

awk: getopt_ulflags'isation

 ------------------------------------------------------------------------

Index: editors/awk.c
===================================================================
--- editors/awk.c	(revision 16184)
+++ editors/awk.c	(revision 16185)
@@ -2605,6 +2605,8 @@
 
 int awk_main(int argc, char **argv)
 {
+	unsigned long opt;
+	char *opt_F, *opt_v, *opt_W;
 	char *s, *s1;
 	int i, j, c, flen;
 	var *v;
@@ -2660,49 +2662,37 @@
 		free(s);
 	}
 
-	while((c = getopt(argc, argv, "F:v:f:W:")) != EOF) {
-		switch (c) {
-			case 'F':
-				setvar_s(V[FS], optarg);
-				break;
-			case 'v':
-				if (! is_assignment(optarg))
-					bb_show_usage();
-				break;
-			case 'f':
-				from_file = TRUE;
-				F = afopen(programname = optarg, "r");
-				s = NULL;
-				/* one byte is reserved for some trick in next_token */
-				if (fseek(F, 0, SEEK_END) == 0) {
-					flen = ftell(F);
-					s = (char *)xmalloc(flen+4);
-					fseek(F, 0, SEEK_SET);
-					i = 1 + fread(s+1, 1, flen, F);
-				} else {
-					for (i=j=1; j>0; i+=j) {
-						s = (char *)xrealloc(s, i+4096);
-						j = fread(s+i, 1, 4094, F);
-					}
-				}
-				s[i] = '\0';
-				fclose(F);
-				parse_program(s+1);
-				free(s);
-				break;
-			case 'W':
-				bb_error_msg("Warning: unrecognized option '-W %s' ignored", optarg);
-				break;
-
-			default:
-				bb_show_usage();
+	opt = bb_getopt_ulflags(argc, argv, "F:v:f:W:", &opt_F, &opt_v, &programname, &opt_W);
+	if (opt & 0x1) setvar_s(V[FS], opt_F); // -F
+	if (opt & 0x2) if (!is_assignment(opt_v)) bb_show_usage(); // -v
+	if (opt & 0x4) { // -f
+		from_file = TRUE;
+		F = afopen(programname, "r");
+		s = NULL;
+		/* one byte is reserved for some trick in next_token */
+		if (fseek(F, 0, SEEK_END) == 0) {
+			flen = ftell(F);
+			s = (char *)xmalloc(flen+4);
+			fseek(F, 0, SEEK_SET);
+			i = 1 + fread(s+1, 1, flen, F);
+		} else {
+			for (i=j=1; j>0; i+=j) {
+				s = (char *)xrealloc(s, i+4096);
+				j = fread(s+i, 1, 4094, F);
+			}
 		}
+		s[i] = '\0';
+		fclose(F);
+		parse_program(s+1);
+		free(s);
 	}
+	if (opt & 0x8) // -W
+		bb_error_msg("Warning: unrecognized option '-W %s' ignored", opt_W);
 
 	if (!from_file) {
 		if (argc == optind)
 			bb_show_usage();
-		programname="cmd. line";
+		programname = "cmd. line";
 		parse_program(argv[optind++]);
 
 	}

 ------------------------------------------------------------------------
r16184 | vda | 2006-09-22 04:56:03 -0400 (Fri, 22 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/editors/sed.c

sed: getopt_ulflags'isation

 ------------------------------------------------------------------------

Index: editors/sed.c
===================================================================
--- editors/sed.c	(revision 16183)
+++ editors/sed.c	(revision 16184)
@@ -1086,7 +1086,9 @@
 
 int sed_main(int argc, char **argv)
 {
-	int status = EXIT_SUCCESS, opt, getpat = 1;
+	unsigned long opt;
+	char *opt_e, *opt_f;
+	int status = EXIT_SUCCESS, getpat = 1;
 
 	bbg.sed_cmd_tail=&bbg.sed_cmd_head;
 
@@ -1100,41 +1102,27 @@
 	}
 
 	/* do normal option parsing */
-	while ((opt = getopt(argc, argv, "irne:f:")) > 0) {
-		switch (opt) {
-		case 'i':
-			bbg.in_place++;
-			atexit(cleanup_outname);
-			break;
-		case 'r':
-			bbg.regex_type|=REG_EXTENDED;
-			break;
-		case 'n':
-			bbg.be_quiet++;
-			break;
-		case 'e':
-			add_cmd_block(optarg);
+	opt = bb_getopt_ulflags(argc, argv, "irne:f:", &opt_e, &opt_f);
+	if (opt & 0x1) { // -i
+		bbg.in_place++;
+		atexit(cleanup_outname);
+	}
+	if (opt & 0x2) bbg.regex_type|=REG_EXTENDED; // -r
+	if (opt & 0x4) bbg.be_quiet++; // -n
+	if (opt & 0x8) { // -e
+		add_cmd_block(opt_e);
+		getpat=0;
+	}
+	if (opt & 0x10) { // -f
+		FILE *cmdfile;
+		char *line;
+		cmdfile = xfopen(opt_f, "r");
+		while ((line = bb_get_chomped_line_from_file(cmdfile)) != NULL) {
+			add_cmd(line);
 			getpat=0;
-			break;
-		case 'f':
-		{
-			FILE *cmdfile;
-			char *line;
-
-			cmdfile = xfopen(optarg, "r");
-
-			while ((line = bb_get_chomped_line_from_file(cmdfile)) != NULL) {
-				add_cmd(line);
-				getpat=0;
-				free(line);
-			}
-			xprint_and_close_file(cmdfile);
-
-			break;
+			free(line);
 		}
-		default:
-			bb_show_usage();
-		}
+		xprint_and_close_file(cmdfile);
 	}
 
 	/* if we didn't get a pattern from -e or -f, use argv[optind] */

 ------------------------------------------------------------------------
r16183 | vda | 2006-09-22 04:53:14 -0400 (Fri, 22 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/networking/hostname.c

hostname: getopt_ulflags'isation

 ------------------------------------------------------------------------

Index: networking/hostname.c
===================================================================
--- networking/hostname.c	(revision 16182)
+++ networking/hostname.c	(revision 16183)
@@ -14,15 +14,11 @@
  */
 
 #include "busybox.h"
-#include 
 
-extern char *optarg; /* in unistd.h */
-extern int  optind, opterr, optopt; /* in unistd.h */
-
 static void do_sethostname(char *s, int isfile)
 {
 	FILE *f;
-	char buf[255];
+	char buf[256];
 
 	if (!s)
 		return;
@@ -35,7 +31,7 @@
 		}
 	} else {
 		f = xfopen(s, "r");
-		while (fgets(buf, 255, f) != NULL) {
+		while (fgets(buf, sizeof(buf), f) != NULL) {
 			if (buf[0] =='#') {
 				continue;
 			}
@@ -50,64 +46,57 @@
 
 int hostname_main(int argc, char **argv)
 {
-	int opt;
-	int type = 0;
-	struct hostent *hp;
-	char *filename = NULL;
-	char buf[255];
-	char *p = NULL;
+	enum {
+		OPT_d = 0x1,
+		OPT_f = 0x2,
+		OPT_i = 0x4,
+		OPT_s = 0x8,
+		OPT_dfis = 0xf,
+	};
 
+	char buf[256];
+	unsigned long opt;
+	char *hostname_str = NULL;
+
 	if (argc < 1)
 		bb_show_usage();
 
-	while ((opt = getopt(argc, argv, "dfisF:")) > 0) {
-		switch (opt) {
-		case 'd':
-		case 'f':
-		case 'i':
-		case 's':
-			type = opt;
-			break;
-		case 'F':
-			filename = optarg;
-			break;
-		default:
-			bb_show_usage();
-		}
-	}
+	opt = bb_getopt_ulflags(argc, argv, "dfisF:", &hostname_str);
 
 	/* Output in desired format */
-	if (type != 0) {
-		gethostname(buf, 255);
+	if (opt & OPT_dfis) {
+		struct hostent *hp;
+		char *p;
+		gethostname(buf, sizeof(buf));
 		hp = xgethostbyname(buf);
 		p = strchr(hp->h_name, '.');
-		if (type == 'f') {
+		if (opt & OPT_f) {
 			puts(hp->h_name);
-		} else if (type == 's') {
+		} else if (opt & OPT_s) {
 			if (p != NULL) {
 				*p = 0;
 			}
 			puts(hp->h_name);
-		} else if (type == 'd') {
+		} else if (opt & OPT_d) {
 			if (p) puts(p + 1);
-		} else if (type == 'i') {
+		} else if (opt & OPT_i) {
 			while (hp->h_addr_list[0]) {
 				printf("%s ", inet_ntoa(*(struct in_addr *) (*hp->h_addr_list++)));
 			}
-			printf("\n");
+			puts("");
 		}
 	}
 	/* Set the hostname */
-	else if (filename != NULL) {
-		do_sethostname(filename, 1);
+	else if (hostname_str != NULL) {
+		do_sethostname(hostname_str, 1);
 	} else if (optind < argc) {
 		do_sethostname(argv[optind], 0);
 	}
 	/* Or if all else fails,
 	 * just print the current hostname */
-	 else {
-		gethostname(buf, 255);
+	else {
+		gethostname(buf, sizeof(buf));
 		puts(buf);
 	}
-	return(0);
+	return 0;
 }

 ------------------------------------------------------------------------
r16182 | vda | 2006-09-22 04:50:29 -0400 (Fri, 22 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/networking/telnetd.c

telnetd: getopt_ulflags'isation

 ------------------------------------------------------------------------

Index: networking/telnetd.c
===================================================================
--- networking/telnetd.c	(revision 16181)
+++ networking/telnetd.c	(revision 16182)
@@ -362,24 +362,17 @@
 int
 telnetd_main(int argc, char **argv)
 {
-#ifndef CONFIG_FEATURE_TELNETD_INETD
-	sockaddr_type sa;
-	int master_fd;
-#endif /* CONFIG_FEATURE_TELNETD_INETD */
+	unsigned long opt;
 	fd_set rdfdset, wrfdset;
 	int selret;
 #ifndef CONFIG_FEATURE_TELNETD_INETD
+	sockaddr_type sa;
+	int master_fd;
 	int on = 1;
 	int portnbr = 23;
 	struct in_addr bind_addr = { .s_addr = 0x0 };
+	char *opt_portnbr, *opt_bindaddr;
 #endif /* CONFIG_FEATURE_TELNETD_INETD */
-	int c;
-	static const char options[] =
-#ifdef CONFIG_FEATURE_TELNETD_INETD
-		"f:l:";
-#else /* CONFIG_EATURE_TELNETD_INETD */
-		"f:l:p:b:";
-#endif /* CONFIG_FEATURE_TELNETD_INETD */
 	int maxlen, w, r;
 
 #ifndef CONFIG_LOGIN
@@ -394,29 +387,16 @@
 	openlog(bb_applet_name, 0, LOG_USER);
 	logmode = LOGMODE_SYSLOG;
 
-	for (;;) {
-		c = getopt( argc, argv, options);
-		if (c == EOF) break;
-		switch (c) {
-			case 'f':
-				issuefile = optarg;
-				break;
-			case 'l':
-				loginpath = optarg;
-				break;
+	opt = bb_getopt_ulflags(argc, argv, "f:l:" USE_FEATURE_TELNETD_INETD("p:b:"),
+			&issuefile, &loginpath
+			SKIP_FEATURE_TELNETD_INETD(, &opt_portnbr, &opt_bindaddr));
+	//if (opt & 1) // -f
+	//if (opt & 2) // -l
 #ifndef CONFIG_FEATURE_TELNETD_INETD
-			case 'p':
-				portnbr = atoi(optarg);
-				break;
-			case 'b':
-				if (inet_aton(optarg, &bind_addr) == 0)
-					bb_show_usage();
-				break;
+	if (opt & 4) portnbr = atoi(opt_portnbr); // -p
+	if (opt & 8) // -b
+		if (inet_aton(opt_bindaddr, &bind_addr) == 0) bb_show_usage();
 #endif /* CONFIG_FEATURE_TELNETD_INETD */
-			default:
-				bb_show_usage();
-		}
-	}
 
 	if (access(loginpath, X_OK) < 0) {
 		bb_error_msg_and_die("'%s' unavailable", loginpath);

 ------------------------------------------------------------------------
r16181 | vda | 2006-09-22 04:47:54 -0400 (Fri, 22 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/miscutils/adjtimex.c

adjtimex: getopt_ulflags'isation

 ------------------------------------------------------------------------

Index: miscutils/adjtimex.c
===================================================================
--- miscutils/adjtimex.c	(revision 16180)
+++ miscutils/adjtimex.c	(revision 16181)
@@ -44,49 +44,44 @@
 
 int adjtimex_main(int argc, char **argv)
 {
+	enum {
+		OPT_quiet = 0x1
+	};
+	unsigned long opt;
+	char *opt_o, *opt_f, *opt_p, *opt_t;
 	struct timex txc;
-	int quiet=0;
-	int c, i, ret, sep;
+	int i, ret, sep;
 	const char *descript;
 	txc.modes=0;
-	for (;;) {
-		c = getopt( argc, argv, "qo:f:p:t:");
-		if (c == EOF) break;
-		switch (c) {
-			case 'q':
-				quiet=1;
-				break;
-			case 'o':
-				txc.offset = atoi(optarg);
-				txc.modes |= ADJ_OFFSET_SINGLESHOT;
-				break;
-			case 'f':
-				txc.freq = atoi(optarg);
-				txc.modes |= ADJ_FREQUENCY;
-				break;
-			case 'p':
-				txc.constant = atoi(optarg);
-				txc.modes |= ADJ_TIMECONST;
-				break;
-			case 't':
-				txc.tick = atoi(optarg);
-				txc.modes |= ADJ_TICK;
-				break;
-			default:
-				bb_show_usage();
-				exit(1);
-		}
+
+	opt = bb_getopt_ulflags(argc, argv, "qo:f:p:t:",
+			&opt_o, &opt_f, &opt_p, &opt_t);
+	//if (opt & 0x1) // -q
+	if (opt & 0x2) { // -o
+		txc.offset = atoi(opt_o);
+		txc.modes |= ADJ_OFFSET_SINGLESHOT;
 	}
+	if (opt & 0x4) { // -f
+		txc.freq = atoi(opt_f);
+		txc.modes |= ADJ_FREQUENCY;
+	}
+	if (opt & 0x8) { // -p
+		txc.constant = atoi(opt_p);
+		txc.modes |= ADJ_TIMECONST;
+	}
+	if (opt & 0x10) { // -t
+		txc.tick = atoi(opt_t);
+		txc.modes |= ADJ_TICK;
+	}
 	if (argc != optind) { /* no valid non-option parameters */
 		bb_show_usage();
-		exit(1);
 	}
 
 	ret = adjtimex(&txc);
 
 	if (ret < 0) perror("adjtimex");
 
-	if (!quiet && ret>=0) {
+	if (!(opt & OPT_quiet) && ret>=0) {
 		printf(
 			"    mode:         %d\n"
 			"-o  offset:       %ld\n"

 ------------------------------------------------------------------------
r16180 | vda | 2006-09-22 04:44:58 -0400 (Fri, 22 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/sysklogd/logger.c

logger: getopt_ulflags'isation

 ------------------------------------------------------------------------

Index: sysklogd/logger.c
===================================================================
--- sysklogd/logger.c	(revision 16179)
+++ sysklogd/logger.c	(revision 16180)
@@ -89,30 +89,21 @@
 
 int logger_main(int argc, char **argv)
 {
+	unsigned long opt;
+	char *opt_p, *opt_t;
 	int pri = LOG_USER | LOG_NOTICE;
 	int option = 0;
-	int c, i, opt;
+	int c, i;
 	char buf[1024], name[128];
 
 	/* Fill out the name string early (may be overwritten later) */
 	bb_getpwuid(name, geteuid(), sizeof(name));
 
 	/* Parse any options */
-	while ((opt = getopt(argc, argv, "p:st:")) > 0) {
-		switch (opt) {
-			case 's':
-				option |= LOG_PERROR;
-				break;
-			case 'p':
-				pri = pencode(optarg);
-				break;
-			case 't':
-				safe_strncpy(name, optarg, sizeof(name));
-				break;
-			default:
-				bb_show_usage();
-		}
-	}
+	opt = bb_getopt_ulflags(argc, argv, "p:st:", &opt_p, &opt_t);
+	if (opt & 0x1) pri = pencode(opt_p); // -p
+	if (opt & 0x2) option |= LOG_PERROR; // -s
+	if (opt & 0x4) safe_strncpy(name, opt_t, sizeof(name)); // -t
 
 	openlog(name, option, 0);
 	if (optind == argc) {

 ------------------------------------------------------------------------
r16179 | vda | 2006-09-22 04:42:06 -0400 (Fri, 22 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/util-linux/getopt.c

getopt: fix whitespace damage

 ------------------------------------------------------------------------

Index: util-linux/getopt.c
===================================================================
--- util-linux/getopt.c	(revision 16178)
+++ util-linux/getopt.c	(revision 16179)
@@ -56,7 +56,7 @@
 /* Function prototypes */
 static const char *normalize(const char *arg);
 static int generate_output(char * argv[],int argc,const char *optstr,
-		    const struct option *longopts);
+		const struct option *longopts);
 static void add_long_options(char *options);
 static void add_longopt(const char *name,int has_arg);
 static void set_shell(const char *new_shell);
@@ -80,7 +80,7 @@
 	free(BUFFER);
 
 	if (!quote) { /* Just copy arg */
-	       BUFFER=xstrdup(arg);
+		BUFFER=xstrdup(arg);
 		return BUFFER;
 	}
 
@@ -134,7 +134,7 @@
  * Other settings are found in global variables.
  */
 int generate_output(char * argv[],int argc,const char *optstr,
-		    const struct option *longopts)
+		const struct option *longopts)
 {
 	int exit_code = 0; /* We assume everything will be OK */
 	int opt;
@@ -146,8 +146,8 @@
 	optind=0; /* Reset getopt(3) */
 
 	while ((opt = (alternative?
-		       getopt_long_only(argc,argv,optstr,longopts,&longindex):
-		       getopt_long(argc,argv,optstr,longopts,&longindex)))
+			getopt_long_only(argc,argv,optstr,longopts,&longindex):
+			getopt_long(argc,argv,optstr,longopts,&longindex)))
 	       != EOF)
 		if (opt == '?' || opt == ':' )
 			exit_code = 1;
@@ -156,7 +156,7 @@
 				printf(" --%s",longopts[longindex].name);
 				if (longopts[longindex].has_arg)
 					printf(" %s",
-					       normalize(optarg?optarg:""));
+						normalize(optarg?optarg:""));
 			} else if (opt == NON_OPT)
 				printf(" %s",normalize(optarg));
 			else {
@@ -164,7 +164,7 @@
 				charptr = strchr(optstr,opt);
 				if (charptr != NULL && *++charptr == ':')
 					printf(" %s",
-					       normalize(optarg?optarg:""));
+						normalize(optarg?optarg:""));
 			}
 		}
 
@@ -209,7 +209,7 @@
 		long_options[long_options_nr-1].has_arg=has_arg;
 		long_options[long_options_nr-1].flag=NULL;
 		long_options[long_options_nr-1].val=LONG_OPT;
-	       long_options[long_options_nr-1].name=xstrdup(name);
+		long_options[long_options_nr-1].name=xstrdup(name);
 	}
 	long_options_nr++;
 }
@@ -305,7 +305,7 @@
 			/* For some reason, the original getopt gave no error
 			   when there were no arguments. */
 			printf(" --\n");
-		       return 0;
+			return 0;
 		} else
 			bb_error_msg_and_die("missing optstring argument");
 	}
@@ -317,7 +317,7 @@
 		s=xmalloc(strlen(argv[1])+1);
 		strcpy(s,argv[1]+strspn(argv[1],"-+"));
 		argv[1]=argv[0];
-	       return (generate_output(argv+1,argc-1,s,long_options));
+		return (generate_output(argv+1,argc-1,s,long_options));
 	}
 
 	while ((opt=getopt_long(argc,argv,shortopts,longopts,NULL)) != EOF)
@@ -326,13 +326,13 @@
 			alternative=1;
 			break;
 		case 'o':
-		       optstr = optarg;
+			optstr = optarg;
 			break;
 		case 'l':
 			add_long_options(optarg);
 			break;
 		case 'n':
-		       name = optarg;
+			name = optarg;
 			break;
 		case 'q':
 			quiet_errors=1;
@@ -344,7 +344,7 @@
 			set_shell(optarg);
 			break;
 		case 'T':
-		       return 4;
+			return 4;
 		case 'u':
 			quote=0;
 			break;
@@ -361,5 +361,5 @@
 		argv[optind-1]=name;
 	else
 		argv[optind-1]=argv[0];
-       return (generate_output(argv+optind-1,argc-optind+1,optstr,long_options));
+	return generate_output(argv+optind-1,argc-optind+1,optstr,long_options);
 }

 ------------------------------------------------------------------------
r16178 | vda | 2006-09-22 04:39:49 -0400 (Fri, 22 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/util-linux/readprofile.c

readprofile: getopt_ulflags'isation

 ------------------------------------------------------------------------

Index: util-linux/readprofile.c
===================================================================
--- util-linux/readprofile.c	(revision 16177)
+++ util-linux/readprofile.c	(revision 16178)
@@ -50,10 +50,9 @@
 	uint64_t add0=0;
 	unsigned int step;
 	unsigned int *buf, total, fn_len;
-	unsigned long long fn_add, next_add;          /* current and next address */
+	unsigned long long fn_add, next_add;     /* current and next address */
 	char fn_name[S_LEN], next_name[S_LEN];   /* current and next name */
 	char mode[8];
-	int c;
 	int optAll=0, optInfo=0, optReset=0, optVerbose=0, optNative=0;
 	int optBins=0, optSub=0;
 	char mapline[S_LEN];
@@ -65,42 +64,11 @@
 	proFile = defaultpro;
 	mapFile = defaultmap;
 
-	while ((c = getopt(argc, argv, "M:m:np:itvarVbs")) != -1) {
-		switch(c) {
-		case 'm':
-			mapFile = optarg;
-			break;
-		case 'n':
-			optNative++;
-			break;
-		case 'p':
-			proFile = optarg;
-			break;
-		case 'a':
-			optAll++;
-			break;
-		case 'b':
-			optBins++;
-			break;
-		case 's':
-			optSub++;
-			break;
-		case 'i':
-			optInfo++;
-			break;
-		case 'M':
-			mult = optarg;
-			break;
-		case 'r':
-			optReset++;
-			break;
-		case 'v':
-			optVerbose++;
-			break;
-		default:
-			bb_show_usage();
-		}
-	}
+	bb_opt_complementally = "nn:aa:bb:ss:ii:rr:vv";
+	bb_getopt_ulflags(argc, argv, "M:m:p:nabsirv",
+			&mult, &mapFile, &proFile,
+			&optNative, &optAll, &optBins, &optSub,
+			&optInfo, &optReset, &optVerbose);
 
 	if (optReset || mult) {
 		int multiplier, fd, to_write;

 ------------------------------------------------------------------------
r16177 | vda | 2006-09-22 04:30:52 -0400 (Fri, 22 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/util-linux/ipcs.c

ipcs: fix my recent breakage

 ------------------------------------------------------------------------

Index: util-linux/ipcs.c
===================================================================
--- util-linux/ipcs.c	(revision 16176)
+++ util-linux/ipcs.c	(revision 16177)
@@ -581,7 +581,7 @@
 
 	opt = bb_getopt_ulflags(argc, argv, "i:aqsmtcplu", &opt_i);
 	if (opt & 0x1) { // -i
-		id = atoi(optarg);
+		id = atoi(opt_i);
 		flags |= flag_print;
 	}
 	if (opt & 0x2) flags |= flag_msg | flag_sem | flag_shm; // -a

 ------------------------------------------------------------------------
r16176 | aldot | 2006-09-22 04:18:41 -0400 (Fri, 22 Sep 2006) | 5 lines
Changed paths:
   M /trunk/busybox/console-tools/Config.in
   M /trunk/busybox/console-tools/Makefile.in
   A /trunk/busybox/console-tools/resize.c
   M /trunk/busybox/include/applets.h
   M /trunk/busybox/include/usage.h

- add new applet resize.
   text    data     bss     dec     hex filename
    185       0       0     185      b9 console-tools/resize.o
    255       0       0     255      ff console-tools/resize.o.print

 ------------------------------------------------------------------------

Index: console-tools/Makefile.in
===================================================================
--- console-tools/Makefile.in	(revision 16175)
+++ console-tools/Makefile.in	(revision 16176)
@@ -20,6 +20,7 @@
 CONSOLETOOLS-$(CONFIG_LOADKMAP)	+= loadkmap.o
 CONSOLETOOLS-$(CONFIG_OPENVT)	+= openvt.o
 CONSOLETOOLS-$(CONFIG_RESET)	+= reset.o
+CONSOLETOOLS-$(CONFIG_APP_RESIZE)	+= resize.o
 CONSOLETOOLS-$(CONFIG_SETKEYCODES)	+= setkeycodes.o
 CONSOLETOOLS-$(CONFIG_SETLOGCONS)	+= setlogcons.o
 
Index: console-tools/resize.c
===================================================================
--- console-tools/resize.c	(revision 0)
+++ console-tools/resize.c	(revision 16176)
@@ -0,0 +1,38 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * resize - set terminal width and height.
+ *
+ * Copyright 2006 Bernhard Fischer
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ */
+/* no options, no getopt */
+#include "busybox.h"
+
+int resize_main(int argc, char **argv)
+{
+	struct termios old, new;
+	struct winsize w = {0,0,0,0};
+	int ret;
+
+	tcgetattr(STDOUT_FILENO, &old); /* fiddle echo */
+	new = old;
+	new.c_cflag |= (CLOCAL | CREAD);
+	new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
+	tcsetattr(STDOUT_FILENO, TCSANOW, &new);
+	/* save_cursor_pos 7
+	 * scroll_whole_screen [r
+	 * put_cursor_waaaay_off [$x;$yH
+	 * get_cursor_pos [6n
+	 * restore_cursor_pos 8
+	 */
+	printf("\0337\033[r\033[999;999H\033[6n");
+	scanf("\033[%hu;%huR", &w.ws_row, &w.ws_col);
+	ret = ioctl(STDOUT_FILENO, TIOCSWINSZ, &w);
+	printf("\0338");
+	tcsetattr(STDOUT_FILENO, TCSANOW, &old);
+	if (ENABLE_FEATURE_RESIZE_PRINT)
+		printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;",
+			w.ws_col, w.ws_row);
+	return ret;
+}
Index: console-tools/Config.in
===================================================================
--- console-tools/Config.in	(revision 16175)
+++ console-tools/Config.in	(revision 16176)
@@ -58,6 +58,23 @@
 	  This program is used to reset the terminal screen, if it
 	  gets messed up.
 
+config CONFIG_APP_RESIZE
+	bool "resize"
+	default n
+	help
+	  This program is used to (re)set the width and height of your current
+	  terminal.
+
+config CONFIG_FEATURE_RESIZE_PRINT
+	bool "print environment variables"
+	default n
+	depends on CONFIG_APP_RESIZE
+	help
+	  Prints the newly set size (number of columns and rows) of
+	  the terminal.
+	  E.g.:
+	  COLUMNS=80;LINES=44;export COLUMNS LINES;
+
 config CONFIG_SETCONSOLE
 	bool "setconsole"
 	default n
Index: include/usage.h
===================================================================
--- include/usage.h	(revision 16175)
+++ include/usage.h	(revision 16176)
@@ -2455,6 +2455,11 @@
 #define reset_full_usage \
 	"Resets the screen."
 
+#define resize_trivial_usage \
+	""
+#define resize_full_usage \
+	"Resizes the screen."
+
 #define rm_trivial_usage \
 	"[OPTION]... FILE..."
 #define rm_full_usage \
Index: include/applets.h
===================================================================
--- include/applets.h	(revision 16175)
+++ include/applets.h	(revision 16176)
@@ -226,6 +226,7 @@
 USE_HALT(APPLET_ODDNAME(reboot, halt, _BB_DIR_SBIN, _BB_SUID_NEVER, reboot))
 USE_RENICE(APPLET(renice, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
 USE_RESET(APPLET(reset, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
+USE_APP_RESIZE(APPLET(resize, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
 USE_RM(APPLET(rm, _BB_DIR_BIN, _BB_SUID_NEVER))
 USE_RMDIR(APPLET(rmdir, _BB_DIR_BIN, _BB_SUID_NEVER))
 USE_RMMOD(APPLET(rmmod, _BB_DIR_SBIN, _BB_SUID_NEVER))

 ------------------------------------------------------------------------
r16175 | landley | 2006-09-21 22:52:41 -0400 (Thu, 21 Sep 2006) | 3 lines
Changed paths:
   M /trunk/busybox/applets/individual.c
   M /trunk/busybox/editors/sed.c
   M /trunk/busybox/findutils/find.c
   M /trunk/busybox/init/halt.c
   M /trunk/busybox/init/init_shared.c
   M /trunk/busybox/loginutils/deluser.c
   M /trunk/busybox/miscutils/last.c
   M /trunk/busybox/miscutils/time.c
   M /trunk/busybox/procps/free.c
   M /trunk/busybox/procps/pidof.c
   M /trunk/busybox/procps/ps.c
   M /trunk/busybox/procps/uptime.c
   M /trunk/busybox/util-linux/dmesg.c
   M /trunk/busybox/util-linux/freeramdisk.c
   M /trunk/busybox/util-linux/mdev.c
   M /trunk/busybox/util-linux/mkswap.c
   M /trunk/busybox/util-linux/pivot_root.c
   M /trunk/busybox/util-linux/swaponoff.c
   M /trunk/busybox/util-linux/switch_root.c
   M /trunk/busybox/util-linux/umount.c

Change license statements (and clean up headers) on some of the files that
Erik or I are primary copyright holders on.

 ------------------------------------------------------------------------

Index: miscutils/time.c
===================================================================
--- miscutils/time.c	(revision 16174)
+++ miscutils/time.c	(revision 16175)
@@ -2,7 +2,7 @@
 /* `time' utility to display resource usage of processes.
    Copyright (C) 1990, 91, 92, 93, 96 Free Software Foundation, Inc.
 
-   Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+   Licensed under GPL version 2, see file LICENSE in this tarball for details.
 */
 /* Originally written by David Keppel .
    Heavily modified by David MacKenzie .
@@ -10,20 +10,8 @@
 */
 
 #include "busybox.h"
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 	/* For pid_t. */
-#include 
-#include 	/* For getpagesize, maybe.  */
 
 #define TV_MSEC tv_usec / 1000
-#include 
 
 /* Information on the resources used by a child process.  */
 typedef struct {
Index: miscutils/last.c
===================================================================
--- miscutils/last.c	(revision 16174)
+++ miscutils/last.c	(revision 16175)
@@ -4,7 +4,7 @@
  *
  * Copyright (C) 2003-2004 by Erik Andersen 
  *
- * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
+ * Licensed under the GPL version 2, see the file LICENSE in this tarball.
  */
 
 #include "busybox.h"
Index: loginutils/deluser.c
===================================================================
--- loginutils/deluser.c	(revision 16174)
+++ loginutils/deluser.c	(revision 16175)
@@ -6,15 +6,10 @@
  * Copyright (C) 1999,2000,2001 by John Beppu 
  * Unified with delgroup by Tito Ragusa 
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPL version 2, see file LICENSE in this tarball for details.
  *
  */
 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include "busybox.h"
 
 /* where to start and stop deletion */
Index: findutils/find.c
===================================================================
--- findutils/find.c	(revision 16174)
+++ findutils/find.c	(revision 16175)
@@ -7,7 +7,7 @@
  * Reworked by David Douthitt  and
  *  Matt Kraai .
  *
- * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
+ * Licensed under the GPL version 2, see the file LICENSE in this tarball.
  */
 
 #include "busybox.h"
Index: init/halt.c
===================================================================
--- init/halt.c	(revision 16174)
+++ init/halt.c	(revision 16175)
@@ -4,13 +4,11 @@
  *
  * Copyright 2006 by Rob Landley 
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPL version 2, see file LICENSE in this tarball for details.
  */
 
 #include "busybox.h"
-#include 
 #include 
-#include 
 
 int halt_main(int argc, char *argv[])
 {
Index: init/init_shared.c
===================================================================
--- init/init_shared.c	(revision 16174)
+++ init/init_shared.c	(revision 16175)
@@ -4,15 +4,10 @@
  *
  * Copyright (C) 1999-2004 by Erik Andersen 
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPL version 2, see file LICENSE in this tarball for details.
  */
 
 #include "busybox.h"
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
 #include 
 #include "init_shared.h"
Index: procps/free.c
===================================================================
--- procps/free.c	(revision 16174)
+++ procps/free.c	(revision 16175)
@@ -4,15 +4,12 @@
  *
  * Copyright (C) 1999-2004 by Erik Andersen 
  *
- * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
+ * Licensed under the GPL version 2, see the file LICENSE in this tarball.
  */
 
 /* getopt not needed */
 
 #include "busybox.h"
-#include 
-#include 
-#include 
 
 int free_main(int argc, char **argv)
 {
Index: procps/pidof.c
===================================================================
--- procps/pidof.c	(revision 16174)
+++ procps/pidof.c	(revision 16175)
@@ -4,19 +4,10 @@
  *
  * Copyright (C) 1999-2004 by Erik Andersen 
  *
- * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
+ * Licensed under the GPL version 2, see the file LICENSE in this tarball.
  */
 
 #include "busybox.h"
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 
 #if ENABLE_FEATURE_PIDOF_SINGLE
 #define _SINGLE_COMPL(a) a
Index: procps/ps.c
===================================================================
--- procps/ps.c	(revision 16174)
+++ procps/ps.c	(revision 16175)
@@ -4,23 +4,10 @@
  *
  * Copyright (C) 1999-2004 by Erik Andersen 
  *
- * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
+ * Licensed under the GPL version 2, see the file LICENSE in this tarball.
  */
 
 #include "busybox.h"
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#if ENABLE_SELINUX
-#include   /* for is_selinux_enabled()  */
-#endif
 
 int ps_main(int argc, char **argv)
 {
Index: procps/uptime.c
===================================================================
--- procps/uptime.c	(revision 16174)
+++ procps/uptime.c	(revision 16175)
@@ -4,7 +4,7 @@
  *
  * Copyright (C) 1999-2004 by Erik Andersen 
  *
- * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
+ * Licensed under the GPL version 2, see the file LICENSE in this tarball.
  */
 
 /* This version of uptime doesn't display the number of users on the system,
@@ -16,10 +16,6 @@
 /* getopt not needed */
 
 #include "busybox.h"
-#include 
-#include 
-#include 
-#include 
 
 #ifndef FSHIFT
 # define FSHIFT 16              /* nr of bits of precision */
Index: applets/individual.c
===================================================================
--- applets/individual.c	(revision 16174)
+++ applets/individual.c	(revision 16175)
@@ -2,7 +2,7 @@
  *
  * Copyright 2005 Rob Landley 
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPL version 2, see file LICENSE in this tarball for details.
  */
 
 /* Code overview.
Index: util-linux/dmesg.c
===================================================================
--- util-linux/dmesg.c	(revision 16174)
+++ util-linux/dmesg.c	(revision 16175)
@@ -6,7 +6,7 @@
  * Copyright 2006 Rob Landley 
  * Copyright 2006 Bernhard Fischer 
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2, see file LICENSE in this tarball for details.
  */
 
 #include "busybox.h"
Index: util-linux/mkswap.c
===================================================================
--- util-linux/mkswap.c	(revision 16174)
+++ util-linux/mkswap.c	(revision 16175)
@@ -3,7 +3,7 @@
  *
  * Copyright 2006 Rob Landley 
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPL version 2, see file LICENSE in this tarball for details.
  */
 
 #include 
Index: util-linux/swaponoff.c
===================================================================
--- util-linux/swaponoff.c	(revision 16174)
+++ util-linux/swaponoff.c	(revision 16175)
@@ -4,14 +4,11 @@
  *
  * Copyright (C) 1999-2004 by Erik Andersen 
  *
- * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
+ * Licensed under the GPL version 2, see the file LICENSE in this tarball.
  */
 
 #include "busybox.h"
 #include 
-#include 
-#include 
-#include 
 #include 
 
 
Index: util-linux/pivot_root.c
===================================================================
--- util-linux/pivot_root.c	(revision 16174)
+++ util-linux/pivot_root.c	(revision 16175)
@@ -6,11 +6,8 @@
  * pivot_root syscall stubbed by Erik Andersen, so it will compile
  *     regardless of the kernel being used.
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPL version 2, see file LICENSE in this tarball for details.
  */
-#include 
-#include 
-#include 
 #include "busybox.h"
 
 extern int pivot_root(const char * new_root,const char * put_old);
Index: util-linux/switch_root.c
===================================================================
--- util-linux/switch_root.c	(revision 16174)
+++ util-linux/switch_root.c	(revision 16175)
@@ -3,14 +3,11 @@
  *
  * Switch from rootfs to another filesystem as the root of the mount tree.
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPL version 2, see file LICENSE in this tarball for details.
  */
 
 #include "busybox.h"
-#include 
-#include 
 #include 
-#include 
 
 
 // Make up for header deficiencies.
Index: util-linux/umount.c
===================================================================
--- util-linux/umount.c	(revision 16174)
+++ util-linux/umount.c	(revision 16175)
@@ -5,10 +5,7 @@
  * Copyright (C) 1999-2004 by Erik Andersen 
  * Copyright (C) 2005 by Rob Landley 
  *
- * This program is licensed under the GNU General Public license (GPL)
- * version 2 or later, see http://www.fsf.org/licensing/licenses/gpl.html
- * or the file "LICENSE" in the busybox source tarball for the full text.
- *
+ * Licensed under GPL version 2, see file LICENSE in this tarball for details.
  */
 
 #include "busybox.h"
Index: util-linux/mdev.c
===================================================================
--- util-linux/mdev.c	(revision 16174)
+++ util-linux/mdev.c	(revision 16175)
@@ -6,7 +6,7 @@
  * Copyright 2005 Rob Landley 
  * Copyright 2005 Frank Sorenson 
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPL version 2, see file LICENSE in this tarball for details.
  */
 
 #include "busybox.h"
Index: util-linux/freeramdisk.c
===================================================================
--- util-linux/freeramdisk.c	(revision 16174)
+++ util-linux/freeramdisk.c	(revision 16175)
@@ -6,7 +6,7 @@
  * Adjusted a bit by Erik Andersen 
  * Unified with fdflush by Tito Ragusa 
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2, see file LICENSE in this tarball for details.
  */
 
 #include "busybox.h"

 ------------------------------------------------------------------------
r16174 | aldot | 2006-09-21 18:58:38 -0400 (Thu, 21 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/TODO

- update and expand TODO a little bit

 ------------------------------------------------------------------------

Index: TODO
===================================================================
--- TODO	(revision 16173)
+++ TODO	(revision 16174)
@@ -117,13 +117,21 @@
     This one's open to everybody, but I'll wind up doing it...
 
 
-Bernhard Fischer :
+Bernhard Fischer  suggests to look at these:
   Makefile stuff:
-    make -j is broken, -j1 is forced atm
+    make -j is broken. klibc make infrastructure (vda?)
   New debug options:
     -Wlarger-than-127
+    Cleanup any big users
+    -Wunused-parameter
+    Facilitate applet PROTOTYPES to provide means for having applets that
+    do a) not take any arguments b) need only one of argc or argv c) need
+    both argc and argv. All of these three options should go for the most
+    feature complete denominator.
   Collate BUFSIZ IOBUF_SIZE MY_BUF_SIZE PIPE_PROGRESS_SIZE BUFSIZE PIPESIZE
-    Use bb_common_bufsiz1?
+    make bb_common_bufsiz1 configurable, size wise.
+    make pipesize configurable, size wise.
+    Use bb_common_bufsiz1 throughout applets!
 
 As yet unclaimed:
 

 ------------------------------------------------------------------------
r16173 | aldot | 2006-09-21 18:10:24 -0400 (Thu, 21 Sep 2006) | 14 lines
Changed paths:
   M /trunk/busybox/coreutils/nohup.c

- pull r15578 from busybox_scratch branch:
  - fix bug where it would behave wrong if ./nohup.out was not writable.
  - debloat and make it readable while at it.
$ size coreutils/nohup.o*
   text    data     bss     dec     hex filename
    362       0       0     362     16a coreutils/nohup.o.trunk
    344       0       0     344     158 coreutils/nohup.o
$ make bloatcheck
function                                             old     new   delta
nohup_main                                           324     310     -14
 ------------------------------------------------------------------------------

(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-14)             Total: -14 bytes


 ------------------------------------------------------------------------

Index: coreutils/nohup.c
===================================================================
--- coreutils/nohup.c	(revision 16172)
+++ coreutils/nohup.c	(revision 16173)
@@ -5,53 +5,49 @@
  * http://www.opengroup.org/onlinepubs/007904975/utilities/nohup.html
  *
  * Copyright 2006 Rob Landley 
+ * Copyright 2006 Bernhard Fischer
  *
  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
 #include "busybox.h"
 
-int nohup_main(int argc, char *argv[])
+int nohup_main(int argc, char **argv)
 {
 	int temp, nullfd;
-	char *nohupout = "nohup.out", *home = NULL;
+	char *nohupout, *home = NULL;
 
-	// I have no idea why the standard cares about this.
-
 	bb_default_error_retval = 127;
 
 	if (argc<2) bb_show_usage();
 
 	nullfd = xopen(bb_dev_null, O_WRONLY|O_APPEND);
-	// If stdin is a tty, detach from it.
+	/* If stdin is a tty, detach from it. */
+	if (isatty(STDIN_FILENO)) dup2(nullfd, STDIN_FILENO);
 
-	if (isatty(0)) dup2(nullfd, 0);
-
-	// Redirect stdout to nohup.out, either in "." or in "$HOME".
-
-	if (isatty(1)) {
-		close(1);
+	nohupout = "nohup.out";
+	/* Redirect stdout to nohup.out, either in "." or in "$HOME". */
+	if (isatty(STDOUT_FILENO)) {
+		close(STDOUT_FILENO);
 		if (open(nohupout, O_CREAT|O_WRONLY|O_APPEND, S_IRUSR|S_IWUSR) < 0) {
 			home = getenv("HOME");
 			if (home) {
-				home = concat_path_file(home, nohupout);
+				nohupout = concat_path_file(home, nohupout);
 				xopen3(nohupout, O_CREAT|O_WRONLY|O_APPEND, S_IRUSR|S_IWUSR);
 			}
 		}
-	} else dup2(nullfd, 1);
+	} else dup2(nullfd, STDOUT_FILENO);
 
-	// If we have a tty on strderr, announce filename and redirect to stdout.
-	// Else redirect to /dev/null.
-
-	temp = isatty(2);
-	if (temp) fdprintf(2,"Writing to %s\n", home ? home : nohupout);
-	dup2(temp ? 1 : nullfd, 2);
+	/* If we have a tty on strderr, announce filename and redirect to stdout.
+	 * Else redirect to /dev/null.
+	 */
+	temp = isatty(STDERR_FILENO);
+	if (temp) bb_error_msg("Appending to %s", nohupout);
+	dup2(temp ? STDOUT_FILENO : nullfd, STDERR_FILENO);
 	close(nullfd);
-	signal(SIGHUP, SIG_IGN);
+	signal (SIGHUP, SIG_IGN);
 
-	// Exec our new program.
-
 	execvp(argv[1],argv+1);
-	if (ENABLE_FEATURE_CLEAN_UP) free(home);
-	bb_error_msg_and_die("exec %s",argv[1]);
+	if (00 && ENABLE_FEATURE_CLEAN_UP && home) free(nohupout);
+	bb_perror_msg_and_die("%s",argv[1]);
 }

 ------------------------------------------------------------------------
r16172 | aldot | 2006-09-21 16:40:56 -0400 (Thu, 21 Sep 2006) | 6 lines
Changed paths:
   M /trunk/busybox/coreutils/uudecode.c

- silence gcc warning about a funcptr possibly being used uninitialized.
  This is a perfect example on where we should NOT care if the functor is not
  initialized since the result will not be what the user may expect.
  Safe bet would be to init to NULL, but let's try normal uu for good measure.
- fix commentary typo while at it.

 ------------------------------------------------------------------------

Index: coreutils/uudecode.c
===================================================================
--- coreutils/uudecode.c	(revision 16171)
+++ coreutils/uudecode.c	(revision 16172)
@@ -36,7 +36,7 @@
 		}
 
 		line_ptr++;
-		/* Tolerate an overly long line to acomadate a possible exta '`' */
+		/* Tolerate an overly long line to accomodate a possible exta '`' */
 		if (strlen(line_ptr) < (size_t)length) {
 			bb_error_msg_and_die("Short file");
 		}
@@ -125,7 +125,7 @@
 
 int uudecode_main(int argc, char **argv)
 {
-	int (*decode_fn_ptr) (FILE * src, FILE * dst);
+	int (*decode_fn_ptr)(FILE * src, FILE * dst) = read_stduu; /* silence gcc */
 	FILE *src_stream;
 	char *outname = NULL;
 	char *line;

 ------------------------------------------------------------------------
r16171 | vda | 2006-09-21 08:30:16 -0400 (Thu, 21 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/util-linux/Config.in

mount: nfs mount should enable bb_error-to-syslog support

 ------------------------------------------------------------------------

Index: util-linux/Config.in
===================================================================
--- util-linux/Config.in	(revision 16170)
+++ util-linux/Config.in	(revision 16171)
@@ -369,6 +369,7 @@
 	bool "Support mounting NFS file systems"
 	default n
 	depends on CONFIG_MOUNT
+	select CONFIG_FEATURE_SYSLOG
 	help
 	  Enable mounting of NFS file systems.
 

 ------------------------------------------------------------------------
r16170 | aldot | 2006-09-21 07:54:51 -0400 (Thu, 21 Sep 2006) | 3 lines
Changed paths:
   M /trunk/busybox/Rules.mak

- gcc-2.95 doesn't support -static-libgcc
- remove Winline

 ------------------------------------------------------------------------

Index: Rules.mak
===================================================================
--- Rules.mak	(revision 16169)
+++ Rules.mak	(revision 16170)
@@ -175,9 +175,12 @@
 CHECKED_CFLAGS+=$(call check_cc,$(CC),-funsigned-char,)
 CHECKED_CFLAGS+=$(call check_cc,$(CC),-fno-builtin-strlen,)
 CHECKED_CFLAGS+=$(call check_cc,$(CC),-finline-limit=0,)
-CHECKED_CFLAGS+=$(call check_cc,$(CC),-Winline,)
-CHECKED_CFLAGS+=$(call check_cc,$(CC),-static-libgcc,)
 
+# gcc 2.95 exits with 0 for "unrecognized option"
+ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0)
+  CHECKED_CFLAGS+=$(call check_cc,$(CC),-static-libgcc,)
+endif
+
 # Preemptively pin this too.
 PROG_CFLAGS:=
 

 ------------------------------------------------------------------------
r16169 | vda | 2006-09-21 07:13:08 -0400 (Thu, 21 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/util-linux/mount.c

mount: make Rob happy by reinstating #defines

 ------------------------------------------------------------------------

Index: util-linux/mount.c
===================================================================
--- util-linux/mount.c	(revision 16168)
+++ util-linux/mount.c	(revision 16169)
@@ -220,10 +220,8 @@
 static int useMtab = 1;
 static int fakeIt;
 #else
-enum {
-	useMtab = 0,
-	fakeIt = 0,
-};
+#define useMtab 0
+#define fakeIt 0
 #endif
 
 // Perform actual mount of specific filesystem at specific location.

 ------------------------------------------------------------------------
r16167 | landley | 2006-09-20 18:06:01 -0400 (Wed, 20 Sep 2006) | 3 lines
Changed paths:
   M /trunk/busybox/libbb/Makefile.in
   D /trunk/busybox/libbb/get_terminal_width_height.c
   M /trunk/busybox/libbb/xfuncs.c

Teach get_terminal_width_height to fall back to $LINES and $COLUMNS when
used via things like a serial console.

 ------------------------------------------------------------------------

Index: libbb/Makefile.in
===================================================================
--- libbb/Makefile.in	(revision 16166)
+++ libbb/Makefile.in	(revision 16167)
@@ -22,16 +22,14 @@
 	kernel_version.c last_char_is.c login.c \
 	make_directory.c md5.c mode_string.c mtab_file.c \
 	obscure.c parse_mode.c parse_number.c perror_msg.c \
-	perror_msg_and_die.c get_console.c \
-	process_escape_sequence.c procps.c \
-	recursive_action.c remove_file.c \
+	perror_msg_and_die.c get_console.c process_escape_sequence.c procps.c \
+	recursive_action.c remove_file.c info_msg.c vinfo_msg.c \
 	restricted_shell.c run_parts.c run_shell.c safe_read.c safe_write.c \
 	safe_strncpy.c setup_environment.c sha1.c simplify_path.c \
 	trim.c u_signal_names.c vdprintf.c verror_msg.c \
-	info_msg.c vinfo_msg.c \
 	vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c \
 	xgethostbyname.c xgethostbyname2.c xreadlink.c xgetlarg.c \
-	get_terminal_width_height.c fclose_nonstdin.c fflush_stdout_and_exit.c \
+	fclose_nonstdin.c fflush_stdout_and_exit.c \
 	getopt_ulflags.c default_error_retval.c wfopen_input.c speed_table.c \
 	perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \
 	warn_ignoring_args.c concat_subpath_file.c vfork_daemon_rexec.c \
Index: libbb/xfuncs.c
===================================================================
--- libbb/xfuncs.c	(revision 16166)
+++ libbb/xfuncs.c	(revision 16167)
@@ -6,7 +6,7 @@
  * Copyright (C) 2006 Rob Landley
  * Copyright (C) 2006 Denis Vlasenko
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPL version 2, see file LICENSE in this tarball for details.
  */
 
 #include "busybox.h"
@@ -494,3 +494,26 @@
 }
 #endif
 
+#ifdef L_get_terminal_width_height
+/* It is perfectly ok to pass in a NULL for either width or for
+ *  * height, in which case that value will not be set.  */
+int get_terminal_width_height(int fd, int *width, int *height)
+{
+	struct winsize win = { 0, 0, 0, 0 };
+	int ret = ioctl(fd, TIOCGWINSZ, &win);
+	if (!win.ws_row) {
+		char *s = getenv("LINES");
+		if (s) win.ws_row = atoi(s);
+	}
+	if (win.ws_row <= 1) win.ws_row = 24;
+	if (!win.ws_col) {
+		char *s = getenv("COLUMNS");
+		if (s) win.ws_col = atoi(s);
+	}
+	if (win.ws_col <= 1) win.ws_col = 80;
+	if (height) *height = (int) win.ws_row;
+	if (width) *width = (int) win.ws_col;
+
+	return ret;
+}
+#endif
Index: libbb/get_terminal_width_height.c
===================================================================
--- libbb/get_terminal_width_height.c	(revision 16166)
+++ libbb/get_terminal_width_height.c	(revision 16167)
@@ -1,31 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Determine the width and height of the terminal.
- *
- * Copyright (C) 1999-2004 by Erik Andersen 
- *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include "libbb.h"
-
-/* It is perfectly ok to pass in a NULL for either width or for
- * height, in which case that value will not be set.  */
-int get_terminal_width_height(int fd, int *width, int *height)
-{
-	struct winsize win = { 0, 0, 0, 0 };
-	int ret = ioctl(fd, TIOCGWINSZ, &win);
-	if (win.ws_row <= 1) win.ws_row = 24;
-	if (win.ws_col <= 1) win.ws_col = 80;
-	if (height) *height = (int) win.ws_row;
-	if (width) *width = (int) win.ws_col;
-
-	return ret;
-}

 ------------------------------------------------------------------------
r16166 | landley | 2006-09-20 17:57:36 -0400 (Wed, 20 Sep 2006) | 5 lines
Changed paths:
   M /trunk/busybox/shell/bbsh.c

The version checked into the tree is a snapshot of an unifinished applet, and
you just made lots of ">>>>>>> mine" lines show up in my working copy of this.

Please don't do that again.

 ------------------------------------------------------------------------

Index: shell/bbsh.c
===================================================================
--- shell/bbsh.c	(revision 16165)
+++ shell/bbsh.c	(revision 16166)
@@ -1,5 +1,5 @@
 /* vi: set ts=4 :
- *
+ * 
  * bbsh - busybox shell
  *
  * Copyright 2006 Rob Landley 
@@ -51,7 +51,7 @@
 // What we know about a single process.
 struct command {
 	struct command *next;
-	int flags;		// exit, suspend, && ||
+	int flags;		// exit, suspend, && || 
 	int pid;		// pid (or exit code)
 	int argc;
 	char *argv[0];
@@ -125,9 +125,9 @@
 			return 0;
 		}
 
-		// Allocate next command structure if necessary
+		// Allocate next command structure if necessary		
 		if (!*cmd) *cmd = xzalloc(sizeof(struct command)+8*sizeof(char *));
-
+		
 		// Parse next argument and add the results to argv[]
 		end = parse_word(start, cmd);
 
@@ -138,7 +138,7 @@
 					start++;
 					break;
 				}
-				// handle | & < > >> << || &&
+				// handle | & < > >> << || && 
 			}
 			break;
 		}
@@ -160,7 +160,7 @@
 	if (cmd->argc==2 && !strcmp(cmd->argv[0],"cd"))
 		chdir(cmd->argv[1]);
 	else if(!strcmp(cmd->argv[0],"exit"))
-		exit(cmd->argc>1 ? atoi(cmd->argv[1]) : 0);
+		exit(cmd->argc>1 ? atoi(cmd->argv[1]) : 0); 
 	else {
 		int status;
 		pid_t pid=fork();
@@ -217,6 +217,6 @@
 		}
 		if (ENABLE_FEATURE_CLEAN_UP) free(command);
 	}
-
+		
 	return 1;
 }

 ------------------------------------------------------------------------
r16165 | landley | 2006-09-20 17:41:13 -0400 (Wed, 20 Sep 2006) | 14 lines
Changed paths:
   M /trunk/busybox/applets/busybox.c
   M /trunk/busybox/include/libbb.h

The Software Freedom Law Center wants us to add a copyright notice to the
generated binaries, to make copyright enforcement easier.  Our liason with
them (Bradley Kuhn) suggested the following text:

> Copyright (C) YEAR-2006  Erik Andersen, Rob Landley, and others.
> Licensed under GPLv2.  See source distribution for full notice.

And the busybox help message seems the least offensive place to put it.  (At
some point in the future, I need to strip 128 bytes from the binary to feel
good about this, though. :)

Minor header file cleanup while I was there, since libbb.h already #includes
most of that stuff...

 ------------------------------------------------------------------------

Index: include/libbb.h
===================================================================
--- include/libbb.h	(revision 16164)
+++ include/libbb.h	(revision 16165)
@@ -2,11 +2,10 @@
 /*
  * Busybox main internal header file
  *
- * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
- *
  * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
  * Permission has been granted to redistribute this code under the GPL.
- *
+ * 
+ * Licensed under the GPL version 2, see the file LICENSE in this tarball.
  */
 #ifndef	__LIBBUSYBOX_H__
 #define	__LIBBUSYBOX_H__    1
@@ -47,6 +46,8 @@
 
 #ifdef CONFIG_LOCALE_SUPPORT
 #include 
+#else
+#define setlocale(x,y)
 #endif
 
 #include "pwd_.h"
Index: applets/busybox.c
===================================================================
--- applets/busybox.c	(revision 16164)
+++ applets/busybox.c	(revision 16165)
@@ -2,19 +2,9 @@
 /*
  * BusyBox' main applet dispatcher.
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2, see file LICENSE in this tarball for details.
  */
 #include "busybox.h"
-#include 
-#include 
-#include 
-#include 
-#include 
-#if ENABLE_LOCALE_SUPPORT
-#include 
-#else
-#define setlocale(x,y)
-#endif
 
 const char *bb_applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
 
@@ -128,7 +118,9 @@
 				output_width -= 20;
 			} else output_width = 60;
 
-			printf("%s\n\n"
+			printf("%s\n"
+				   "Copyright (C) 1998-2006  Erik Andersen, Rob Landley, and others.\n"
+				   "Licensed under GPLv2.  See source distribution for full notice.\n\n"
 			       "Usage: busybox [function] [arguments]...\n"
 			       "   or: [function] [arguments]...\n\n"
 			       "\tBusyBox is a multi-call binary that combines many common Unix\n"

 ------------------------------------------------------------------------
r16164 | landley | 2006-09-20 16:01:29 -0400 (Wed, 20 Sep 2006) | 2 lines
Changed paths:
   M /trunk/busybox/LICENSE
   M /trunk/busybox/docs/busybox.net/license.html

License clarification.

 ------------------------------------------------------------------------

Index: docs/busybox.net/license.html
===================================================================
--- docs/busybox.net/license.html	(revision 16163)
+++ docs/busybox.net/license.html	(revision 16164)
@@ -1,13 +1,16 @@
 
 
 

-

BusyBox is licensed under the GNU General Public License

+

BusyBox is licensed under the GNU General Public License, version 2

BusyBox is licensed under the -GNU General Public License version 2, which is generally -abbreviated as the GPL. (This is the same license the Linux kernel is under, -so you may be somewhat familiar with it by now.)

+GNU General Public License version 2, which is often abbreviated as GPLv2. +(This is the same license the Linux kernel is under, so you may be somewhat +familiar with it by now.)

+

A complete copy of the license text is included in the file LICENSE in +the BusyBox source code.

+

Anyone thinking of shipping BusyBox as part of a product should be familiar with the licensing terms under which they are allowed to use and distribute BusyBox. Read the full test of the GPL (either @@ -22,6 +25,42 @@ (This requirement applies whether or not you modified BusyBox; either way the license terms still apply to you.) Read the license text for the details.

+

A note on GPL versions

+ +

Version 2 of the GPL is the only version of the GPL which current versions +of BusyBox may be distributed under. New code added to the tree is licensed +GPL version 2, and the project's license is GPL version 2.

+ +

Older versions of BusyBox (versions 1.2.2 and earlier, up through about svn +16112) included variants of the recommended "GPL version 2 or (at your option) +later versions" boilerplate permission grant. Ancient versions of BusyBox +(before svn 49) did not specify any version at all, and section 9 of GPLv2 +(the most recent version at the time) says those old versions may be +redistributed under any version of GPL (including the obsolete V1). This was +conceptually similar to a dual license, except that the different licenses were +different versions of the GPL.

+ +

However, BusyBox has apparently always contained chunks of code that were +licensed under GPL version 2 only. Examples include applets written by Linus +Torvalds (util-linux/mkfs_minix.c and util_linux/mkswap.c) which stated they +"may be redistributed as per the Linux copyright" (which Linus clarified in the +2.4.0-pre8 release announcement in 2000 was GPLv2 only), and Linux kernel code +copied into libbb/loop.c (after Linus's announcement). There are probably +more, because all we used to check was that the code was GPL, not which +version. (Before the GPLv3 draft proceedings in 2006, it was a purely +theoretical issue that didn't come up much.)

+ +

To summarize: every version of BusyBox may be distributed under the terms of +GPL version 2. New versions (after 1.2.2) may only be distributed under +GPLv2, not under other versions of the GPL. Older versions of BusyBox might +(or might not) be distributable under other versions of the GPL. If you +want to use a GPL version other than 2, you should start with one of the old +versions such as release 1.2.2 or SVN 16112, and do your own homework to +identify and remove any code that can't be licensed under the GPL version you +want to use. New development is all GPLv2.

+ +

License enforcement

+

BusyBox's copyrights are enforced by the Software Freedom Law Center, which "accepts primary responsibility for enforcement of US copyrights on the Index: LICENSE =================================================================== --- LICENSE (revision 16163) +++ LICENSE (revision 16164) @@ -1,3 +1,11 @@ +--- A note on GPL versions + +BusyBox is distributed under version 2 of the General Public License (included +in its entirety, below). Version 2 is the only version of this license which +this version of BusyBox (or modified versions derived from this one) may be +distributed under. + +------------------------------------------------------------------------ GNU GENERAL PUBLIC LICENSE Version 2, June 1991 ------------------------------------------------------------------------ r16163 | aldot | 2006-09-20 11:56:53 -0400 (Wed, 20 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/include/usage.h - fix documentation for the command-line options of ipcs. Closes #1036 ------------------------------------------------------------------------ Index: include/usage.h =================================================================== --- include/usage.h (revision 16162) +++ include/usage.h (revision 16163) @@ -1440,7 +1440,7 @@ "\t-[sS]\tRemove the semaphore" #define ipcs_trivial_usage \ - "[[-smq] -i shmid] | [[-asmq] [-tclup]]" + "[[-smq] -i shmid] | [[-asmq] [-tcplu]]" #define ipcs_full_usage \ "\t-i\tspecify a specific resource id\n" \ "Resource specification:\n" \ @@ -1450,10 +1450,10 @@ "\t-a\tall (default)\n" \ "Output format:\n" \ "\t-t\ttime\n" \ + "\t-c\tcreator\n" \ "\t-p\tpid\n" \ - "\t-s\tcreator\n" \ - "\t-a\tlimits\n" \ - "\t-i\tsummary" + "\t-l\tlimits\n" \ + "\t-u\tsummary" #define iplink_trivial_usage \ "{ set DEVICE { up | down | arp { on | off } | show [ DEVICE ] }" ------------------------------------------------------------------------ r16162 | aldot | 2006-09-20 11:29:13 -0400 (Wed, 20 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/coreutils/cmp.c - fix embarrassing typo of mine. Closes bug #1038 ------------------------------------------------------------------------ Index: coreutils/cmp.c =================================================================== --- coreutils/cmp.c (revision 16161) +++ coreutils/cmp.c (revision 16162) @@ -56,7 +56,7 @@ opt = bb_getopt_ulflags(argc, argv, opt_chars); - if ((opt & (CMP_OPT_s|CMP_OPT_l)) + if (((opt & (CMP_OPT_s|CMP_OPT_l)) == (CMP_OPT_s|CMP_OPT_l)) || (((unsigned int)(--argc - optind)) > 1)) bb_show_usage(); @@ -103,7 +103,7 @@ * make sure we fflush before writing to stderr. */ xfflush_stdout(); } - if (!opt & CMP_OPT_s) { + if (!(opt & CMP_OPT_s)) { if (opt & CMP_OPT_l) { line_pos = c1; /* line_pos is unused in the -l case. */ } ------------------------------------------------------------------------ r16161 | vda | 2006-09-19 13:43:56 -0400 (Tue, 19 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/util-linux/ipcs.c ipcs: fix output (misaligned columns) ------------------------------------------------------------------------ Index: util-linux/ipcs.c =================================================================== --- util-linux/ipcs.c (revision 16160) +++ util-linux/ipcs.c (revision 16161) @@ -234,7 +234,7 @@ bb_printf("%-10d %-10.10s", shmid, pw->pw_name); else bb_printf("%-10d %-10d", shmid, ipcp->uid); - bb_printf("%-10o %-10lu %-10ld %-6s %-6s\n", ipcp->mode & 0777, + bb_printf(" %-10o %-10lu %-10ld %-6s %-6s\n", ipcp->mode & 0777, /* * earlier: int, Austin has size_t */ @@ -344,7 +344,7 @@ bb_printf("%-10d %-10.9s", semid, pw->pw_name); else bb_printf("%-10d %-9d", semid, ipcp->uid); - bb_printf("%-10o %-10ld\n", ipcp->mode & 0777, + bb_printf(" %-10o %-10ld\n", ipcp->mode & 0777, /* * glibc-2.1.3 and earlier has unsigned short; * glibc-2.1.91 has variation between ------------------------------------------------------------------------ r16160 | vda | 2006-09-19 13:40:31 -0400 (Tue, 19 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/util-linux/ipcs.c ipcs: getopt_ulflag'ification, -170 bytes ------------------------------------------------------------------------ Index: util-linux/ipcs.c =================================================================== --- util-linux/ipcs.c (revision 16159) +++ util-linux/ipcs.c (revision 16160) @@ -570,52 +570,29 @@ int ipcs_main(int argc, char **argv) { - int opt, id = 0; + int id = 0; unsigned flags = 0; + unsigned long opt; + char *opt_i; #define flag_print (1<<0) #define flag_msg (1<<1) #define flag_sem (1<<2) #define flag_shm (1<<3) - const char *const options = "atclupsmqi:ih?"; - while ((opt = getopt(argc, argv, options)) != -1) { - switch (opt) { - case 'i': - id = atoi(optarg); - flags |= flag_print; - break; - case 'a': - flags |= flag_msg | flag_sem | flag_shm; - break; - case 'q': - flags |= flag_msg; - break; - case 's': - flags |= flag_sem; - break; - case 'm': - flags |= flag_shm; - break; - case 't': - format = TIME; - break; - case 'c': - format = CREATOR; - break; - case 'p': - format = PID; - break; - case 'l': - format = LIMITS; - break; - case 'u': - format = STATUS; - break; - case 'h': - case '?': - bb_show_usage(); - } + opt = bb_getopt_ulflags(argc, argv, "i:aqsmtcplu", &opt_i); + if (opt & 0x1) { // -i + id = atoi(optarg); + flags |= flag_print; } + if (opt & 0x2) flags |= flag_msg | flag_sem | flag_shm; // -a + if (opt & 0x4) flags |= flag_msg; // -q + if (opt & 0x8) flags |= flag_sem; // -s + if (opt & 0x10) flags |= flag_shm; // -m + if (opt & 0x20) format = TIME; // -t + if (opt & 0x40) format = CREATOR; // -c + if (opt & 0x80) format = PID; // -p + if (opt & 0x100) format = LIMITS; // -l + if (opt & 0x200) format = STATUS; // -u if (flags & flag_print) { if (flags & flag_shm) { ------------------------------------------------------------------------ r16158 | vda | 2006-09-19 11:12:12 -0400 (Tue, 19 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/coreutils/stty.c stty: fix few bugs found in testing ------------------------------------------------------------------------ Index: coreutils/stty.c =================================================================== --- coreutils/stty.c (revision 16157) +++ coreutils/stty.c (revision 16158) @@ -68,8 +68,8 @@ # define CSWTCH _POSIX_VDISABLE #endif -/* SunOS 5.3 loses (^Z doesn't work) if `swtch' is the same as `susp'. - So the default is to disable `swtch.' */ +/* SunOS 5.3 loses (^Z doesn't work) if 'swtch' is the same as 'susp'. + So the default is to disable 'swtch.' */ #if defined (__sparc__) && defined (__svr4__) # undef CSWTCH # define CSWTCH _POSIX_VDISABLE @@ -120,7 +120,7 @@ input_speed, output_speed, both_speeds }; -/* Which member(s) of `struct termios' a mode uses */ +/* Which member(s) of 'struct termios' a mode uses */ enum { /* Do NOT change the order or values, as mode_type_flag() * depends on them */ @@ -150,10 +150,10 @@ static const char stty_crt [] = "crt"; static const char stty_dec [] = "dec"; -/* Flags for `struct mode_info' */ -#define SANE_SET 1 /* Set in `sane' mode */ -#define SANE_UNSET 2 /* Unset in `sane' mode */ -#define REV 4 /* Can be turned off by prepending `-' */ +/* Flags for 'struct mode_info' */ +#define SANE_SET 1 /* Set in 'sane' mode */ +#define SANE_UNSET 2 /* Unset in 'sane' mode */ +#define REV 4 /* Can be turned off by prepending '-' */ #define OMIT 8 /* Don't display value */ /* Each mode */ @@ -161,7 +161,7 @@ const char *name; /* Name given on command line */ char type; /* Which structure element to change */ char flags; /* Setting and display options */ - unsigned short mask; /* Other bits to turn off for this mode */ + unsigned short mask; /* Other bits to turn off for this mode */ unsigned long bits; /* Bits to set for this mode */ }; @@ -320,7 +320,7 @@ /* Control character settings */ struct control_info { const char *name; /* Name given on command line */ - unsigned char saneval; /* Value to set for `stty sane' */ + unsigned char saneval; /* Value to set for 'stty sane' */ unsigned char offset; /* Offset in c_cc */ }; @@ -376,7 +376,7 @@ static const char *device_name = bb_msg_standard_input; /* Return a string that is the printable representation of character CH */ -/* Adapted from `cat' by Torbjorn Granlund */ +/* Adapted from 'cat' by Torbjorn Granlund */ static const char *visible(unsigned int ch) { static char buf[10]; @@ -470,11 +470,13 @@ if (current_col > 0) { current_col++; - if (current_col + buflen >= max_col) { - putchar('\n'); - current_col = 0; - } else - if (buf[0] != '\n') putchar(' '); + if (buf[0] != '\n') { + if (current_col + buflen >= max_col) { + putchar('\n'); + current_col = 0; + } else + putchar(' '); + } } fputs(buf, stdout); current_col += buflen; @@ -484,16 +486,16 @@ #ifdef TIOCGWINSZ -static int get_win_size(struct winsize *win) +static int get_win_size(int fd, struct winsize *win) { - return ioctl(STDIN_FILENO, TIOCGWINSZ, (char *) win); + return ioctl(fd, TIOCGWINSZ, (char *) win); } static void set_window_size(int rows, int cols) { struct winsize win; - if (get_win_size(&win)) { + if (get_win_size(STDIN_FILENO, &win)) { if (errno != EINVAL) { perror_on_device("%s"); return; @@ -538,7 +540,7 @@ const char *fmt_str = "%s\0%s: no size information for this device"; struct winsize win; - if (get_win_size(&win)) { + if (get_win_size(STDIN_FILENO, &win)) { if ((errno != EINVAL) || ((fmt_str += 2), !fancy)) { perror_on_device(fmt_str); } @@ -568,7 +570,7 @@ (but it works for ptys). It can also fail on any system when stdout isn't a tty. In case of any failure, just use the default */ - if (get_win_size(&win) == 0 && win.ws_col > 0) + if (get_win_size(STDOUT_FILENO, &win) == 0 && win.ws_col > 0) return win.ws_col; #endif @@ -704,7 +706,7 @@ bb_error_msg_and_die(bb_msg_requires_arg, "-F"); /* remove -F param from arg[vc] */ --argc; - while (argv[p+1]) { argv[p] = argv[p+1]; ++p; } + while (argv[p]) { argv[p] = argv[p+1]; ++p; } } goto end_option; default: @@ -784,8 +786,8 @@ int fd, fdflags; device_name = file_name; fd = xopen(device_name, O_RDONLY | O_NONBLOCK); - if (fd != 0) { - dup2(fd, 0); + if (fd != STDIN_FILENO) { + dup2(fd, STDIN_FILENO); close(fd); } fdflags = fcntl(STDIN_FILENO, F_GETFL); @@ -894,7 +896,7 @@ /* POSIX (according to Zlotnick's book) tcsetattr returns zero if it performs *any* of the requested operations. This means it - can report `success' when it has actually failed to perform + can report 'success' when it has actually failed to perform some proper subset of the requested operations. To detect this partial failure, get the current terminal attributes and compare them to the requested ones */ @@ -1254,7 +1256,7 @@ unsigned long iflag, oflag, cflag, lflag; /* Scan into temporaries since it is too much trouble to figure out - the right format for `tcflag_t' */ + the right format for 'tcflag_t' */ if (sscanf(arg, "%lx:%lx:%lx:%lx%n", &iflag, &oflag, &cflag, &lflag, &n) != 4) return 0; ------------------------------------------------------------------------ r16156 | vda | 2006-09-19 10:47:54 -0400 (Tue, 19 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/loginutils/getty.c getty: oops... removing duplicate #include ------------------------------------------------------------------------ Index: loginutils/getty.c =================================================================== --- loginutils/getty.c (revision 16155) +++ loginutils/getty.c (revision 16156) @@ -25,10 +25,8 @@ #define _PATH_LOGIN "/bin/login" - /* If USE_SYSLOG is undefined all diagnostics go directly to /dev/console. */ #ifdef CONFIG_SYSLOGD #include -#include #endif ------------------------------------------------------------------------ r16155 | vda | 2006-09-19 10:31:44 -0400 (Tue, 19 Sep 2006) | 3 lines Changed paths: M /trunk/busybox/coreutils/stty.c stty: reorder code, reducing need in forward declarations. added few missed bits of error checking for parameters. ------------------------------------------------------------------------ Index: coreutils/stty.c =================================================================== --- coreutils/stty.c (revision 16154) +++ coreutils/stty.c (revision 16155) @@ -371,31 +371,75 @@ /* The width of the screen, for output wrapping */ static int max_col; - /* Current position, to know when to wrap */ static int current_col; +static const char *device_name = bb_msg_standard_input; -static const char * visible(unsigned int ch); -static int recover_mode(const char *arg, struct termios *mode); -static int screen_columns(void); -static void set_mode(const struct mode_info *info, - int reversed, struct termios *mode); -static speed_t string_to_baud(const char *arg); -static tcflag_t* mode_type_flag(unsigned type, const struct termios *mode); -static void display_all(const struct termios *mode); -static void display_changed(const struct termios *mode); -static void display_recoverable(const struct termios *mode); -static void display_speed(const struct termios *mode, int fancy); -static void display_window_size(int fancy); -static void sane_mode(struct termios *mode); -static void set_control_char_or_die(const struct control_info *info, - const char *arg, struct termios *mode); -static void set_speed(enum speed_setting type, - const char *arg, struct termios *mode); -static void set_window_size(int rows, int cols); +/* Return a string that is the printable representation of character CH */ +/* Adapted from `cat' by Torbjorn Granlund */ +static const char *visible(unsigned int ch) +{ + static char buf[10]; + char *bpout = buf; -static const char *device_name = bb_msg_standard_input; + if (ch == _POSIX_VDISABLE) + return ""; + if (ch >= 128) { + ch -= 128; + *bpout++ = 'M'; + *bpout++ = '-'; + } + + if (ch < 32) { + *bpout++ = '^'; + *bpout++ = ch + 64; + } else if (ch < 127) { + *bpout++ = ch; + } else { + *bpout++ = '^'; + *bpout++ = '?'; + } + + *bpout = '\0'; + return buf; +} + +static tcflag_t *mode_type_flag(unsigned type, const struct termios *mode) +{ + static const unsigned char tcflag_offsets[] = { + offsetof(struct termios, c_cflag), /* control */ + offsetof(struct termios, c_iflag), /* input */ + offsetof(struct termios, c_oflag), /* output */ + offsetof(struct termios, c_lflag), /* local */ + }; + + if (type <= local) { + return (tcflag_t*) (((char*)mode) + tcflag_offsets[type]); + } + return NULL; +} + +static speed_t string_to_baud_or_die(const char *arg) +{ + return tty_value_to_baud(bb_xparse_number(arg, 0)); +} + +static void set_speed_or_die(enum speed_setting type, const char *arg, + struct termios *mode) +{ + speed_t baud; + + baud = string_to_baud_or_die(arg); + + if (type != output_speed) { /* either input or both */ + cfsetispeed(mode, baud); + } + if (type != input_speed) { /* either output or both */ + cfsetospeed(mode, baud); + } +} + static ATTRIBUTE_NORETURN void perror_on_device_and_die(const char *fmt) { bb_perror_msg_and_die(fmt, device_name); @@ -438,6 +482,103 @@ current_col = 0; } +#ifdef TIOCGWINSZ + +static int get_win_size(struct winsize *win) +{ + return ioctl(STDIN_FILENO, TIOCGWINSZ, (char *) win); +} + +static void set_window_size(int rows, int cols) +{ + struct winsize win; + + if (get_win_size(&win)) { + if (errno != EINVAL) { + perror_on_device("%s"); + return; + } + memset(&win, 0, sizeof(win)); + } + + if (rows >= 0) + win.ws_row = rows; + if (cols >= 0) + win.ws_col = cols; + +# ifdef TIOCSSIZE + /* Alexander Dupuy wrote: + The following code deals with a bug in the SunOS 4.x (and 3.x?) kernel. + This comment from sys/ttold.h describes Sun's twisted logic - a better + test would have been (ts_lines > 64k || ts_cols > 64k || ts_cols == 0). + At any rate, the problem is gone in Solaris 2.x */ + + if (win.ws_row == 0 || win.ws_col == 0) { + struct ttysize ttysz; + + ttysz.ts_lines = win.ws_row; + ttysz.ts_cols = win.ws_col; + + win.ws_row = win.ws_col = 1; + + if ((ioctl(STDIN_FILENO, TIOCSWINSZ, (char *) &win) != 0) + || (ioctl(STDIN_FILENO, TIOCSSIZE, (char *) &ttysz) != 0)) { + perror_on_device("%s"); + } + return; + } +# endif + + if (ioctl(STDIN_FILENO, TIOCSWINSZ, (char *) &win)) + perror_on_device("%s"); +} + +static void display_window_size(int fancy) +{ + const char *fmt_str = "%s\0%s: no size information for this device"; + struct winsize win; + + if (get_win_size(&win)) { + if ((errno != EINVAL) || ((fmt_str += 2), !fancy)) { + perror_on_device(fmt_str); + } + } else { + wrapf(fancy ? "rows %d; columns %d;" : "%d %d\n", + win.ws_row, win.ws_col); + } +} + +#else /* !TIOCGWINSZ */ + +static inline void display_window_size(int fancy) {} + +#endif /* !TIOCGWINSZ */ + +static int screen_columns(void) +{ + int columns; + const char *s; + +#ifdef TIOCGWINSZ + struct winsize win; + + /* With Solaris 2.[123], this ioctl fails and errno is set to + EINVAL for telnet (but not rlogin) sessions. + On ISC 3.0, it fails for the console and the serial port + (but it works for ptys). + It can also fail on any system when stdout isn't a tty. + In case of any failure, just use the default */ + if (get_win_size(&win) == 0 && win.ws_col > 0) + return win.ws_col; +#endif + + columns = 80; + if ((s = getenv("COLUMNS"))) { + columns = atoi(s); + } + return columns; +} + static const struct suffix_mult stty_suffixes[] = { {"b", 512 }, {"k", 1024}, @@ -469,9 +610,9 @@ param_rows = 2 | 0x80, param_cols = 3 | 0x80, param_size = 4, - param_ispeed = 5 | 0x80, - param_ospeed = 6 | 0x80, - param_speed = 7, + param_speed = 5, + param_ispeed = 6 | 0x80, + param_ospeed = 7 | 0x80, }; static int find_param(const char *name) @@ -485,13 +626,24 @@ if (streq(name, "columns")) return param_cols; if (streq(name, "size")) return param_size; #endif + if (streq(name, "speed")) return param_speed; if (streq(name, "ispeed")) return param_ispeed; if (streq(name, "ospeed")) return param_ospeed; - if (streq(name, "speed")) return param_speed; return 0; } +static int recover_mode(const char *arg, struct termios *mode); +static void set_mode(const struct mode_info *info, + int reversed, struct termios *mode); +static void display_all(const struct termios *mode); +static void display_changed(const struct termios *mode); +static void display_recoverable(const struct termios *mode); +static void display_speed(const struct termios *mode, int fancy); +static void sane_mode(struct termios *mode); +static void set_control_char_or_die(const struct control_info *info, + const char *arg, struct termios *mode); + int stty_main(int argc, char **argv) { struct termios mode; @@ -602,13 +754,19 @@ break; case param_size: #endif + case param_speed: + break; case param_ispeed: + /* called for the side effect of xfunc death only */ + set_speed_or_die(input_speed, argnext, &mode); + break; case param_ospeed: - case param_speed: + /* called for the side effect of xfunc death only */ + set_speed_or_die(output_speed, argnext, &mode); break; default: if (recover_mode(arg, &mode) == 1) break; - if (string_to_baud(arg) != (speed_t) -1) break; + if (string_to_baud_or_die(arg) != (speed_t) -1) break; bb_error_msg_and_die("invalid argument '%s'", arg); } noargs = 0; @@ -643,7 +801,6 @@ if (verbose_output || recoverable_output || noargs) { max_col = screen_columns(); - current_col = 0; output_func(&mode); return EXIT_SUCCESS; } @@ -697,32 +854,31 @@ break; case param_size: max_col = screen_columns(); - current_col = 0; display_window_size(0); break; case param_rows: set_window_size((int) bb_xparse_number(argnext, stty_suffixes), -1); break; #endif + case param_speed: + max_col = screen_columns(); + display_speed(&mode, 0); + break; case param_ispeed: - set_speed(input_speed, argnext, &mode); + set_speed_or_die(input_speed, argnext, &mode); speed_was_set = 1; require_set_attr = 1; break; case param_ospeed: - set_speed(output_speed, argnext, &mode); + set_speed_or_die(output_speed, argnext, &mode); speed_was_set = 1; require_set_attr = 1; break; - case param_speed: - max_col = screen_columns(); - display_speed(&mode, 0); - break; default: if (recover_mode(arg, &mode) == 1) require_set_attr = 1; - else /* true: if (string_to_baud(arg) != (speed_t) -1) */ { - set_speed(both_speeds, arg, &mode); + else /* true: if (string_to_baud_or_die(arg) != (speed_t) -1) */ { + set_speed_or_die(both_speeds, arg, &mode); speed_was_set = 1; require_set_attr = 1; } /* else - impossible (caught in the first pass): @@ -805,8 +961,8 @@ #define ECHOKE 0 #endif -static void -set_mode(const struct mode_info *info, int reversed, struct termios *mode) +static void set_mode(const struct mode_info *info, int reversed, + struct termios *mode) { tcflag_t *bitsp; @@ -932,9 +1088,8 @@ } } -static void -set_control_char_or_die(const struct control_info *info, const char *arg, - struct termios *mode) +static void set_control_char_or_die(const struct control_info *info, + const char *arg, struct termios *mode) { unsigned char value; @@ -945,143 +1100,14 @@ else if (streq(arg, "^-") || streq(arg, "undef")) value = _POSIX_VDISABLE; else if (arg[0] == '^') { /* Ignore any trailing junk (^Cjunk) */ + value = arg[1] & 0x1f; /* Non-letters get weird results */ if (arg[1] == '?') value = 127; - else - value = arg[1] & 0x1f; /* Non-letters get weird results */ } else value = bb_xparse_number(arg, stty_suffixes); mode->c_cc[info->offset] = value; } -static void -set_speed(enum speed_setting type, const char *arg, struct termios *mode) -{ - speed_t baud; - - baud = string_to_baud(arg); - - if (type != output_speed) { /* either input or both */ - cfsetispeed(mode, baud); - } - if (type != input_speed) { /* either output or both */ - cfsetospeed(mode, baud); - } -} - -#ifdef TIOCGWINSZ - -static int get_win_size(struct winsize *win) -{ - return ioctl(STDIN_FILENO, TIOCGWINSZ, (char *) win); -} - -static void -set_window_size(int rows, int cols) -{ - struct winsize win; - - if (get_win_size(&win)) { - if (errno != EINVAL) { - perror_on_device("%s"); - return; - } - memset(&win, 0, sizeof(win)); - } - - if (rows >= 0) - win.ws_row = rows; - if (cols >= 0) - win.ws_col = cols; - -# ifdef TIOCSSIZE - /* Alexander Dupuy wrote: - The following code deals with a bug in the SunOS 4.x (and 3.x?) kernel. - This comment from sys/ttold.h describes Sun's twisted logic - a better - test would have been (ts_lines > 64k || ts_cols > 64k || ts_cols == 0). - At any rate, the problem is gone in Solaris 2.x */ - - if (win.ws_row == 0 || win.ws_col == 0) { - struct ttysize ttysz; - - ttysz.ts_lines = win.ws_row; - ttysz.ts_cols = win.ws_col; - - win.ws_row = win.ws_col = 1; - - if ((ioctl(STDIN_FILENO, TIOCSWINSZ, (char *) &win) != 0) - || (ioctl(STDIN_FILENO, TIOCSSIZE, (char *) &ttysz) != 0)) { - perror_on_device("%s"); - } - return; - } -# endif - - if (ioctl(STDIN_FILENO, TIOCSWINSZ, (char *) &win)) - perror_on_device("%s"); -} - -static void display_window_size(int fancy) -{ - const char *fmt_str = "%s\0%s: no size information for this device"; - struct winsize win; - - if (get_win_size(&win)) { - if ((errno != EINVAL) || ((fmt_str += 2), !fancy)) { - perror_on_device(fmt_str); - } - } else { - wrapf(fancy ? "rows %d; columns %d;" : "%d %d\n", - win.ws_row, win.ws_col); - } -} - -#else /* !TIOCGWINSZ */ - -static inline void display_window_size(int fancy) {} - -#endif /* !TIOCGWINSZ */ - -static int screen_columns(void) -{ - int columns; - const char *s; - -#ifdef TIOCGWINSZ - struct winsize win; - - /* With Solaris 2.[123], this ioctl fails and errno is set to - EINVAL for telnet (but not rlogin) sessions. - On ISC 3.0, it fails for the console and the serial port - (but it works for ptys). - It can also fail on any system when stdout isn't a tty. - In case of any failure, just use the default */ - if (get_win_size(&win) == 0 && win.ws_col > 0) - return win.ws_col; -#endif - - columns = 80; - if ((s = getenv("COLUMNS"))) { - columns = atoi(s); - } - return columns; -} - -static tcflag_t *mode_type_flag(unsigned type, const struct termios *mode) -{ - static const unsigned char tcflag_offsets[] = { - offsetof(struct termios, c_cflag), /* control */ - offsetof(struct termios, c_iflag), /* input */ - offsetof(struct termios, c_oflag), /* output */ - offsetof(struct termios, c_lflag), /* local */ - }; - - if (type <= local) { - return (tcflag_t*) (((char*)mode) + tcflag_offsets[type]); - } - return NULL; -} - static void display_changed(const struct termios *mode) { int i; @@ -1140,8 +1166,7 @@ if (current_col) wrapf("\n"); } -static void -display_all(const struct termios *mode) +static void display_all(const struct termios *mode) { int i; tcflag_t *bitsp; @@ -1214,7 +1239,6 @@ static void display_recoverable(const struct termios *mode) { int i; - printf("%lx:%lx:%lx:%lx", (unsigned long) mode->c_iflag, (unsigned long) mode->c_oflag, (unsigned long) mode->c_cflag, (unsigned long) mode->c_lflag); @@ -1253,11 +1277,6 @@ return 1; } -static speed_t string_to_baud(const char *arg) -{ - return tty_value_to_baud(bb_xparse_number(arg, 0)); -} - static void sane_mode(struct termios *mode) { int i; @@ -1283,35 +1302,3 @@ } } } - -/* Return a string that is the printable representation of character CH */ -/* Adapted from `cat' by Torbjorn Granlund */ - -static const char *visible(unsigned int ch) -{ - static char buf[10]; - char *bpout = buf; - - if (ch == _POSIX_VDISABLE) { - return ""; - } - - if (ch >= 128) { - ch -= 128; - *bpout++ = 'M'; - *bpout++ = '-'; - } - - if (ch < 32) { - *bpout++ = '^'; - *bpout++ = ch + 64; - } else if (ch < 127) { - *bpout++ = ch; - } else { - *bpout++ = '^'; - *bpout++ = '?'; - } - - *bpout = '\0'; - return buf; -} ------------------------------------------------------------------------ r16154 | vda | 2006-09-19 10:24:23 -0400 (Tue, 19 Sep 2006) | 4 lines Changed paths: M /trunk/busybox/coreutils/stty.c stty: convert "enum mode_type" into unnamed enum (reduces code obfuscation); deindent set_mode; add _or_die suffixes to few functions ------------------------------------------------------------------------ Index: coreutils/stty.c =================================================================== --- coreutils/stty.c (revision 16153) +++ coreutils/stty.c (revision 16154) @@ -121,7 +121,7 @@ }; /* Which member(s) of `struct termios' a mode uses */ -enum mode_type { +enum { /* Do NOT change the order or values, as mode_type_flag() * depends on them */ control, input, output, local, combination @@ -159,13 +159,11 @@ /* Each mode */ struct mode_info { const char *name; /* Name given on command line */ - /* enum mode_type type; */ char type; /* Which structure element to change */ char flags; /* Setting and display options */ unsigned short mask; /* Other bits to turn off for this mode */ unsigned long bits; /* Bits to set for this mode */ }; -#define EMT(t) ((enum mode_type)(t)) #define MI_ENTRY(N,T,F,B,M) { N, T, F, M, B } @@ -383,14 +381,14 @@ static void set_mode(const struct mode_info *info, int reversed, struct termios *mode); static speed_t string_to_baud(const char *arg); -static tcflag_t* mode_type_flag(enum mode_type type, const struct termios *mode); +static tcflag_t* mode_type_flag(unsigned type, const struct termios *mode); static void display_all(const struct termios *mode); static void display_changed(const struct termios *mode); static void display_recoverable(const struct termios *mode); static void display_speed(const struct termios *mode, int fancy); static void display_window_size(int fancy); static void sane_mode(struct termios *mode); -static void set_control_char(const struct control_info *info, +static void set_control_char_or_die(const struct control_info *info, const char *arg, struct termios *mode); static void set_speed(enum speed_setting type, const char *arg, struct termios *mode); @@ -398,11 +396,16 @@ static const char *device_name = bb_msg_standard_input; -static ATTRIBUTE_NORETURN void perror_on_device(const char *fmt) +static ATTRIBUTE_NORETURN void perror_on_device_and_die(const char *fmt) { bb_perror_msg_and_die(fmt, device_name); } +static void perror_on_device(const char *fmt) +{ + bb_perror_msg(fmt, device_name); +} + /* No, inline won't be as efficient (gcc 3.4.3) */ #define streq(a,b) (!strcmp((a),(b))) @@ -570,6 +573,8 @@ if (cp) { if (!argnext) bb_error_msg_and_die(bb_msg_requires_arg, arg); + /* called for the side effect of xfunc death only */ + set_control_char_or_die(cp, argnext, &mode); noargs = 0; ++k; continue; @@ -627,14 +632,14 @@ } fdflags = fcntl(STDIN_FILENO, F_GETFL); if (fdflags == -1 || fcntl(STDIN_FILENO, F_SETFL, fdflags & ~O_NONBLOCK) < 0) - perror_on_device("%s: couldn't reset non-blocking mode"); + perror_on_device_and_die("%s: couldn't reset non-blocking mode"); } /* Initialize to all zeroes so there is no risk memcmp will report a spurious difference in an uninitialized portion of the structure */ memset(&mode, 0, sizeof(mode)); if (tcgetattr(STDIN_FILENO, &mode)) - perror_on_device("%s"); + perror_on_device_and_die("%s"); if (verbose_output || recoverable_output || noargs) { max_col = screen_columns(); @@ -670,7 +675,7 @@ cp = find_control(arg); if (cp) { ++k; - set_control_char(cp, argnext, &mode); + set_control_char_or_die(cp, argnext, &mode); continue; } @@ -729,7 +734,7 @@ struct termios new_mode; if (tcsetattr(STDIN_FILENO, TCSADRAIN, &mode)) - perror_on_device("%s"); + perror_on_device_and_die("%s"); /* POSIX (according to Zlotnick's book) tcsetattr returns zero if it performs *any* of the requested operations. This means it @@ -742,7 +747,7 @@ spurious difference in an uninitialized portion of the structure */ memset(&new_mode, 0, sizeof(new_mode)); if (tcgetattr(STDIN_FILENO, &new_mode)) - perror_on_device("%s"); + perror_on_device_and_die("%s"); if (memcmp(&mode, &new_mode, sizeof(mode)) != 0) { #ifdef CIBAUD @@ -758,7 +763,7 @@ new_mode.c_cflag &= (~CIBAUD); if (speed_was_set || memcmp(&mode, &new_mode, sizeof(mode)) != 0) #endif - perror_on_device ("%s: unable to perform all requested operations"); + perror_on_device_and_die ("%s: unable to perform all requested operations"); } } @@ -805,127 +810,130 @@ { tcflag_t *bitsp; - bitsp = mode_type_flag(EMT(info->type), mode); + bitsp = mode_type_flag(info->type, mode); - if (bitsp == NULL) { - /* Combination mode */ - if (info->name == evenp || info->name == parity) { - if (reversed) - mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; - else - mode->c_cflag = - (mode->c_cflag & ~PARODD & ~CSIZE) | PARENB | CS7; - } else if (info->name == stty_oddp) { - if (reversed) - mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; - else - mode->c_cflag = - (mode->c_cflag & ~CSIZE) | CS7 | PARODD | PARENB; - } else if (info->name == stty_nl) { - if (reversed) { - mode->c_iflag = (mode->c_iflag | ICRNL) & ~INLCR & ~IGNCR; - mode->c_oflag = (mode->c_oflag | ONLCR) & ~OCRNL & ~ONLRET; - } else { - mode->c_iflag = mode->c_iflag & ~ICRNL; - if (ONLCR) mode->c_oflag = mode->c_oflag & ~ONLCR; - } - } else if (info->name == stty_ek) { - mode->c_cc[VERASE] = CERASE; - mode->c_cc[VKILL] = CKILL; - } else if (info->name == stty_sane) - sane_mode(mode); - else if (info->name == cbreak) { - if (reversed) - mode->c_lflag |= ICANON; - else - mode->c_lflag &= ~ICANON; - } else if (info->name == stty_pass8) { - if (reversed) { - mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARENB; - mode->c_iflag |= ISTRIP; - } else { - mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; - mode->c_iflag &= ~ISTRIP; - } - } else if (info->name == litout) { - if (reversed) { - mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARENB; - mode->c_iflag |= ISTRIP; - mode->c_oflag |= OPOST; - } else { - mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; - mode->c_iflag &= ~ISTRIP; - mode->c_oflag &= ~OPOST; - } - } else if (info->name == raw || info->name == cooked) { - if ((info->name[0] == 'r' && reversed) - || (info->name[0] == 'c' && !reversed)) { - /* Cooked mode */ - mode->c_iflag |= BRKINT | IGNPAR | ISTRIP | ICRNL | IXON; - mode->c_oflag |= OPOST; - mode->c_lflag |= ISIG | ICANON; + if (bitsp) { + if (reversed) + *bitsp = *bitsp & ~((unsigned long)info->mask) & ~info->bits; + else + *bitsp = (*bitsp & ~((unsigned long)info->mask)) | info->bits; + return; + } + + /* Combination mode */ + if (info->name == evenp || info->name == parity) { + if (reversed) + mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; + else + mode->c_cflag = (mode->c_cflag & ~PARODD & ~CSIZE) | PARENB | CS7; + } else if (info->name == stty_oddp) { + if (reversed) + mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; + else + mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARODD | PARENB; + } else if (info->name == stty_nl) { + if (reversed) { + mode->c_iflag = (mode->c_iflag | ICRNL) & ~INLCR & ~IGNCR; + mode->c_oflag = (mode->c_oflag | ONLCR) & ~OCRNL & ~ONLRET; + } else { + mode->c_iflag = mode->c_iflag & ~ICRNL; + if (ONLCR) mode->c_oflag = mode->c_oflag & ~ONLCR; + } + } else if (info->name == stty_ek) { + mode->c_cc[VERASE] = CERASE; + mode->c_cc[VKILL] = CKILL; + } else if (info->name == stty_sane) { + sane_mode(mode); + } + else if (info->name == cbreak) { + if (reversed) + mode->c_lflag |= ICANON; + else + mode->c_lflag &= ~ICANON; + } else if (info->name == stty_pass8) { + if (reversed) { + mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARENB; + mode->c_iflag |= ISTRIP; + } else { + mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; + mode->c_iflag &= ~ISTRIP; + } + } else if (info->name == litout) { + if (reversed) { + mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARENB; + mode->c_iflag |= ISTRIP; + mode->c_oflag |= OPOST; + } else { + mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; + mode->c_iflag &= ~ISTRIP; + mode->c_oflag &= ~OPOST; + } + } else if (info->name == raw || info->name == cooked) { + if ((info->name[0] == 'r' && reversed) + || (info->name[0] == 'c' && !reversed)) { + /* Cooked mode */ + mode->c_iflag |= BRKINT | IGNPAR | ISTRIP | ICRNL | IXON; + mode->c_oflag |= OPOST; + mode->c_lflag |= ISIG | ICANON; #if VMIN == VEOF - mode->c_cc[VEOF] = CEOF; + mode->c_cc[VEOF] = CEOF; #endif #if VTIME == VEOL - mode->c_cc[VEOL] = CEOL; + mode->c_cc[VEOL] = CEOL; #endif - } else { - /* Raw mode */ - mode->c_iflag = 0; - mode->c_oflag &= ~OPOST; - mode->c_lflag &= ~(ISIG | ICANON | XCASE); - mode->c_cc[VMIN] = 1; - mode->c_cc[VTIME] = 0; - } + } else { + /* Raw mode */ + mode->c_iflag = 0; + mode->c_oflag &= ~OPOST; + mode->c_lflag &= ~(ISIG | ICANON | XCASE); + mode->c_cc[VMIN] = 1; + mode->c_cc[VTIME] = 0; } - else if (IXANY && info->name == decctlq) { - if (reversed) - mode->c_iflag |= IXANY; - else - mode->c_iflag &= ~IXANY; + } + else if (IXANY && info->name == decctlq) { + if (reversed) + mode->c_iflag |= IXANY; + else + mode->c_iflag &= ~IXANY; + } + else if (TABDLY && info->name == stty_tabs) { + if (reversed) + mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB3; + else + mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB0; + } + else if (OXTABS && info->name == stty_tabs) { + if (reversed) + mode->c_oflag |= OXTABS; + else + mode->c_oflag &= ~OXTABS; + } + else if (XCASE && IUCLC && OLCUC + && (info->name == stty_lcase || info->name == stty_LCASE)) { + if (reversed) { + mode->c_lflag &= ~XCASE; + mode->c_iflag &= ~IUCLC; + mode->c_oflag &= ~OLCUC; + } else { + mode->c_lflag |= XCASE; + mode->c_iflag |= IUCLC; + mode->c_oflag |= OLCUC; } - else if (TABDLY && info->name == stty_tabs) { - if (reversed) - mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB3; - else - mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB0; - } - else if (OXTABS && info->name == stty_tabs) { - if (reversed) - mode->c_oflag = mode->c_oflag | OXTABS; - else - mode->c_oflag = mode->c_oflag & ~OXTABS; - } - else if (XCASE && IUCLC && OLCUC - && (info->name == stty_lcase || info->name == stty_LCASE)) { - if (reversed) { - mode->c_lflag &= ~XCASE; - mode->c_iflag &= ~IUCLC; - mode->c_oflag &= ~OLCUC; - } else { - mode->c_lflag |= XCASE; - mode->c_iflag |= IUCLC; - mode->c_oflag |= OLCUC; - } - } - else if (info->name == stty_crt) - mode->c_lflag |= ECHOE | ECHOCTL | ECHOKE; - else if (info->name == stty_dec) { - mode->c_cc[VINTR] = 3; /* ^C */ - mode->c_cc[VERASE] = 127; /* DEL */ - mode->c_cc[VKILL] = 21; /* ^U */ - mode->c_lflag |= ECHOE | ECHOCTL | ECHOKE; - if (IXANY) mode->c_iflag &= ~IXANY; - } - } else if (reversed) - *bitsp = *bitsp & ~((unsigned long)info->mask) & ~info->bits; - else - *bitsp = (*bitsp & ~((unsigned long)info->mask)) | info->bits; + } + else if (info->name == stty_crt) { + mode->c_lflag |= ECHOE | ECHOCTL | ECHOKE; + } + else if (info->name == stty_dec) { + mode->c_cc[VINTR] = 3; /* ^C */ + mode->c_cc[VERASE] = 127; /* DEL */ + mode->c_cc[VKILL] = 21; /* ^U */ + mode->c_lflag |= ECHOE | ECHOCTL | ECHOKE; + if (IXANY) mode->c_iflag &= ~IXANY; + } } static void -set_control_char(const struct control_info *info, const char *arg, +set_control_char_or_die(const struct control_info *info, const char *arg, struct termios *mode) { unsigned char value; @@ -936,11 +944,11 @@ value = arg[0]; else if (streq(arg, "^-") || streq(arg, "undef")) value = _POSIX_VDISABLE; - else if (arg[0] == '^' && arg[1] != '\0') { /* Ignore any trailing junk */ + else if (arg[0] == '^') { /* Ignore any trailing junk (^Cjunk) */ if (arg[1] == '?') value = 127; else - value = arg[1] & ~0140; /* Non-letters get weird results */ + value = arg[1] & 0x1f; /* Non-letters get weird results */ } else value = bb_xparse_number(arg, stty_suffixes); mode->c_cc[info->offset] = value; @@ -963,9 +971,9 @@ #ifdef TIOCGWINSZ -static int get_win_size(int fd, struct winsize *win) +static int get_win_size(struct winsize *win) { - return ioctl(fd, TIOCGWINSZ, (char *) win); + return ioctl(STDIN_FILENO, TIOCGWINSZ, (char *) win); } static void @@ -973,9 +981,11 @@ { struct winsize win; - if (get_win_size(STDIN_FILENO, &win)) { - if (errno != EINVAL) + if (get_win_size(&win)) { + if (errno != EINVAL) { perror_on_device("%s"); + return; + } memset(&win, 0, sizeof(win)); } @@ -1000,7 +1010,7 @@ win.ws_row = win.ws_col = 1; if ((ioctl(STDIN_FILENO, TIOCSWINSZ, (char *) &win) != 0) - || (ioctl(STDIN_FILENO, TIOCSSIZE, (char *) &ttysz) != 0)) { + || (ioctl(STDIN_FILENO, TIOCSSIZE, (char *) &ttysz) != 0)) { perror_on_device("%s"); } return; @@ -1013,20 +1023,25 @@ static void display_window_size(int fancy) { - const char *fmt_str = "%s" "\0" "%s: no size information for this device"; + const char *fmt_str = "%s\0%s: no size information for this device"; struct winsize win; - if (get_win_size(STDIN_FILENO, &win)) { + if (get_win_size(&win)) { if ((errno != EINVAL) || ((fmt_str += 2), !fancy)) { perror_on_device(fmt_str); } } else { wrapf(fancy ? "rows %d; columns %d;" : "%d %d\n", - win.ws_row, win.ws_col); + win.ws_row, win.ws_col); } } -#endif +#else /* !TIOCGWINSZ */ + +static inline void display_window_size(int fancy) {} + +#endif /* !TIOCGWINSZ */ + static int screen_columns(void) { int columns; @@ -1041,7 +1056,7 @@ (but it works for ptys). It can also fail on any system when stdout isn't a tty. In case of any failure, just use the default */ - if (get_win_size(STDOUT_FILENO, &win) == 0 && win.ws_col > 0) + if (get_win_size(&win) == 0 && win.ws_col > 0) return win.ws_col; #endif @@ -1052,17 +1067,17 @@ return columns; } -static tcflag_t *mode_type_flag(enum mode_type type, const struct termios *mode) +static tcflag_t *mode_type_flag(unsigned type, const struct termios *mode) { static const unsigned char tcflag_offsets[] = { offsetof(struct termios, c_cflag), /* control */ offsetof(struct termios, c_iflag), /* input */ offsetof(struct termios, c_oflag), /* output */ - offsetof(struct termios, c_lflag) /* local */ + offsetof(struct termios, c_lflag), /* local */ }; - if (((unsigned int) type) <= local) { - return (tcflag_t *)(((char *) mode) + tcflag_offsets[(int)type]); + if (type <= local) { + return (tcflag_t*) (((char*)mode) + tcflag_offsets[type]); } return NULL; } @@ -1072,7 +1087,7 @@ int i; tcflag_t *bitsp; unsigned long mask; - enum mode_type prev_type = control; + int prev_type = control; display_speed(mode, 1); #ifdef HAVE_C_LINE @@ -1107,12 +1122,12 @@ for (i = 0; i < NUM_mode_info; ++i) { if (mode_info[i].flags & OMIT) continue; - if (EMT(mode_info[i].type) != prev_type) { + if (mode_info[i].type != prev_type) { if (current_col) wrapf("\n"); - prev_type = EMT(mode_info[i].type); + prev_type = mode_info[i].type; } - bitsp = mode_type_flag(EMT(mode_info[i].type), mode); + bitsp = mode_type_flag(mode_info[i].type, mode); mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits; if ((*bitsp & mask) == mode_info[i].bits) { if (mode_info[i].flags & SANE_UNSET) { @@ -1131,12 +1146,10 @@ int i; tcflag_t *bitsp; unsigned long mask; - enum mode_type prev_type = control; + int prev_type = control; display_speed(mode, 1); -#ifdef TIOCGWINSZ display_window_size(1); -#endif #ifdef HAVE_C_LINE wrapf("line = %d;\n", mode->c_line); #else @@ -1167,13 +1180,12 @@ for (i = 0; i < NUM_mode_info; ++i) { if (mode_info[i].flags & OMIT) continue; - if (EMT(mode_info[i].type) != prev_type) { - putchar('\n'); - current_col = 0; - prev_type = EMT(mode_info[i].type); + if (mode_info[i].type != prev_type) { + wrapf("\n"); + prev_type = mode_info[i].type; } - bitsp = mode_type_flag(EMT(mode_info[i].type), mode); + bitsp = mode_type_flag(mode_info[i].type, mode); mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits; if ((*bitsp & mask) == mode_info[i].bits) wrapf("%s", mode_info[i].name); @@ -1185,14 +1197,14 @@ static void display_speed(const struct termios *mode, int fancy) { - //12345678 9 10 + //01234567 8 9 const char *fmt_str = "%lu %lu\n\0ispeed %lu baud; ospeed %lu baud;"; unsigned long ispeed, ospeed; ospeed = ispeed = cfgetispeed(mode); if (ispeed == 0 || ispeed == (ospeed = cfgetospeed(mode))) { ispeed = ospeed; /* in case ispeed was 0 */ - //1234 5 6 7 8 9 10 + //0123 4 5 6 7 8 9 fmt_str = "%lu\n\0\0\0\0\0speed %lu baud;"; } if (fancy) fmt_str += 9; @@ -1261,11 +1273,11 @@ for (i = 0; i < NUM_mode_info; ++i) { if (mode_info[i].flags & SANE_SET) { - bitsp = mode_type_flag(EMT(mode_info[i].type), mode); + bitsp = mode_type_flag(mode_info[i].type, mode); *bitsp = (*bitsp & ~((unsigned long)mode_info[i].mask)) | mode_info[i].bits; } else if (mode_info[i].flags & SANE_UNSET) { - bitsp = mode_type_flag(EMT(mode_info[i].type), mode); + bitsp = mode_type_flag(mode_info[i].type, mode); *bitsp = *bitsp & ~((unsigned long)mode_info[i].mask) & ~mode_info[i].bits; } ------------------------------------------------------------------------ r16153 | vda | 2006-09-19 10:20:22 -0400 (Tue, 19 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/coreutils/stty.c stty: reduce #ifdef forest ------------------------------------------------------------------------ Index: coreutils/stty.c =================================================================== --- coreutils/stty.c (revision 16152) +++ coreutils/stty.c (revision 16153) @@ -765,6 +765,40 @@ return EXIT_SUCCESS; } +/* Save set_mode from #ifdef forest plague */ +#ifndef ONLCR +#define ONLCR 0 +#endif +#ifndef OCRNL +#define OCRNL 0 +#endif +#ifndef ONLRET +#define ONLRET 0 +#endif +#ifndef XCASE +#define XCASE 0 +#endif +#ifndef IXANY +#define IXANY 0 +#endif +#ifndef TABDLY +#define TABDLY 0 +#endif +#ifndef OXTABS +#define OXTABS 0 +#endif +#ifndef IUCLC +#define IUCLC 0 +#endif +#ifndef OLCUC +#define OLCUC 0 +#endif +#ifndef ECHOCTL +#define ECHOCTL 0 +#endif +#ifndef ECHOKE +#define ECHOKE 0 +#endif static void set_mode(const struct mode_info *info, int reversed, struct termios *mode) @@ -790,23 +824,10 @@ } else if (info->name == stty_nl) { if (reversed) { mode->c_iflag = (mode->c_iflag | ICRNL) & ~INLCR & ~IGNCR; - mode->c_oflag = (mode->c_oflag -#ifdef ONLCR - | ONLCR -#endif - ) -#ifdef OCRNL - & ~OCRNL -#endif -#ifdef ONLRET - & ~ONLRET -#endif - ; + mode->c_oflag = (mode->c_oflag | ONLCR) & ~OCRNL & ~ONLRET; } else { mode->c_iflag = mode->c_iflag & ~ICRNL; -#ifdef ONLCR - mode->c_oflag = mode->c_oflag & ~ONLCR; -#endif + if (ONLCR) mode->c_oflag = mode->c_oflag & ~ONLCR; } } else if (info->name == stty_ek) { mode->c_cc[VERASE] = CERASE; @@ -853,42 +874,31 @@ /* Raw mode */ mode->c_iflag = 0; mode->c_oflag &= ~OPOST; - mode->c_lflag &= ~(ISIG | ICANON -#ifdef XCASE - | XCASE -#endif - ); + mode->c_lflag &= ~(ISIG | ICANON | XCASE); mode->c_cc[VMIN] = 1; mode->c_cc[VTIME] = 0; } } -#ifdef IXANY - else if (info->name == decctlq) { + else if (IXANY && info->name == decctlq) { if (reversed) mode->c_iflag |= IXANY; else mode->c_iflag &= ~IXANY; } -#endif -#ifdef TABDLY - else if (info->name == stty_tabs) { + else if (TABDLY && info->name == stty_tabs) { if (reversed) mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB3; else mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB0; } -#else -# ifdef OXTABS - else if (info->name == stty_tabs) { + else if (OXTABS && info->name == stty_tabs) { if (reversed) mode->c_oflag = mode->c_oflag | OXTABS; else mode->c_oflag = mode->c_oflag & ~OXTABS; } -# endif -#endif -#if defined(XCASE) && defined(IUCLC) && defined(OLCUC) - else if (info->name == stty_lcase || info->name == stty_LCASE) { + else if (XCASE && IUCLC && OLCUC + && (info->name == stty_lcase || info->name == stty_LCASE)) { if (reversed) { mode->c_lflag &= ~XCASE; mode->c_iflag &= ~IUCLC; @@ -899,31 +909,14 @@ mode->c_oflag |= OLCUC; } } -#endif else if (info->name == stty_crt) - mode->c_lflag |= ECHOE -#ifdef ECHOCTL - | ECHOCTL -#endif -#ifdef ECHOKE - | ECHOKE -#endif - ; + mode->c_lflag |= ECHOE | ECHOCTL | ECHOKE; else if (info->name == stty_dec) { mode->c_cc[VINTR] = 3; /* ^C */ mode->c_cc[VERASE] = 127; /* DEL */ mode->c_cc[VKILL] = 21; /* ^U */ - mode->c_lflag |= ECHOE -#ifdef ECHOCTL - | ECHOCTL -#endif -#ifdef ECHOKE - | ECHOKE -#endif - ; -#ifdef IXANY - mode->c_iflag &= ~IXANY; -#endif + mode->c_lflag |= ECHOE | ECHOCTL | ECHOKE; + if (IXANY) mode->c_iflag &= ~IXANY; } } else if (reversed) *bitsp = *bitsp & ~((unsigned long)info->mask) & ~info->bits; ------------------------------------------------------------------------ r16152 | vda | 2006-09-19 10:19:42 -0400 (Tue, 19 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/coreutils/stty.c stty: simplify linewrapping code a bit ------------------------------------------------------------------------ Index: coreutils/stty.c =================================================================== --- coreutils/stty.c (revision 16151) +++ coreutils/stty.c (revision 16152) @@ -403,35 +403,36 @@ bb_perror_msg_and_die(fmt, device_name); } -static ATTRIBUTE_ALWAYS_INLINE int streq(const char *a, const char *b) -{ - return strcmp(a, b) == 0; -} +/* No, inline won't be as efficient (gcc 3.4.3) */ +#define streq(a,b) (!strcmp((a),(b))) /* Print format string MESSAGE and optional args. Wrap to next line first if it won't fit. Print a space first unless MESSAGE will start a new line */ - static void wrapf(const char *message, ...) { + char buf[128]; va_list args; - char buf[1024]; /* Plenty long for our needs */ int buflen; va_start(args, message); - vsprintf(buf, message, args); + vsnprintf(buf, sizeof(buf), message, args); va_end(args); buflen = strlen(buf); - if (current_col + (current_col > 0) + buflen >= max_col) { - putchar('\n'); - current_col = 0; - } + if (!buflen) return; + if (current_col > 0) { - putchar(' '); current_col++; + if (current_col + buflen >= max_col) { + putchar('\n'); + current_col = 0; + } else + if (buf[0] != '\n') putchar(' '); } fputs(buf, stdout); current_col += buflen; + if (buf[buflen-1] == '\n') + current_col = 0; } static const struct suffix_mult stty_suffixes[] = { @@ -584,13 +585,13 @@ switch (param) { #ifdef HAVE_C_LINE case param_line: +# ifndef TIOCGWINSZ bb_xparse_number(argnext, stty_suffixes); break; +# endif /* else fall-through */ #endif #ifdef TIOCGWINSZ case param_rows: - bb_xparse_number(argnext, stty_suffixes); - break; case param_cols: bb_xparse_number(argnext, stty_suffixes); break; @@ -1029,8 +1030,6 @@ } else { wrapf(fancy ? "rows %d; columns %d;" : "%d %d\n", win.ws_row, win.ws_col); - if (!fancy) - current_col = 0; } } #endif @@ -1078,19 +1077,17 @@ static void display_changed(const struct termios *mode) { int i; - int empty_line; tcflag_t *bitsp; unsigned long mask; enum mode_type prev_type = control; display_speed(mode, 1); #ifdef HAVE_C_LINE - wrapf("line = %d;", mode->c_line); + wrapf("line = %d;\n", mode->c_line); +#else + wrapf("\n"); #endif - putchar('\n'); - current_col = 0; - empty_line = 1; for (i = 0; control_info[i].name != stty_min; ++i) { if (mode->c_cc[control_info[i].offset] == control_info[i].saneval) continue; @@ -1105,28 +1102,20 @@ && (control_info[i].name == stty_eof || control_info[i].name == stty_eol)) continue; #endif - - empty_line = 0; wrapf("%s = %s;", control_info[i].name, visible(mode->c_cc[control_info[i].offset])); } if ((mode->c_lflag & ICANON) == 0) { - wrapf("min = %d; time = %d;\n", (int) mode->c_cc[VMIN], + wrapf("min = %d; time = %d;", (int) mode->c_cc[VMIN], (int) mode->c_cc[VTIME]); - } else if (empty_line == 0) - putchar('\n'); - current_col = 0; + } + if (current_col) wrapf("\n"); - empty_line = 1; for (i = 0; i < NUM_mode_info; ++i) { if (mode_info[i].flags & OMIT) continue; if (EMT(mode_info[i].type) != prev_type) { - if (empty_line == 0) { - putchar('\n'); - current_col = 0; - empty_line = 1; - } + if (current_col) wrapf("\n"); prev_type = EMT(mode_info[i].type); } @@ -1135,16 +1124,12 @@ if ((*bitsp & mask) == mode_info[i].bits) { if (mode_info[i].flags & SANE_UNSET) { wrapf("%s", mode_info[i].name); - empty_line = 0; } } else if ((mode_info[i].flags & (SANE_SET | REV)) == (SANE_SET | REV)) { wrapf("-%s", mode_info[i].name); - empty_line = 0; } } - if (empty_line == 0) - putchar('\n'); - current_col = 0; + if (current_col) wrapf("\n"); } static void @@ -1160,10 +1145,10 @@ display_window_size(1); #endif #ifdef HAVE_C_LINE - wrapf("line = %d;", mode->c_line); + wrapf("line = %d;\n", mode->c_line); +#else + wrapf("\n"); #endif - putchar('\n'); - current_col = 0; for (i = 0; control_info[i].name != stty_min; ++i) { /* If swtch is the same as susp, don't print both */ @@ -1184,9 +1169,7 @@ if ((mode->c_lflag & ICANON) == 0) #endif wrapf("min = %d; time = %d;", mode->c_cc[VMIN], mode->c_cc[VTIME]); - if (current_col != 0) - putchar('\n'); - current_col = 0; + if (current_col) wrapf("\n"); for (i = 0; i < NUM_mode_info; ++i) { if (mode_info[i].flags & OMIT) @@ -1204,28 +1187,23 @@ else if (mode_info[i].flags & REV) wrapf("-%s", mode_info[i].name); } - putchar('\n'); - current_col = 0; + if (current_col) wrapf("\n"); } static void display_speed(const struct termios *mode, int fancy) { + //12345678 9 10 + const char *fmt_str = "%lu %lu\n\0ispeed %lu baud; ospeed %lu baud;"; unsigned long ispeed, ospeed; - const char *fmt_str = - "%lu %lu\n\0" "ispeed %lu baud; ospeed %lu baud;\0" - "%lu\n\0" "\0\0\0\0" "speed %lu baud;"; ospeed = ispeed = cfgetispeed(mode); if (ispeed == 0 || ispeed == (ospeed = cfgetospeed(mode))) { ispeed = ospeed; /* in case ispeed was 0 */ - fmt_str += 43; + //1234 5 6 7 8 9 10 + fmt_str = "%lu\n\0\0\0\0\0speed %lu baud;"; } - if (fancy) { - fmt_str += 9; - } + if (fancy) fmt_str += 9; wrapf(fmt_str, tty_baud_to_value(ispeed), tty_baud_to_value(ospeed)); - if (!fancy) - current_col = 0; } static void display_recoverable(const struct termios *mode) ------------------------------------------------------------------------ r16150 | vda | 2006-09-19 10:17:10 -0400 (Tue, 19 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/coreutils/stty.c stty: style fixes ------------------------------------------------------------------------ Index: coreutils/stty.c =================================================================== --- coreutils/stty.c (revision 16149) +++ coreutils/stty.c (revision 16150) @@ -23,17 +23,14 @@ #include "busybox.h" -#define STREQ(a, b) (strcmp ((a), (b)) == 0) - - #ifndef _POSIX_VDISABLE # define _POSIX_VDISABLE ((unsigned char) 0) #endif #define Control(c) ((c) & 0x1f) -/* Canonical values for control characters. */ +/* Canonical values for control characters */ #ifndef CINTR -# define CINTR Control ('c') +# define CINTR Control('c') #endif #ifndef CQUIT # define CQUIT 28 @@ -42,27 +39,27 @@ # define CERASE 127 #endif #ifndef CKILL -# define CKILL Control ('u') +# define CKILL Control('u') #endif #ifndef CEOF -# define CEOF Control ('d') +# define CEOF Control('d') #endif #ifndef CEOL # define CEOL _POSIX_VDISABLE #endif #ifndef CSTART -# define CSTART Control ('q') +# define CSTART Control('q') #endif #ifndef CSTOP -# define CSTOP Control ('s') +# define CSTOP Control('s') #endif #ifndef CSUSP -# define CSUSP Control ('z') +# define CSUSP Control('z') #endif #if defined(VEOL2) && !defined(CEOL2) # define CEOL2 _POSIX_VDISABLE #endif -/* ISC renamed swtch to susp for termios, but we'll accept either name. */ +/* ISC renamed swtch to susp for termios, but we'll accept either name */ #if defined(VSUSP) && !defined(VSWTCH) # define VSWTCH VSUSP # define CSWTCH CSUSP @@ -82,19 +79,19 @@ # define VWERASE VWERSE #endif #if defined(VDSUSP) && !defined (CDSUSP) -# define CDSUSP Control ('y') +# define CDSUSP Control('y') #endif #if !defined(VREPRINT) && defined(VRPRNT) /* Irix 4.0.5 */ # define VREPRINT VRPRNT #endif #if defined(VREPRINT) && !defined(CRPRNT) -# define CRPRNT Control ('r') +# define CRPRNT Control('r') #endif #if defined(VWERASE) && !defined(CWERASE) -# define CWERASE Control ('w') +# define CWERASE Control('w') #endif #if defined(VLNEXT) && !defined(CLNEXT) -# define CLNEXT Control ('v') +# define CLNEXT Control('v') #endif #if defined(VDISCARD) && !defined(VFLUSHO) # define VFLUSHO VDISCARD @@ -112,25 +109,24 @@ # define ECHOKE CRTKIL #endif #if defined(VFLUSHO) && !defined(CFLUSHO) -# define CFLUSHO Control ('o') +# define CFLUSHO Control('o') #endif #if defined(VSTATUS) && !defined(CSTATUS) -# define CSTATUS Control ('t') +# define CSTATUS Control('t') #endif -/* Which speeds to set. */ +/* Which speeds to set */ enum speed_setting { input_speed, output_speed, both_speeds }; -/* Which member(s) of `struct termios' a mode uses. */ +/* Which member(s) of `struct termios' a mode uses */ enum mode_type { /* Do NOT change the order or values, as mode_type_flag() - * depends on them. */ + * depends on them */ control, input, output, local, combination }; - static const char evenp [] = "evenp"; static const char raw [] = "raw"; static const char stty_min [] = "min"; @@ -154,22 +150,22 @@ static const char stty_crt [] = "crt"; static const char stty_dec [] = "dec"; +/* Flags for `struct mode_info' */ +#define SANE_SET 1 /* Set in `sane' mode */ +#define SANE_UNSET 2 /* Unset in `sane' mode */ +#define REV 4 /* Can be turned off by prepending `-' */ +#define OMIT 8 /* Don't display value */ -/* Flags for `struct mode_info'. */ -#define SANE_SET 1 /* Set in `sane' mode. */ -#define SANE_UNSET 2 /* Unset in `sane' mode. */ -#define REV 4 /* Can be turned off by prepending `-'. */ -#define OMIT 8 /* Don't display value. */ - -/* Each mode. */ +/* Each mode */ struct mode_info { - const char *name; /* Name given on command line. */ + const char *name; /* Name given on command line */ /* enum mode_type type; */ - char type; /* Which structure element to change. */ - char flags; /* Setting and display options. */ - unsigned short mask; /* Other bits to turn off for this mode. */ - unsigned long bits; /* Bits to set for this mode. */ + char type; /* Which structure element to change */ + char flags; /* Setting and display options */ + unsigned short mask; /* Other bits to turn off for this mode */ + unsigned long bits; /* Bits to set for this mode */ }; +#define EMT(t) ((enum mode_type)(t)) #define MI_ENTRY(N,T,F,B,M) { N, T, F, M, B } @@ -308,7 +304,7 @@ #ifdef IXANY MI_ENTRY(decctlq, combination, REV | OMIT, 0, 0 ), #endif -#if defined (TABDLY) || defined (OXTABS) +#if defined(TABDLY) || defined(OXTABS) MI_ENTRY(stty_tabs, combination, REV | OMIT, 0, 0 ), #endif #if defined(XCASE) && defined(IUCLC) && defined(OLCUC) @@ -320,18 +316,17 @@ }; enum { - NUM_mode_info = - (sizeof(mode_info) / sizeof(struct mode_info)) + NUM_mode_info = (sizeof(mode_info) / sizeof(mode_info[0])) }; -/* Control character settings. */ +/* Control character settings */ struct control_info { - const char *name; /* Name given on command line. */ - unsigned char saneval; /* Value to set for `stty sane'. */ - unsigned char offset; /* Offset in c_cc. */ + const char *name; /* Name given on command line */ + unsigned char saneval; /* Value to set for `stty sane' */ + unsigned char offset; /* Offset in c_cc */ }; -/* Control characters. */ +/* Control characters */ static const struct control_info control_info[] = { {"intr", CINTR, VINTR}, @@ -367,29 +362,32 @@ #ifdef VSTATUS {"status", CSTATUS, VSTATUS}, #endif - /* These must be last because of the display routines. */ + /* These must be last because of the display routines */ {stty_min, 1, VMIN}, {stty_time, 0, VTIME}, }; enum { - NUM_control_info = - (sizeof(control_info) / sizeof(struct control_info)) + NUM_control_info = (sizeof(control_info) / sizeof(control_info[0])) }; -#define EMT(t) ((enum mode_type)(t)) +/* The width of the screen, for output wrapping */ +static int max_col; +/* Current position, to know when to wrap */ +static int current_col; + static const char * visible(unsigned int ch); static int recover_mode(const char *arg, struct termios *mode); static int screen_columns(void); static void set_mode(const struct mode_info *info, int reversed, struct termios *mode); static speed_t string_to_baud(const char *arg); -static tcflag_t* mode_type_flag(enum mode_type type, struct termios *mode); -static void display_all(struct termios *mode); -static void display_changed(struct termios *mode); -static void display_recoverable(struct termios *mode); -static void display_speed(struct termios *mode, int fancy); +static tcflag_t* mode_type_flag(enum mode_type type, const struct termios *mode); +static void display_all(const struct termios *mode); +static void display_changed(const struct termios *mode); +static void display_recoverable(const struct termios *mode); +static void display_speed(const struct termios *mode, int fancy); static void display_window_size(int fancy); static void sane_mode(struct termios *mode); static void set_control_char(const struct control_info *info, @@ -405,21 +403,19 @@ bb_perror_msg_and_die(fmt, device_name); } +static ATTRIBUTE_ALWAYS_INLINE int streq(const char *a, const char *b) +{ + return strcmp(a, b) == 0; +} -/* The width of the screen, for output wrapping. */ -static int max_col; - -/* Current position, to know when to wrap. */ -static int current_col; - /* Print format string MESSAGE and optional args. Wrap to next line first if it won't fit. - Print a space first unless MESSAGE will start a new line. */ + Print a space first unless MESSAGE will start a new line */ static void wrapf(const char *message, ...) { va_list args; - char buf[1024]; /* Plenty long for our needs. */ + char buf[1024]; /* Plenty long for our needs */ int buflen; va_start(args, message); @@ -449,7 +445,7 @@ { int i; for (i = 0; i < NUM_mode_info; ++i) - if (STREQ(name, mode_info[i].name)) + if (streq(name, mode_info[i].name)) return &mode_info[i]; return 0; } @@ -458,7 +454,7 @@ { int i; for (i = 0; i < NUM_control_info; ++i) - if (STREQ(name, control_info[i].name)) + if (streq(name, control_info[i].name)) return &control_info[i]; return 0; } @@ -477,17 +473,17 @@ static int find_param(const char *name) { #ifdef HAVE_C_LINE - if (STREQ(name, "line")) return param_line; + if (streq(name, "line")) return param_line; #endif #ifdef TIOCGWINSZ - if (STREQ(name, "rows")) return param_rows; - if (STREQ(name, "cols")) return param_cols; - if (STREQ(name, "columns")) return param_cols; - if (STREQ(name, "size")) return param_size; + if (streq(name, "rows")) return param_rows; + if (streq(name, "cols")) return param_cols; + if (streq(name, "columns")) return param_cols; + if (streq(name, "size")) return param_size; #endif - if (STREQ(name, "ispeed")) return param_ispeed; - if (STREQ(name, "ospeed")) return param_ospeed; - if (STREQ(name, "speed")) return param_speed; + if (streq(name, "ispeed")) return param_ispeed; + if (streq(name, "ospeed")) return param_ospeed; + if (streq(name, "speed")) return param_speed; return 0; } @@ -495,7 +491,7 @@ int stty_main(int argc, char **argv) { struct termios mode; - void (*output_func)(struct termios *); + void (*output_func)(const struct termios *); const char *file_name = NULL; int require_set_attr; int speed_was_set; @@ -634,7 +630,7 @@ } /* Initialize to all zeroes so there is no risk memcmp will report a - spurious difference in an uninitialized portion of the structure. */ + spurious difference in an uninitialized portion of the structure */ memset(&mode, 0, sizeof(mode)); if (tcgetattr(STDIN_FILENO, &mode)) perror_on_device("%s"); @@ -739,10 +735,10 @@ can report `success' when it has actually failed to perform some proper subset of the requested operations. To detect this partial failure, get the current terminal attributes and - compare them to the requested ones. */ + compare them to the requested ones */ /* Initialize to all zeroes so there is no risk memcmp will report a - spurious difference in an uninitialized portion of the structure. */ + spurious difference in an uninitialized portion of the structure */ memset(&new_mode, 0, sizeof(new_mode)); if (tcgetattr(STDIN_FILENO, &new_mode)) perror_on_device("%s"); @@ -756,7 +752,7 @@ Sun users a little confusion, don't report an error if this happens. But suppress the error only if we haven't tried to set the baud rate explicitly -- otherwise we'd never give an - error for a true failure to set the baud rate. */ + error for a true failure to set the baud rate */ new_mode.c_cflag &= (~CIBAUD); if (speed_was_set || memcmp(&mode, &new_mode, sizeof(mode)) != 0) @@ -768,7 +764,6 @@ return EXIT_SUCCESS; } -/* Return 0 if not applied because not reversible; otherwise return 1. */ static void set_mode(const struct mode_info *info, int reversed, struct termios *mode) @@ -778,7 +773,7 @@ bitsp = mode_type_flag(EMT(info->type), mode); if (bitsp == NULL) { - /* Combination mode. */ + /* Combination mode */ if (info->name == evenp || info->name == parity) { if (reversed) mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; @@ -843,7 +838,7 @@ } else if (info->name == raw || info->name == cooked) { if ((info->name[0] == 'r' && reversed) || (info->name[0] == 'c' && !reversed)) { - /* Cooked mode. */ + /* Cooked mode */ mode->c_iflag |= BRKINT | IGNPAR | ISTRIP | ICRNL | IXON; mode->c_oflag |= OPOST; mode->c_lflag |= ISIG | ICANON; @@ -854,7 +849,7 @@ mode->c_cc[VEOL] = CEOL; #endif } else { - /* Raw mode. */ + /* Raw mode */ mode->c_iflag = 0; mode->c_oflag &= ~OPOST; mode->c_lflag &= ~(ISIG | ICANON @@ -945,13 +940,13 @@ value = bb_xparse_number(arg, stty_suffixes); else if (arg[0] == '\0' || arg[1] == '\0') value = arg[0]; - else if (STREQ(arg, "^-") || STREQ(arg, "undef")) + else if (streq(arg, "^-") || streq(arg, "undef")) value = _POSIX_VDISABLE; - else if (arg[0] == '^' && arg[1] != '\0') { /* Ignore any trailing junk. */ + else if (arg[0] == '^' && arg[1] != '\0') { /* Ignore any trailing junk */ if (arg[1] == '?') value = 127; else - value = arg[1] & ~0140; /* Non-letters get weird results. */ + value = arg[1] & ~0140; /* Non-letters get weird results */ } else value = bb_xparse_number(arg, stty_suffixes); mode->c_cc[info->offset] = value; @@ -976,9 +971,7 @@ static int get_win_size(int fd, struct winsize *win) { - int err = ioctl(fd, TIOCGWINSZ, (char *) win); - - return err; + return ioctl(fd, TIOCGWINSZ, (char *) win); } static void @@ -1002,7 +995,7 @@ The following code deals with a bug in the SunOS 4.x (and 3.x?) kernel. This comment from sys/ttold.h describes Sun's twisted logic - a better test would have been (ts_lines > 64k || ts_cols > 64k || ts_cols == 0). - At any rate, the problem is gone in Solaris 2.x. */ + At any rate, the problem is gone in Solaris 2.x */ if (win.ws_row == 0 || win.ws_col == 0) { struct ttysize ttysz; @@ -1055,7 +1048,7 @@ On ISC 3.0, it fails for the console and the serial port (but it works for ptys). It can also fail on any system when stdout isn't a tty. - In case of any failure, just use the default. */ + In case of any failure, just use the default */ if (get_win_size(STDOUT_FILENO, &win) == 0 && win.ws_col > 0) return win.ws_col; #endif @@ -1067,7 +1060,7 @@ return columns; } -static tcflag_t *mode_type_flag(enum mode_type type, struct termios *mode) +static tcflag_t *mode_type_flag(enum mode_type type, const struct termios *mode) { static const unsigned char tcflag_offsets[] = { offsetof(struct termios, c_cflag), /* control */ @@ -1082,7 +1075,7 @@ return NULL; } -static void display_changed(struct termios *mode) +static void display_changed(const struct termios *mode) { int i; int empty_line; @@ -1101,12 +1094,12 @@ for (i = 0; control_info[i].name != stty_min; ++i) { if (mode->c_cc[control_info[i].offset] == control_info[i].saneval) continue; - /* If swtch is the same as susp, don't print both. */ + /* If swtch is the same as susp, don't print both */ #if VSWTCH == VSUSP if (control_info[i].name == stty_swtch) continue; #endif - /* If eof uses the same slot as min, only print whichever applies. */ + /* If eof uses the same slot as min, only print whichever applies */ #if VEOF == VMIN if ((mode->c_lflag & ICANON) == 0 && (control_info[i].name == stty_eof @@ -1144,9 +1137,7 @@ wrapf("%s", mode_info[i].name); empty_line = 0; } - } - else if ((mode_info[i].flags & (SANE_SET | REV)) == - (SANE_SET | REV)) { + } else if ((mode_info[i].flags & (SANE_SET | REV)) == (SANE_SET | REV)) { wrapf("-%s", mode_info[i].name); empty_line = 0; } @@ -1157,7 +1148,7 @@ } static void -display_all(struct termios *mode) +display_all(const struct termios *mode) { int i; tcflag_t *bitsp; @@ -1175,12 +1166,12 @@ current_col = 0; for (i = 0; control_info[i].name != stty_min; ++i) { - /* If swtch is the same as susp, don't print both. */ + /* If swtch is the same as susp, don't print both */ #if VSWTCH == VSUSP if (control_info[i].name == stty_swtch) continue; #endif - /* If eof uses the same slot as min, only print whichever applies. */ + /* If eof uses the same slot as min, only print whichever applies */ #if VEOF == VMIN if ((mode->c_lflag & ICANON) == 0 && (control_info[i].name == stty_eof @@ -1217,7 +1208,7 @@ current_col = 0; } -static void display_speed(struct termios *mode, int fancy) +static void display_speed(const struct termios *mode, int fancy) { unsigned long ispeed, ospeed; const char *fmt_str = @@ -1237,7 +1228,7 @@ current_col = 0; } -static void display_recoverable(struct termios *mode) +static void display_recoverable(const struct termios *mode) { int i; @@ -1256,7 +1247,7 @@ unsigned long iflag, oflag, cflag, lflag; /* Scan into temporaries since it is too much trouble to figure out - the right format for `tcflag_t'. */ + the right format for `tcflag_t' */ if (sscanf(arg, "%lx:%lx:%lx:%lx%n", &iflag, &oflag, &cflag, &lflag, &n) != 4) return 0; @@ -1272,7 +1263,7 @@ arg += n; } - /* Fail if there are too many fields. */ + /* Fail if there are too many fields */ if (*arg != '\0') return 0; @@ -1310,8 +1301,8 @@ } } -/* Return a string that is the printable representation of character CH. */ -/* Adapted from `cat' by Torbjorn Granlund. */ +/* Return a string that is the printable representation of character CH */ +/* Adapted from `cat' by Torbjorn Granlund */ static const char *visible(unsigned int ch) { ------------------------------------------------------------------------ r16149 | vda | 2006-09-19 10:16:28 -0400 (Tue, 19 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/coreutils/stty.c stty: fix a longstanding FIXME (was able to die half-way setting term params) ------------------------------------------------------------------------ Index: coreutils/stty.c =================================================================== --- coreutils/stty.c (revision 16148) +++ coreutils/stty.c (revision 16149) @@ -173,7 +173,7 @@ #define MI_ENTRY(N,T,F,B,M) { N, T, F, M, B } -static const struct mode_info mode_info[] = { +static const struct mode_info mode_info[] = { MI_ENTRY("parenb", control, REV, PARENB, 0 ), MI_ENTRY("parodd", control, REV, PARODD, 0 ), MI_ENTRY("cs5", control, 0, CS5, CSIZE), @@ -333,7 +333,7 @@ /* Control characters. */ -static const struct control_info control_info[] = { +static const struct control_info control_info[] = { {"intr", CINTR, VINTR}, {"quit", CQUIT, VQUIT}, {"erase", CERASE, VERASE}, @@ -380,9 +380,9 @@ #define EMT(t) ((enum mode_type)(t)) static const char * visible(unsigned int ch); -static int recover_mode(char *arg, struct termios *mode); +static int recover_mode(const char *arg, struct termios *mode); static int screen_columns(void); -static int set_mode(const struct mode_info *info, +static void set_mode(const struct mode_info *info, int reversed, struct termios *mode); static speed_t string_to_baud(const char *arg); static tcflag_t* mode_type_flag(enum mode_type type, struct termios *mode); @@ -398,7 +398,7 @@ const char *arg, struct termios *mode); static void set_window_size(int rows, int cols); -static const char *device_name; +static const char *device_name = bb_msg_standard_input; static ATTRIBUTE_NORETURN void perror_on_device(const char *fmt) { @@ -445,80 +445,192 @@ {NULL, 0 } }; +static const struct mode_info *find_mode(const char *name) +{ + int i; + for (i = 0; i < NUM_mode_info; ++i) + if (STREQ(name, mode_info[i].name)) + return &mode_info[i]; + return 0; +} + +static const struct control_info *find_control(const char *name) +{ + int i; + for (i = 0; i < NUM_control_info; ++i) + if (STREQ(name, control_info[i].name)) + return &control_info[i]; + return 0; +} + +enum { + param_need_arg = 0x80, + param_line = 1 | 0x80, + param_rows = 2 | 0x80, + param_cols = 3 | 0x80, + param_size = 4, + param_ispeed = 5 | 0x80, + param_ospeed = 6 | 0x80, + param_speed = 7, +}; + +static int find_param(const char *name) +{ +#ifdef HAVE_C_LINE + if (STREQ(name, "line")) return param_line; +#endif +#ifdef TIOCGWINSZ + if (STREQ(name, "rows")) return param_rows; + if (STREQ(name, "cols")) return param_cols; + if (STREQ(name, "columns")) return param_cols; + if (STREQ(name, "size")) return param_size; +#endif + if (STREQ(name, "ispeed")) return param_ispeed; + if (STREQ(name, "ospeed")) return param_ospeed; + if (STREQ(name, "speed")) return param_speed; + return 0; +} + + int stty_main(int argc, char **argv) { struct termios mode; void (*output_func)(struct termios *); - int optc; - int require_set_attr; - int speed_was_set; - int verbose_output; - int recoverable_output; - int k; - int noargs = 1; - char * file_name = NULL; + const char *file_name = NULL; + int require_set_attr; + int speed_was_set; + int verbose_output; + int recoverable_output; + int noargs; + int k; output_func = display_changed; + noargs = 1; + speed_was_set = 0; + require_set_attr = 0; verbose_output = 0; recoverable_output = 0; - /* Don't print error messages for unrecognized options. */ - opterr = 0; + /* First pass: only parse/verify command line params */ + k = 0; + while (argv[++k]) { + const struct mode_info *mp; + const struct control_info *cp; + const char *arg = argv[k]; + const char *argnext = argv[k+1]; + int param; - while ((optc = getopt(argc, argv, "agF:")) != -1) { - switch (optc) { - case 'a': - verbose_output = 1; - output_func = display_all; - break; + if (arg[0] == '-') { + int i; + mp = find_mode(arg+1); + if (mp) { + if (!(mp->flags & REV)) + bb_error_msg_and_die("invalid argument '%s'", arg); + noargs = 0; + continue; + } + /* It is an option - parse it */ + i = 0; + while (arg[++i]) { + switch (arg[i]) { + case 'a': + verbose_output = 1; + output_func = display_all; + break; + case 'g': + recoverable_output = 1; + output_func = display_recoverable; + break; + case 'F': + if (file_name) + bb_error_msg_and_die("only one device may be specified"); + file_name = &arg[i+1]; /* "-Fdevice" ? */ + if (!file_name[0]) { /* nope, "-F device" */ + int p = k+1; /* argv[p] is argnext */ + file_name = argnext; + if (!file_name) + bb_error_msg_and_die(bb_msg_requires_arg, "-F"); + /* remove -F param from arg[vc] */ + --argc; + while (argv[p+1]) { argv[p] = argv[p+1]; ++p; } + } + goto end_option; + default: + bb_error_msg_and_die("invalid argument '%s'", arg); + } + } +end_option: + continue; + } - case 'g': - recoverable_output = 1; - output_func = display_recoverable; - break; + mp = find_mode(arg); + if (mp) { + noargs = 0; + continue; + } - case 'F': - if (file_name) - bb_error_msg_and_die("only one device may be specified"); - file_name = optarg; - break; - - default: /* unrecognized option */ + cp = find_control(arg); + if (cp) { + if (!argnext) + bb_error_msg_and_die(bb_msg_requires_arg, arg); noargs = 0; - break; + ++k; + continue; } - if (noargs == 0) + param = find_param(arg); + if (param & param_need_arg) { + if (!argnext) + bb_error_msg_and_die(bb_msg_requires_arg, arg); + ++k; + } + + switch (param) { +#ifdef HAVE_C_LINE + case param_line: + bb_xparse_number(argnext, stty_suffixes); break; +#endif +#ifdef TIOCGWINSZ + case param_rows: + bb_xparse_number(argnext, stty_suffixes); + break; + case param_cols: + bb_xparse_number(argnext, stty_suffixes); + break; + case param_size: +#endif + case param_ispeed: + case param_ospeed: + case param_speed: + break; + default: + if (recover_mode(arg, &mode) == 1) break; + if (string_to_baud(arg) != (speed_t) -1) break; + bb_error_msg_and_die("invalid argument '%s'", arg); + } + noargs = 0; } - if (optind < argc) - noargs = 0; + /* Specifying both -a and -g is an error */ + if (verbose_output && recoverable_output) + bb_error_msg_and_die("verbose and stty-readable output styles are mutually exclusive"); + /* Specifying -a or -g with non-options is an error */ + if (!noargs && (verbose_output || recoverable_output)) + bb_error_msg_and_die("modes may not be set when specifying an output style"); - /* Specifying both -a and -g gets an error. */ - if (verbose_output & recoverable_output) - bb_error_msg_and_die ("verbose and stty-readable output styles are mutually exclusive"); - - /* Specifying any other arguments with -a or -g gets an error. */ - if (~noargs & (verbose_output | recoverable_output)) - bb_error_msg_and_die ("modes may not be set when specifying an output style"); - - /* FIXME: it'd be better not to open the file until we've verified - that all arguments are valid. Otherwise, we could end up doing - only some of the requested operations and then failing, probably - leaving things in an undesirable state. */ - + /* Now it is safe to start doing things */ if (file_name) { - int fdflags; - + int fd, fdflags; device_name = file_name; - fclose(stdin); - xopen(device_name, O_RDONLY | O_NONBLOCK); + fd = xopen(device_name, O_RDONLY | O_NONBLOCK); + if (fd != 0) { + dup2(fd, 0); + close(fd); + } fdflags = fcntl(STDIN_FILENO, F_GETFL); if (fdflags == -1 || fcntl(STDIN_FILENO, F_SETFL, fdflags & ~O_NONBLOCK) < 0) perror_on_device("%s: couldn't reset non-blocking mode"); - } else { - device_name = bb_msg_standard_input; } /* Initialize to all zeroes so there is no risk memcmp will report a @@ -527,122 +639,92 @@ if (tcgetattr(STDIN_FILENO, &mode)) perror_on_device("%s"); - if (verbose_output | recoverable_output | noargs) { + if (verbose_output || recoverable_output || noargs) { max_col = screen_columns(); current_col = 0; output_func(&mode); return EXIT_SUCCESS; } - speed_was_set = 0; - require_set_attr = 0; + /* Second pass: perform actions */ k = 0; - while (++k < argc) { - int match_found = 0; - int reversed = 0; - int i; + while (argv[++k]) { + const struct mode_info *mp; + const struct control_info *cp; + const char *arg = argv[k]; + const char *argnext = argv[k+1]; + int param; - if (argv[k][0] == '-') { - char *find_dev_opt; + if (arg[0] == '-') { + mp = find_mode(arg+1); + if (mp) { + set_mode(mp, 1 /* reversed */, &mode); + } + /* It is an option - already parsed. Skip it */ + continue; + } - ++argv[k]; + mp = find_mode(arg); + if (mp) { + set_mode(mp, 0 /* non-reversed */, &mode); + continue; + } - /* Handle "-a", "-ag", "-aF/dev/foo", "-aF /dev/foo", etc. - Find the options that have been parsed. This is really - gross, but it's needed because stty SETTINGS look like options to - getopt(), so we need to work around things in a really horrible - way. If any new options are ever added to stty, the short option - MUST NOT be a letter which is the first letter of one of the - possible stty settings. - */ - find_dev_opt = strchr(argv[k], 'F'); /* find -*F* */ - if(find_dev_opt) { - if(find_dev_opt[1]==0) /* -*F /dev/foo */ - k++; /* skip /dev/foo */ - continue; /* else -*F/dev/foo - no skip */ - } - if(argv[k][0]=='a' || argv[k][0]=='g') - continue; - /* Is not options - is reverse params */ - reversed = 1; + cp = find_control(arg); + if (cp) { + ++k; + set_control_char(cp, argnext, &mode); + continue; } - for (i = 0; i < NUM_mode_info; ++i) - if (STREQ(argv[k], mode_info[i].name)) { - match_found = set_mode(&mode_info[i], reversed, &mode); - require_set_attr = 1; - break; - } - if (match_found == 0 && reversed) - bb_error_msg_and_die("invalid argument `%s'", --argv[k]); + param = find_param(arg); + if (param & param_need_arg) { + ++k; + } - if (match_found == 0) - for (i = 0; i < NUM_control_info; ++i) - if (STREQ(argv[k], control_info[i].name)) { - if (k == argc - 1) - bb_error_msg_and_die(bb_msg_requires_arg, argv[k]); - match_found = 1; - ++k; - set_control_char(&control_info[i], argv[k], &mode); - require_set_attr = 1; - break; - } - - if (match_found == 0) { - if (STREQ(argv[k], "ispeed")) { - if (k == argc - 1) - bb_error_msg_and_die(bb_msg_requires_arg, argv[k]); - ++k; - set_speed(input_speed, argv[k], &mode); - speed_was_set = 1; - require_set_attr = 1; - } else if (STREQ(argv[k], "ospeed")) { - if (k == argc - 1) - bb_error_msg_and_die(bb_msg_requires_arg, argv[k]); - ++k; - set_speed(output_speed, argv[k], &mode); - speed_was_set = 1; - require_set_attr = 1; - } + switch (param) { +#ifdef HAVE_C_LINE + case param_line: + mode.c_line = bb_xparse_number(argnext, stty_suffixes); + require_set_attr = 1; + break; +#endif #ifdef TIOCGWINSZ - else if (STREQ(argv[k], "rows")) { - if (k == argc - 1) - bb_error_msg_and_die(bb_msg_requires_arg, argv[k]); - ++k; - set_window_size((int) bb_xparse_number(argv[k], stty_suffixes), - -1); - } else if (STREQ(argv[k], "cols") || STREQ(argv[k], "columns")) { - if (k == argc - 1) - bb_error_msg_and_die(bb_msg_requires_arg, argv[k]); - ++k; - set_window_size(-1, - (int) bb_xparse_number(argv[k], stty_suffixes)); - } else if (STREQ(argv[k], "size")) { - max_col = screen_columns(); - current_col = 0; - display_window_size(0); - } + case param_cols: + set_window_size(-1, (int) bb_xparse_number(argnext, stty_suffixes)); + break; + case param_size: + max_col = screen_columns(); + current_col = 0; + display_window_size(0); + break; + case param_rows: + set_window_size((int) bb_xparse_number(argnext, stty_suffixes), -1); + break; #endif -#ifdef HAVE_C_LINE - else if (STREQ(argv[k], "line")) { - if (k == argc - 1) - bb_error_msg_and_die(bb_msg_requires_arg, argv[k]); - ++k; - mode.c_line = bb_xparse_number(argv[k], stty_suffixes); + case param_ispeed: + set_speed(input_speed, argnext, &mode); + speed_was_set = 1; + require_set_attr = 1; + break; + case param_ospeed: + set_speed(output_speed, argnext, &mode); + speed_was_set = 1; + require_set_attr = 1; + break; + case param_speed: + max_col = screen_columns(); + display_speed(&mode, 0); + break; + default: + if (recover_mode(arg, &mode) == 1) require_set_attr = 1; - } -#endif - else if (STREQ(argv[k], "speed")) { - max_col = screen_columns(); - display_speed(&mode, 0); - } else if (recover_mode(argv[k], &mode) == 1) - require_set_attr = 1; - else if (string_to_baud(argv[k]) != (speed_t) - 1) { - set_speed(both_speeds, argv[k], &mode); + else /* true: if (string_to_baud(arg) != (speed_t) -1) */ { + set_speed(both_speeds, arg, &mode); speed_was_set = 1; require_set_attr = 1; - } else - bb_error_msg_and_die("invalid argument `%s'", argv[k]); + } /* else - impossible (caught in the first pass): + bb_error_msg_and_die("invalid argument '%s'", arg); */ } } @@ -665,13 +747,6 @@ if (tcgetattr(STDIN_FILENO, &new_mode)) perror_on_device("%s"); - /* Normally, one shouldn't use memcmp to compare structures that - may have `holes' containing uninitialized data, but we have been - careful to initialize the storage of these two variables to all - zeroes. One might think it more efficient simply to compare the - modified fields, but that would require enumerating those fields -- - and not all systems have the same fields in this structure. */ - if (memcmp(&mode, &new_mode, sizeof(mode)) != 0) { #ifdef CIBAUD /* SunOS 4.1.3 (at least) has the problem that after this sequence, @@ -695,14 +770,11 @@ /* Return 0 if not applied because not reversible; otherwise return 1. */ -static int +static void set_mode(const struct mode_info *info, int reversed, struct termios *mode) { tcflag_t *bitsp; - if (reversed && (info->flags & REV) == 0) - return 0; - bitsp = mode_type_flag(EMT(info->type), mode); if (bitsp == NULL) { @@ -861,8 +933,6 @@ *bitsp = *bitsp & ~((unsigned long)info->mask) & ~info->bits; else *bitsp = (*bitsp & ~((unsigned long)info->mask)) | info->bits; - - return 1; } static void @@ -1179,7 +1249,7 @@ putchar('\n'); } -static int recover_mode(char *arg, struct termios *mode) +static int recover_mode(const char *arg, struct termios *mode) { int i, n; unsigned int chr; @@ -1269,5 +1339,5 @@ } *bpout = '\0'; - return (const char *) buf; + return buf; } ------------------------------------------------------------------------ r16148 | vda | 2006-09-19 10:14:12 -0400 (Tue, 19 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/util-linux/mount.c mount: fstabname needs to be const char* ------------------------------------------------------------------------ Index: util-linux/mount.c =================================================================== --- util-linux/mount.c (revision 16147) +++ util-linux/mount.c (revision 16148) @@ -1432,7 +1432,8 @@ enum { OPT_ALL = 0x8 }; char *cmdopts = xstrdup(""), *fstype=0, *storage_path=0; - char *opt_o, *fstabname; + char *opt_o; + const char *fstabname; FILE *fstab; int i, j, rc = 0; unsigned long opt; @@ -1526,7 +1527,7 @@ fstab = setmntent(fstabname,"r"); if (!fstab) - bb_perror_msg_and_die("cannot read %s",fstabname); + bb_perror_msg_and_die("cannot read %s", fstabname); // Loop through entries until we find what we're looking for. ------------------------------------------------------------------------ r16147 | vda | 2006-09-19 10:07:52 -0400 (Tue, 19 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/util-linux/mount.c mount: fix warning (printf field width of * wants int, not size_t) ------------------------------------------------------------------------ Index: util-linux/mount.c =================================================================== --- util-linux/mount.c (revision 16146) +++ util-linux/mount.c (revision 16147) @@ -732,7 +732,7 @@ * error_msg_rpc(clnt_*error*(" ")) */ static void error_msg_rpc(const char *msg) { - size_t len; + int len; while (msg[0] == ' ' || msg[0] == ':') msg++; len = strlen(msg); while (len && msg[len-1] == '\n') len--; ------------------------------------------------------------------------ r16146 | vda | 2006-09-19 09:50:55 -0400 (Tue, 19 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/loginutils/getty.c getty: #include ------------------------------------------------------------------------ Index: loginutils/getty.c =================================================================== --- loginutils/getty.c (revision 16145) +++ loginutils/getty.c (revision 16146) @@ -17,6 +17,7 @@ */ #include "busybox.h" +#include #ifdef CONFIG_FEATURE_UTMP #include ------------------------------------------------------------------------ r16145 | vda | 2006-09-19 05:55:09 -0400 (Tue, 19 Sep 2006) | 17 lines Changed paths: M /trunk/busybox/include/libbb.h M /trunk/busybox/libbb/messages.c M /trunk/busybox/libbb/mtab_file.c change char *string = "foo" -> char string[] = "foo" function old new delta xsetenv 45 44 -1 iproute_list_or_flush 1834 1833 -1 ipaddr_modify 1915 1914 -1 ipaddr_list_or_flush 1861 1860 -1 invarg 39 38 -1 do_set 1259 1258 -1 bb_verror_msg 268 267 -1 create_icmp_socket 142 140 -2 create_icmp6_socket 142 140 -2 bb_full_fd_action 324 322 -2 bb_path_mtab_file 10 - -10 .rodata 214796 214720 -76 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 0/11 up/down: 0/-99) Total: -99 bytes ------------------------------------------------------------------------ Index: libbb/mtab_file.c =================================================================== --- libbb/mtab_file.c (revision 16144) +++ libbb/mtab_file.c (revision 16145) @@ -13,5 +13,5 @@ /* Busybox mount uses either /proc/mounts or /etc/mtab to * get the list of currently mounted filesystems */ -char bb_path_mtab_file[] = USE_FEATURE_MTAB_SUPPORT("/etc/mtab") - SKIP_FEATURE_MTAB_SUPPORT("/proc/mounts"); +const char bb_path_mtab_file[] = USE_FEATURE_MTAB_SUPPORT("/etc/mtab") + SKIP_FEATURE_MTAB_SUPPORT("/proc/mounts"); Index: libbb/messages.c =================================================================== --- libbb/messages.c (revision 16144) +++ libbb/messages.c (revision 16145) @@ -13,97 +13,97 @@ #else #define BANNER "BusyBox v" BB_VER " (" BB_EXTRA_VERSION ")" #endif -const char BB_BANNER[]=BANNER; -const char * const bb_msg_full_version = BANNER " multi-call binary"; +const char BB_BANNER[] = BANNER; +const char bb_msg_full_version[] = BANNER " multi-call binary"; #endif #ifdef L_memory_exhausted - const char * const bb_msg_memory_exhausted = "memory exhausted"; + const char bb_msg_memory_exhausted[] = "memory exhausted"; #endif #ifdef L_invalid_date - const char * const bb_msg_invalid_date = "invalid date `%s'"; + const char bb_msg_invalid_date[] = "invalid date `%s'"; #endif #ifdef L_io_error - const char * const bb_msg_io_error = "%s: input/output error -- %m"; + const char bb_msg_io_error[] = "%s: input/output error -- %m"; #endif #ifdef L_write_error - const char * const bb_msg_write_error = "Write Error"; + const char bb_msg_write_error[] = "write error"; #endif #ifdef L_read_error - const char * const bb_msg_read_error = "Read Error"; + const char bb_msg_read_error[] = "read error"; #endif #ifdef L_name_longer_than_foo - const char * const bb_msg_name_longer_than_foo = "Names longer than %d chars not supported."; + const char bb_msg_name_longer_than_foo[] = "names longer than %d chars not supported"; #endif #ifdef L_unknown - const char * const bb_msg_unknown = "(unknown)"; + const char bb_msg_unknown[] = "(unknown)"; #endif #ifdef L_can_not_create_raw_socket - const char * const bb_msg_can_not_create_raw_socket = "can't create raw socket"; + const char bb_msg_can_not_create_raw_socket[] = "can't create raw socket"; #endif #ifdef L_perm_denied_are_you_root - const char * const bb_msg_perm_denied_are_you_root = "permission denied. (are you root?)"; + const char bb_msg_perm_denied_are_you_root[] = "permission denied. (are you root?)"; #endif #ifdef L_msg_requires_arg - const char * const bb_msg_requires_arg = "%s requires an argument"; + const char bb_msg_requires_arg[] = "%s requires an argument"; #endif #ifdef L_msg_invalid_arg - const char * const bb_msg_invalid_arg = "invalid argument `%s' to `%s'"; + const char bb_msg_invalid_arg[] = "invalid argument `%s' to `%s'"; #endif #ifdef L_msg_standard_input - const char * const bb_msg_standard_input = "standard input"; + const char bb_msg_standard_input[] = "standard input"; #endif #ifdef L_msg_standard_output - const char * const bb_msg_standard_output = "standard output"; + const char bb_msg_standard_output[] = "standard output"; #endif #ifdef L_passwd_file #define PASSWD_FILE "/etc/passwd" -const char * const bb_path_passwd_file = PASSWD_FILE; +const char bb_path_passwd_file[] = PASSWD_FILE; #endif #ifdef L_shadow_file #define SHADOW_FILE "/etc/shadow" -const char * const bb_path_shadow_file = SHADOW_FILE; +const char bb_path_shadow_file[] = SHADOW_FILE; #endif #ifdef L_group_file #define GROUP_FILE "/etc/group" -const char * const bb_path_group_file = GROUP_FILE; +const char bb_path_group_file[] = GROUP_FILE; #endif #ifdef L_gshadow_file #define GSHADOW_FILE "/etc/gshadow" -const char * const bb_path_gshadow_file = GSHADOW_FILE; +const char bb_path_gshadow_file[] = GSHADOW_FILE; #endif #ifdef L_nologin_file #define NOLOGIN_FILE "/etc/nologin" -const char * const bb_path_nologin_file = NOLOGIN_FILE; +const char bb_path_nologin_file[] = NOLOGIN_FILE; #endif #ifdef L_securetty_file #define SECURETTY_FILE "/etc/securetty" -const char * const bb_path_securetty_file = SECURETTY_FILE; +const char bb_path_securetty_file[] = SECURETTY_FILE; #endif #ifdef L_motd_file #define MOTD_FILE "/etc/motd" -const char * const bb_path_motd_file = MOTD_FILE; +const char bb_path_motd_file[] = MOTD_FILE; #endif #ifdef L_shell_file -const char * const bb_default_login_shell = LIBBB_DEFAULT_LOGIN_SHELL; +const char bb_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL; #endif #ifdef L_bb_dev_null -const char * const bb_dev_null = "/dev/null"; +const char bb_dev_null[] = "/dev/null"; #endif #ifdef L_bb_path_wtmp_file #include /* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */ -const char * const bb_path_wtmp_file = +const char bb_path_wtmp_file[] = #if defined _PATH_WTMP _PATH_WTMP; #elif defined WTMP_FILE Index: include/libbb.h =================================================================== --- include/libbb.h (revision 16144) +++ include/libbb.h (revision 16145) @@ -369,30 +369,30 @@ extern const char *bb_applet_name; -extern const char * const bb_msg_full_version; -extern const char * const bb_msg_memory_exhausted; -extern const char * const bb_msg_invalid_date; -extern const char * const bb_msg_io_error; -extern const char * const bb_msg_read_error; -extern const char * const bb_msg_write_error; -extern const char * const bb_msg_name_longer_than_foo; -extern const char * const bb_msg_unknown; -extern const char * const bb_msg_can_not_create_raw_socket; -extern const char * const bb_msg_perm_denied_are_you_root; -extern const char * const bb_msg_requires_arg; -extern const char * const bb_msg_invalid_arg; -extern const char * const bb_msg_standard_input; -extern const char * const bb_msg_standard_output; +extern const char bb_msg_full_version[]; +extern const char bb_msg_memory_exhausted[]; +extern const char bb_msg_invalid_date[]; +extern const char bb_msg_io_error[]; +extern const char bb_msg_read_error[]; +extern const char bb_msg_write_error[]; +extern const char bb_msg_name_longer_than_foo[]; +extern const char bb_msg_unknown[]; +extern const char bb_msg_can_not_create_raw_socket[]; +extern const char bb_msg_perm_denied_are_you_root[]; +extern const char bb_msg_requires_arg[]; +extern const char bb_msg_invalid_arg[]; +extern const char bb_msg_standard_input[]; +extern const char bb_msg_standard_output[]; -extern const char * const bb_path_nologin_file; -extern const char * const bb_path_passwd_file; -extern const char * const bb_path_shadow_file; -extern const char * const bb_path_gshadow_file; -extern const char * const bb_path_group_file; -extern const char * const bb_path_securetty_file; -extern const char * const bb_path_motd_file; -extern const char * const bb_path_wtmp_file; -extern const char * const bb_dev_null; +extern const char bb_path_nologin_file[]; +extern const char bb_path_passwd_file[]; +extern const char bb_path_shadow_file[]; +extern const char bb_path_gshadow_file[]; +extern const char bb_path_group_file[]; +extern const char bb_path_securetty_file[]; +extern const char bb_path_motd_file[]; +extern const char bb_path_wtmp_file[]; +extern const char bb_dev_null[]; #ifndef BUFSIZ #define BUFSIZ 4096 @@ -407,14 +407,14 @@ */ #define LIBBB_DEFAULT_LOGIN_SHELL "-/bin/sh" -extern const char * const bb_default_login_shell; +extern const char bb_default_login_shell[]; /* "/bin/sh" */ #define DEFAULT_SHELL (bb_default_login_shell+1) /* "sh" */ #define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+6) -extern char bb_path_mtab_file[]; +extern const char bb_path_mtab_file[]; extern int bb_default_error_retval; ------------------------------------------------------------------------ r16142 | vda | 2006-09-17 12:28:10 -0400 (Sun, 17 Sep 2006) | 3 lines Changed paths: M /trunk/busybox/AUTHORS M /trunk/busybox/TODO M /trunk/busybox/applets/Makefile.in M /trunk/busybox/applets/individual.c M /trunk/busybox/archival/dpkg.c M /trunk/busybox/archival/libunarchive/decompress_unzip.c M /trunk/busybox/console-tools/setlogcons.c M /trunk/busybox/coreutils/Config.in M /trunk/busybox/coreutils/cal.c M /trunk/busybox/coreutils/cksum.c M /trunk/busybox/coreutils/cp.c M /trunk/busybox/coreutils/dd.c M /trunk/busybox/coreutils/diff.c M /trunk/busybox/coreutils/head.c M /trunk/busybox/coreutils/ls.c M /trunk/busybox/coreutils/nohup.c M /trunk/busybox/coreutils/seq.c M /trunk/busybox/coreutils/sort.c M /trunk/busybox/coreutils/who.c M /trunk/busybox/debianutils/start_stop_daemon.c M /trunk/busybox/docs/busybox.net/news.html M /trunk/busybox/docs/busybox.net/oldnews.html M /trunk/busybox/docs/busybox.net/products.html M /trunk/busybox/docs/busybox.net/shame.html M /trunk/busybox/docs/busybox.net/tinyutils.html M /trunk/busybox/e2fsprogs/blkid/blkid.h M /trunk/busybox/e2fsprogs/blkid/dev.c M /trunk/busybox/e2fsprogs/blkid/probe.c M /trunk/busybox/e2fsprogs/blkid/read.c M /trunk/busybox/e2fsprogs/blkid/tag.c M /trunk/busybox/e2fsprogs/e2fsck.c M /trunk/busybox/e2fsprogs/e2p/ls.c M /trunk/busybox/e2fsprogs/mke2fs.c M /trunk/busybox/e2fsprogs/util.c M /trunk/busybox/editors/sed.c M /trunk/busybox/editors/vi.c M /trunk/busybox/examples/depmod.pl M /trunk/busybox/include/platform.h M /trunk/busybox/include/usage.h M /trunk/busybox/include/xregex.h M /trunk/busybox/libbb/crc32.c M /trunk/busybox/libbb/login.c M /trunk/busybox/libbb/loop.c M /trunk/busybox/libbb/md5.c M /trunk/busybox/libbb/sha1.c M /trunk/busybox/libbb/u_signal_names.c M /trunk/busybox/libbb/xfuncs.c M /trunk/busybox/loginutils/addgroup.c M /trunk/busybox/loginutils/adduser.c M /trunk/busybox/loginutils/getty.c M /trunk/busybox/loginutils/sulogin.c M /trunk/busybox/miscutils/Config.in M /trunk/busybox/miscutils/hdparm.c M /trunk/busybox/miscutils/less.c M /trunk/busybox/miscutils/readahead.c M /trunk/busybox/miscutils/strings.c M /trunk/busybox/modutils/insmod.c M /trunk/busybox/modutils/lsmod.c M /trunk/busybox/modutils/rmmod.c M /trunk/busybox/networking/Config.in M /trunk/busybox/networking/ifupdown.c M /trunk/busybox/networking/nc.c M /trunk/busybox/networking/ping6.c M /trunk/busybox/networking/telnet.c M /trunk/busybox/networking/udhcp/dhcpc.h M /trunk/busybox/networking/wget.c M /trunk/busybox/networking/zcip.c M /trunk/busybox/scripts/checkhelp.awk M /trunk/busybox/scripts/config/lxdialog/BIG.FAT.WARNING M /trunk/busybox/scripts/config/lxdialog/menubox.c M /trunk/busybox/scripts/config/lxdialog/util.c M /trunk/busybox/scripts/config/mconf.c M /trunk/busybox/scripts/config/menu.c M /trunk/busybox/shell/bbsh.c M /trunk/busybox/testsuite/cp/cp-dir-create-dir M /trunk/busybox/testsuite/cp/cp-dir-existing-dir M /trunk/busybox/testsuite/grep.tests M /trunk/busybox/testsuite/mount.testroot M /trunk/busybox/testsuite/pidof.tests M /trunk/busybox/testsuite/readlink.tests M /trunk/busybox/testsuite/sed.tests M /trunk/busybox/testsuite/sort.tests M /trunk/busybox/testsuite/testing.sh M /trunk/busybox/testsuite/tr/tr-works M /trunk/busybox/testsuite/uniq.tests M /trunk/busybox/util-linux/dmesg.c M /trunk/busybox/util-linux/fdisk.c M /trunk/busybox/util-linux/hexdump.c M /trunk/busybox/util-linux/mdev.c M /trunk/busybox/util-linux/mkswap.c M /trunk/busybox/util-linux/mount.c M /trunk/busybox/util-linux/umount.c whitespace cleanup ------------------------------------------------------------------------ Index: AUTHORS =================================================================== --- AUTHORS (revision 16141) +++ AUTHORS (revision 16142) @@ -113,7 +113,7 @@ Vladimir Oleynik cmdedit; bb_mkdep, xargs(current), httpd(current); - ports: ash, crond, fdisk (initial, unmaintained now), inetd, stty, traceroute, + ports: ash, crond, fdisk (initial, unmaintained now), inetd, stty, traceroute, top; locale, various fixes and irreconcilable critic of everything not perfect. Index: scripts/config/mconf.c =================================================================== --- scripts/config/mconf.c (revision 16141) +++ scripts/config/mconf.c (revision 16142) @@ -408,7 +408,7 @@ struct property *prop; str_printf(r, "Symbol: %s [=%s]\n", sym->name, - sym_get_string_value(sym)); + sym_get_string_value(sym)); for_all_prompts(sym, prop) get_prompt_str(r, prop); hit = false; Index: scripts/config/menu.c =================================================================== --- scripts/config/menu.c (revision 16141) +++ scripts/config/menu.c (revision 16142) @@ -185,7 +185,7 @@ case P_RANGE: if (sym->type != S_INT && sym->type != S_HEX) prop_warn(prop, "range is only allowed " - "for int or hex symbols"); + "for int or hex symbols"); if (!sym_string_valid(sym, prop->expr->left.sym->name) || !sym_string_valid(sym, prop->expr->right.sym->name)) prop_warn(prop, "range is invalid"); Index: scripts/config/lxdialog/BIG.FAT.WARNING =================================================================== --- scripts/config/lxdialog/BIG.FAT.WARNING (revision 16141) +++ scripts/config/lxdialog/BIG.FAT.WARNING (revision 16142) @@ -1,4 +1,4 @@ This is NOT the official version of dialog. This version has been significantly modified from the original. It is for use by the Linux -kernel configuration script. Please do not bother Savio Lam with +kernel configuration script. Please do not bother Savio Lam with questions about this program. Index: scripts/config/lxdialog/menubox.c =================================================================== --- scripts/config/lxdialog/menubox.c (revision 16141) +++ scripts/config/lxdialog/menubox.c (revision 16142) @@ -305,7 +305,7 @@ if (key == KEY_UP || key == '-') { if (choice < 2 && scroll) { - /* Scroll menu down */ + /* Scroll menu down */ scrollok (menu, TRUE); wscrl (menu, -1); scrollok (menu, FALSE); @@ -339,7 +339,7 @@ choice = MIN(choice+1, max_choice-1); } else if (key == KEY_PPAGE) { - scrollok (menu, TRUE); + scrollok (menu, TRUE); for (i=0; (i < max_choice); i++) { if (scroll > 0) { wscrl (menu, -1); @@ -361,8 +361,8 @@ scrollok (menu, FALSE); scroll++; print_item (menu, items[scroll + max_choice - 1]->name, - max_choice-1, FALSE, - (items[scroll + max_choice - 1]->tag[0] != ':')); + max_choice-1, FALSE, + (items[scroll + max_choice - 1]->tag[0] != ':')); } else { if (choice+1 < max_choice) choice++; Index: scripts/config/lxdialog/util.c =================================================================== --- scripts/config/lxdialog/util.c (revision 16141) +++ scripts/config/lxdialog/util.c (revision 16142) @@ -224,7 +224,7 @@ while (word && *word) { sp = strchr(word, ' '); if (sp) - *sp++ = 0; + *sp++ = 0; /* Wrap to next line if either the word does not fit, or it is the first word of a new sentence, and it is @@ -242,11 +242,11 @@ getyx (win, cur_y, cur_x); cur_x++; if (sp && *sp == ' ') { - cur_x++; /* double space */ + cur_x++; /* double space */ while (*++sp == ' '); newl = 1; } else - newl = 0; + newl = 0; word = sp; } } Index: scripts/checkhelp.awk =================================================================== --- scripts/checkhelp.awk (revision 16141) +++ scripts/checkhelp.awk (revision 16142) @@ -2,7 +2,7 @@ # AWK script to check for missing help entries for config options # # Copyright (C) 2006 Bernhard Fischer -# +# # This file is distributed under the terms and conditions of the # MIT/X public licenses. See http://opensource.org/licenses/mit-license.html # and notice http://www.gnu.org/licenses/license-list.html#X11License Index: networking/wget.c =================================================================== --- networking/wget.c (revision 16141) +++ networking/wget.c (revision 16142) @@ -483,7 +483,7 @@ do { while (filesize > 0 || !got_clen) { unsigned rdsz = sizeof(buf); - if (filesize < sizeof(buf) && (chunked || got_clen)) + if (filesize < sizeof(buf) && (chunked || got_clen)) rdsz = filesize; n = safe_fread(buf, 1, rdsz, dfp); if (n <= 0) Index: networking/ifupdown.c =================================================================== --- networking/ifupdown.c (revision 16141) +++ networking/ifupdown.c (revision 16142) @@ -708,7 +708,7 @@ llist_t *iface_list; for (iface_list = defn->ifaces; iface_list; iface_list = iface_list->link) { struct interface_defn_t *tmp = (struct interface_defn_t *) iface_list->data; - if ((strcmp(tmp->iface, currif->iface) == 0) && + if ((strcmp(tmp->iface, currif->iface) == 0) && (tmp->address_family == currif->address_family)) { bb_error_msg("duplicate interface \"%s\"", tmp->iface); return NULL; Index: networking/nc.c =================================================================== --- networking/nc.c (revision 16141) +++ networking/nc.c (revision 16142) @@ -1,9 +1,9 @@ /* vi: set sw=4 ts=4: */ /* nc: mini-netcat - built from the ground up for LRP - * + * * Copyright (C) 1998, 1999 Charles P. Wright * Copyright (C) 1998 Dave Cinege - * + * * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ @@ -25,7 +25,7 @@ memset(&address, 0, sizeof(address)); - if (ENABLE_NC_SERVER || ENABLE_NC_EXTRA) { + if (ENABLE_NC_SERVER || ENABLE_NC_EXTRA) { while ((opt = getopt(argc, argv, "lp:" USE_NC_EXTRA("i:ew:f:"))) > 0) { if (ENABLE_NC_SERVER && opt=='l') do_listen++; else if (ENABLE_NC_SERVER && opt=='p') @@ -40,7 +40,7 @@ } } - + // For listen or file we need zero arguments, dialout is 2. // For exec we need at least one more argument at the end, more ok @@ -53,7 +53,7 @@ signal(SIGALRM, timeout); alarm(wsecs); } - + if (infile) cfd = xopen(infile, O_RDWR); else { opt = 1; @@ -132,7 +132,7 @@ } // Select loop copying stdin to cfd, and cfd to stdout. - + FD_ZERO(&readfds); FD_SET(cfd, &readfds); FD_SET(STDIN_FILENO, &readfds); Index: networking/zcip.c =================================================================== --- networking/zcip.c (revision 16141) +++ networking/zcip.c (revision 16142) @@ -314,7 +314,7 @@ tv1.tv_sec++; } tv1.tv_sec += timeout / 1000; - + VDBG("...wait %ld %s nprobes=%d, nclaims=%d\n", timeout, intf, nprobes, nclaims); switch (poll(fds, 1, timeout)) { @@ -479,7 +479,7 @@ target_ip_conflict = 1; } - VDBG("state = %d, source ip conflict = %d, target ip conflict = %d\n", + VDBG("state = %d, source ip conflict = %d, target ip conflict = %d\n", state, source_ip_conflict, target_ip_conflict); switch (state) { case PROBE: Index: networking/udhcp/dhcpc.h =================================================================== --- networking/udhcp/dhcpc.h (revision 16141) +++ networking/udhcp/dhcpc.h (revision 16142) @@ -29,7 +29,7 @@ uint8_t *hostname; /* Optional hostname to use */ uint8_t *fqdn; /* Optional fully qualified domain name to use */ int ifindex; /* Index number of the interface to use */ - int retries; /* Max number of request packets */ + int retries; /* Max number of request packets */ int timeout; /* Number of seconds to try to get a lease */ uint8_t arp[6]; /* Our arp address */ }; Index: networking/ping6.c =================================================================== --- networking/ping6.c (revision 16141) +++ networking/ping6.c (revision 16142) @@ -370,7 +370,7 @@ pingaddr.sin6_scope_id = if_index; printf("PING %s (%s): %d data bytes\n", - hostent->h_name, + hostent->h_name, inet_ntop(AF_INET6, &pingaddr.sin6_addr, buf, sizeof(buf)), datalen); Index: networking/Config.in =================================================================== --- networking/Config.in (revision 16141) +++ networking/Config.in (revision 16142) @@ -22,7 +22,7 @@ bool "dnsd" default n help - Small and static DNS server daemon. + Small and static DNS server daemon. config CONFIG_ETHER_WAKE bool "ether-wake" @@ -132,9 +132,9 @@ default n depends on CONFIG_FEATURE_HTTPD_CGI help - This option enables support for running scripts through an - interpreter. Turn this on if you want PHP scripts to work - properly. You need to supply an addition line in your httpd + This option enables support for running scripts through an + interpreter. Turn this on if you want PHP scripts to work + properly. You need to supply an addition line in your httpd config file: *.php:/path/to/your/php Index: networking/telnet.c =================================================================== --- networking/telnet.c (revision 16141) +++ networking/telnet.c (revision 16142) @@ -185,9 +185,9 @@ * I don't agree. * first - I cannot use programs like sz/rz * second - the 0x0D is sent as one character and if the next - * char is 0x0A then it's eaten by a server side. + * char is 0x0A then it's eaten by a server side. * third - whay doy you have to make 'many write()s'? - * I don't understand. + * I don't understand. * So I implemented it. It's realy useful for me. I hope that * others people will find it interesting to. */ Index: docs/busybox.net/news.html =================================================================== --- docs/busybox.net/news.html (revision 16141) +++ docs/busybox.net/news.html (revision 16142) @@ -62,7 +62,7 @@ will be released before then if more bug fixes crop up. (The new plan is to have a 1.x.0 new development release every 3 months, with 1.x.y stable bugfix only releases based on that as appropriate.)

- +
  • 27 March 2006 -- Software Freedom Law Center representing BusyBox and uClibc

    One issue Erik Andersen wanted to resolve when handing off BusyBox maintainership to Rob Landley was license enforcement. BusyBox and Index: docs/busybox.net/shame.html =================================================================== --- docs/busybox.net/shame.html (revision 16141) +++ docs/busybox.net/shame.html (revision 16142) @@ -71,7 +71,7 @@

  • United *DVX4066 mpeg4 capable DVD players
  • Avaks alink Roadrunner 64
    Partial source available, based on source distributed under NDA from LSILogic. Why the NDA LSILogic, what are you hiding ? -
    To verify the Avaks infrigment see my slashdot journal. +
    To verify the Avaks infrigment see my slashdot journal.
    The ZipIt wireless IM device appears to be using Busybox-1.00-pre1 in the ramdisk, however no source has been made available.
  • Undoubtedly there are others... Please report them so we can shame them (or if necessary sue them) into compliance. Index: docs/busybox.net/products.html =================================================================== --- docs/busybox.net/products.html (revision 16141) +++ docs/busybox.net/products.html (revision 16142) @@ -159,7 +159,7 @@ with source here, I think... with some details here.
  • Free Remote Windows Terminal - +
  • ZyXEL Routers
  • Index: docs/busybox.net/tinyutils.html =================================================================== --- docs/busybox.net/tinyutils.html (revision 16141) +++ docs/busybox.net/tinyutils.html (revision 16142) @@ -3,8 +3,8 @@

    External Tiny Utilities

    -This is a list of tiny utilities whose functionality is not provided by -busybox. If you have additional suggestions, please send an e-mail to our +This is a list of tiny utilities whose functionality is not provided by +busybox. If you have additional suggestions, please send an e-mail to our dev mailing list.

    Index: docs/busybox.net/oldnews.html =================================================================== --- docs/busybox.net/oldnews.html (revision 16141) +++ docs/busybox.net/oldnews.html (revision 16142) @@ -4,7 +4,7 @@
    • 31 October 2005 -- 1.1.0-pre1

      The development branch of busybox is stable enough for wider testing, so - you can now + you can now download, the first prerelease of 1.1.0. This prerelease includes a lot of new @@ -27,7 +27,7 @@ developers of BusyBox are busy people, and have only so much they can keep in their brains at a time. In my case, I'm lucky if I can remember my own name, much less a bug report posted last week... To prevent your bug report - from getting lost, if you find a bug in BusyBox, please use the + from getting lost, if you find a bug in BusyBox, please use the shiny new Bug and Patch Tracking System to post all the gory details. @@ -856,7 +856,7 @@

           mount ./busybox.floppy.img /mnt -o loop -t msdos
      -    cp /mnt/initrd.gz /tmp      
      +    cp /mnt/initrd.gz /tmp
           umount /mnt
           gunzip /tmp/initrd.gz
           mount /tmp/initrd /mnt -o loop -t minix
      Index: archival/dpkg.c
      ===================================================================
      --- archival/dpkg.c	(revision 16141)
      +++ archival/dpkg.c	(revision 16142)
      @@ -1316,8 +1316,8 @@
       	/* go through status hash, dereference package hash and finally strings */
       	for (i=0; i
        *
      Index: debianutils/start_stop_daemon.c
      ===================================================================
      --- debianutils/start_stop_daemon.c	(revision 16141)
      +++ debianutils/start_stop_daemon.c	(revision 16142)
      @@ -45,7 +45,7 @@
       	sprintf(buf, "/proc/%d/exe", pid);
       	execbuf = xstrdup(name);
       	readlink(buf, execbuf, strlen(name)+1);
      -	
      +
       	equal = ! strcmp(execbuf, name);
       	if (ENABLE_FEATURE_CLEAN_UP)
       		free(execbuf);
      Index: shell/bbsh.c
      ===================================================================
      --- shell/bbsh.c	(revision 16141)
      +++ shell/bbsh.c	(revision 16142)
      @@ -1,5 +1,5 @@
       /* vi: set ts=4 :
      - * 
      + *
        * bbsh - busybox shell
        *
        * Copyright 2006 Rob Landley 
      @@ -51,7 +51,7 @@
       // What we know about a single process.
       struct command {
       	struct command *next;
      -	int flags;		// exit, suspend, && || 
      +	int flags;		// exit, suspend, && ||
       	int pid;		// pid (or exit code)
       	int argc;
       	char *argv[0];
      @@ -125,9 +125,9 @@
       			return 0;
       		}
       
      -		// Allocate next command structure if necessary		
      +		// Allocate next command structure if necessary
       		if (!*cmd) *cmd = xzalloc(sizeof(struct command)+8*sizeof(char *));
      -		
      +
       		// Parse next argument and add the results to argv[]
       		end = parse_word(start, cmd);
       
      @@ -138,7 +138,7 @@
       					start++;
       					break;
       				}
      -				// handle | & < > >> << || && 
      +				// handle | & < > >> << || &&
       			}
       			break;
       		}
      @@ -160,7 +160,7 @@
       	if (cmd->argc==2 && !strcmp(cmd->argv[0],"cd"))
       		chdir(cmd->argv[1]);
       	else if(!strcmp(cmd->argv[0],"exit"))
      -		exit(cmd->argc>1 ? atoi(cmd->argv[1]) : 0); 
      +		exit(cmd->argc>1 ? atoi(cmd->argv[1]) : 0);
       	else {
       		int status;
       		pid_t pid=fork();
      @@ -217,6 +217,6 @@
       		}
       		if (ENABLE_FEATURE_CLEAN_UP) free(command);
       	}
      -		
      +
       	return 1;
       }
      Index: coreutils/dd.c
      ===================================================================
      --- coreutils/dd.c	(revision 16141)
      +++ coreutils/dd.c	(revision 16142)
      @@ -200,7 +200,7 @@
       				out_part++;
       		}
       	}
      -	
      +
       	if (ENABLE_FEATURE_DD_IBS_OBS && oc) {
       		xwrite(ofd, obuf, oc);
       		out_part++;
      Index: coreutils/diff.c
      ===================================================================
      --- coreutils/diff.c	(revision 16141)
      +++ coreutils/diff.c	(revision 16142)
      @@ -820,8 +820,8 @@
       }
       
       /*
      - *      The following code uses an algorithm due to Harold Stone, 
      - *      which finds a pair of longest identical subsequences in 
      + *      The following code uses an algorithm due to Harold Stone,
      + *      which finds a pair of longest identical subsequences in
        *      the two files.
        *
        *      The major goal is to generate the match vector J.
      Index: coreutils/cksum.c
      ===================================================================
      --- coreutils/cksum.c	(revision 16141)
      +++ coreutils/cksum.c	(revision 16142)
      @@ -10,7 +10,7 @@
       
       int cksum_main(int argc, char **argv)
       {
      -	
      +
       	uint32_t *crc32_table = crc32_filltable(1);
       
       	FILE *fp;
      Index: coreutils/sort.c
      ===================================================================
      --- coreutils/sort.c	(revision 16141)
      +++ coreutils/sort.c	(revision 16142)
      @@ -5,7 +5,7 @@
        * Copyright (C) 2004 by Rob Landley 
        *
        * MAINTAINER: Rob Landley 
      - * 
      + *
        * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
        *
        * See SuS3 sort standard at:
      Index: coreutils/seq.c
      ===================================================================
      --- coreutils/seq.c	(revision 16141)
      +++ coreutils/seq.c	(revision 16142)
      @@ -14,7 +14,7 @@
       int seq_main(int argc, char **argv)
       {
       	double last, first, increment, i;
      -	
      +
       	first = increment = 1;
       	switch (argc) {
       		case 4:
      Index: coreutils/nohup.c
      ===================================================================
      --- coreutils/nohup.c	(revision 16141)
      +++ coreutils/nohup.c	(revision 16142)
      @@ -1,11 +1,11 @@
       /* vi: set sw=4 ts=4: */
       /* nohup - invoke a utility immune to hangups.
      - * 
      + *
        * Busybox version based on nohup specification at
        * http://www.opengroup.org/onlinepubs/007904975/utilities/nohup.html
      - * 
      + *
        * Copyright 2006 Rob Landley 
      - * 
      + *
        * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
        */
       
      Index: coreutils/head.c
      ===================================================================
      --- coreutils/head.c	(revision 16141)
      +++ coreutils/head.c	(revision 16142)
      @@ -28,7 +28,7 @@
       	{ NULL, 0 }
       };
       #endif
      -                                        
      +
       static const char header_fmt_str[] = "\n==> %s <==\n";
       
       int head_main(int argc, char **argv)
      @@ -83,8 +83,8 @@
       #if !ENABLE_FEATURE_FANCY_HEAD
       				count = bb_xgetularg10(p);
       #else
      -				count = bb_xgetularg_bnd_sfx(p, 10, 
      -								0, ULONG_MAX, 
      +				count = bb_xgetularg_bnd_sfx(p, 10,
      +								0, ULONG_MAX,
       								head_suffixes);
       #endif
       				break;
      Index: coreutils/cp.c
      ===================================================================
      --- coreutils/cp.c	(revision 16141)
      +++ coreutils/cp.c	(revision 16142)
      @@ -77,7 +77,7 @@
       	/* If there are only two arguments and...  */
       	if (optind + 2 == argc) {
       		s_flags = cp_mv_stat2(*argv, &source_stat,
      -		                      (flags & FILEUTILS_DEREFERENCE) ? stat : lstat);
      +				      (flags & FILEUTILS_DEREFERENCE) ? stat : lstat);
       		if ((s_flags < 0) || ((d_flags = cp_mv_stat(last, &dest_stat)) < 0)) {
       			exit(EXIT_FAILURE);
       		}
      Index: coreutils/who.c
      ===================================================================
      --- coreutils/who.c	(revision 16141)
      +++ coreutils/who.c	(revision 16142)
      @@ -24,7 +24,7 @@
       static const char * idle_string (time_t t)
       {
       	static char str[6];
      -	
      +
       	time_t s = time(NULL) - t;
       
       	if (s < 60)
      @@ -43,11 +43,11 @@
       	struct utmp *ut;
       	struct stat st;
       	char *name;
      -	
      +
       	if (argc > 1) {
       		bb_show_usage();
       	}
      -	
      +
       	setutent();
       	printf("USER       TTY      IDLE      TIME           HOST\n");
       	while ((ut = getutent()) != NULL) {
      Index: coreutils/cal.c
      ===================================================================
      --- coreutils/cal.c	(revision 16141)
      +++ coreutils/cal.c	(revision 16142)
      @@ -33,7 +33,7 @@
       };
       
       static const char sep1752[] = {
      -	         1,	2,	14,	15,	16,
      +		 1,	2,	14,	15,	16,
       	17,	18,	19,	20,	21,	22,	23,
       	24,	25,	26,	27,	28,	29,	30
       };
      @@ -207,7 +207,7 @@
       
       	if ((month == 9) && (year == 1752)) {
       		size_t oday = 0;
      -		
      +
       		j_offset = julian * 244;
       		do {
       			days[oday+2] = sep1752[oday] + j_offset;
      Index: coreutils/ls.c
      ===================================================================
      --- coreutils/ls.c	(revision 16141)
      +++ coreutils/ls.c	(revision 16142)
      @@ -196,7 +196,7 @@
       #endif
       	{
       #ifdef CONFIG_SELINUX
      -	        if  (is_selinux_enabled())  {
      +		if  (is_selinux_enabled()) {
       		  lgetfilecon(fullname,&sid);
       		}
       #endif
      Index: coreutils/Config.in
      ===================================================================
      --- coreutils/Config.in	(revision 16141)
      +++ coreutils/Config.in	(revision 16142)
      @@ -120,11 +120,11 @@
       	default y
       	depends on CONFIG_DD
       	help
      -	  sending a SIGUSR1 signal to a running `dd' process makes it 
      -	  print to standard error the number of records read and written 
      +	  sending a SIGUSR1 signal to a running `dd' process makes it
      +	  print to standard error the number of records read and written
       	  so far, then to resume copying.
       
      -	  $ dd if=/dev/zero of=/dev/null& pid=$! $ kill -USR1 $pid; sleep 1; kill $pid 
      +	  $ dd if=/dev/zero of=/dev/null& pid=$! $ kill -USR1 $pid; sleep 1; kill $pid
       	  10899206+0 records in 10899206+0 records out
       
       config CONFIG_FEATURE_DD_IBS_OBS
      @@ -744,9 +744,9 @@
       	depends on CONFIG_LS || CONFIG_MORE || CONFIG_TELNET
       	help
       	  This option allows utilities such as 'ls', 'more' and 'telnet'
      -	  to determine the width of the screen, which can allow them to 
      +	  to determine the width of the screen, which can allow them to
       	  display additional text or avoid wrapping text onto the next line.
      -	  If you leave this disabled, your utilities will be especially 
      +	  If you leave this disabled, your utilities will be especially
       	  primitive and will be unable to determine the current screen width.
       
       comment "Common options for df, du, ls"
      Index: libbb/crc32.c
      ===================================================================
      --- libbb/crc32.c	(revision 16141)
      +++ libbb/crc32.c	(revision 16142)
      @@ -6,7 +6,7 @@
        * very well-known)
        *
        * The following function creates a CRC32 table depending on whether
      - * a big-endian (0x04c11db7) or little-endian (0xedb88320) CRC32 is 
      + * a big-endian (0x04c11db7) or little-endian (0xedb88320) CRC32 is
        * required. Admittedly, there are other CRC32 polynomials floating
        * around, but Busybox doesn't use them.
        *
      @@ -18,12 +18,12 @@
       
       uint32_t *crc32_filltable(int endian)
       {
      -	
      +
       	uint32_t *crc_table = xmalloc(256 * sizeof(uint32_t));
       	uint32_t polynomial = endian ? 0x04c11db7 : 0xedb88320;
       	uint32_t c;
       	int i, j;
      -	
      +
       	for (i = 0; i < 256; i++) {
       		c = endian ? (i << 24) : i;
       		for (j = 8; j; j--) {
      Index: libbb/md5.c
      ===================================================================
      --- libbb/md5.c	(revision 16141)
      +++ libbb/md5.c	(revision 16142)
      @@ -440,7 +440,7 @@
       	/* Process last bytes.  */
       	if (buf != ctx->buffer) md5_hash_block(ctx->buffer, ctx);
       	md5_hash_block(buf, ctx);
      -	
      +
       	/* Put result from CTX in first 16 bytes following RESBUF.  The result is
       	 * always in little endian byte order, so that a byte-wise output yields
       	 * to the wanted ASCII representation of the message digest.
      Index: libbb/login.c
      ===================================================================
      --- libbb/login.c	(revision 16141)
      +++ libbb/login.c	(revision 16142)
      @@ -72,7 +72,7 @@
       					case 'D':
       					case 'o':
       						c = getdomainname(buf, sizeof(buf) - 1);
      -						buf[c >= 0 ? c : 0] = '\0'; 
      +						buf[c >= 0 ? c : 0] = '\0';
       						break;
       
       					case 'd':
      Index: libbb/loop.c
      ===================================================================
      --- libbb/loop.c	(revision 16141)
      +++ libbb/loop.c	(revision 16142)
      @@ -83,7 +83,7 @@
       	bb_loop_info loopinfo;
       	struct stat statbuf;
       	int i, dfd, ffd, mode, rc=-1;
      -	
      +
       	/* Open the file.  Barf if this doesn't work.  */
       	if((ffd = open(file, mode=O_RDWR))<0 && (ffd = open(file,mode=O_RDONLY))<0)
       		return -errno;
      Index: libbb/u_signal_names.c
      ===================================================================
      --- libbb/u_signal_names.c	(revision 16141)
      +++ libbb/u_signal_names.c	(revision 16142)
      @@ -16,12 +16,12 @@
       	// SUSv3 says kill must support these, and specifies the numerical values,
       	// http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html
       	{"0", 0}, {"HUP", 1}, {"INT", 2}, {"QUIT", 3}, {"ABRT", 6}, {"KILL", 9},
      -   	{"ALRM", 14}, {"TERM", 15},
      +	{"ALRM", 14}, {"TERM", 15},
       	// And Posix adds the following:
       	{"ILL", SIGILL}, {"TRAP", SIGTRAP}, {"FPE", SIGFPE}, {"USR1", SIGUSR1},
      -   	{"SEGV", SIGSEGV}, {"USR2", SIGUSR2}, {"PIPE", SIGPIPE}, {"CHLD", SIGCHLD},
      -   	{"CONT", SIGCONT}, {"STOP", SIGSTOP}, {"TSTP", SIGTSTP}, {"TTIN", SIGTTIN},
      -   	{"TTOU", SIGTTOU}
      +	{"SEGV", SIGSEGV}, {"USR2", SIGUSR2}, {"PIPE", SIGPIPE}, {"CHLD", SIGCHLD},
      +	{"CONT", SIGCONT}, {"STOP", SIGSTOP}, {"TSTP", SIGTSTP}, {"TTIN", SIGTTIN},
      +	{"TTOU", SIGTTOU}
       };
       
       // Convert signal name to number.
      Index: libbb/sha1.c
      ===================================================================
      --- libbb/sha1.c	(revision 16141)
      +++ libbb/sha1.c	(revision 16142)
      @@ -6,7 +6,7 @@
        *  Copyright (C) 2002 Dr Brian Gladman , Worcester, UK.
        *  Copyright (C) 2003 Glenn L. McGrath
        *  Copyright (C) 2003 Erik Andersen
      - *  
      + *
        * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
        *
        *  ---------------------------------------------------------------------------
      @@ -172,7 +172,7 @@
       
       	for (i = 0; i < SHA1_DIGEST_SIZE; ++i)
       		hval[i] = (unsigned char) (ctx->hash[i >> 2] >> 8 * (~i & 3));
      -	
      +
       	return resbuf;
       }
       
      Index: libbb/xfuncs.c
      ===================================================================
      --- libbb/xfuncs.c	(revision 16141)
      +++ libbb/xfuncs.c	(revision 16142)
      @@ -489,8 +489,8 @@
       // xstat() - a stat() which dies on failure with meaningful error message
       void xstat(char *name, struct stat *stat_buf)
       {
      -        if (stat(name, stat_buf))
      -                bb_perror_msg_and_die("Can't stat '%s'", name);
      +	if (stat(name, stat_buf))
      +		bb_perror_msg_and_die("Can't stat '%s'", name);
       }
       #endif
       
      Index: e2fsprogs/blkid/dev.c
      ===================================================================
      --- e2fsprogs/blkid/dev.c	(revision 16141)
      +++ e2fsprogs/blkid/dev.c	(revision 16142)
      @@ -76,8 +76,8 @@
       
       	list_for_each(p, &dev->bid_tags) {
       		blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags);
      -		if (tag)   
      -			printf("    tag: %s=\"%s\"\n", tag->bit_name, 
      +		if (tag)
      +			printf("    tag: %s=\"%s\"\n", tag->bit_name,
       			       tag->bit_val);
       		else
       			printf("    tag: NULL\n");
      @@ -177,7 +177,7 @@
       		case 'm':
       			blkid_debug_mask = strtoul (optarg, &tmp, 0);
       			if (*tmp) {
      -				fprintf(stderr, "Invalid debug mask: %d\n", 
      +				fprintf(stderr, "Invalid debug mask: %d\n",
       					optarg);
       				exit(1);
       			}
      Index: e2fsprogs/blkid/probe.c
      ===================================================================
      --- e2fsprogs/blkid/probe.c	(revision 16141)
      +++ e2fsprogs/blkid/probe.c	(revision 16142)
      @@ -99,7 +99,7 @@
       static int probe_ext3(int fd __BLKID_ATTR((unused)),
       		      blkid_cache cache __BLKID_ATTR((unused)),
       		      blkid_dev dev,
      -		      const struct blkid_magic *id __BLKID_ATTR((unused)), 
      +		      const struct blkid_magic *id __BLKID_ATTR((unused)),
       		      unsigned char *buf)
       {
       	struct ext2_super_block *es;
      @@ -126,7 +126,7 @@
       static int probe_ext2(int fd __BLKID_ATTR((unused)),
       		      blkid_cache cache __BLKID_ATTR((unused)),
       		      blkid_dev dev,
      -		      const struct blkid_magic *id __BLKID_ATTR((unused)), 
      +		      const struct blkid_magic *id __BLKID_ATTR((unused)),
       		      unsigned char *buf)
       {
       	struct ext2_super_block *es;
      @@ -305,10 +305,10 @@
       	return 0;
       }
       
      -static int probe_cramfs(int fd __BLKID_ATTR((unused)), 
      -		       blkid_cache cache __BLKID_ATTR((unused)), 
      +static int probe_cramfs(int fd __BLKID_ATTR((unused)),
      +		       blkid_cache cache __BLKID_ATTR((unused)),
       		       blkid_dev dev,
      -		       const struct blkid_magic *id __BLKID_ATTR((unused)), 
      +		       const struct blkid_magic *id __BLKID_ATTR((unused)),
       		       unsigned char *buf)
       {
       	struct cramfs_super_block *csb;
      Index: e2fsprogs/blkid/blkid.h
      ===================================================================
      --- e2fsprogs/blkid/blkid.h	(revision 16141)
      +++ e2fsprogs/blkid/blkid.h	(revision 16142)
      @@ -56,7 +56,7 @@
       extern const char *blkid_dev_devname(blkid_dev dev);
       
       extern blkid_dev_iterate blkid_dev_iterate_begin(blkid_cache cache);
      -extern int blkid_dev_set_search(blkid_dev_iterate iter, 
      +extern int blkid_dev_set_search(blkid_dev_iterate iter,
       				char *search_type, char *search_value);
       extern int blkid_dev_next(blkid_dev_iterate iterate, blkid_dev *dev);
       extern void blkid_dev_iterate_end(blkid_dev_iterate iterate);
      @@ -90,7 +90,7 @@
       extern int blkid_tag_next(blkid_tag_iterate iterate,
       			      const char **type, const char **value);
       extern void blkid_tag_iterate_end(blkid_tag_iterate iterate);
      -extern int blkid_dev_has_tag(blkid_dev dev, const char *type, 
      +extern int blkid_dev_has_tag(blkid_dev dev, const char *type,
       			      const char *value);
       extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache,
       					 const char *type,
      Index: e2fsprogs/blkid/read.c
      ===================================================================
      --- e2fsprogs/blkid/read.c	(revision 16141)
      +++ e2fsprogs/blkid/read.c	(revision 16142)
      @@ -432,7 +432,7 @@
       	list_for_each(p, &dev->bid_tags) {
       		blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags);
       		if (tag)
      -			printf("    tag: %s=\"%s\"\n", tag->bit_name, 
      +			printf("    tag: %s=\"%s\"\n", tag->bit_name,
       			       tag->bit_val);
       		else
       			printf("    tag: NULL\n");
      Index: e2fsprogs/blkid/tag.c
      ===================================================================
      --- e2fsprogs/blkid/tag.c	(revision 16141)
      +++ e2fsprogs/blkid/tag.c	(revision 16142)
      @@ -355,7 +355,7 @@
       void usage(char *prog)
       {
       	fprintf(stderr, "Usage: %s [-f blkid_file] [-m debug_mask] device "
      -		"[type value]\n", 
      +		"[type value]\n",
       		prog);
       	fprintf(stderr, "\tList all tags for a device and exit\n", prog);
       	exit(1);
      @@ -383,7 +383,7 @@
       		case 'm':
       			blkid_debug_mask = strtoul (optarg, &tmp, 0);
       			if (*tmp) {
      -				fprintf(stderr, "Invalid debug mask: %d\n", 
      +				fprintf(stderr, "Invalid debug mask: %d\n",
       					optarg);
       				exit(1);
       			}
      @@ -414,7 +414,7 @@
       	if (search_type) {
       		found = blkid_dev_has_tag(dev, search_type, search_value);
       		printf("Device %s: (%s, %s) %s\n", blkid_dev_devname(dev),
      -		       search_type, search_value ? search_value : "NULL", 
      +		       search_type, search_value ? search_value : "NULL",
       		       found ? "FOUND" : "NOT FOUND");
       		return(!found);
       	}
      Index: e2fsprogs/e2p/ls.c
      ===================================================================
      --- e2fsprogs/e2p/ls.c	(revision 16141)
      +++ e2fsprogs/e2p/ls.c	(revision 16142)
      @@ -26,14 +26,14 @@
       {
       	struct passwd *pw = getpwuid(uid);
       	fprintf(f, "%u (user %s)\n", uid,
      -	        (pw == NULL ? "unknown" : pw->pw_name));
      +			(pw == NULL ? "unknown" : pw->pw_name));
       }
       
       static void print_group(unsigned short gid, FILE *f)
       {
       	struct group *gr = getgrgid(gid);
       	fprintf(f, "%u (group %s)\n", gid,
      -	        (gr == NULL ? "unknown" : gr->gr_name));
      +			(gr == NULL ? "unknown" : gr->gr_name));
       }
       
       #define MONTH_INT (86400 * 30)
      Index: e2fsprogs/e2fsck.c
      ===================================================================
      --- e2fsprogs/e2fsck.c	(revision 16141)
      +++ e2fsprogs/e2fsck.c	(revision 16142)
      @@ -3661,7 +3661,7 @@
       		e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode,
       				  "recreate inode");
       		inode->i_mtime = time(0);
      -		e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode, 
      +		e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode,
       				  "recreate inode");
       		fs->block_map = save_bmap;
       		ctx->flags &= ~E2F_FLAG_RESIZE_INODE;
      Index: e2fsprogs/util.c
      ===================================================================
      --- e2fsprogs/util.c	(revision 16141)
      +++ e2fsprogs/util.c	(revision 16142)
      @@ -99,7 +99,7 @@
       			bb_error_msg_and_die("it's not safe to run badblocks!");
       	}
       
      -	if (mount_flags & EXT2_MF_BUSY) {  
      +	if (mount_flags & EXT2_MF_BUSY) {
       		bb_error_msg("%s is apparently in use by the system", device);
       		goto force_check;
       	}
      Index: e2fsprogs/mke2fs.c
      ===================================================================
      --- e2fsprogs/mke2fs.c	(revision 16141)
      +++ e2fsprogs/mke2fs.c	(revision 16142)
      @@ -737,7 +737,7 @@
       			}
       			if (resize <= sb_param->s_blocks_count) {
       				bb_error_msg("The resize maximum must be greater "
      -				             "than the filesystem size");
      +						"than the filesystem size");
       				r_usage++;
       				continue;
       			}
      Index: miscutils/readahead.c
      ===================================================================
      --- miscutils/readahead.c	(revision 16141)
      +++ miscutils/readahead.c	(revision 16142)
      @@ -22,7 +22,7 @@
       	while (*++argv) {
       		if ((f = bb_wfopen(*argv, "r")) != NULL) {
       			int r, fd=fileno(f);
      -			
      +
       			r = readahead(fd, 0, fdlength(fd));
       			fclose(f);
       			if (r >= 0) continue;
      Index: miscutils/less.c
      ===================================================================
      --- miscutils/less.c	(revision 16141)
      +++ miscutils/less.c	(revision 16142)
      @@ -610,26 +610,26 @@
       
       	match_found = 0;
       	match_status = regexec(pattern, line2, 1, &match_structs, 0);
      -	
      +
       	while (match_status == 0) {
       		if (match_found == 0)
       			match_found = 1;
      -		
      +
       		if (action) {
      -			growline = xasprintf("%s%.*s%s%.*s%s", growline, match_structs.rm_so, line2, HIGHLIGHT, match_structs.rm_eo - match_structs.rm_so, line2 + match_structs.rm_so, NORMAL); 
      +			growline = xasprintf("%s%.*s%s%.*s%s", growline, match_structs.rm_so, line2, HIGHLIGHT, match_structs.rm_eo - match_structs.rm_so, line2 + match_structs.rm_so, NORMAL);
       		}
       		else {
       			growline = xasprintf("%s%.*s%.*s", growline, match_structs.rm_so - 4, line2, match_structs.rm_eo - match_structs.rm_so, line2 + match_structs.rm_so);
       		}
      -		
      +
       		line2 += match_structs.rm_eo;
       		match_status = regexec(pattern, line2, 1, &match_structs, REG_NOTBOL);
       	}
      -	
      +
       	growline = xasprintf("%s%s", growline, line2);
      -	
      +
       	return (match_found ? growline : line);
      -	
      +
       	free(growline);
       	free(line2);
       }
      @@ -656,7 +656,7 @@
       	putchar((match_backwards) ? '?' : '/');
       	uncomp_regex[0] = 0;
       	fgets(uncomp_regex, sizeof(uncomp_regex), inp);
      -	
      +
       	if (strlen(uncomp_regex) == 1) {
       		if (num_matches)
       			goto_match(match_backwards ? match_pos - 1 : match_pos + 1);
      @@ -665,7 +665,7 @@
       		return;
       	}
       	uncomp_regex[strlen(uncomp_regex) - 1] = '\0';
      -	
      +
       	/* Compile the regex and check for errors */
       	xregcomp(&pattern, uncomp_regex, 0);
       
      @@ -677,7 +677,7 @@
       		}
       	}
       	old_pattern = pattern;
      -	
      +
       	/* Reset variables */
       	match_lines = xrealloc(match_lines, sizeof(int));
       	match_lines[0] = -1;
      @@ -694,7 +694,7 @@
       			j++;
       		}
       	}
      -	
      +
       	num_matches = j;
       	if ((match_lines[0] != -1) && (num_flines > height - 2)) {
       		if (match_backwards) {
      Index: miscutils/hdparm.c
      ===================================================================
      --- miscutils/hdparm.c	(revision 16141)
      +++ miscutils/hdparm.c	(revision 16142)
      @@ -755,7 +755,7 @@
       			strng = "<=10ms with INTRQ";
       		else if ((val[GEN_CONFIG] & DRQ_RESPONSE_TIME) ==  DRQ_50US_VAL)
       			strng ="50us";
      -		else 
      +		else
       			strng = "Unknown";
       		printf("\tDRQ response: %s\n\tPacket size: ", strng); /* Data Request (DRQ) */
       
      @@ -817,7 +817,7 @@
       
       		if (bbbig > 1000)
       			printf("(%"PRIu64" GB)\n", bbbig/1000);
      -		else 
      +		else
       			printf("\n");
       	}
       
      @@ -833,8 +833,8 @@
       
       	if (like_std != 1)
       	{
      -		printf("IORDY%s(can%s be disabled)\n", 
      -				!(val[CAPAB_0] & IORDY_SUP) ? "(may be)" : "", 
      +		printf("IORDY%s(can%s be disabled)\n",
      +				!(val[CAPAB_0] & IORDY_SUP) ? "(may be)" : "",
       				(val[CAPAB_0] & IORDY_OFF) ? "" :"not");
       	}
       	else
      @@ -843,7 +843,7 @@
       	if ((like_std == 1) && val[BUF_TYPE])
       	{
       		printf("\tBuffer type: %04x: %s%s\n", val[BUF_TYPE],
      -				(val[BUF_TYPE] < 2) ? "single port, single-sector" : "dual port, multi-sector", 
      +				(val[BUF_TYPE] < 2) ? "single port, single-sector" : "dual port, multi-sector",
       				(val[BUF_TYPE] > 2) ? " with read caching ability" : "");
       	}
       
      @@ -1063,9 +1063,9 @@
       			strng = " determined by the jumper";
       		else if ((jj & DEV_DET) == CSEL_VAL)
       			strng = " determined by CSEL";
      -		else 
      +		else
       			strng = "";
      -		printf("HW reset results:\n\tCBLID- %s Vih\n\tDevice num = %i%s\n", 
      +		printf("HW reset results:\n\tCBLID- %s Vih\n\tDevice num = %i%s\n",
       				(val[HWRST_RSLT] & CBLID) ? "above" : "below", !(oo), strng);
       	}
       
      @@ -1200,8 +1200,8 @@
       		printf(" (maybe):");
       
       	printf(" CurCHS=%u/%u/%u, CurSects=%lu, LBA=%s",id->cur_cyls, id->cur_heads,
      -													id->cur_sectors, 
      - 													(BB_BIG_ENDIAN) ? 
      +													id->cur_sectors,
      +													(BB_BIG_ENDIAN) ?
       													(long unsigned int)(id->cur_capacity0 << 16) | id->cur_capacity1 :
       													(long unsigned int)(id->cur_capacity1 << 16) | id->cur_capacity0,
       													((id->capability&2) == 0) ? "no" : "yes");
      @@ -1213,7 +1213,7 @@
       
       	if (((id->capability&8) || (id->field_valid&2)) && id->field_valid&2)
       		printf(", tPIO={min:%u,w/IORDY:%u}", id->eide_pio, id->eide_pio_iordy);
      -	
      +
       	if ((id->capability&1) && (id->field_valid&2))
       		printf(", tDMA={min:%u,rec:%u}", id->eide_dma_min, id->eide_dma_time);
       
      @@ -1254,7 +1254,7 @@
       		}
       	}
       	if (((id->capability&8) || (id->field_valid&2))	&& id->field_valid&4)
      -	{	
      +	{
       		printf("\n UDMA modes: ");
       		if (id->dma_ultra & 0x100) printf("*");
       		if (id->dma_ultra & 0x001) printf("udma0 ");
      @@ -1399,7 +1399,7 @@
       		if (read_big_block (fd, buf)) return;
       		printf(" Timing cached reads:   ");
       		fflush(stdout);
      -	
      +
       		/* Now do the timing */
       		iterations = 0;
       		getitimer(ITIMER_REAL, &e1);
      @@ -1422,9 +1422,9 @@
       			elapsed2 = (e1.it_value.tv_sec - e2.it_value.tv_sec)
       			+ ((e1.it_value.tv_usec - e2.it_value.tv_usec) / 1000000.0);
       		} while (--iterations);
      -	
      +
       		elapsed -= elapsed2;
      -		print_timing(BUFCACHE_FACTOR * total_MB, elapsed);	
      +		print_timing(BUFCACHE_FACTOR * total_MB, elapsed);
       		flush_buffer_cache(fd);
       		sleep(1);
       	}
      @@ -1447,7 +1447,7 @@
       			elapsed = (e1.it_value.tv_sec - e2.it_value.tv_sec)
       			+ ((e1.it_value.tv_usec - e2.it_value.tv_usec) / 1000000.0);
       		} while (elapsed < 3.0 && iterations < max_iterations);
      -	
      +
       		total_MB = iterations * TIMING_BUF_MB;
       		print_timing(total_MB, elapsed);
       	}
      @@ -2124,7 +2124,7 @@
       		do_flush |= do_timings |= (c == 't');
       		do_flush |= do_ctimings |= (c == 'T');
       #ifdef HDIO_DRIVE_CMD
      -		if (c == 'S') parse_opts(&get_standby, &set_standby, &standby_requested, 0, INT_MAX);	
      +		if (c == 'S') parse_opts(&get_standby, &set_standby, &standby_requested, 0, INT_MAX);
       		if (c == 'D') parse_opts(&get_defects, &set_defects, &defects, 0, INT_MAX);
       		if (c == 'P') parse_opts(&get_prefetch, &set_prefetch, &prefetch, 0, INT_MAX);
       		parse_xfermode((c == 'X'), &get_xfermode, &set_xfermode, &xfermode_requested);
      @@ -2138,22 +2138,22 @@
       		reread_partn |= (c == 'z');
       		get_seagate = set_seagate |= (c == 'Z');
       #endif
      -		USE_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(if (c == 'U') parse_opts(NULL, &unregister_hwif, &hwif, 0, INT_MAX));	
      +		USE_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(if (c == 'U') parse_opts(NULL, &unregister_hwif, &hwif, 0, INT_MAX));
       #ifdef HDIO_GET_QDMA
       		if (c == 'Q') {
       #ifdef HDIO_SET_QDMA
       			parse_opts(&get_dma_q, &set_dma_q, &dma_q, 0, INT_MAX);
       #else
      -			parse_opts(&get_dma_q, NULL, NULL, 0, 0);	
      +			parse_opts(&get_dma_q, NULL, NULL, 0, 0);
       #endif
       		}
      -#endif		
      +#endif
       		USE_FEATURE_HDPARM_HDIO_DRIVE_RESET(perform_reset = (c == 'r'));
      -		USE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(if (c == 'x') parse_opts(NULL, &perform_tristate, &tristate, 0, 1));	
      -		USE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(if (c == 'b') parse_opts(&get_busstate, &set_busstate, &busstate, 0, 2));	
      +		USE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(if (c == 'x') parse_opts(NULL, &perform_tristate, &tristate, 0, 1));
      +		USE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(if (c == 'b') parse_opts(&get_busstate, &set_busstate, &busstate, 0, 2));
       #if ENABLE_FEATURE_HDPARM_HDIO_SCAN_HWIF
       		if (c == 'R') {
      -			parse_opts(NULL, &scan_hwif, &hwif_data, 0, INT_MAX);	
      +			parse_opts(NULL, &scan_hwif, &hwif_data, 0, INT_MAX);
       			hwif_ctrl =  bb_xgetlarg((argv[optind]) ? argv[optind] : "", 10, 0, INT_MAX);
       			hwif_irq  =  bb_xgetlarg((argv[optind+1]) ? argv[optind+1] : "", 10, 0, INT_MAX);
       			/* Move past the 2 additional arguments */
      Index: miscutils/Config.in
      ===================================================================
      --- miscutils/Config.in	(revision 16141)
      +++ miscutils/Config.in	(revision 16142)
      @@ -292,7 +292,7 @@
       	  significantly speed up system startup.
       
       	  As readahead(2) blocks until each file has been read, it is best to
      -	  run this applet as a background job. 
      +	  run this applet as a background job.
       
       config CONFIG_RUNLEVEL
               bool "runlevel"
      Index: miscutils/strings.c
      ===================================================================
      --- miscutils/strings.c	(revision 16141)
      +++ miscutils/strings.c	(revision 16142)
      @@ -3,7 +3,7 @@
        * strings implementation for busybox
        *
        * Copyright Tito Ragusa 
      - * 
      + *
        * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
        */
       
      Index: include/xregex.h
      ===================================================================
      --- include/xregex.h	(revision 16141)
      +++ include/xregex.h	(revision 16142)
      @@ -5,7 +5,7 @@
        *
        * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
        * Permission has been granted to redistribute this code under the GPL.
      - * 
      + *
        * Licensed under GPLv2 or later, see file License in this tarball for details.
        */
       #ifndef __BB_REGEX__
      Index: include/platform.h
      ===================================================================
      --- include/platform.h	(revision 16141)
      +++ include/platform.h	(revision 16142)
      @@ -11,7 +11,7 @@
       #undef __GNUC_PREREQ
       #if defined __GNUC__ && defined __GNUC_MINOR__
       # define __GNUC_PREREQ(maj, min) \
      -	        ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
      +		((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
       #else
       # define __GNUC_PREREQ(maj, min) 0
       #endif
      @@ -264,7 +264,7 @@
       #define MS_SHARED      (1<<20)
       #endif
       
      - 
      +
       #if !defined(BLKSSZGET)
       #define BLKSSZGET _IO(0x12, 104)
       #endif
      Index: include/usage.h
      ===================================================================
      --- include/usage.h	(revision 16141)
      +++ include/usage.h	(revision 16142)
      @@ -499,9 +499,9 @@
       	"\t-s SIZE\t\tUse a buffer of size SIZE"
       
       #define dnsd_trivial_usage \
      -        "[-c config] [-t seconds] [-p port] [-i iface-ip] [-d]"
      +	"[-c config] [-t seconds] [-p port] [-i iface-ip] [-d]"
       #define dnsd_full_usage \
      -        "Small and static DNS server daemon\n\n" \
      +	"Small and static DNS server daemon\n\n" \
       	"Options:\n" \
       	"\t-c\t\tconfig filename\n" \
       	"\t-t\t\tTTL in seconds\n" \
      @@ -2058,7 +2058,7 @@
       	"$ mount /tmp/diskimage /opt -t ext2 -o loop\n" \
       	"$ mount cd_image.iso mydir\n"
       #define mount_notes_usage \
      -	"Returns 0 for success, number of failed mounts for -a, or errno for one mount." 
      +	"Returns 0 for success, number of failed mounts for -a, or errno for one mount."
       
       #define mountpoint_trivial_usage \
       	"[-q] <[-d] DIR | -x DEVICE>"
      Index: testsuite/testing.sh
      ===================================================================
      --- testsuite/testing.sh	(revision 16141)
      +++ testsuite/testing.sh	(revision 16142)
      @@ -76,7 +76,7 @@
         echo -ne "$5" | eval "$2" > actual
         RETVAL=$?
       
      -  cmp expected actual > /dev/null 
      +  cmp expected actual > /dev/null
         if [ $? -ne 0 ]
         then
           FAILCOUNT=$[$FAILCOUNT+1]
      Index: testsuite/pidof.tests
      ===================================================================
      --- testsuite/pidof.tests	(revision 16141)
      +++ testsuite/pidof.tests	(revision 16142)
      @@ -4,7 +4,7 @@
       # Copyright 2005 by Bernhard Fischer
       # Licensed under GPL v2, see file LICENSE for details.
       
      -# AUDIT: 
      +# AUDIT:
       
       . testing.sh
       
      @@ -24,6 +24,6 @@
       optional FEATURE_PIDOF_OMIT
       testing "pidof -o %PPID" "pidof -o %PPID pidof.tests | grep -o -w $$" "" "" ""
       testing "pidof -o %PPID NOP" "pidof -o %PPID -s init" "1\n" "" ""
      -testing "pidof -o init" "pidof -o 1 init | grep -o -w 1" "" "" "" 
      +testing "pidof -o init" "pidof -o 1 init | grep -o -w 1" "" "" ""
       
       exit $FAILCOUNT
      Index: testsuite/sed.tests
      ===================================================================
      --- testsuite/sed.tests	(revision 16141)
      +++ testsuite/sed.tests	(revision 16142)
      @@ -116,7 +116,7 @@
       testing "sed autoinsert newline" "sed -e 's/woo/bang/' input -" "bang\nbang" \
       	"woo" "woo"
       testing "sed empty file plus cat" "sed -e 's/nohit//' input -" "one\ntwo" \
      -	"" "one\ntwo" 
      +	"" "one\ntwo"
       testing "sed cat plus empty file" "sed -e 's/nohit//' input -" "one\ntwo" \
       	"one\ntwo" ""
       testing "sed append autoinserts newline" "sed -e '/woot/a woo' -" \
      @@ -138,7 +138,7 @@
       	"c no\nd no"
       testing "sed clusternewline" \
       	"sed -e '/one/a 111' -e '/two/i 222' -e p input -" \
      -	"one\none\n111\n222\ntwo\ntwo" "one" "two" 
      +	"one\none\n111\n222\ntwo\ntwo" "one" "two"
       
       # Test end-of-file matching behavior
       
      Index: testsuite/mount.testroot
      ===================================================================
      --- testsuite/mount.testroot	(revision 16141)
      +++ testsuite/mount.testroot	(revision 16142)
      @@ -86,7 +86,7 @@
       
       # Fun with mount -a
       
      -testing "mount -a no fstab" "mount -a 2>/dev/null || echo yes" "yes\n" "" "" 
      +testing "mount -a no fstab" "mount -a 2>/dev/null || echo yes" "yes\n" "" ""
       
       umount /proc
       
      Index: testsuite/tr/tr-works
      ===================================================================
      --- testsuite/tr/tr-works	(revision 16141)
      +++ testsuite/tr/tr-works	(revision 16142)
      @@ -7,7 +7,7 @@
       tr_test ()
       {
       	run_tr "cbaab"		abc 		zyx
      -	run_tr "TESTING A B C" 	'[A-Z]' 	'[a-z]' 
      +	run_tr "TESTING A B C" 	'[A-Z]' 	'[a-z]'
       	run_tr "abc[]" 		"a[b" 		AXB
       	run_tr abc		'[:alpha:]' 	A-ZA-Z
       	run_tr abc56		'[:alnum:]' 	A-ZA-Zxxxxxxxxxx
      Index: testsuite/sort.tests
      ===================================================================
      --- testsuite/sort.tests	(revision 16141)
      +++ testsuite/sort.tests	(revision 16142)
      @@ -56,7 +56,7 @@
       7	3	42	soup
       " "$data" ""
       
      -# 
      +#
       
       testing "sort key range with multiple options" "sort -k2,3rn input" \
       "7	3	42	soup
      @@ -67,7 +67,7 @@
       " "$data" ""
       
       testing "sort key doesn't strip leading blanks, disables fallback global sort" \
      -"sort -n -k2 -t ' '" " a \n 1 \n 2 \n" "" " 2 \n 1 \n a \n" 
      +"sort -n -k2 -t ' '" " a \n 1 \n 2 \n" "" " 2 \n 1 \n a \n"
       
       testing "sort key edge case with -t" "sort -n -k4 -t/" \
       "/usr/lib/finish-install.d/1
      Index: testsuite/readlink.tests
      ===================================================================
      --- testsuite/readlink.tests	(revision 16141)
      +++ testsuite/readlink.tests	(revision 16142)
      @@ -28,5 +28,5 @@
       
       
       # clean up
      -rm -r "$TESTLINK" "$TESTDIR" 
      +rm -r "$TESTLINK" "$TESTDIR"
       
      Index: testsuite/grep.tests
      ===================================================================
      --- testsuite/grep.tests	(revision 16141)
      +++ testsuite/grep.tests	(revision 16142)
      @@ -4,7 +4,7 @@
       # Copyright 2005 by Rob Landley 
       # Licensed under GPL v2, see file LICENSE for details.
       
      -# AUDIT: 
      +# AUDIT:
       
       . testing.sh
       
      Index: testsuite/cp/cp-dir-existing-dir
      ===================================================================
      --- testsuite/cp/cp-dir-existing-dir	(revision 16141)
      +++ testsuite/cp/cp-dir-existing-dir	(revision 16142)
      @@ -1,5 +1,5 @@
      -mkdir bar 
      +mkdir bar
       touch bar/baz
       mkdir foo
      -busybox cp -R bar foo 
      -test -f foo/bar/baz 
      +busybox cp -R bar foo
      +test -f foo/bar/baz
      Index: testsuite/cp/cp-dir-create-dir
      ===================================================================
      --- testsuite/cp/cp-dir-create-dir	(revision 16141)
      +++ testsuite/cp/cp-dir-create-dir	(revision 16142)
      @@ -1,4 +1,4 @@
      -mkdir bar 
      +mkdir bar
       touch bar/baz
      -busybox cp -R bar foo 
      -test -f foo/baz 
      +busybox cp -R bar foo
      +test -f foo/baz
      Index: testsuite/uniq.tests
      ===================================================================
      --- testsuite/uniq.tests	(revision 16141)
      +++ testsuite/uniq.tests	(revision 16142)
      @@ -40,7 +40,7 @@
       #-s skip chars
       #-c occurrences
       #-d dups only
      -#-u 
      +#-u
       
       # Test various command line options
       
      Index: loginutils/sulogin.c
      ===================================================================
      --- loginutils/sulogin.c	(revision 16141)
      +++ loginutils/sulogin.c	(revision 16142)
      @@ -73,7 +73,7 @@
       
       	if (!(pwd = getpwuid(0))) {
       		goto auth_error;
      -	} 
      +	}
       
       	if (ENABLE_FEATURE_SHADOWPASSWDS) {
       		if (!(spwd = getspnam(pwd->pw_name))) {
      @@ -108,6 +108,6 @@
       	run_shell(pwd->pw_shell, 1, 0, 0);
       	/* never returns */
       
      -auth_error:	
      +auth_error:
       	bb_error_msg_and_die("no password entry for `root'");
       }
      Index: loginutils/addgroup.c
      ===================================================================
      --- loginutils/addgroup.c	(revision 16141)
      +++ loginutils/addgroup.c	(revision 16142)
      @@ -88,7 +88,7 @@
       {
       	char *group;
       	gid_t gid = 0;
      -	
      +
       	/* check for min, max and missing args and exit on error */
       	bb_opt_complementally = "-1:?2:?";
       
      Index: loginutils/adduser.c
      ===================================================================
      --- loginutils/adduser.c	(revision 16141)
      +++ loginutils/adduser.c	(revision 16142)
      @@ -137,8 +137,8 @@
       		if (mkdir(p->pw_dir, 0755)
       		|| chown(p->pw_dir, p->pw_uid, p->pw_gid)
       		|| chmod(p->pw_dir, 02755)) {
      - 			bb_perror_msg("%s", p->pw_dir);
      - 		}
      +			bb_perror_msg("%s", p->pw_dir);
      +		}
       	}
       
       	if (!(flags & DONT_SET_PASS)) {
      @@ -175,7 +175,7 @@
       	/* got root? */
       	if(geteuid()) {
       		bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
      - 	}
      +	}
       
       	/* create string for $HOME if not specified already */
       	if (!pw.pw_dir) {
      Index: loginutils/getty.c
      ===================================================================
      --- loginutils/getty.c	(revision 16141)
      +++ loginutils/getty.c	(revision 16142)
      @@ -337,7 +337,7 @@
       		if(fd) {
       			xdup2(fd, 0, tty);
       			close(fd);
      -		}		
      +		}
       	} else {
       		/*
       		 * Standard input should already be connected to an open port. Make
      @@ -812,11 +812,11 @@
       	setsid();
       #endif
       	/* We want special flavor of error_msg_and_die */
      -	die_sleep = 10;		
      +	die_sleep = 10;
       	msg_eol = "\r\n";
       	/* Was "/dev/console". Why should we spam *system console*
       	 * if there is a problem with getty on /dev/ttyS15?... */
      -	nullfd = xopen(bb_dev_null, O_RDWR); 
      +	nullfd = xopen(bb_dev_null, O_RDWR);
       	dup2(nullfd, 0);
       	dup2(nullfd, 1);
       	dup2(nullfd, 2);
      Index: TODO
      ===================================================================
      --- TODO	(revision 16141)
      +++ TODO	(revision 16142)
      @@ -33,7 +33,7 @@
         depmod
           busybox lacks a way to update module deps when running from firmware without the
           use of the depmod.pl (perl is to bloated for most embedded setups) and or orig
      -    modutils. The orig depmod is rather pointless to have to add to a firmware image 
      +    modutils. The orig depmod is rather pointless to have to add to a firmware image
           in when we already have a insmod/rmmod and friends.
         Unify base64 handling.
           There's base64 encoding and decoding going on in:
      Index: applets/Makefile.in
      ===================================================================
      --- applets/Makefile.in	(revision 16141)
      +++ applets/Makefile.in	(revision 16142)
      @@ -21,6 +21,6 @@
       $(APPLETS_DIR)$(APPLETS_AR): $(APPLET_OBJ)
       	$(do_ar)
       
      -$(APPLET_OBJ): $(top_builddir)/.config 
      +$(APPLET_OBJ): $(top_builddir)/.config
       $(APPLET_OBJ): $(APPLETS_DIR)%.o: $(srcdir)/%.c
       	$(compile.c)
      Index: applets/individual.c
      ===================================================================
      --- applets/individual.c	(revision 16141)
      +++ applets/individual.c	(revision 16142)
      @@ -1,7 +1,7 @@
       /* Minimal wrapper to build an individual busybox applet.
        *
        * Copyright 2005 Rob Landley beg_line > 0 && (sed_cmd->beg_line == linenum))
       
       			/* Or does this line match our begin address regex? */
      -			        || (sed_cmd->beg_match &&
      +				|| (sed_cmd->beg_match &&
       				    !regexec(sed_cmd->beg_match, pattern_space, 0, NULL, 0))
       
       			/* Or did we match last line of input? */
      Index: util-linux/dmesg.c
      ===================================================================
      --- util-linux/dmesg.c	(revision 16141)
      +++ util-linux/dmesg.c	(revision 16142)
      @@ -1,6 +1,6 @@
       /* vi: set sw=4 ts=4: */
       /*
      - * 
      + *
        * dmesg - display/control kernel ring buffer.
        *
        * Copyright 2006 Rob Landley 
      @@ -30,7 +30,7 @@
       		if (0 > (len = klogctl(3 + (flags & 1), buf, len)))
       			bb_perror_msg_and_die("klogctl");
       
      -		// Skip <#> at the start of lines, and make sure we end with a newline. 
      +		// Skip <#> at the start of lines, and make sure we end with a newline.
       
       		if (ENABLE_FEATURE_DMESG_PRETTY) {
       			int last = '\n';
      Index: util-linux/fdisk.c
      ===================================================================
      --- util-linux/fdisk.c	(revision 16141)
      +++ util-linux/fdisk.c	(revision 16142)
      @@ -1914,9 +1914,9 @@
       static int
       sgi_check_bootfile(const char* aFile)
       {
      - 	if (strlen(aFile) < 3) /* "/a\n" is minimum */ {
      - 		printf(_("\nInvalid Bootfile!\n"
      - 			"\tThe bootfile must be an absolute non-zero pathname,\n"
      +	if (strlen(aFile) < 3) /* "/a\n" is minimum */ {
      +		printf(_("\nInvalid Bootfile!\n"
      +			"\tThe bootfile must be an absolute non-zero pathname,\n"
       			"\te.g. \"/unix\" or \"/unix.save\".\n"));
       		return 0;
       	} else {
      @@ -1931,7 +1931,7 @@
       				return 0;
       			}
       		}
      - 	}
      +	}
       	if (strncmp(aFile, (char*)sgilabel->boot_file, 16)) {
       		printf(_("\n\tBe aware, that the bootfile is not checked for existence.\n\t"
       			 "SGI's default is \"/unix\" and for backup \"/unix.save\".\n"));
      @@ -2505,7 +2505,7 @@
       	{ "\x83" "Linux native" }, /* LINUX_NATIVE */
       	{ "\x8e" "Linux LVM"    }, /* 0x8e         */
       /* New (2.2.x) raid partition with autodetect using persistent superblock */
      -	{ "\xfd" "Linux raid autodetect" }, /* 0xfd         */  
      +	{ "\xfd" "Linux raid autodetect" }, /* 0xfd         */
       	{ NULL }
       };
       
      @@ -3080,14 +3080,14 @@
       			uint32_t start = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * heads * sectors;
       			uint32_t len = SUN_SSWAP32(sunlabel->partitions[i].num_sectors);
       			printf("%s %c%c %9ld %9ld %9ld%c  %2x  %s\n",
      -				partname(disk_device, i+1, w),			/* device */            
      -				(sunlabel->infos[i].flags & 0x01) ? 'u' : ' ',  /* flags */             
      -				(sunlabel->infos[i].flags & 0x10) ? 'r' : ' ',  			
      -				(long) scround(start),                          /* start */             
      -				(long) scround(start+len),                      /* end */               
      -				(long) len / 2, len & 1 ? '+' : ' ',            /* odd flag on end */   
      -				sunlabel->infos[i].id,                          /* type id */           
      -				partition_type(sunlabel->infos[i].id));         /* type name */         
      +				partname(disk_device, i+1, w),			/* device */
      +				(sunlabel->infos[i].flags & 0x01) ? 'u' : ' ',  /* flags */
      +				(sunlabel->infos[i].flags & 0x10) ? 'r' : ' ',
      +				(long) scround(start),                          /* start */
      +				(long) scround(start+len),                      /* end */
      +				(long) len / 2, len & 1 ? '+' : ' ',            /* odd flag on end */
      +				sunlabel->infos[i].id,                          /* type id */
      +				partition_type(sunlabel->infos[i].id));         /* type name */
       		}
       	}
       }
      @@ -4280,8 +4280,8 @@
       	if (warn) {
       		if (
       			(
      -				label_sun != current_label_type && 
      -				label_sgi != current_label_type && 
      +				label_sun != current_label_type &&
      +				label_sgi != current_label_type &&
       				!pe->part_table->sys_ind
       			)
       #ifdef CONFIG_FEATURE_SUN_LABEL
      Index: util-linux/mkswap.c
      ===================================================================
      --- util-linux/mkswap.c	(revision 16141)
      +++ util-linux/mkswap.c	(revision 16142)
      @@ -19,7 +19,7 @@
       	if (argc!=2) bb_show_usage();
       
       	// Figure out how big the device is and announce our intentions.
      -	
      +
       	fd = xopen(argv[1],O_RDWR);
       	len = fdlength(fd);
       	pagesize = getpagesize();
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16141)
      +++ util-linux/mount.c	(revision 16142)
      @@ -673,7 +673,7 @@
       	p.pm_vers = version;
       	p.pm_prot = proto;
       	p.pm_port = port;
      -	
      +
       	while (pmap) {
       		if (pmap->pml_map.pm_prog != prog)
       			goto next;
      @@ -1315,7 +1315,7 @@
       		s = strrchr(mp->mnt_fsname, '\\');
       		if (s == mp->mnt_fsname+1) goto report_error;
       		*s = 0;
      -	   	he = gethostbyname(mp->mnt_fsname+2);
      +		he = gethostbyname(mp->mnt_fsname+2);
       		*s = '\\';
       		if (!he) goto report_error;
       
      @@ -1517,7 +1517,7 @@
       		if (rc) bb_perror_msg_and_die("%s", argv[0]);
       		goto clean_up;
       	}
      -	
      +
       	// Open either fstab or mtab
       
       	if (parse_mount_options(cmdopts,0) & MS_REMOUNT)
      Index: util-linux/hexdump.c
      ===================================================================
      --- util-linux/hexdump.c	(revision 16141)
      +++ util-linux/hexdump.c	(revision 16142)
      @@ -66,9 +66,9 @@
       				bb_dump_add(add_first);
       				bb_dump_add(add_strings[(int)(p - hexdump_opts)]);
       			} else if (ch == 'C') {
      -			        bb_dump_add("\"%08.8_Ax\n\"");
      +				bb_dump_add("\"%08.8_Ax\n\"");
       				bb_dump_add("\"%08.8_ax  \" 8/1 \"%02x \" \"  \" 8/1 \"%02x \" ");
      -			        bb_dump_add("\"  |\" 16/1 \"%_p\" \"|\\n\"");
      +				bb_dump_add("\"  |\" 16/1 \"%_p\" \"|\\n\"");
       			} else {
       				/* Sae a little bit of space below by omitting the 'else's. */
       				if (ch == 'e') {
      Index: util-linux/umount.c
      ===================================================================
      --- util-linux/umount.c	(revision 16141)
      +++ util-linux/umount.c	(revision 16142)
      @@ -76,7 +76,7 @@
       		m = 0;
       		if (!argc) bb_show_usage();
       	}
      -	
      +
       	// Loop through everything we're supposed to umount, and do so.
       	for (;;) {
       		int curstat;
      Index: util-linux/mdev.c
      ===================================================================
      --- util-linux/mdev.c	(revision 16141)
      +++ util-linux/mdev.c	(revision 16142)
      @@ -138,7 +138,7 @@
       							// Command to run
       							char *s = "@$*", *s2;
       							if (!(s2 = strchr(s, *pos++))) {
      -							  	// Force error
      +								// Force error
       								field = 1;
       								break;
       							}
      @@ -171,13 +171,13 @@
       
       		if (major == bbg.root_major && minor == bbg.root_minor)
       			symlink(device_name, "root");
      -	
      +
       		if (ENABLE_FEATURE_MDEV_CONF) chown(device_name, uid, gid);
       	}
       	if (command) {
       		int rc;
       		char *s;
      -		
      +
       		s=xasprintf("MDEV=%s",device_name);
       		putenv(s);
       		rc = system(command);
      Index: examples/depmod.pl
      ===================================================================
      --- examples/depmod.pl	(revision 16141)
      +++ examples/depmod.pl	(revision 16142)
      @@ -34,7 +34,7 @@
       my $mod = {};
       
       my $usage = < | -F  } [options]... 
      +$0 -b basedir { -k  | -F  } [options]...
         Where:
          -h --help         : Show this help screen
          -b --basedir      : Modules base directory (e.g /lib/modules/<2.x.y>)
      @@ -211,7 +211,7 @@
       
       depmod.pl - a cross platform script to generate kernel module
       dependency lists (modules.conf) which can then be used by modprobe
      -on the target platform. 
      +on the target platform.
       
       It supports Linux 2.4 and 2.6 styles of modules.conf (auto-detected)
       
      @@ -245,7 +245,7 @@
       =item B<-b --basedir>
       
       The base directory uner which the target's modules will be found.  This
      -defaults to the /lib/modules directory. 
      +defaults to the /lib/modules directory.
       
       If you don't specify the kernel version, this script will search for
       one under the specified based directory and use the first thing that
      
       ------------------------------------------------------------------------
      r16141 | vda | 2006-09-17 11:51:52 -0400 (Sun, 17 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/util-linux/mount.c
      
      mount: style fixlet
      
       ------------------------------------------------------------------------
      
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16140)
      +++ util-linux/mount.c	(revision 16141)
      @@ -220,8 +220,10 @@
       static int useMtab = 1;
       static int fakeIt;
       #else
      -#define useMtab 0
      -#define fakeIt 0
      +enum {
      +	useMtab = 0,
      +	fakeIt = 0,
      +};
       #endif
       
       // Perform actual mount of specific filesystem at specific location.
      
       ------------------------------------------------------------------------
      r16140 | vda | 2006-09-17 11:45:48 -0400 (Sun, 17 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/libbb/copyfd.c
      
      style fixes
      
       ------------------------------------------------------------------------
      
      Index: libbb/copyfd.c
      ===================================================================
      --- libbb/copyfd.c	(revision 16139)
      +++ libbb/copyfd.c	(revision 16140)
      @@ -28,8 +28,7 @@
       	RESERVE_CONFIG_BUFFER(buffer,BUFSIZ);
       
       	if (src_fd < 0) goto out;
      -	while (!size || total < size)
      -	{
      +	while (!size || total < size) {
       		ssize_t wr, rd;
       
       		rd = safe_read(src_fd, buffer,
      @@ -64,12 +63,12 @@
       int bb_copyfd_size(int fd1, int fd2, const off_t size)
       {
       	if (size) {
      -		return(bb_full_fd_action(fd1, fd2, size));
      +		return bb_full_fd_action(fd1, fd2, size);
       	}
      -	return(0);
      +	return 0;
       }
       
       int bb_copyfd_eof(int fd1, int fd2)
       {
      -	return(bb_full_fd_action(fd1, fd2, 0));
      +	return bb_full_fd_action(fd1, fd2, 0);
       }
      
       ------------------------------------------------------------------------
      r16139 | vda | 2006-09-17 11:39:22 -0400 (Sun, 17 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/util-linux/mount.c
      
      mount: revert mount --bind to using "bind" as fstype.
      
       ------------------------------------------------------------------------
      
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16138)
      +++ util-linux/mount.c	(revision 16139)
      @@ -277,7 +277,7 @@
       		fsname = 0;
       		if (!mp->mnt_type || !*mp->mnt_type) { /* bind mount */
       			mp->mnt_fsname = fsname = bb_simplify_path(mp->mnt_fsname);
      -			mp->mnt_type = "none";
      +			mp->mnt_type = "bind";
       		}
       		mp->mnt_freq = mp->mnt_passno = 0;
       
      
       ------------------------------------------------------------------------
      r16138 | vda | 2006-09-17 11:09:48 -0400 (Sun, 17 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/util-linux/mount.c
      
      mount: mount_it_now() - char *dir is not really needed.
      
       ------------------------------------------------------------------------
      
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16137)
      +++ util-linux/mount.c	(revision 16138)
      @@ -253,7 +253,7 @@
       	 * mtab file by hand, add the new entry to it now. */
       
       	if (ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc && !(vfsflags & MS_REMOUNT)) {
      -		char *dir,*fsname;
      +		char *fsname;
       		FILE *mountTable = setmntent(bb_path_mtab_file, "a+");
       		int i;
       
      @@ -273,7 +273,7 @@
       
       		// Convert to canonical pathnames as needed
       
      -		mp->mnt_dir = dir = bb_simplify_path(mp->mnt_dir);
      +		mp->mnt_dir = bb_simplify_path(mp->mnt_dir);
       		fsname = 0;
       		if (!mp->mnt_type || !*mp->mnt_type) { /* bind mount */
       			mp->mnt_fsname = fsname = bb_simplify_path(mp->mnt_fsname);
      @@ -286,7 +286,7 @@
       		addmntent(mountTable, mp);
       		endmntent(mountTable);
       		if (ENABLE_FEATURE_CLEAN_UP) {
      -			free(dir);
      +			free(mp->mnt_dir);
       			free(fsname);
       		}
       	}
      
       ------------------------------------------------------------------------
      r16137 | vda | 2006-09-17 11:08:12 -0400 (Sun, 17 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/util-linux/mount.c
      
      mount: fix "duplicate mount options in mtab" bug
      
       ------------------------------------------------------------------------
      
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16136)
      +++ util-linux/mount.c	(revision 16137)
      @@ -102,9 +102,27 @@
       static void append_mount_options(char **oldopts, char *newopts)
       {
       	if (*oldopts && **oldopts) {
      -		char *temp = xasprintf("%s,%s",*oldopts,newopts);
      -		free(*oldopts);
      -		*oldopts = temp;
      +		/* do not insert options which are already there */
      +		while (newopts[0]) {
      +			char *p;
      +			int len = strlen(newopts);
      +			p = strchr(newopts, ',');
      +			if (p) len = p - newopts;
      +			p = *oldopts;
      +			while (1) {
      +				if (!strncmp(p,newopts,len) && (p[len]==',' || p[len]==0))
      +					goto skip;
      +				p = strchr(p,',');
      +				if(!p) break;
      +				p++;
      +			}
      +			p = xasprintf("%s,%.*s", *oldopts, len, newopts);
      +			free(*oldopts);
      +			*oldopts = p;
      +skip:
      +			newopts += len;
      +			while (newopts[0] == ',') newopts++;
      +		}
       	} else {
       		if (ENABLE_FEATURE_CLEAN_UP) free(*oldopts);
       		*oldopts = xstrdup(newopts);
      
       ------------------------------------------------------------------------
      r16136 | vda | 2006-09-17 11:06:34 -0400 (Sun, 17 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/util-linux/mount.c
      
      mount: nfs_strerror's static buffer was bigger than needed.
      
       ------------------------------------------------------------------------
      
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16135)
      +++ util-linux/mount.c	(revision 16136)
      @@ -515,7 +515,7 @@
       static char *nfs_strerror(int status)
       {
       	int i;
      -	static char buf[256];
      +	static char buf[sizeof("unknown nfs status return value: ") + sizeof(int)*3];
       
       	for (i = 0; nfs_errtbl[i].stat != -1; i++) {
       		if (nfs_errtbl[i].stat == status)
      
       ------------------------------------------------------------------------
      r16135 | vda | 2006-09-17 11:05:31 -0400 (Sun, 17 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/util-linux/mount.c
      
      mount: getopt_ulflag'ification
      
       ------------------------------------------------------------------------
      
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16134)
      +++ util-linux/mount.c	(revision 16135)
      @@ -1378,11 +1378,8 @@
       
       		for (fl = fslist; fl; fl = fl->link) {
       			mp->mnt_type = fl->data;
      -
       			rc = mount_it_now(mp, vfsflags, filteropts);
       			if (!rc) break;
      -
      -			mp->mnt_type = 0;
       		}
       	}
       
      @@ -1412,52 +1409,41 @@
       
       int mount_main(int argc, char **argv)
       {
      -	char *cmdopts = xstrdup(""), *fstabname, *fstype=0, *storage_path=0;
      +	enum { OPT_ALL = 0x8 };
      +
      +	char *cmdopts = xstrdup(""), *fstype=0, *storage_path=0;
      +	char *opt_o, *fstabname;
       	FILE *fstab;
      -	int i, opt, all = FALSE, rc = 0;
      +	int i, j, rc = 0;
      +	unsigned long opt;
       	struct mntent mtpair[2], *mtcur = mtpair;
       
       	/* parse long options, like --bind and --move.  Note that -o option
       	 * and --option are synonymous.  Yes, this means --remount,rw works. */
       
      -	for (i = opt = 0; i < argc; i++) {
      +	for (i = j = 0; i < argc; i++) {
       		if (argv[i][0] == '-' && argv[i][1] == '-') {
       			append_mount_options(&cmdopts,argv[i]+2);
      -		} else argv[opt++] = argv[i];
      +		} else argv[j++] = argv[i];
       	}
      -	argc = opt;
      +	argc = j;
       
       	// Parse remaining options
       
      -	while ((opt = getopt(argc, argv, "o:t:rwavnf")) > 0) {
      -		switch (opt) {
      -		case 'o':
      -			append_mount_options(&cmdopts, optarg);
      -			break;
      -		case 't':
      -			fstype = optarg;
      -			break;
      -		case 'r':
      -			append_mount_options(&cmdopts, "ro");
      -			break;
      -		case 'w':
      -			append_mount_options(&cmdopts, "rw");
      -			break;
      -		case 'a':
      -			all = TRUE;
      -			break;
      -		case 'n':
      -			USE_FEATURE_MTAB_SUPPORT(useMtab = FALSE;)
      -			break;
      -		case 'f':
      -			USE_FEATURE_MTAB_SUPPORT(fakeIt = FALSE;)
      -			break;
      -		case 'v':
      -			break;		// ignore -v
      -		default:
      -			bb_show_usage();
      -		}
      -	}
      +	opt = bb_getopt_ulflags(argc, argv, "o:t:rwavnf", &opt_o, &fstype);
      +	if (opt & 1) // -o
      +		append_mount_options(&cmdopts, opt_o);
      +	//if (opt & 1) // -t
      +	if (opt & 2) // -r
      +		append_mount_options(&cmdopts, "ro");
      +	if (opt & 4) // -w
      +		append_mount_options(&cmdopts, "rw");
      +	//if (opt & 8) // -a
      +	if (opt & 0x10) // -n
      +		USE_FEATURE_MTAB_SUPPORT(useMtab = FALSE);
      +	if (opt & 0x20) // -f
      +		USE_FEATURE_MTAB_SUPPORT(fakeIt = FALSE);
      +	//if (opt & 0x40) // ignore -v
       	argv += optind;
       	argc -= optind;
       
      @@ -1468,7 +1454,7 @@
       	// If we have no arguments, show currently mounted filesystems
       
       	if (!argc) {
      -		if (!all) {
      +		if (!(opt & OPT_ALL)) {
       			FILE *mountTable = setmntent(bb_path_mtab_file, "r");
       
       			if (!mountTable) bb_error_msg_and_die("no %s",bb_path_mtab_file);
      
       ------------------------------------------------------------------------
      r16134 | vda | 2006-09-17 11:04:35 -0400 (Sun, 17 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/util-linux/mount.c
      
      mount: style fixes
      
       ------------------------------------------------------------------------
      
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16133)
      +++ util-linux/mount.c	(revision 16134)
      @@ -1340,14 +1340,14 @@
       			loopFile = bb_simplify_path(mp->mnt_fsname);
       			mp->mnt_fsname = 0;
       			switch (set_loop(&(mp->mnt_fsname), loopFile, 0)) {
      -				case 0:
      -				case 1:
      -					break;
      -				default:
      -					bb_error_msg( errno == EPERM || errno == EACCES
      -						? bb_msg_perm_denied_are_you_root
      -						: "cannot setup loop device");
      -					return errno;
      +			case 0:
      +			case 1:
      +				break;
      +			default:
      +				bb_error_msg( errno == EPERM || errno == EACCES
      +					? bb_msg_perm_denied_are_you_root
      +					: "cannot setup loop device");
      +				return errno;
       			}
       
       		// Autodetect bind mounts
      @@ -1379,7 +1379,7 @@
       		for (fl = fslist; fl; fl = fl->link) {
       			mp->mnt_type = fl->data;
       
      -			rc = mount_it_now(mp,vfsflags, filteropts);
      +			rc = mount_it_now(mp, vfsflags, filteropts);
       			if (!rc) break;
       
       			mp->mnt_type = 0;
      @@ -1431,31 +1431,31 @@
       
       	while ((opt = getopt(argc, argv, "o:t:rwavnf")) > 0) {
       		switch (opt) {
      -			case 'o':
      -				append_mount_options(&cmdopts, optarg);
      -				break;
      -			case 't':
      -				fstype = optarg;
      -				break;
      -			case 'r':
      -				append_mount_options(&cmdopts, "ro");
      -				break;
      -			case 'w':
      -				append_mount_options(&cmdopts, "rw");
      -				break;
      -			case 'a':
      -				all = TRUE;
      -				break;
      -			case 'n':
      -				USE_FEATURE_MTAB_SUPPORT(useMtab = FALSE;)
      -				break;
      -			case 'f':
      -				USE_FEATURE_MTAB_SUPPORT(fakeIt = FALSE;)
      -				break;
      -			case 'v':
      -				break;		// ignore -v
      -			default:
      -				bb_show_usage();
      +		case 'o':
      +			append_mount_options(&cmdopts, optarg);
      +			break;
      +		case 't':
      +			fstype = optarg;
      +			break;
      +		case 'r':
      +			append_mount_options(&cmdopts, "ro");
      +			break;
      +		case 'w':
      +			append_mount_options(&cmdopts, "rw");
      +			break;
      +		case 'a':
      +			all = TRUE;
      +			break;
      +		case 'n':
      +			USE_FEATURE_MTAB_SUPPORT(useMtab = FALSE;)
      +			break;
      +		case 'f':
      +			USE_FEATURE_MTAB_SUPPORT(fakeIt = FALSE;)
      +			break;
      +		case 'v':
      +			break;		// ignore -v
      +		default:
      +			bb_show_usage();
       		}
       	}
       	argv += optind;
      
       ------------------------------------------------------------------------
      r16133 | vda | 2006-09-17 11:04:01 -0400 (Sun, 17 Sep 2006) | 3 lines
      Changed paths:
         M /trunk/busybox/util-linux/mount.c
      
      mount: fix bugs: free(mp->mnt_fsname) of non-malloced ptr;
      check for "more than 2 arguments" was actually checking for -2.
      
       ------------------------------------------------------------------------
      
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16132)
      +++ util-linux/mount.c	(revision 16133)
      @@ -719,6 +719,7 @@
       	bb_error_msg("%.*s", len, msg);
       }
       
      +// NB: mp->xxx fields may be trashed on exit
       static int nfsmount(struct mntent *mp, int vfsflags, char *filteropts)
       {
       	CLIENT *mclient;
      @@ -1260,7 +1261,7 @@
       
       // Mount one directory.  Handles CIFS, NFS, loopback, autobind, and filesystem
       // type detection.  Returns 0 for success, nonzero for failure.
      -
      +// NB: mp->xxx fields may be trashed on exit
       static int singlemount(struct mntent *mp, int ignore_busy)
       {
       	int rc = -1, vfsflags;
      @@ -1306,15 +1307,15 @@
       
       		// compose new unc '\\server-ip\share'
       
      -		s = xasprintf("\\\\%s%s",ip+3,strchr(mp->mnt_fsname+2,'\\'));
      -		if (ENABLE_FEATURE_CLEAN_UP) free(mp->mnt_fsname);
      -		mp->mnt_fsname = s;
      +		mp->mnt_fsname = xasprintf("\\\\%s%s", ip+3,
      +					strchr(mp->mnt_fsname+2,'\\'));
       
       		// lock is required
       		vfsflags |= MS_MANDLOCK;
       
       		mp->mnt_type = "cifs";
       		rc = mount_it_now(mp, vfsflags, filteropts);
      +		if (ENABLE_FEATURE_CLEAN_UP) free(mp->mnt_fsname);
       		goto report_error;
       	}
       
      @@ -1457,14 +1458,16 @@
       				bb_show_usage();
       		}
       	}
      +	argv += optind;
      +	argc -= optind;
       
       	// Three or more non-option arguments?  Die with a usage message.
       
      -	if (optind-argc>2) bb_show_usage();
      +	if (argc > 2) bb_show_usage();
       
       	// If we have no arguments, show currently mounted filesystems
       
      -	if (optind == argc) {
      +	if (!argc) {
       		if (!all) {
       			FILE *mountTable = setmntent(bb_path_mtab_file, "r");
       
      @@ -1484,15 +1487,15 @@
       			if (ENABLE_FEATURE_CLEAN_UP) endmntent(mountTable);
       			return EXIT_SUCCESS;
       		}
      -	} else storage_path = bb_simplify_path(argv[optind]);
      +	} else storage_path = bb_simplify_path(argv[0]);
       
       	// When we have two arguments, the second is the directory and we can
       	// skip looking at fstab entirely.  We can always abspath() the directory
       	// argument when we get it.
       
      -	if (optind+2 == argc) {
      -		mtpair->mnt_fsname = argv[optind];
      -		mtpair->mnt_dir = argv[optind+1];
      +	if (argc == 2) {
      +		mtpair->mnt_fsname = argv[0];
      +		mtpair->mnt_dir = argv[1];
       		mtpair->mnt_type = fstype;
       		mtpair->mnt_opts = cmdopts;
       		rc = singlemount(mtpair, 0);
      @@ -1504,8 +1507,8 @@
       	if (ENABLE_FEATURE_MOUNT_FLAGS &&
       			(i & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE )))
       	{
      -		rc = mount("", argv[optind], "", i, "");
      -		if (rc) bb_perror_msg_and_die("%s", argv[optind]);
      +		rc = mount("", argv[0], "", i, "");
      +		if (rc) bb_perror_msg_and_die("%s", argv[0]);
       		goto clean_up;
       	}
       	
      @@ -1533,13 +1536,13 @@
       		{
       			// Were we looking for something specific?
       
      -			if (optind != argc) {
      +			if (argc) {
       
       				// If we didn't find anything, complain.
       
       				if (!mtnext->mnt_fsname)
       					bb_error_msg_and_die("can't find %s in %s",
      -						argv[optind], fstabname);
      +						argv[0], fstabname);
       
       				// Mount the last thing we found.
       
      @@ -1556,13 +1559,13 @@
       		 * skip it.  Note we must match both the exact text in fstab (ala
       		 * "proc") or a full path from root */
       
      -		if (optind != argc) {
      +		if (argc) {
       
       			// Is this what we're looking for?
       
      -			if (strcmp(argv[optind],mtcur->mnt_fsname) &&
      +			if (strcmp(argv[0],mtcur->mnt_fsname) &&
       			   strcmp(storage_path,mtcur->mnt_fsname) &&
      -			   strcmp(argv[optind],mtcur->mnt_dir) &&
      +			   strcmp(argv[0],mtcur->mnt_dir) &&
       			   strcmp(storage_path,mtcur->mnt_dir)) continue;
       
       			// Remember this entry.  Something later may have overmounted
      
       ------------------------------------------------------------------------
      r16132 | vda | 2006-09-17 11:01:53 -0400 (Sun, 17 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/util-linux/mount.c
      
      mount: use bb_simplify_path as appropriate
      
       ------------------------------------------------------------------------
      
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16131)
      +++ util-linux/mount.c	(revision 16132)
      @@ -234,43 +234,31 @@
       	/* If the mount was successful, and we're maintaining an old-style
       	 * mtab file by hand, add the new entry to it now. */
       
      -	if(ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc && !(vfsflags & MS_REMOUNT)) {
      -		char dirbuf[PATH_MAX];
      -		char srcbuf[PATH_MAX];
      +	if (ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc && !(vfsflags & MS_REMOUNT)) {
      +		char *dir,*fsname;
       		FILE *mountTable = setmntent(bb_path_mtab_file, "a+");
       		int i;
       
      -		if(!mountTable)
      +		if (!mountTable)
       			bb_error_msg("no %s",bb_path_mtab_file);
       
       		// Add vfs string flags
       
      -		for(i=0; mount_options[i].flags != MS_REMOUNT; i++)
      +		for (i=0; mount_options[i].flags != MS_REMOUNT; i++)
       			if (mount_options[i].flags > 0 && (mount_options[i].flags & vfsflags))
       				append_mount_options(&(mp->mnt_opts), mount_options[i].name);
       
       		// Remove trailing / (if any) from directory we mounted on
       
       		i = strlen(mp->mnt_dir) - 1;
      -		if(i > 0 && mp->mnt_dir[i] == '/') mp->mnt_dir[i] = 0;
      +		if (i > 0 && mp->mnt_dir[i] == '/') mp->mnt_dir[i] = 0;
       
      -		// Add full pathnames as needed
      +		// Convert to canonical pathnames as needed
       
      -		if (mp->mnt_dir[0] != '/') {
      -			getcwd(dirbuf, sizeof(dirbuf));
      -			i = strlen(dirbuf);
      -			/* strcat() would be unsafe here */
      -			snprintf(dirbuf+i, sizeof(dirbuf)-i, "/%s", mp->mnt_dir);
      -			mp->mnt_dir = dirbuf;
      -		}
      +		mp->mnt_dir = dir = bb_simplify_path(mp->mnt_dir);
      +		fsname = 0;
       		if (!mp->mnt_type || !*mp->mnt_type) { /* bind mount */
      -			if (mp->mnt_fsname[0] != '/') {
      -				getcwd(srcbuf, sizeof(srcbuf));
      -				i = strlen(srcbuf);
      -				snprintf(srcbuf+i, sizeof(srcbuf)-i, "/%s",
      -						mp->mnt_fsname);
      -				mp->mnt_fsname = srcbuf;
      -			}
      +			mp->mnt_fsname = fsname = bb_simplify_path(mp->mnt_fsname);
       			mp->mnt_type = "none";
       		}
       		mp->mnt_freq = mp->mnt_passno = 0;
      @@ -279,6 +267,10 @@
       
       		addmntent(mountTable, mp);
       		endmntent(mountTable);
      +		if (ENABLE_FEATURE_CLEAN_UP) {
      +			free(dir);
      +			free(fsname);
      +		}
       	}
       
       	return rc;
      
       ------------------------------------------------------------------------
      r16131 | vda | 2006-09-17 11:00:58 -0400 (Sun, 17 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/util-linux/mount.c
      
      mount: style fixes
      
       ------------------------------------------------------------------------
      
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16130)
      +++ util-linux/mount.c	(revision 16131)
      @@ -101,7 +101,7 @@
       /* Append mount options to string */
       static void append_mount_options(char **oldopts, char *newopts)
       {
      -	if(*oldopts && **oldopts) {
      +	if (*oldopts && **oldopts) {
       		char *temp = xasprintf("%s,%s",*oldopts,newopts);
       		free(*oldopts);
       		*oldopts = temp;
      @@ -128,7 +128,7 @@
       		for (i = 0; i < (sizeof(mount_options) / sizeof(*mount_options)); i++) {
       			if (!strcasecmp(mount_options[i].name, options)) {
       				long fl = mount_options[i].flags;
      -				if(fl < 0) flags &= fl;
      +				if (fl < 0) flags &= fl;
       				else flags |= fl;
       				break;
       			}
      @@ -147,7 +147,7 @@
       		}
       
       		// Advance to next option, or finish
      -		if(comma) {
      +		if (comma) {
       			*comma = ',';
       			options = ++comma;
       		} else break;
      @@ -166,17 +166,18 @@
       	int i;
       	FILE *f;
       
      -	for(i = 0; filesystems[i]; i++) {
      -		if(!(f = fopen(filesystems[i], "r"))) continue;
      +	for (i = 0; filesystems[i]; i++) {
      +		f = fopen(filesystems[i], "r");
      +		if (!f) continue;
       
      -		for(fs = buf = 0; (fs = buf = bb_get_chomped_line_from_file(f));
      +		for (fs = buf = 0; (fs = buf = bb_get_chomped_line_from_file(f));
       			free(buf))
       		{
      -			if(!strncmp(buf,"nodev",5) && isspace(buf[5])) continue;
      +			if (!strncmp(buf,"nodev",5) && isspace(buf[5])) continue;
       
      -			while(isspace(*fs)) fs++;
      -			if(*fs=='#' || *fs=='*') continue;
      -			if(!*fs) continue;
      +			while (isspace(*fs)) fs++;
      +			if (*fs=='#' || *fs=='*') continue;
      +			if (!*fs) continue;
       
       			llist_add_to_end(&list,xstrdup(fs));
       		}
      @@ -206,18 +207,19 @@
       #endif
       
       // Perform actual mount of specific filesystem at specific location.
      +// NB: mp->xxx fields may be trashed on exit
       static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
       {
       	int rc;
       
      -	if (fakeIt) { return 0; }
      +	if (fakeIt) return 0;
       
       	// Mount, with fallback to read-only if necessary.
       
      -	for(;;) {
      +	for (;;) {
       		rc = mount(mp->mnt_fsname, mp->mnt_dir, mp->mnt_type,
       				vfsflags, filteropts);
      -		if(!rc || (vfsflags&MS_RDONLY) || (errno!=EACCES && errno!=EROFS))
      +		if (!rc || (vfsflags&MS_RDONLY) || (errno!=EACCES && errno!=EROFS))
       			break;
       		bb_error_msg("%s is write-protected, mounting read-only",
       				mp->mnt_fsname);
      @@ -440,7 +442,6 @@
       #endif
       };
       
      -
       /*
        * We want to be able to compile mount on old kernels in such a way
        * that the binary will work well on more recent kernels.
      @@ -1283,7 +1284,7 @@
       
       	// Might this be an CIFS filesystem?
       
      -	if(ENABLE_FEATURE_MOUNT_CIFS &&
      +	if (ENABLE_FEATURE_MOUNT_CIFS &&
       		(!mp->mnt_type || !strcmp(mp->mnt_type,"cifs")) &&
       		(mp->mnt_fsname[0]==mp->mnt_fsname[1] && (mp->mnt_fsname[0]=='/' || mp->mnt_fsname[0]=='\\')))
       	{
      @@ -1345,7 +1346,7 @@
       		if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) {
       			loopFile = bb_simplify_path(mp->mnt_fsname);
       			mp->mnt_fsname = 0;
      -			switch(set_loop(&(mp->mnt_fsname), loopFile, 0)) {
      +			switch (set_loop(&(mp->mnt_fsname), loopFile, 0)) {
       				case 0:
       				case 1:
       					break;
      @@ -1385,7 +1386,8 @@
       		for (fl = fslist; fl; fl = fl->link) {
       			mp->mnt_type = fl->data;
       
      -			if (!(rc = mount_it_now(mp,vfsflags, filteropts))) break;
      +			rc = mount_it_now(mp,vfsflags, filteropts);
      +			if (!rc) break;
       
       			mp->mnt_type = 0;
       		}
      @@ -1474,7 +1476,7 @@
       		if (!all) {
       			FILE *mountTable = setmntent(bb_path_mtab_file, "r");
       
      -			if(!mountTable) bb_error_msg_and_die("no %s",bb_path_mtab_file);
      +			if (!mountTable) bb_error_msg_and_die("no %s",bb_path_mtab_file);
       
       			while (getmntent_r(mountTable,mtpair,bb_common_bufsiz1,
       								sizeof(bb_common_bufsiz1)))
      @@ -1521,14 +1523,15 @@
       		fstabname = bb_path_mtab_file;
       	else fstabname="/etc/fstab";
       
      -	if (!(fstab=setmntent(fstabname,"r")))
      +	fstab = setmntent(fstabname,"r");
      +	if (!fstab)
       		bb_perror_msg_and_die("cannot read %s",fstabname);
       
       	// Loop through entries until we find what we're looking for.
       
       	memset(mtpair,0,sizeof(mtpair));
       	for (;;) {
      -		struct mntent *mtnext = mtpair + (mtcur==mtpair ? 1 : 0);
      +		struct mntent *mtnext = (mtcur==mtpair ? mtpair+1 : mtpair);
       
       		// Get next fstab entry
       
      @@ -1565,7 +1568,7 @@
       
       			// Is this what we're looking for?
       
      -			if(strcmp(argv[optind],mtcur->mnt_fsname) &&
      +			if (strcmp(argv[optind],mtcur->mnt_fsname) &&
       			   strcmp(storage_path,mtcur->mnt_fsname) &&
       			   strcmp(argv[optind],mtcur->mnt_dir) &&
       			   strcmp(storage_path,mtcur->mnt_dir)) continue;
      
       ------------------------------------------------------------------------
      r16130 | vda | 2006-09-17 10:45:09 -0400 (Sun, 17 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/loginutils/login.c
      
      login: apply fixes + getopt_ulflag'ification by Bernhard
      
       ------------------------------------------------------------------------
      
      Index: loginutils/login.c
      ===================================================================
      --- loginutils/login.c	(revision 16129)
      +++ loginutils/login.c	(revision 16130)
      @@ -40,7 +40,9 @@
        *	This means that getty should never invoke login with any
        *	command line flags.
        */
      +
       static struct utmp utent;
      +
       static void read_or_build_utent(int picky)
       {
       	struct utmp *ut;
      @@ -97,10 +99,10 @@
       	updwtmp(bb_path_wtmp_file, &utent);
       #endif
       }
      -#else /* !CONFIG_FEATURE_UTMP */
      -static inline void read_or_build_utent(int) {}
      -static inline void write_utent(const char *) {}
      -#endif /* !CONFIG_FEATURE_UTMP */
      +#else /* !ENABLE_FEATURE_UTMP */
      +static inline void read_or_build_utent(int ATTRIBUTE_UNUSED picky) {}
      +static inline void write_utent(const char ATTRIBUTE_UNUSED *username) {}
      +#endif /* !ENABLE_FEATURE_UTMP */
       
       static void die_if_nologin_and_non_root(int amroot)
       {
      @@ -211,53 +213,35 @@
       
       int login_main(int argc, char **argv)
       {
      +	enum {
      +		LOGIN_OPT_f = (1<<0),
      +		LOGIN_OPT_h = (1<<1),
      +		LOGIN_OPT_p = (1<<2),
      +	};
       	char fromhost[512];
       	char username[USERNAME_SIZE];
       	const char *tmp;
       	int amroot;
      -	int flag;
      +	unsigned long opt;
       	int count = 0;
       	struct passwd *pw;
      -	int opt_preserve = 0;
      -	int opt_fflag = 0;
      -	char *opt_host = 0;
      -#ifdef CONFIG_SELINUX
      -	security_context_t user_sid = NULL;
      -#endif
      +	char *opt_host = NULL;
      +	char *opt_user = NULL;
      +	USE_SELINUX(security_context_t user_sid = NULL;)
       
       	username[0] = '\0';
       	amroot = (getuid() == 0);
       	signal(SIGALRM, alarm_handler);
       	alarm(TIMEOUT);
       
      -	while ((flag = getopt(argc, argv, "f:h:p")) != EOF) {
      -		switch (flag) {
      -		case 'p':
      -			opt_preserve = 1;
      -			break;
      -		case 'f':
      -			/*
      -			 * username must be a separate token
      -			 * (-f root, *NOT* -froot). --marekm
      -			 */
      -			if (optarg != argv[optind-1])
      -				bb_show_usage();
      +	opt = bb_getopt_ulflags(argc, argv, "f:h:p", &opt_user, &opt_host);
       
      -			if (!amroot)	/* Auth bypass only if real UID is zero */
      -				bb_error_msg_and_die("-f is for root only");
      -
      -			safe_strncpy(username, optarg, sizeof(username));
      -			opt_fflag = 1;
      -			break;
      -		case 'h':
      -			opt_host = optarg;
      -			break;
      -		default:
      -			bb_show_usage();
      -		}
      +	if (opt & LOGIN_OPT_f) {
      +		if (!amroot)
      +			bb_error_msg_and_die("-f is for root only");
      +		safe_strncpy(username, opt_user, strlen(opt_user));
       	}
      -	if (optind < argc)             /* user from command line (getty) */
      -		safe_strncpy(username, argv[optind], sizeof(username));
      +	username[USERNAME_SIZE] = 0;
       
       	/* Let's find out and memorize our tty */
       	if (!isatty(0) || !isatty(1) || !isatty(2))
      @@ -273,8 +257,9 @@
       	read_or_build_utent(!amroot);
       
       	if (opt_host) {
      -		if (ENABLE_FEATURE_UTMP)
      +		USE_FEATURE_UTMP(
       			safe_strncpy(utent.ut_host, opt_host, sizeof(utent.ut_host));
      +		)
       		snprintf(fromhost, sizeof(fromhost)-1, " on `%.100s' from "
       					"`%.200s'", short_tty, opt_host);
       	}
      @@ -298,7 +283,7 @@
       		if (pw->pw_passwd[0] == '!' || pw->pw_passwd[0] == '*')
       			goto auth_failed;
       
      -		if (opt_fflag)
      +		if (opt & LOGIN_OPT_f)
       			break; /* -f USER: success without asking passwd */
       
       		if (pw->pw_uid == 0 && !check_securetty())
      @@ -306,14 +291,14 @@
       
       		/* Don't check the password if password entry is empty (!) */
       		if (!pw->pw_passwd[0])
      -			break; 
      +			break;
       
       		/* authorization takes place here */
       		if (correct_password(pw))
      -			break; 
      +			break;
       
       auth_failed:
      -		opt_fflag = 0;
      +		opt &= ~LOGIN_OPT_f;
       		bb_do_delay(FAIL_DELAY);
       		puts("Login incorrect");
       		if (++count == 3) {
      @@ -382,7 +367,7 @@
       	tmp = pw->pw_shell;
       	if (!tmp || !*tmp)
       		tmp = DEFAULT_SHELL;
      -	setup_environment(tmp, 1, !opt_preserve, pw);
      +	setup_environment(tmp, 1, !(opt & LOGIN_OPT_p), pw);
       
       	motd();
       	signal(SIGALRM, SIG_DFL);	/* default alarm signal */
      
       ------------------------------------------------------------------------
      r16129 | aldot | 2006-09-15 15:25:18 -0400 (Fri, 15 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/include/usage.h
      
      - Steven Scholz pointed out that ssd's make-pid doesn't take an argument.
      
       ------------------------------------------------------------------------
      
      Index: include/usage.h
      ===================================================================
      --- include/usage.h	(revision 16128)
      +++ include/usage.h	(revision 16129)
      @@ -2714,7 +2714,7 @@
       	"\n\t-b|--background\t\t\tforce process into background" \
       	"\n\t-u|--user |\tstop this user's processes" \
       	"\n\t-x|--exec \t\tprogram to either start or check" \
      -	"\n\t-m|--make-pidfile \tcreate the -p file and enter pid in it" \
      +	"\n\t-m|--make-pidfile\tcreate the -p file and enter pid in it" \
       	"\n\t-n|--name \tstop processes with this name" \
       	"\n\t-p|--pidfile \t\tsave or load pid using a pid-file" \
       	"\n\t-q|--quiet\t\t\tbe quiet" \
      
       ------------------------------------------------------------------------
      r16128 | vda | 2006-09-15 11:12:00 -0400 (Fri, 15 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/util-linux/mount.c
      
      mount: reorder things, fix NFS-less mount.
      
       ------------------------------------------------------------------------
      
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16127)
      +++ util-linux/mount.c	(revision 16128)
      @@ -25,6 +25,16 @@
       #include "busybox.h"
       #include 
       
      +/* Needed for nfs support only... */
      +#include 
      +#include 
      +#undef TRUE
      +#undef FALSE
      +#include 
      +#include 
      +#include 
      +
      +
       // Not real flags, but we want to be able to check for this.
       #define MOUNT_NOAUTO    (1<<29)
       #define MOUNT_SWAP      (1<<30)
      @@ -86,8 +96,8 @@
       	{"remount", MS_REMOUNT},  // action flag
       };
       
      -static int nfsmount(struct mntent *mp, int vfsflags, char *filteropts);
       
      +
       /* Append mount options to string */
       static void append_mount_options(char **oldopts, char *newopts)
       {
      @@ -272,349 +282,6 @@
       	return rc;
       }
       
      -// Mount one directory.  Handles CIFS, NFS, loopback, autobind, and filesystem
      -// type detection.  Returns 0 for success, nonzero for failure.
      -
      -static int singlemount(struct mntent *mp, int ignore_busy)
      -{
      -	int rc = -1, vfsflags;
      -	char *loopFile = 0, *filteropts = 0;
      -	llist_t *fl = 0;
      -	struct stat st;
      -
      -	vfsflags = parse_mount_options(mp->mnt_opts, &filteropts);
      -
      -	// Treat fstype "auto" as unspecified.
      -
      -	if (mp->mnt_type && !strcmp(mp->mnt_type,"auto")) mp->mnt_type = 0;
      -
      -	// Might this be an CIFS filesystem?
      -
      -	if(ENABLE_FEATURE_MOUNT_CIFS &&
      -		(!mp->mnt_type || !strcmp(mp->mnt_type,"cifs")) &&
      -		(mp->mnt_fsname[0]==mp->mnt_fsname[1] && (mp->mnt_fsname[0]=='/' || mp->mnt_fsname[0]=='\\')))
      -	{
      -		struct hostent *he;
      -		char ip[32], *s;
      -
      -		rc = 1;
      -		// Replace '/' with '\' and verify that unc points to "//server/share".
      -
      -		for (s = mp->mnt_fsname; *s; ++s)
      -			if (*s == '/') *s = '\\';
      -
      -		// get server IP
      -
      -		s = strrchr(mp->mnt_fsname, '\\');
      -		if (s == mp->mnt_fsname+1) goto report_error;
      -		*s = 0;
      -	   	he = gethostbyname(mp->mnt_fsname+2);
      -		*s = '\\';
      -		if (!he) goto report_error;
      -
      -		// Insert ip=... option into string flags.  (NOTE: Add IPv6 support.)
      -
      -		sprintf(ip, "ip=%d.%d.%d.%d", he->h_addr[0], he->h_addr[1],
      -				he->h_addr[2], he->h_addr[3]);
      -		parse_mount_options(ip, &filteropts);
      -
      -		// compose new unc '\\server-ip\share'
      -
      -		s = xasprintf("\\\\%s%s",ip+3,strchr(mp->mnt_fsname+2,'\\'));
      -		if (ENABLE_FEATURE_CLEAN_UP) free(mp->mnt_fsname);
      -		mp->mnt_fsname = s;
      -
      -		// lock is required
      -		vfsflags |= MS_MANDLOCK;
      -
      -		mp->mnt_type = "cifs";
      -		rc = mount_it_now(mp, vfsflags, filteropts);
      -		goto report_error;
      -	}
      -
      -	// Might this be an NFS filesystem?
      -
      -	if (ENABLE_FEATURE_MOUNT_NFS &&
      -		(!mp->mnt_type || !strcmp(mp->mnt_type,"nfs")) &&
      -		strchr(mp->mnt_fsname, ':') != NULL)
      -	{
      -		rc = nfsmount(mp, vfsflags, filteropts);
      -		goto report_error;
      -	}
      -
      -	// Look at the file.  (Not found isn't a failure for remount, or for
      -	// a synthetic filesystem like proc or sysfs.)
      -
      -	if (!lstat(mp->mnt_fsname, &st) && !(vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE)))
      -	{
      -		// Do we need to allocate a loopback device for it?
      -
      -		if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) {
      -			loopFile = bb_simplify_path(mp->mnt_fsname);
      -			mp->mnt_fsname = 0;
      -			switch(set_loop(&(mp->mnt_fsname), loopFile, 0)) {
      -				case 0:
      -				case 1:
      -					break;
      -				default:
      -					bb_error_msg( errno == EPERM || errno == EACCES
      -						? bb_msg_perm_denied_are_you_root
      -						: "cannot setup loop device");
      -					return errno;
      -			}
      -
      -		// Autodetect bind mounts
      -
      -		} else if (S_ISDIR(st.st_mode) && !mp->mnt_type)
      -			vfsflags |= MS_BIND;
      -	}
      -
      -	/* If we know the fstype (or don't need to), jump straight
      -	 * to the actual mount. */
      -
      -	if (mp->mnt_type || (vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE)))
      -		rc = mount_it_now(mp, vfsflags, filteropts);
      -
      -	// Loop through filesystem types until mount succeeds or we run out
      -
      -	else {
      -
      -		/* Initialize list of block backed filesystems.  This has to be
      -		 * done here so that during "mount -a", mounts after /proc shows up
      -		 * can autodetect. */
      -
      -		if (!fslist) {
      -			fslist = get_block_backed_filesystems();
      -			if (ENABLE_FEATURE_CLEAN_UP && fslist)
      -				atexit(delete_block_backed_filesystems);
      -		}
      -
      -		for (fl = fslist; fl; fl = fl->link) {
      -			mp->mnt_type = fl->data;
      -
      -			if (!(rc = mount_it_now(mp,vfsflags, filteropts))) break;
      -
      -			mp->mnt_type = 0;
      -		}
      -	}
      -
      -	// If mount failed, clean up loop file (if any).
      -
      -	if (ENABLE_FEATURE_MOUNT_LOOP && rc && loopFile) {
      -		del_loop(mp->mnt_fsname);
      -		if (ENABLE_FEATURE_CLEAN_UP) {
      -			free(loopFile);
      -			free(mp->mnt_fsname);
      -		}
      -	}
      -
      -report_error:
      -	if (ENABLE_FEATURE_CLEAN_UP) free(filteropts);
      -
      -	if (rc && errno == EBUSY && ignore_busy) rc = 0;
      -	if (rc < 0)
      -		/* perror here sometimes says "mounting ... on ... failed: Success" */
      -		bb_error_msg("mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir);
      -
      -	return rc;
      -}
      -
      -// Parse options, if necessary parse fstab/mtab, and call singlemount for
      -// each directory to be mounted.
      -
      -int mount_main(int argc, char **argv)
      -{
      -	char *cmdopts = xstrdup(""), *fstabname, *fstype=0, *storage_path=0;
      -	FILE *fstab;
      -	int i, opt, all = FALSE, rc = 0;
      -	struct mntent mtpair[2], *mtcur = mtpair;
      -
      -	/* parse long options, like --bind and --move.  Note that -o option
      -	 * and --option are synonymous.  Yes, this means --remount,rw works. */
      -
      -	for (i = opt = 0; i < argc; i++) {
      -		if (argv[i][0] == '-' && argv[i][1] == '-') {
      -			append_mount_options(&cmdopts,argv[i]+2);
      -		} else argv[opt++] = argv[i];
      -	}
      -	argc = opt;
      -
      -	// Parse remaining options
      -
      -	while ((opt = getopt(argc, argv, "o:t:rwavnf")) > 0) {
      -		switch (opt) {
      -			case 'o':
      -				append_mount_options(&cmdopts, optarg);
      -				break;
      -			case 't':
      -				fstype = optarg;
      -				break;
      -			case 'r':
      -				append_mount_options(&cmdopts, "ro");
      -				break;
      -			case 'w':
      -				append_mount_options(&cmdopts, "rw");
      -				break;
      -			case 'a':
      -				all = TRUE;
      -				break;
      -			case 'n':
      -				USE_FEATURE_MTAB_SUPPORT(useMtab = FALSE;)
      -				break;
      -			case 'f':
      -				USE_FEATURE_MTAB_SUPPORT(fakeIt = FALSE;)
      -				break;
      -			case 'v':
      -				break;		// ignore -v
      -			default:
      -				bb_show_usage();
      -		}
      -	}
      -
      -	// Three or more non-option arguments?  Die with a usage message.
      -
      -	if (optind-argc>2) bb_show_usage();
      -
      -	// If we have no arguments, show currently mounted filesystems
      -
      -	if (optind == argc) {
      -		if (!all) {
      -			FILE *mountTable = setmntent(bb_path_mtab_file, "r");
      -
      -			if(!mountTable) bb_error_msg_and_die("no %s",bb_path_mtab_file);
      -
      -			while (getmntent_r(mountTable,mtpair,bb_common_bufsiz1,
      -								sizeof(bb_common_bufsiz1)))
      -			{
      -				// Don't show rootfs.
      -				if (!strcmp(mtpair->mnt_fsname, "rootfs")) continue;
      -
      -				if (!fstype || !strcmp(mtpair->mnt_type, fstype))
      -					printf("%s on %s type %s (%s)\n", mtpair->mnt_fsname,
      -							mtpair->mnt_dir, mtpair->mnt_type,
      -							mtpair->mnt_opts);
      -			}
      -			if (ENABLE_FEATURE_CLEAN_UP) endmntent(mountTable);
      -			return EXIT_SUCCESS;
      -		}
      -	} else storage_path = bb_simplify_path(argv[optind]);
      -
      -	// When we have two arguments, the second is the directory and we can
      -	// skip looking at fstab entirely.  We can always abspath() the directory
      -	// argument when we get it.
      -
      -	if (optind+2 == argc) {
      -		mtpair->mnt_fsname = argv[optind];
      -		mtpair->mnt_dir = argv[optind+1];
      -		mtpair->mnt_type = fstype;
      -		mtpair->mnt_opts = cmdopts;
      -		rc = singlemount(mtpair, 0);
      -		goto clean_up;
      -	}
      -
      -	// If we have a shared subtree flag, don't worry about fstab or mtab.
      -	i = parse_mount_options(cmdopts,0);
      -	if (ENABLE_FEATURE_MOUNT_FLAGS &&
      -			(i & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE )))
      -	{
      -		rc = mount("", argv[optind], "", i, "");
      -		if (rc) bb_perror_msg_and_die("%s", argv[optind]);
      -		goto clean_up;
      -	}
      -	
      -	// Open either fstab or mtab
      -
      -	if (parse_mount_options(cmdopts,0) & MS_REMOUNT)
      -		fstabname = bb_path_mtab_file;
      -	else fstabname="/etc/fstab";
      -
      -	if (!(fstab=setmntent(fstabname,"r")))
      -		bb_perror_msg_and_die("cannot read %s",fstabname);
      -
      -	// Loop through entries until we find what we're looking for.
      -
      -	memset(mtpair,0,sizeof(mtpair));
      -	for (;;) {
      -		struct mntent *mtnext = mtpair + (mtcur==mtpair ? 1 : 0);
      -
      -		// Get next fstab entry
      -
      -		if (!getmntent_r(fstab, mtcur, bb_common_bufsiz1
      -					+ (mtcur==mtpair ? sizeof(bb_common_bufsiz1)/2 : 0),
      -				sizeof(bb_common_bufsiz1)/2))
      -		{
      -			// Were we looking for something specific?
      -
      -			if (optind != argc) {
      -
      -				// If we didn't find anything, complain.
      -
      -				if (!mtnext->mnt_fsname)
      -					bb_error_msg_and_die("can't find %s in %s",
      -						argv[optind], fstabname);
      -
      -				// Mount the last thing we found.
      -
      -				mtcur = mtnext;
      -				mtcur->mnt_opts = xstrdup(mtcur->mnt_opts);
      -				append_mount_options(&(mtcur->mnt_opts),cmdopts);
      -				rc = singlemount(mtcur, 0);
      -				free(mtcur->mnt_opts);
      -			}
      -			goto clean_up;
      -		}
      -
      -		/* If we're trying to mount something specific and this isn't it,
      -		 * skip it.  Note we must match both the exact text in fstab (ala
      -		 * "proc") or a full path from root */
      -
      -		if (optind != argc) {
      -
      -			// Is this what we're looking for?
      -
      -			if(strcmp(argv[optind],mtcur->mnt_fsname) &&
      -			   strcmp(storage_path,mtcur->mnt_fsname) &&
      -			   strcmp(argv[optind],mtcur->mnt_dir) &&
      -			   strcmp(storage_path,mtcur->mnt_dir)) continue;
      -
      -			// Remember this entry.  Something later may have overmounted
      -			// it, and we want the _last_ match.
      -
      -			mtcur = mtnext;
      -
      -		// If we're mounting all.
      -
      -		} else {
      -
      -			// Do we need to match a filesystem type?
      -			if (fstype && strcmp(mtcur->mnt_type,fstype)) continue;
      -
      -			// Skip noauto and swap anyway.
      -
      -			if (parse_mount_options(mtcur->mnt_opts,0)
      -				& (MOUNT_NOAUTO | MOUNT_SWAP)) continue;
      -
      -			// Mount this thing.
      -
      -			if (singlemount(mtcur, 1)) {
      -				/* Count number of failed mounts */
      -				rc++;
      -			}
      -		}
      -	}
      -	if (ENABLE_FEATURE_CLEAN_UP) endmntent(fstab);
      -
      -clean_up:
      -
      -	if (ENABLE_FEATURE_CLEAN_UP) {
      -		free(storage_path);
      -		free(cmdopts);
      -	}
      -
      -	return rc;
      -}
      -
      -
       #if ENABLE_FEATURE_MOUNT_NFS
       
       /*
      @@ -639,17 +306,9 @@
        * plus NFSv3 stuff.
        */
       
      -#include 
      -#include 
      -#undef TRUE
      -#undef FALSE
      -#include 
      -#include 
      -#include 
      -
       /* This is just a warning of a common mistake.  Possibly this should be a
        * uclibc faq entry rather than in busybox... */
      -#if ENABLE_FEATURE_MOUNT_NFS && defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__)
      +#if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__)
       #error "You need to build uClibc with UCLIBC_HAS_RPC for NFS support."
       #endif
       
      @@ -1314,25 +973,6 @@
       	if (!data.timeo)
       		data.timeo = tcp ? 70 : 7;
       
      -#ifdef NFS_MOUNT_DEBUG
      -	printf("rsize = %d, wsize = %d, timeo = %d, retrans = %d\n",
      -		data.rsize, data.wsize, data.timeo, data.retrans);
      -	printf("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)\n",
      -		data.acregmin, data.acregmax, data.acdirmin, data.acdirmax);
      -	printf("port = %d, bg = %d, retry = %d, flags = %.8x\n",
      -		port, bg, retry, data.flags);
      -	printf("mountprog = %d, mountvers = %d, nfsprog = %d, nfsvers = %d\n",
      -		mountprog, mountvers, nfsprog, nfsvers);
      -	printf("soft = %d, intr = %d, posix = %d, nocto = %d, noac = %d\n",
      -		(data.flags & NFS_MOUNT_SOFT) != 0,
      -		(data.flags & NFS_MOUNT_INTR) != 0,
      -		(data.flags & NFS_MOUNT_POSIX) != 0,
      -		(data.flags & NFS_MOUNT_NOCTO) != 0,
      -		(data.flags & NFS_MOUNT_NOAC) != 0);
      -	printf("tcp = %d\n",
      -		(data.flags & NFS_MOUNT_TCP) != 0);
      -#endif
      -
       	data.version = nfs_mount_version;
       
       	if (vfsflags & MS_REMOUNT)
      @@ -1559,14 +1199,7 @@
       					tcp ? IPPROTO_TCP : IPPROTO_UDP);
       		if (port == 0)
       			port = NFS_PORT;
      -#ifdef NFS_MOUNT_DEBUG
      -		else
      -			printf("used portmapper to find NFS port\n");
      -#endif
       	}
      -#ifdef NFS_MOUNT_DEBUG
      -	printf("using port %d for nfs daemon\n", port);
      -#endif
       	server_addr.sin_port = htons(port);
       
       	/* prepare data structure for kernel */
      @@ -1625,4 +1258,351 @@
       	return retval;
       }
       
      -#endif /* ENABLE_FEATURE_MOUNT_NFS */
      +#else /* !ENABLE_FEATURE_MOUNT_NFS */
      +
      +/* Never called. Call should be optimized out. */
      +int nfsmount(struct mntent *mp, int vfsflags, char *filteropts);
      +
      +#endif /* !ENABLE_FEATURE_MOUNT_NFS */
      +
      +// Mount one directory.  Handles CIFS, NFS, loopback, autobind, and filesystem
      +// type detection.  Returns 0 for success, nonzero for failure.
      +
      +static int singlemount(struct mntent *mp, int ignore_busy)
      +{
      +	int rc = -1, vfsflags;
      +	char *loopFile = 0, *filteropts = 0;
      +	llist_t *fl = 0;
      +	struct stat st;
      +
      +	vfsflags = parse_mount_options(mp->mnt_opts, &filteropts);
      +
      +	// Treat fstype "auto" as unspecified.
      +
      +	if (mp->mnt_type && !strcmp(mp->mnt_type,"auto")) mp->mnt_type = 0;
      +
      +	// Might this be an CIFS filesystem?
      +
      +	if(ENABLE_FEATURE_MOUNT_CIFS &&
      +		(!mp->mnt_type || !strcmp(mp->mnt_type,"cifs")) &&
      +		(mp->mnt_fsname[0]==mp->mnt_fsname[1] && (mp->mnt_fsname[0]=='/' || mp->mnt_fsname[0]=='\\')))
      +	{
      +		struct hostent *he;
      +		char ip[32], *s;
      +
      +		rc = 1;
      +		// Replace '/' with '\' and verify that unc points to "//server/share".
      +
      +		for (s = mp->mnt_fsname; *s; ++s)
      +			if (*s == '/') *s = '\\';
      +
      +		// get server IP
      +
      +		s = strrchr(mp->mnt_fsname, '\\');
      +		if (s == mp->mnt_fsname+1) goto report_error;
      +		*s = 0;
      +	   	he = gethostbyname(mp->mnt_fsname+2);
      +		*s = '\\';
      +		if (!he) goto report_error;
      +
      +		// Insert ip=... option into string flags.  (NOTE: Add IPv6 support.)
      +
      +		sprintf(ip, "ip=%d.%d.%d.%d", he->h_addr[0], he->h_addr[1],
      +				he->h_addr[2], he->h_addr[3]);
      +		parse_mount_options(ip, &filteropts);
      +
      +		// compose new unc '\\server-ip\share'
      +
      +		s = xasprintf("\\\\%s%s",ip+3,strchr(mp->mnt_fsname+2,'\\'));
      +		if (ENABLE_FEATURE_CLEAN_UP) free(mp->mnt_fsname);
      +		mp->mnt_fsname = s;
      +
      +		// lock is required
      +		vfsflags |= MS_MANDLOCK;
      +
      +		mp->mnt_type = "cifs";
      +		rc = mount_it_now(mp, vfsflags, filteropts);
      +		goto report_error;
      +	}
      +
      +	// Might this be an NFS filesystem?
      +
      +	if (ENABLE_FEATURE_MOUNT_NFS &&
      +		(!mp->mnt_type || !strcmp(mp->mnt_type,"nfs")) &&
      +		strchr(mp->mnt_fsname, ':') != NULL)
      +	{
      +		rc = nfsmount(mp, vfsflags, filteropts);
      +		goto report_error;
      +	}
      +
      +	// Look at the file.  (Not found isn't a failure for remount, or for
      +	// a synthetic filesystem like proc or sysfs.)
      +
      +	if (!lstat(mp->mnt_fsname, &st) && !(vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE)))
      +	{
      +		// Do we need to allocate a loopback device for it?
      +
      +		if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) {
      +			loopFile = bb_simplify_path(mp->mnt_fsname);
      +			mp->mnt_fsname = 0;
      +			switch(set_loop(&(mp->mnt_fsname), loopFile, 0)) {
      +				case 0:
      +				case 1:
      +					break;
      +				default:
      +					bb_error_msg( errno == EPERM || errno == EACCES
      +						? bb_msg_perm_denied_are_you_root
      +						: "cannot setup loop device");
      +					return errno;
      +			}
      +
      +		// Autodetect bind mounts
      +
      +		} else if (S_ISDIR(st.st_mode) && !mp->mnt_type)
      +			vfsflags |= MS_BIND;
      +	}
      +
      +	/* If we know the fstype (or don't need to), jump straight
      +	 * to the actual mount. */
      +
      +	if (mp->mnt_type || (vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE)))
      +		rc = mount_it_now(mp, vfsflags, filteropts);
      +
      +	// Loop through filesystem types until mount succeeds or we run out
      +
      +	else {
      +
      +		/* Initialize list of block backed filesystems.  This has to be
      +		 * done here so that during "mount -a", mounts after /proc shows up
      +		 * can autodetect. */
      +
      +		if (!fslist) {
      +			fslist = get_block_backed_filesystems();
      +			if (ENABLE_FEATURE_CLEAN_UP && fslist)
      +				atexit(delete_block_backed_filesystems);
      +		}
      +
      +		for (fl = fslist; fl; fl = fl->link) {
      +			mp->mnt_type = fl->data;
      +
      +			if (!(rc = mount_it_now(mp,vfsflags, filteropts))) break;
      +
      +			mp->mnt_type = 0;
      +		}
      +	}
      +
      +	// If mount failed, clean up loop file (if any).
      +
      +	if (ENABLE_FEATURE_MOUNT_LOOP && rc && loopFile) {
      +		del_loop(mp->mnt_fsname);
      +		if (ENABLE_FEATURE_CLEAN_UP) {
      +			free(loopFile);
      +			free(mp->mnt_fsname);
      +		}
      +	}
      +
      +report_error:
      +	if (ENABLE_FEATURE_CLEAN_UP) free(filteropts);
      +
      +	if (rc && errno == EBUSY && ignore_busy) rc = 0;
      +	if (rc < 0)
      +		/* perror here sometimes says "mounting ... on ... failed: Success" */
      +		bb_error_msg("mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir);
      +
      +	return rc;
      +}
      +
      +// Parse options, if necessary parse fstab/mtab, and call singlemount for
      +// each directory to be mounted.
      +
      +int mount_main(int argc, char **argv)
      +{
      +	char *cmdopts = xstrdup(""), *fstabname, *fstype=0, *storage_path=0;
      +	FILE *fstab;
      +	int i, opt, all = FALSE, rc = 0;
      +	struct mntent mtpair[2], *mtcur = mtpair;
      +
      +	/* parse long options, like --bind and --move.  Note that -o option
      +	 * and --option are synonymous.  Yes, this means --remount,rw works. */
      +
      +	for (i = opt = 0; i < argc; i++) {
      +		if (argv[i][0] == '-' && argv[i][1] == '-') {
      +			append_mount_options(&cmdopts,argv[i]+2);
      +		} else argv[opt++] = argv[i];
      +	}
      +	argc = opt;
      +
      +	// Parse remaining options
      +
      +	while ((opt = getopt(argc, argv, "o:t:rwavnf")) > 0) {
      +		switch (opt) {
      +			case 'o':
      +				append_mount_options(&cmdopts, optarg);
      +				break;
      +			case 't':
      +				fstype = optarg;
      +				break;
      +			case 'r':
      +				append_mount_options(&cmdopts, "ro");
      +				break;
      +			case 'w':
      +				append_mount_options(&cmdopts, "rw");
      +				break;
      +			case 'a':
      +				all = TRUE;
      +				break;
      +			case 'n':
      +				USE_FEATURE_MTAB_SUPPORT(useMtab = FALSE;)
      +				break;
      +			case 'f':
      +				USE_FEATURE_MTAB_SUPPORT(fakeIt = FALSE;)
      +				break;
      +			case 'v':
      +				break;		// ignore -v
      +			default:
      +				bb_show_usage();
      +		}
      +	}
      +
      +	// Three or more non-option arguments?  Die with a usage message.
      +
      +	if (optind-argc>2) bb_show_usage();
      +
      +	// If we have no arguments, show currently mounted filesystems
      +
      +	if (optind == argc) {
      +		if (!all) {
      +			FILE *mountTable = setmntent(bb_path_mtab_file, "r");
      +
      +			if(!mountTable) bb_error_msg_and_die("no %s",bb_path_mtab_file);
      +
      +			while (getmntent_r(mountTable,mtpair,bb_common_bufsiz1,
      +								sizeof(bb_common_bufsiz1)))
      +			{
      +				// Don't show rootfs.
      +				if (!strcmp(mtpair->mnt_fsname, "rootfs")) continue;
      +
      +				if (!fstype || !strcmp(mtpair->mnt_type, fstype))
      +					printf("%s on %s type %s (%s)\n", mtpair->mnt_fsname,
      +							mtpair->mnt_dir, mtpair->mnt_type,
      +							mtpair->mnt_opts);
      +			}
      +			if (ENABLE_FEATURE_CLEAN_UP) endmntent(mountTable);
      +			return EXIT_SUCCESS;
      +		}
      +	} else storage_path = bb_simplify_path(argv[optind]);
      +
      +	// When we have two arguments, the second is the directory and we can
      +	// skip looking at fstab entirely.  We can always abspath() the directory
      +	// argument when we get it.
      +
      +	if (optind+2 == argc) {
      +		mtpair->mnt_fsname = argv[optind];
      +		mtpair->mnt_dir = argv[optind+1];
      +		mtpair->mnt_type = fstype;
      +		mtpair->mnt_opts = cmdopts;
      +		rc = singlemount(mtpair, 0);
      +		goto clean_up;
      +	}
      +
      +	// If we have a shared subtree flag, don't worry about fstab or mtab.
      +	i = parse_mount_options(cmdopts,0);
      +	if (ENABLE_FEATURE_MOUNT_FLAGS &&
      +			(i & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE )))
      +	{
      +		rc = mount("", argv[optind], "", i, "");
      +		if (rc) bb_perror_msg_and_die("%s", argv[optind]);
      +		goto clean_up;
      +	}
      +	
      +	// Open either fstab or mtab
      +
      +	if (parse_mount_options(cmdopts,0) & MS_REMOUNT)
      +		fstabname = bb_path_mtab_file;
      +	else fstabname="/etc/fstab";
      +
      +	if (!(fstab=setmntent(fstabname,"r")))
      +		bb_perror_msg_and_die("cannot read %s",fstabname);
      +
      +	// Loop through entries until we find what we're looking for.
      +
      +	memset(mtpair,0,sizeof(mtpair));
      +	for (;;) {
      +		struct mntent *mtnext = mtpair + (mtcur==mtpair ? 1 : 0);
      +
      +		// Get next fstab entry
      +
      +		if (!getmntent_r(fstab, mtcur, bb_common_bufsiz1
      +					+ (mtcur==mtpair ? sizeof(bb_common_bufsiz1)/2 : 0),
      +				sizeof(bb_common_bufsiz1)/2))
      +		{
      +			// Were we looking for something specific?
      +
      +			if (optind != argc) {
      +
      +				// If we didn't find anything, complain.
      +
      +				if (!mtnext->mnt_fsname)
      +					bb_error_msg_and_die("can't find %s in %s",
      +						argv[optind], fstabname);
      +
      +				// Mount the last thing we found.
      +
      +				mtcur = mtnext;
      +				mtcur->mnt_opts = xstrdup(mtcur->mnt_opts);
      +				append_mount_options(&(mtcur->mnt_opts),cmdopts);
      +				rc = singlemount(mtcur, 0);
      +				free(mtcur->mnt_opts);
      +			}
      +			goto clean_up;
      +		}
      +
      +		/* If we're trying to mount something specific and this isn't it,
      +		 * skip it.  Note we must match both the exact text in fstab (ala
      +		 * "proc") or a full path from root */
      +
      +		if (optind != argc) {
      +
      +			// Is this what we're looking for?
      +
      +			if(strcmp(argv[optind],mtcur->mnt_fsname) &&
      +			   strcmp(storage_path,mtcur->mnt_fsname) &&
      +			   strcmp(argv[optind],mtcur->mnt_dir) &&
      +			   strcmp(storage_path,mtcur->mnt_dir)) continue;
      +
      +			// Remember this entry.  Something later may have overmounted
      +			// it, and we want the _last_ match.
      +
      +			mtcur = mtnext;
      +
      +		// If we're mounting all.
      +
      +		} else {
      +
      +			// Do we need to match a filesystem type?
      +			if (fstype && strcmp(mtcur->mnt_type,fstype)) continue;
      +
      +			// Skip noauto and swap anyway.
      +
      +			if (parse_mount_options(mtcur->mnt_opts,0)
      +				& (MOUNT_NOAUTO | MOUNT_SWAP)) continue;
      +
      +			// Mount this thing.
      +
      +			if (singlemount(mtcur, 1)) {
      +				/* Count number of failed mounts */
      +				rc++;
      +			}
      +		}
      +	}
      +	if (ENABLE_FEATURE_CLEAN_UP) endmntent(fstab);
      +
      +clean_up:
      +
      +	if (ENABLE_FEATURE_CLEAN_UP) {
      +		free(storage_path);
      +		free(cmdopts);
      +	}
      +
      +	return rc;
      +}
      
       ------------------------------------------------------------------------
      r16127 | landley | 2006-09-15 00:10:05 -0400 (Fri, 15 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/shell/hush.c
      
      Unbreak allbareconfig.
      
       ------------------------------------------------------------------------
      
      Index: shell/hush.c
      ===================================================================
      --- shell/hush.c	(revision 16126)
      +++ shell/hush.c	(revision 16127)
      @@ -2664,11 +2664,8 @@
       
       	/* Initialize some more globals to non-zero values */
       	set_cwd();
      -#ifdef CONFIG_FEATURE_COMMAND_EDITING
      -	cmdedit_set_initial_prompt();
      -#else
      -	PS1 = NULL;
      -#endif
      +    if (ENABLE_FEATURE_COMMAND_EDITING) cmdedit_set_initial_prompt();
      +	else PS1 = NULL;
       	PS2 = "> ";
       
       	/* initialize our shell local variables with the values
      
       ------------------------------------------------------------------------
      r16126 | landley | 2006-09-15 00:08:25 -0400 (Fri, 15 Sep 2006) | 16 lines
      Changed paths:
         M /trunk/busybox/networking/wget.c
      
      So, in the cornucopia of superfulous warning directives I didn't add to the
      tree, we have the warning about failed inlines (which with our inline
      limit set to zero means any usage of the "inline" keyword at all).  Note
      that setting the inline limit to zero, and using -Werror, both predated
      adding the warning about inlines to the tree.  So whatever checkin added
      that did nothing but break the tree.  But oh well.
      
      The second category of superfluous warnings is warning about functions with
      no previous declaration.  Apparently, if you add ALWAYS_INLINE to an empty
      function definition, it considers the sucker undeclared as far as the
      warning is concerned.  (I.E. it's a buggy warning.  I try not to ask the
      compiler to generate warnings it can't competently generate.)
      
      This is why I removed "inline" (unbreak allbareconfig), and couldn't replace it
      with "ALWAYS_INLINE" (still broke allbareconfig).
      
       ------------------------------------------------------------------------
      
      Index: networking/wget.c
      ===================================================================
      --- networking/wget.c	(revision 16125)
      +++ networking/wget.c	(revision 16126)
      @@ -36,7 +36,7 @@
       	STALLTIME = 5
       };
       #else
      -static inline void progressmeter(int flag) {}
      +static void progressmeter(int flag) {}
       #endif
       
       static void close_and_delete_outfile(FILE* output, char *fname_out, int do_continue)
      
       ------------------------------------------------------------------------
      r16125 | landley | 2006-09-15 00:01:03 -0400 (Fri, 15 Sep 2006) | 6 lines
      Changed paths:
         M /trunk/busybox/include/libbb.h
      
      Unbreak allbareconfig.
      
      We've had -Werror in the tree for quite a while, so adding #warning
      somewhat counterproductve way to make comments on the code that belong on the
      mailing list anyway.
      
       ------------------------------------------------------------------------
      
      Index: include/libbb.h
      ===================================================================
      --- include/libbb.h	(revision 16124)
      +++ include/libbb.h	(revision 16125)
      @@ -220,9 +220,6 @@
       extern int bb_printf(const char * __restrict format, ...)
       	__attribute__ ((format (printf, 1, 2)));
       
      -#if ENABLE_NITPICK
      -#warning rename to xferror_filename?
      -#endif
       extern void xferror(FILE *fp, const char *fn);
       extern void xferror_stdout(void);
       extern void xfflush_stdout(void);
      @@ -276,9 +273,6 @@
       extern long bb_xgetlarg10_sfx(const char *arg, const struct suffix_mult *suffixes);
       
       
      -#if ENABLE_NITPICK
      -#warning pitchable now?
      -#endif
       extern unsigned long bb_xparse_number(const char *numstr,
       		const struct suffix_mult *suffixes);
       
      @@ -340,9 +334,6 @@
       char *concat_subpath_file(const char *path, const char *filename);
       char *last_char_is(const char *s, int c);
       
      -#if ENABLE_NITPICK
      -#warning yuk!
      -#endif
       char *fgets_str(FILE *file, const char *terminating_string);
       
       extern int uncompress(int fd_in, int fd_out);
      @@ -356,9 +347,9 @@
       extern unsigned short bb_lookup_port(const char *port, const char *protocol, unsigned short default_port);
       extern void bb_lookup_host(struct sockaddr_in *s_in, const char *host);
       
      -#if ENABLE_NITPICK
      -#warning wrap this?
      -#endif
      +// This is declared here rather than #including  in order to avoid
      +// confusing the two versions of basename.  See the dirname/basename man page
      +// for details.
       char *dirname (char *path);
       
       int bb_make_directory (char *path, long mode, int flags);
      @@ -471,9 +462,6 @@
       #endif
       
       
      -#if ENABLE_NITPICK
      -#warning put these in .o files
      -#endif
       /* The following devices are the same on devfs and non-devfs systems.  */
       #define CURRENT_TTY "/dev/tty"
       #define CONSOLE_DEV "/dev/console"
      
       ------------------------------------------------------------------------
      r16124 | landley | 2006-09-14 15:52:07 -0400 (Thu, 14 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/libbb/xfuncs.c
      
      Strangely, using // in the comments I added was not a persistent accident.
      
       ------------------------------------------------------------------------
      
      Index: libbb/xfuncs.c
      ===================================================================
      --- libbb/xfuncs.c	(revision 16123)
      +++ libbb/xfuncs.c	(revision 16124)
      @@ -21,7 +21,7 @@
        * included after these prototypes in libbb.h, all is well.
        */
       #ifdef L_xmalloc
      -/* Die if we can't allocate size bytes of memory. */
      +// Die if we can't allocate size bytes of memory.
       void *xmalloc(size_t size)
       {
       	void *ptr = malloc(size);
      @@ -32,9 +32,9 @@
       #endif
       
       #ifdef L_xrealloc
      -/* Die if we can't resize previously allocated memory.  (This returns a pointer
      - * to the new memory, which may or may not be the same as the old memory.
      - * It'll copy the contents to a new chunk and free the old one if necessary.) */
      +// Die if we can't resize previously allocated memory.  (This returns a pointer
      +// to the new memory, which may or may not be the same as the old memory.
      +// It'll copy the contents to a new chunk and free the old one if necessary.)
       void *xrealloc(void *ptr, size_t size)
       {
       	ptr = realloc(ptr, size);
      @@ -47,7 +47,7 @@
       
       
       #ifdef L_xzalloc
      -/* Die if we can't allocate and zero size bytes of memory. */
      +// Die if we can't allocate and zero size bytes of memory.
       void *xzalloc(size_t size)
       {
       	void *ptr = xmalloc(size);
      @@ -57,7 +57,7 @@
       #endif
       
       #ifdef L_xstrdup
      -/* Die if we can't copy a string to freshly allocated memory. */
      +// Die if we can't copy a string to freshly allocated memory.
       char * xstrdup(const char *s)
       {
       	char *t;
      @@ -75,9 +75,8 @@
       #endif
       
       #ifdef L_xstrndup
      -/* Die if we can't allocate n+1 bytes (space for the null terminator) and copy
      - * the (possibly truncated to length n) string into it.
      - */
      +// Die if we can't allocate n+1 bytes (space for the null terminator) and copy
      +// the (possibly truncated to length n) string into it.
       char * xstrndup(const char *s, int n)
       {
       	char *t;
      @@ -92,9 +91,8 @@
       #endif
       
       #ifdef L_xfopen
      -/* Die if we can't open a file and return a FILE * to it.
      - * Notice we haven't got xfread(), This is for use with fscanf() and friends.
      - */
      +// Die if we can't open a file and return a FILE * to it.
      +// Notice we haven't got xfread(), This is for use with fscanf() and friends.
       FILE *xfopen(const char *path, const char *mode)
       {
       	FILE *fp;
      @@ -105,7 +103,7 @@
       #endif
       
       #ifdef L_xopen
      -/* Die if we can't open an existing file and return an fd. */
      +// Die if we can't open an existing file and return an fd.
       int xopen(const char *pathname, int flags)
       {
       	if (ENABLE_DEBUG && (flags & O_CREAT))
      @@ -116,7 +114,7 @@
       #endif
       
       #ifdef L_xopen3
      -/* Die if we can't open a new file and return an fd. */
      +// Die if we can't open a new file and return an fd.
       int xopen3(const char *pathname, int flags, int mode)
       {
       	int ret;
      @@ -130,7 +128,7 @@
       #endif
       
       #ifdef L_xread
      -/* Die with an error message if we can't read the entire buffer. */
      +// Die with an error message if we can't read the entire buffer.
       void xread(int fd, void *buf, size_t count)
       {
       	while (count) {
      @@ -145,7 +143,7 @@
       #endif
       
       #ifdef L_xwrite
      -/* Die with an error message if we can't write the entire buffer. */
      +// Die with an error message if we can't write the entire buffer.
       void xwrite(int fd, void *buf, size_t count)
       {
       	while (count) {
      @@ -160,7 +158,7 @@
       #endif
       
       #ifdef L_xlseek
      -/* Die with an error message if we can't lseek to the right spot. */
      +// Die with an error message if we can't lseek to the right spot.
       void xlseek(int fd, off_t offset, int whence)
       {
       	if (offset != lseek(fd, offset, whence)) bb_error_msg_and_die("lseek");
      @@ -168,7 +166,7 @@
       #endif
       
       #ifdef L_xread_char
      -/* Die with an error message if we can't read one character. */
      +// Die with an error message if we can't read one character.
       unsigned char xread_char(int fd)
       {
       	char tmp;
      @@ -180,7 +178,7 @@
       #endif
       
       #ifdef L_xferror
      -/* Die with supplied error message if this FILE * has ferror set. */
      +// Die with supplied error message if this FILE * has ferror set.
       void xferror(FILE *fp, const char *fn)
       {
       	if (ferror(fp)) {
      @@ -190,7 +188,7 @@
       #endif
       
       #ifdef L_xferror_stdout
      -/* Die with an error message if stdout has ferror set. */
      +// Die with an error message if stdout has ferror set.
       void xferror_stdout(void)
       {
       	xferror(stdout, bb_msg_standard_output);
      @@ -198,7 +196,7 @@
       #endif
       
       #ifdef L_xfflush_stdout
      -/* Die with an error message if we have trouble flushing stdout. */
      +// Die with an error message if we have trouble flushing stdout.
       void xfflush_stdout(void)
       {
       	if (fflush(stdout)) {
      @@ -208,25 +206,24 @@
       #endif
       
       #ifdef L_spawn
      -/* This does a fork/exec in one call, using vfork().  Return PID of new child,
      - * -1 for failure.  Runs argv[0], searching path if that has no / in it.
      - */
      +// This does a fork/exec in one call, using vfork().  Return PID of new child,
      +// -1 for failure.  Runs argv[0], searching path if that has no / in it.
       pid_t spawn(char **argv)
       {
       	static int failed;
       	pid_t pid;
       	void *app = ENABLE_FEATURE_SH_STANDALONE_SHELL ? find_applet_by_name(argv[0]) : 0;
       
      -	/* Be nice to nommu machines. */
      +	// Be nice to nommu machines.
       	failed = 0;
       	pid = vfork();
       	if (pid < 0) return pid;
       	if (!pid) {
       		execvp(app ? CONFIG_BUSYBOX_EXEC_PATH : *argv, argv);
       
      -		/* We're sharing a stack with blocked parent, let parent know we failed
      -		 * and then exit to unblock parent (but don't run atexit() stuff, which
      -		   would screw up parent.) */
      +		// We're sharing a stack with blocked parent, let parent know we failed
      +		// and then exit to unblock parent (but don't run atexit() stuff, which
      +		// would screw up parent.)
       
       		failed = -1;
       		_exit(0);
      @@ -236,7 +233,7 @@
       #endif
       
       #ifdef L_xspawn
      -/* Die with an error message if we can't spawn a child process. */
      +// Die with an error message if we can't spawn a child process.
       pid_t xspawn(char **argv)
       {
       	pid_t pid = spawn(argv);
      @@ -246,7 +243,7 @@
       #endif
       
       #ifdef L_wait4
      -/* Wait for the specified child PID to exit, returning child's error return. */
      +// Wait for the specified child PID to exit, returning child's error return.
       int wait4pid(int pid)
       {
       	int status;
      @@ -259,9 +256,9 @@
       #endif
       
       #ifdef L_itoa
      -/* Convert unsigned integer to ascii, writing into supplied buffer.  A
      - * truncated result is always null terminated (unless buflen is 0), and
      - * contains the first few digits of the result ala strncpy. */
      +// Convert unsigned integer to ascii, writing into supplied buffer.  A
      +// truncated result is always null terminated (unless buflen is 0), and
      +// contains the first few digits of the result ala strncpy.
       void utoa_to_buf(unsigned n, char *buf, unsigned buflen)
       {
       	int i, out = 0;
      @@ -279,7 +276,7 @@
       	}
       }
       
      -/* Convert signed integer to ascii, like utoa_to_buf() */
      +// Convert signed integer to ascii, like utoa_to_buf()
       void itoa_to_buf(int n, char *buf, unsigned buflen)
       {
       	if (buflen && n<0) {
      @@ -290,16 +287,16 @@
       	utoa_to_buf((unsigned)n, buf, buflen);
       }
       
      -/* The following two functions use a static buffer, so calling either one a
      - * second time will overwrite previous results.
      - *
      - * The largest 32 bit integer is -2 billion plus null terminator, or 12 bytes.
      - * Int should always be 32 bits on any remotely Unix-like system, see
      - * http://www.unix.org/whitepapers/64bit.html for the reasons why.
      -*/
      +// The following two functions use a static buffer, so calling either one a
      +// second time will overwrite previous results.
      +//
      +// The largest 32 bit integer is -2 billion plus null terminator, or 12 bytes.
      +// Int should always be 32 bits on any remotely Unix-like system, see
      +// http://www.unix.org/whitepapers/64bit.html for the reasons why.
      +
       static char local_buf[12];
       
      -/* Convert unsigned integer to ascii using a static buffer (returned). */
      +// Convert unsigned integer to ascii using a static buffer (returned).
       char *utoa(unsigned n)
       {
       	utoa_to_buf(n, local_buf, sizeof(local_buf));
      @@ -307,7 +304,7 @@
       	return local_buf;
       }
       
      -/* Convert signed integer to ascii using a static buffer (returned). */
      +// Convert signed integer to ascii using a static buffer (returned).
       char *itoa(int n)
       {
       	itoa_to_buf(n, local_buf, sizeof(local_buf));
      @@ -317,15 +314,15 @@
       #endif
       
       #ifdef L_setuid
      -/* Die with an error message if we can't set gid.  (Because resource limits may
      - * limit this user to a given number of processes, and if that fills up the
      - * setgid() will fail and we'll _still_be_root_, which is bad.) */
      +// Die with an error message if we can't set gid.  (Because resource limits may
      +// limit this user to a given number of processes, and if that fills up the
      +// setgid() will fail and we'll _still_be_root_, which is bad.)
       void xsetgid(gid_t gid)
       {
       	if (setgid(gid)) bb_error_msg_and_die("setgid");
       }
       
      -/* Die with an error message if we cant' set uid.  (See xsetgid() for why.) */
      +// Die with an error message if we cant' set uid.  (See xsetgid() for why.)
       void xsetuid(uid_t uid)
       {
       	if (setuid(uid)) bb_error_msg_and_die("setuid");
      @@ -333,31 +330,31 @@
       #endif
       
       #ifdef L_fdlength
      -/* Return how long the file at fd is, if there's any way to determine it. */
      +// Return how long the file at fd is, if there's any way to determine it.
       off_t fdlength(int fd)
       {
       	off_t bottom = 0, top = 0, pos;
       	long size;
       
      -	/* If the ioctl works for this, return it. */
      +	// If the ioctl works for this, return it.
       
       	if (ioctl(fd, BLKGETSIZE, &size) >= 0) return size*512;
       
      -	/* If not, do a binary search for the last location we can read.  (Some
      -	 * block devices don't do BLKGETSIZE right.) */
      +	// If not, do a binary search for the last location we can read.  (Some
      +	// block devices don't do BLKGETSIZE right.)
       
       	do {
       		char temp;
       
       		pos = bottom + (top - bottom) / 2;
       
      -		/* If we can read from the current location, it's bigger. */
      +		// If we can read from the current location, it's bigger.
       
       		if (lseek(fd, pos, 0)>=0 && safe_read(fd, &temp, 1)==1) {
       			if (bottom == top) bottom = top = (top+1) * 2;
       			else bottom = pos;
       
      -		/* If we can't, it's smaller. */
      +		// If we can't, it's smaller.
       
       		} else {
       			if (bottom == top) {
      @@ -373,8 +370,8 @@
       #endif
       
       #ifdef L_xasprintf
      -/* Die with an error message if we can't malloc() enough space and do an
      - * sprintf() into that space. */
      +// Die with an error message if we can't malloc() enough space and do an
      +// sprintf() into that space.
       char *xasprintf(const char *format, ...)
       {
       	va_list p;
      @@ -403,8 +400,8 @@
       #endif
       
       #ifdef L_xprint_and_close_file
      -/* Die with an error message if we can't copy an entire FILE * to stdout, then
      - * close that file. */
      +// Die with an error message if we can't copy an entire FILE * to stdout, then
      +// close that file.
       void xprint_and_close_file(FILE *file)
       {
       	// copyfd outputs error messages for us.
      @@ -416,7 +413,7 @@
       #endif
       
       #ifdef L_xchdir
      -/* Die if we can't chdir to a new path. */
      +// Die if we can't chdir to a new path.
       void xchdir(const char *path)
       {
       	if (chdir(path))
      @@ -425,7 +422,7 @@
       #endif
       
       #ifdef L_warn_opendir
      -/* Print a warning message if opendir() fails, but don't die. */
      +// Print a warning message if opendir() fails, but don't die.
       DIR *warn_opendir(const char *path)
       {
       	DIR *dp;
      @@ -439,7 +436,7 @@
       #endif
       
       #ifdef L_xopendir
      -/* Die with an error message if opendir() fails. */
      +// Die with an error message if opendir() fails.
       DIR *xopendir(const char *path)
       {
       	DIR *dp;
      @@ -452,7 +449,7 @@
       
       #ifdef L_xdaemon
       #ifndef BB_NOMMU
      -/* Die with an error message if we can't daemonize. */
      +// Die with an error message if we can't daemonize.
       void xdaemon(int nochdir, int noclose)
       {
       	if (daemon(nochdir, noclose)) bb_perror_msg_and_die("daemon");
      @@ -461,7 +458,7 @@
       #endif
       
       #ifdef L_xsocket
      -/* Die with an error message if we can't open a new socket. */
      +// Die with an error message if we can't open a new socket.
       int xsocket(int domain, int type, int protocol)
       {
       	int r = socket(domain, type, protocol);
      @@ -473,7 +470,7 @@
       #endif
       
       #ifdef L_xbind
      -/* Die with an error message if we can't bind a socket to an address. */
      +// Die with an error message if we can't bind a socket to an address.
       void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen)
       {
       	if (bind(sockfd, my_addr, addrlen)) bb_perror_msg_and_die("bind");
      @@ -481,7 +478,7 @@
       #endif
       
       #ifdef L_xlisten
      -/* Die with an error message if we can't listen for connections on a socket. */
      +// Die with an error message if we can't listen for connections on a socket.
       void xlisten(int s, int backlog)
       {
       	if (listen(s, backlog)) bb_perror_msg_and_die("listen");
      @@ -489,7 +486,7 @@
       #endif
       
       #ifdef L_xstat
      -/* xstat() - a stat() which dies on failure with meaningful error message */
      +// xstat() - a stat() which dies on failure with meaningful error message
       void xstat(char *name, struct stat *stat_buf)
       {
               if (stat(name, stat_buf))
      
       ------------------------------------------------------------------------
      r16123 | vda | 2006-09-14 13:03:18 -0400 (Thu, 14 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/loginutils/login.c
      
      login: eliminate forward decls and #ifdefs
      
       ------------------------------------------------------------------------
      
      Index: loginutils/login.c
      ===================================================================
      --- loginutils/login.c	(revision 16122)
      +++ loginutils/login.c	(revision 16123)
      @@ -15,13 +15,6 @@
       #include 
       #endif
       
      -/* import from utmp.c
      - * XXX: FIXME: provide empty bodies if ENABLE_FEATURE_UTMP == 0
      - */
      -static struct utmp utent;
      -static void read_or_build_utent(int);
      -static void write_utent(const char *);
      -
       enum {
       	TIMEOUT = 60,
       	EMPTY_USERNAME_COUNT = 10,
      @@ -29,17 +22,177 @@
       	TTYNAME_SIZE = 32,
       };
       
      -static void die_if_nologin_and_non_root(int amroot);
      +static char full_tty[TTYNAME_SIZE];
      +static char* short_tty = full_tty;
       
      +#if ENABLE_FEATURE_UTMP
      +/* vv  Taken from tinylogin utmp.c  vv */
      +/*
      + * read_or_build_utent - see if utmp file is correct for this process
      + *
      + *	System V is very picky about the contents of the utmp file
      + *	and requires that a slot for the current process exist.
      + *	The utmp file is scanned for an entry with the same process
      + *	ID.  If no entry exists the process exits with a message.
      + *
      + *	The "picky" flag is for network and other logins that may
      + *	use special flags.  It allows the pid checks to be overridden.
      + *	This means that getty should never invoke login with any
      + *	command line flags.
      + */
      +static struct utmp utent;
      +static void read_or_build_utent(int picky)
      +{
      +	struct utmp *ut;
      +	pid_t pid = getpid();
      +
      +	setutent();
      +
      +	/* First, try to find a valid utmp entry for this process.  */
      +	while ((ut = getutent()))
      +		if (ut->ut_pid == pid && ut->ut_line[0] && ut->ut_id[0] &&
      +		(ut->ut_type == LOGIN_PROCESS || ut->ut_type == USER_PROCESS))
      +			break;
      +
      +	/* If there is one, just use it, otherwise create a new one.  */
      +	if (ut) {
      +		utent = *ut;
      +	} else {
      +		if (picky)
      +			bb_error_msg_and_die("no utmp entry found");
      +
      +		memset(&utent, 0, sizeof(utent));
      +		utent.ut_type = LOGIN_PROCESS;
      +		utent.ut_pid = pid;
      +		strncpy(utent.ut_line, short_tty, sizeof(utent.ut_line));
      +		/* This one is only 4 chars wide. Try to fit something
      +		 * remotely meaningful by skipping "tty"... */
      +		strncpy(utent.ut_id, short_tty + 3, sizeof(utent.ut_id));
      +		strncpy(utent.ut_user, "LOGIN", sizeof(utent.ut_user));
      +		utent.ut_time = time(NULL);
      +	}
      +	if (!picky)	/* root login */
      +		memset(utent.ut_host, 0, sizeof(utent.ut_host));
      +}
      +
      +/*
      + * write_utent - put a USER_PROCESS entry in the utmp file
      + *
      + *	write_utent changes the type of the current utmp entry to
      + *	USER_PROCESS.  the wtmp file will be updated as well.
      + */
      +static void write_utent(const char *username)
      +{
      +	utent.ut_type = USER_PROCESS;
      +	strncpy(utent.ut_user, username, sizeof(utent.ut_user));
      +	utent.ut_time = time(NULL);
      +	/* other fields already filled in by read_or_build_utent above */
      +	setutent();
      +	pututline(&utent);
      +	endutent();
      +#if ENABLE_FEATURE_WTMP
      +	if (access(bb_path_wtmp_file, R_OK|W_OK) == -1) {
      +		close(creat(bb_path_wtmp_file, 0664));
      +	}
      +	updwtmp(bb_path_wtmp_file, &utent);
      +#endif
      +}
      +#else /* !CONFIG_FEATURE_UTMP */
      +static inline void read_or_build_utent(int) {}
      +static inline void write_utent(const char *) {}
      +#endif /* !CONFIG_FEATURE_UTMP */
      +
      +static void die_if_nologin_and_non_root(int amroot)
      +{
      +	FILE *fp;
      +	int c;
      +
      +	if (access(bb_path_nologin_file, F_OK))
      +		return;
      +
      +	fp = fopen(bb_path_nologin_file, "r");
      +	if (fp) {
      +		while ((c = getc(fp)) != EOF)
      +			putchar((c=='\n') ? '\r' : c);
      +		fflush(stdout);
      +		fclose(fp);
      +	} else
      +		puts("\r\nSystem closed for routine maintenance\r");
      +	if (!amroot)
      +		exit(1);
      +	puts("\r\n[Disconnect bypassed -- root login allowed.]\r");
      +}
      +
       #if ENABLE_FEATURE_SECURETTY
      -static int check_securetty(void);
      +static int check_securetty(void)
      +{
      +	FILE *fp;
      +	int i;
      +	char buf[BUFSIZ];
      +
      +	fp = fopen(bb_path_securetty_file, "r");
      +	if (!fp) {
      +		/* A missing securetty file is not an error. */
      +		return 1;
      +	}
      +	while (fgets(buf, sizeof(buf)-1, fp)) {
      +		for(i = strlen(buf)-1; i>=0; --i) {
      +			if (!isspace(buf[i]))
      +				break;
      +		}
      +		buf[++i] = '\0';
      +		if ((buf[0]=='\0') || (buf[0]=='#'))
      +			continue;
      +		if (strcmp(buf, short_tty) == 0) {
      +			fclose(fp);
      +			return 1;
      +		}
      +	}
      +	fclose(fp);
      +	return 0;
      +}
       #else
       static inline int check_securetty(void) { return 1; }
       #endif
       
      -static void get_username_or_die(char *buf, int size_buf);
      -static void motd(void);
      +static void get_username_or_die(char *buf, int size_buf)
      +{
      +	int c, cntdown;
      +	cntdown = EMPTY_USERNAME_COUNT;
      +prompt:
      +	/* skip whitespace */
      +	print_login_prompt();
      +	do {
      +		c = getchar();
      +		if (c == EOF) exit(1);
      +		if (c == '\n') {
      +			if (!--cntdown) exit(1);
      +			goto prompt;
      +		}
      +	} while (isspace(c));
       
      +	*buf++ = c;
      +	if (!fgets(buf, size_buf-2, stdin))
      +		exit(1);
      +	if (!strchr(buf, '\n'))
      +		exit(1);
      +	while (isgraph(*buf)) buf++;
      +	*buf = '\0';
      +}
      +
      +static void motd(void)
      +{
      +	FILE *fp;
      +	int c;
      +
      +	fp = fopen(bb_path_motd_file, "r");
      +	if (fp) {
      +		while ((c = getc(fp)) != EOF)
      +			putchar(c);
      +		fclose(fp);
      +	}
      +}
      +
       static void nonblock(int fd)
       {
       	fcntl(fd, F_SETFL, O_NONBLOCK | fcntl(fd, F_GETFL));
      @@ -56,11 +209,6 @@
       	exit(EXIT_SUCCESS);
       }
       
      -
      -static char full_tty[TTYNAME_SIZE];
      -static char* short_tty = full_tty;
      -
      -
       int login_main(int argc, char **argv)
       {
       	char fromhost[512];
      @@ -122,11 +270,7 @@
       			short_tty = full_tty + 5;
       	}
       
      -	if (ENABLE_FEATURE_UTMP) {
      -		read_or_build_utent(!amroot);
      -		if (amroot)
      -			memset(utent.ut_host, 0, sizeof(utent.ut_host));
      -	}
      +	read_or_build_utent(!amroot);
       
       	if (opt_host) {
       		if (ENABLE_FEATURE_UTMP)
      @@ -183,8 +327,7 @@
       	alarm(0);
       	die_if_nologin_and_non_root(pw->pw_uid == 0);
       
      -	if (ENABLE_FEATURE_UTMP)
      -		write_utent(username);
      +	write_utent(username);
       
       #ifdef CONFIG_SELINUX
       	if (is_selinux_enabled()) {
      @@ -255,171 +398,3 @@
       
       	return EXIT_FAILURE;
       }
      -
      -
      -static void get_username_or_die(char *buf, int size_buf)
      -{
      -	int c, cntdown;
      -	cntdown = EMPTY_USERNAME_COUNT;
      -prompt:
      -	/* skip whitespace */
      -	print_login_prompt();
      -	do {
      -		c = getchar();
      -		if (c == EOF) exit(1);
      -		if (c == '\n') {
      -			if (!--cntdown) exit(1);
      -			goto prompt;
      -		}
      -	} while (isspace(c));
      -
      -	*buf++ = c;
      -	if (!fgets(buf, size_buf-2, stdin))
      -		exit(1);
      -	if (!strchr(buf, '\n'))
      -		exit(1);
      -	while (isgraph(*buf)) buf++;
      -	*buf = '\0';
      -}
      -
      -
      -static void die_if_nologin_and_non_root(int amroot)
      -{
      -	FILE *fp;
      -	int c;
      -
      -	if (access(bb_path_nologin_file, F_OK))
      -		return;
      -
      -	fp = fopen(bb_path_nologin_file, "r");
      -	if (fp) {
      -		while ((c = getc(fp)) != EOF)
      -			putchar((c=='\n') ? '\r' : c);
      -		fflush(stdout);
      -		fclose(fp);
      -	} else
      -		puts("\r\nSystem closed for routine maintenance\r");
      -	if (!amroot)
      -		exit(1);
      -	puts("\r\n[Disconnect bypassed -- root login allowed.]\r");
      -}
      -
      -#if ENABLE_FEATURE_SECURETTY
      -
      -static int check_securetty(void)
      -{
      -	FILE *fp;
      -	int i;
      -	char buf[BUFSIZ];
      -
      -	fp = fopen(bb_path_securetty_file, "r");
      -	if (!fp) {
      -		/* A missing securetty file is not an error. */
      -		return 1;
      -	}
      -	while (fgets(buf, sizeof(buf)-1, fp)) {
      -		for(i = strlen(buf)-1; i>=0; --i) {
      -			if (!isspace(buf[i]))
      -				break;
      -		}
      -		buf[++i] = '\0';
      -		if ((buf[0]=='\0') || (buf[0]=='#'))
      -			continue;
      -		if (strcmp(buf, short_tty) == 0) {
      -			fclose(fp);
      -			return 1;
      -		}
      -	}
      -	fclose(fp);
      -	return 0;
      -}
      -
      -#endif
      -
      -static void motd(void)
      -{
      -	FILE *fp;
      -	int c;
      -
      -	fp = fopen(bb_path_motd_file, "r");
      -	if (fp) {
      -		while ((c = getc(fp)) != EOF)
      -			putchar(c);
      -		fclose(fp);
      -	}
      -}
      -
      -
      -#if ENABLE_FEATURE_UTMP
      -/* vv  Taken from tinylogin utmp.c  vv */
      -
      -/*
      - * read_or_build_utent - see if utmp file is correct for this process
      - *
      - *	System V is very picky about the contents of the utmp file
      - *	and requires that a slot for the current process exist.
      - *	The utmp file is scanned for an entry with the same process
      - *	ID.  If no entry exists the process exits with a message.
      - *
      - *	The "picky" flag is for network and other logins that may
      - *	use special flags.  It allows the pid checks to be overridden.
      - *	This means that getty should never invoke login with any
      - *	command line flags.
      - */
      -
      -static void read_or_build_utent(int picky)
      -{
      -	struct utmp *ut;
      -	pid_t pid = getpid();
      -
      -	setutent();
      -
      -	/* First, try to find a valid utmp entry for this process.  */
      -	while ((ut = getutent()))
      -		if (ut->ut_pid == pid && ut->ut_line[0] && ut->ut_id[0] &&
      -		(ut->ut_type == LOGIN_PROCESS || ut->ut_type == USER_PROCESS))
      -			break;
      -
      -	/* If there is one, just use it, otherwise create a new one.  */
      -	if (ut) {
      -		utent = *ut;
      -	} else {
      -		if (picky)
      -			bb_error_msg_and_die("no utmp entry found");
      -
      -		memset(&utent, 0, sizeof(utent));
      -		utent.ut_type = LOGIN_PROCESS;
      -		utent.ut_pid = pid;
      -		strncpy(utent.ut_line, short_tty, sizeof(utent.ut_line));
      -		/* This one is only 4 chars wide. Try to fit something
      -		 * remotely meaningful by skipping "tty"... */
      -		strncpy(utent.ut_id, short_tty + 3, sizeof(utent.ut_id));
      -		strncpy(utent.ut_user, "LOGIN", sizeof(utent.ut_user));
      -		utent.ut_time = time(NULL);
      -	}
      -}
      -
      -/*
      - * write_utent - put a USER_PROCESS entry in the utmp file
      - *
      - *	write_utent changes the type of the current utmp entry to
      - *	USER_PROCESS.  the wtmp file will be updated as well.
      - */
      -
      -static void write_utent(const char *username)
      -{
      -	utent.ut_type = USER_PROCESS;
      -	strncpy(utent.ut_user, username, sizeof(utent.ut_user));
      -	utent.ut_time = time(NULL);
      -	/* other fields already filled in by read_or_build_utent above */
      -	setutent();
      -	pututline(&utent);
      -	endutent();
      -#if ENABLE_FEATURE_WTMP
      -	if (access(bb_path_wtmp_file, R_OK|W_OK) == -1) {
      -		close(creat(bb_path_wtmp_file, 0664));
      -	}
      -	updwtmp(bb_path_wtmp_file, &utent);
      -#endif
      -}
      -#endif /* CONFIG_FEATURE_UTMP */
      
       ------------------------------------------------------------------------
      r16122 | vda | 2006-09-14 12:40:46 -0400 (Thu, 14 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/util-linux/umount.c
      
      umount: do not try to close FILE* which is NULL.
      
       ------------------------------------------------------------------------
      
      Index: util-linux/umount.c
      ===================================================================
      --- util-linux/umount.c	(revision 16121)
      +++ util-linux/umount.c	(revision 16122)
      @@ -59,15 +59,17 @@
       
       	if (!(fp = setmntent(bb_path_mtab_file, "r"))) {
       		if (opt & OPT_ALL)
      -			bb_error_msg_and_die("Cannot open %s", bb_path_mtab_file);
      -	} else while (getmntent_r(fp,&me,path,sizeof(path))) {
      -		m = xmalloc(sizeof(struct mtab_list));
      -		m->next = mtl;
      -		m->device = xstrdup(me.mnt_fsname);
      -		m->dir = xstrdup(me.mnt_dir);
      -		mtl = m;
      +			bb_error_msg_and_die("cannot open %s", bb_path_mtab_file);
      +	} else {
      +		while (getmntent_r(fp,&me,path,sizeof(path))) {
      +			m = xmalloc(sizeof(struct mtab_list));
      +			m->next = mtl;
      +			m->device = xstrdup(me.mnt_fsname);
      +			m->dir = xstrdup(me.mnt_dir);
      +			mtl = m;
      +		}
      +		endmntent(fp);
       	}
      -	endmntent(fp);
       
       	/* If we're not mounting all, we need at least one argument. */
       	if (!(opt & OPT_ALL)) {
      @@ -111,13 +113,13 @@
       		// If still can't umount, maybe remount read-only?
       		if (curstat && (opt & OPT_REMOUNT) && errno == EBUSY && m) {
       			curstat = mount(m->device, zapit, NULL, MS_REMOUNT|MS_RDONLY, NULL);
      -			bb_error_msg(curstat ? "Cannot remount %s read-only" :
      +			bb_error_msg(curstat ? "cannot remount %s read-only" :
       						 "%s busy - remounted read-only", m->device);
       		}
       
       		if (curstat) {
       			status = EXIT_FAILURE;
      -			bb_perror_msg("Couldn't umount %s", zapit);
      +			bb_perror_msg("cannot umount %s", zapit);
       		} else {
       			/* De-allocate the loop device.  This ioctl should be ignored on
       			 * any non-loop block devices. */
      @@ -143,7 +145,7 @@
       			free(mtl->device);
       			free(mtl->dir);
       			free(mtl);
      -			mtl=m;
      +			mtl = m;
       		}
       	}
       
      
       ------------------------------------------------------------------------
      r16121 | vda | 2006-09-14 12:09:27 -0400 (Thu, 14 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/util-linux/mount.c
      
      mount: -o remount should not add lines to /etc/mtab
      
       ------------------------------------------------------------------------
      
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16120)
      +++ util-linux/mount.c	(revision 16121)
      @@ -222,7 +222,7 @@
       	/* If the mount was successful, and we're maintaining an old-style
       	 * mtab file by hand, add the new entry to it now. */
       
      -	if(ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc) {
      +	if(ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc && !(vfsflags & MS_REMOUNT)) {
       		char dirbuf[PATH_MAX];
       		char srcbuf[PATH_MAX];
       		FILE *mountTable = setmntent(bb_path_mtab_file, "a+");
      
       ------------------------------------------------------------------------
      r16120 | vda | 2006-09-14 11:46:33 -0400 (Thu, 14 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/include/libbb.h
         M /trunk/busybox/util-linux/Makefile.in
         M /trunk/busybox/util-linux/mount.c
         D /trunk/busybox/util-linux/nfsmount.c
      
      mount: move code from nfsmount.c into mount.c
      
       ------------------------------------------------------------------------
      
      Index: include/libbb.h
      ===================================================================
      --- include/libbb.h	(revision 16119)
      +++ include/libbb.h	(revision 16120)
      @@ -303,9 +303,6 @@
       extern int vdprintf(int d, const char *format, va_list ap);
       #endif
       
      -int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts);
      -int nfsmount(struct mntent *mp, int vfsflags, char *filteropts);
      -
       /* Include our own copy of struct sysinfo to avoid binary compatibility
        * problems with Linux 2.4, which changed things.  Grumble, grumble. */
       struct sysinfo {
      Index: util-linux/Makefile.in
      ===================================================================
      --- util-linux/Makefile.in	(revision 16119)
      +++ util-linux/Makefile.in	(revision 16120)
      @@ -29,7 +29,6 @@
       UTILLINUX-$(CONFIG_MKSWAP)        +=mkswap.o
       UTILLINUX-$(CONFIG_MORE)          +=more.o
       UTILLINUX-$(CONFIG_MOUNT)         +=mount.o
      -UTILLINUX-$(CONFIG_FEATURE_MOUNT_NFS)	+=nfsmount.o
       UTILLINUX-$(CONFIG_PIVOT_ROOT)    +=pivot_root.o
       UTILLINUX-$(CONFIG_RDATE)         +=rdate.o
       UTILLINUX-$(CONFIG_READPROFILE)   +=readprofile.o
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16119)
      +++ util-linux/mount.c	(revision 16120)
      @@ -84,10 +84,10 @@
       	{"ro", MS_RDONLY},        // vfs flag
       	{"rw", ~MS_RDONLY},       // vfs flag
       	{"remount", MS_REMOUNT},  // action flag
      +};
       
      +static int nfsmount(struct mntent *mp, int vfsflags, char *filteropts);
       
      -};
      -
       /* Append mount options to string */
       static void append_mount_options(char **oldopts, char *newopts)
       {
      @@ -196,7 +196,7 @@
       #endif
       
       // Perform actual mount of specific filesystem at specific location.
      -int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
      +static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
       {
       	int rc;
       
      @@ -234,7 +234,7 @@
       		// Add vfs string flags
       
       		for(i=0; mount_options[i].flags != MS_REMOUNT; i++)
      -			if (mount_options[i].flags > 0 && (mount_options[i].flags&vfsflags))
      +			if (mount_options[i].flags > 0 && (mount_options[i].flags & vfsflags))
       				append_mount_options(&(mp->mnt_opts), mount_options[i].name);
       
       		// Remove trailing / (if any) from directory we mounted on
      @@ -260,8 +260,8 @@
       				mp->mnt_fsname = srcbuf;
       			}
       			mp->mnt_type = "none";
      -			mp->mnt_freq = mp->mnt_passno = 0;
       		}
      +		mp->mnt_freq = mp->mnt_passno = 0;
       
       		// Write and close.
       
      @@ -613,3 +613,1016 @@
       
       	return rc;
       }
      +
      +
      +#if ENABLE_FEATURE_MOUNT_NFS
      +
      +/*
      + * Linux NFS mount
      + * Copyright (C) 1993 Rick Sladkey 
      + *
      + * Licensed under GPLv2, see file LICENSE in this tarball for details.
      + *
      + * Wed Feb  8 12:51:48 1995, biro@yggdrasil.com (Ross Biro): allow all port
      + * numbers to be specified on the command line.
      + *
      + * Fri, 8 Mar 1996 18:01:39, Swen Thuemmler :
      + * Omit the call to connect() for Linux version 1.3.11 or later.
      + *
      + * Wed Oct  1 23:55:28 1997: Dick Streefland 
      + * Implemented the "bg", "fg" and "retry" mount options for NFS.
      + *
      + * 1999-02-22 Arkadiusz Mi¶kiewicz 
      + * - added Native Language Support
      + *
      + * Modified by Olaf Kirch and Trond Myklebust for new NFS code,
      + * plus NFSv3 stuff.
      + */
      +
      +#include 
      +#include 
      +#undef TRUE
      +#undef FALSE
      +#include 
      +#include 
      +#include 
      +
      +/* This is just a warning of a common mistake.  Possibly this should be a
      + * uclibc faq entry rather than in busybox... */
      +#if ENABLE_FEATURE_MOUNT_NFS && defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__)
      +#error "You need to build uClibc with UCLIBC_HAS_RPC for NFS support."
      +#endif
      +
      +#define MOUNTPORT 635
      +#define MNTPATHLEN 1024
      +#define MNTNAMLEN 255
      +#define FHSIZE 32
      +#define FHSIZE3 64
      +
      +typedef char fhandle[FHSIZE];
      +
      +typedef struct {
      +	unsigned int fhandle3_len;
      +	char *fhandle3_val;
      +} fhandle3;
      +
      +enum mountstat3 {
      +	MNT_OK = 0,
      +	MNT3ERR_PERM = 1,
      +	MNT3ERR_NOENT = 2,
      +	MNT3ERR_IO = 5,
      +	MNT3ERR_ACCES = 13,
      +	MNT3ERR_NOTDIR = 20,
      +	MNT3ERR_INVAL = 22,
      +	MNT3ERR_NAMETOOLONG = 63,
      +	MNT3ERR_NOTSUPP = 10004,
      +	MNT3ERR_SERVERFAULT = 10006,
      +};
      +typedef enum mountstat3 mountstat3;
      +
      +struct fhstatus {
      +	unsigned int fhs_status;
      +	union {
      +		fhandle fhs_fhandle;
      +	} fhstatus_u;
      +};
      +typedef struct fhstatus fhstatus;
      +
      +struct mountres3_ok {
      +	fhandle3 fhandle;
      +	struct {
      +		unsigned int auth_flavours_len;
      +		char *auth_flavours_val;
      +	} auth_flavours;
      +};
      +typedef struct mountres3_ok mountres3_ok;
      +
      +struct mountres3 {
      +	mountstat3 fhs_status;
      +	union {
      +		mountres3_ok mountinfo;
      +	} mountres3_u;
      +};
      +typedef struct mountres3 mountres3;
      +
      +typedef char *dirpath;
      +
      +typedef char *name;
      +
      +typedef struct mountbody *mountlist;
      +
      +struct mountbody {
      +	name ml_hostname;
      +	dirpath ml_directory;
      +	mountlist ml_next;
      +};
      +typedef struct mountbody mountbody;
      +
      +typedef struct groupnode *groups;
      +
      +struct groupnode {
      +	name gr_name;
      +	groups gr_next;
      +};
      +typedef struct groupnode groupnode;
      +
      +typedef struct exportnode *exports;
      +
      +struct exportnode {
      +	dirpath ex_dir;
      +	groups ex_groups;
      +	exports ex_next;
      +};
      +typedef struct exportnode exportnode;
      +
      +struct ppathcnf {
      +	int pc_link_max;
      +	short pc_max_canon;
      +	short pc_max_input;
      +	short pc_name_max;
      +	short pc_path_max;
      +	short pc_pipe_buf;
      +	u_char pc_vdisable;
      +	char pc_xxx;
      +	short pc_mask[2];
      +};
      +typedef struct ppathcnf ppathcnf;
      +
      +#define MOUNTPROG 100005
      +#define MOUNTVERS 1
      +
      +#define MOUNTPROC_NULL 0
      +#define MOUNTPROC_MNT 1
      +#define MOUNTPROC_DUMP 2
      +#define MOUNTPROC_UMNT 3
      +#define MOUNTPROC_UMNTALL 4
      +#define MOUNTPROC_EXPORT 5
      +#define MOUNTPROC_EXPORTALL 6
      +
      +#define MOUNTVERS_POSIX 2
      +
      +#define MOUNTPROC_PATHCONF 7
      +
      +#define MOUNT_V3 3
      +
      +#define MOUNTPROC3_NULL 0
      +#define MOUNTPROC3_MNT 1
      +#define MOUNTPROC3_DUMP 2
      +#define MOUNTPROC3_UMNT 3
      +#define MOUNTPROC3_UMNTALL 4
      +#define MOUNTPROC3_EXPORT 5
      +
      +enum {
      +#ifndef NFS_FHSIZE
      +	NFS_FHSIZE = 32,
      +#endif
      +#ifndef NFS_PORT
      +	NFS_PORT = 2049
      +#endif
      +};
      +
      +
      +/*
      + * We want to be able to compile mount on old kernels in such a way
      + * that the binary will work well on more recent kernels.
      + * Thus, if necessary we teach nfsmount.c the structure of new fields
      + * that will come later.
      + *
      + * Moreover, the new kernel includes conflict with glibc includes
      + * so it is easiest to ignore the kernel altogether (at compile time).
      + */
      +
      +struct nfs2_fh {
      +	char                    data[32];
      +};
      +struct nfs3_fh {
      +	unsigned short          size;
      +	unsigned char           data[64];
      +};
      +
      +struct nfs_mount_data {
      +	int		version;		/* 1 */
      +	int		fd;			/* 1 */
      +	struct nfs2_fh	old_root;		/* 1 */
      +	int		flags;			/* 1 */
      +	int		rsize;			/* 1 */
      +	int		wsize;			/* 1 */
      +	int		timeo;			/* 1 */
      +	int		retrans;		/* 1 */
      +	int		acregmin;		/* 1 */
      +	int		acregmax;		/* 1 */
      +	int		acdirmin;		/* 1 */
      +	int		acdirmax;		/* 1 */
      +	struct sockaddr_in addr;		/* 1 */
      +	char		hostname[256];		/* 1 */
      +	int		namlen;			/* 2 */
      +	unsigned int	bsize;			/* 3 */
      +	struct nfs3_fh	root;			/* 4 */
      +};
      +
      +/* bits in the flags field */
      +enum {
      +	NFS_MOUNT_SOFT = 0x0001,	/* 1 */
      +	NFS_MOUNT_INTR = 0x0002,	/* 1 */
      +	NFS_MOUNT_SECURE = 0x0004,	/* 1 */
      +	NFS_MOUNT_POSIX = 0x0008,	/* 1 */
      +	NFS_MOUNT_NOCTO = 0x0010,	/* 1 */
      +	NFS_MOUNT_NOAC = 0x0020,	/* 1 */
      +	NFS_MOUNT_TCP = 0x0040,		/* 2 */
      +	NFS_MOUNT_VER3 = 0x0080,	/* 3 */
      +	NFS_MOUNT_KERBEROS = 0x0100,	/* 3 */
      +	NFS_MOUNT_NONLM = 0x0200	/* 3 */
      +};
      +
      +
      +/*
      + * We need to translate between nfs status return values and
      + * the local errno values which may not be the same.
      + *
      + * Andreas Schwab : change errno:
      + * "after #include  the symbol errno is reserved for any use,
      + *  it cannot even be used as a struct tag or field name".
      + */
      +
      +#ifndef EDQUOT
      +#define EDQUOT	ENOSPC
      +#endif
      +
      +// Convert each NFSERR_BLAH into EBLAH
      +
      +static const struct {
      +	int stat;
      +	int errnum;
      +} nfs_errtbl[] = {
      +	{0,0}, {1,EPERM}, {2,ENOENT}, {5,EIO}, {6,ENXIO}, {13,EACCES}, {17,EEXIST},
      +	{19,ENODEV}, {20,ENOTDIR}, {21,EISDIR}, {22,EINVAL}, {27,EFBIG},
      +	{28,ENOSPC}, {30,EROFS}, {63,ENAMETOOLONG}, {66,ENOTEMPTY}, {69,EDQUOT},
      +	{70,ESTALE}, {71,EREMOTE}, {-1,EIO}
      +};
      +
      +static char *nfs_strerror(int status)
      +{
      +	int i;
      +	static char buf[256];
      +
      +	for (i = 0; nfs_errtbl[i].stat != -1; i++) {
      +		if (nfs_errtbl[i].stat == status)
      +			return strerror(nfs_errtbl[i].errnum);
      +	}
      +	sprintf(buf, "unknown nfs status return value: %d", status);
      +	return buf;
      +}
      +
      +static bool_t xdr_fhandle(XDR *xdrs, fhandle objp)
      +{
      +	if (!xdr_opaque(xdrs, objp, FHSIZE))
      +		 return FALSE;
      +	return TRUE;
      +}
      +
      +static bool_t xdr_fhstatus(XDR *xdrs, fhstatus *objp)
      +{
      +	if (!xdr_u_int(xdrs, &objp->fhs_status))
      +		 return FALSE;
      +	switch (objp->fhs_status) {
      +	case 0:
      +		if (!xdr_fhandle(xdrs, objp->fhstatus_u.fhs_fhandle))
      +			 return FALSE;
      +		break;
      +	default:
      +		break;
      +	}
      +	return TRUE;
      +}
      +
      +static bool_t xdr_dirpath(XDR *xdrs, dirpath *objp)
      +{
      +	if (!xdr_string(xdrs, objp, MNTPATHLEN))
      +		 return FALSE;
      +	return TRUE;
      +}
      +
      +static bool_t xdr_fhandle3(XDR *xdrs, fhandle3 *objp)
      +{
      +	if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val, (unsigned int *) &objp->fhandle3_len, FHSIZE3))
      +		 return FALSE;
      +	return TRUE;
      +}
      +
      +static bool_t xdr_mountres3_ok(XDR *xdrs, mountres3_ok *objp)
      +{
      +	if (!xdr_fhandle3(xdrs, &objp->fhandle))
      +		return FALSE;
      +	if (!xdr_array(xdrs, &(objp->auth_flavours.auth_flavours_val), &(objp->auth_flavours.auth_flavours_len), ~0,
      +				sizeof (int), (xdrproc_t) xdr_int))
      +		return FALSE;
      +	return TRUE;
      +}
      +
      +static bool_t xdr_mountstat3(XDR *xdrs, mountstat3 *objp)
      +{
      +	if (!xdr_enum(xdrs, (enum_t *) objp))
      +		 return FALSE;
      +	return TRUE;
      +}
      +
      +static bool_t xdr_mountres3(XDR *xdrs, mountres3 *objp)
      +{
      +	if (!xdr_mountstat3(xdrs, &objp->fhs_status))
      +		return FALSE;
      +	switch (objp->fhs_status) {
      +	case MNT_OK:
      +		if (!xdr_mountres3_ok(xdrs, &objp->mountres3_u.mountinfo))
      +			 return FALSE;
      +		break;
      +	default:
      +		break;
      +	}
      +	return TRUE;
      +}
      +
      +#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
      +
      +/*
      + * nfs_mount_version according to the sources seen at compile time.
      + */
      +static int nfs_mount_version;
      +static int kernel_version;
      +
      +/*
      + * Unfortunately, the kernel prints annoying console messages
      + * in case of an unexpected nfs mount version (instead of
      + * just returning some error).  Therefore we'll have to try
      + * and figure out what version the kernel expects.
      + *
      + * Variables:
      + *	KERNEL_NFS_MOUNT_VERSION: kernel sources at compile time
      + *	NFS_MOUNT_VERSION: these nfsmount sources at compile time
      + *	nfs_mount_version: version this source and running kernel can handle
      + */
      +static void
      +find_kernel_nfs_mount_version(void)
      +{
      +	if (kernel_version)
      +		return;
      +
      +	nfs_mount_version = 4; /* default */
      +
      +	kernel_version = get_linux_version_code();
      +	if (kernel_version) {
      +		if (kernel_version < KERNEL_VERSION(2,1,32))
      +			nfs_mount_version = 1;
      +		else if (kernel_version < KERNEL_VERSION(2,2,18) ||
      +				(kernel_version >= KERNEL_VERSION(2,3,0) &&
      +				 kernel_version < KERNEL_VERSION(2,3,99)))
      +			nfs_mount_version = 3;
      +		/* else v4 since 2.3.99pre4 */
      +	}
      +}
      +
      +static struct pmap *
      +get_mountport(struct sockaddr_in *server_addr,
      +	long unsigned prog,
      +	long unsigned version,
      +	long unsigned proto,
      +	long unsigned port)
      +{
      +	struct pmaplist *pmap;
      +	static struct pmap p = {0, 0, 0, 0};
      +
      +	server_addr->sin_port = PMAPPORT;
      +	pmap = pmap_getmaps(server_addr);
      +
      +	if (version > MAX_NFSPROT)
      +		version = MAX_NFSPROT;
      +	if (!prog)
      +		prog = MOUNTPROG;
      +	p.pm_prog = prog;
      +	p.pm_vers = version;
      +	p.pm_prot = proto;
      +	p.pm_port = port;
      +	
      +	while (pmap) {
      +		if (pmap->pml_map.pm_prog != prog)
      +			goto next;
      +		if (!version && p.pm_vers > pmap->pml_map.pm_vers)
      +			goto next;
      +		if (version > 2 && pmap->pml_map.pm_vers != version)
      +			goto next;
      +		if (version && version <= 2 && pmap->pml_map.pm_vers > 2)
      +			goto next;
      +		if (pmap->pml_map.pm_vers > MAX_NFSPROT ||
      +		    (proto && p.pm_prot && pmap->pml_map.pm_prot != proto) ||
      +		    (port && pmap->pml_map.pm_port != port))
      +			goto next;
      +		memcpy(&p, &pmap->pml_map, sizeof(p));
      +next:
      +		pmap = pmap->pml_next;
      +	}
      +	if (!p.pm_vers)
      +		p.pm_vers = MOUNTVERS;
      +	if (!p.pm_port)
      +		p.pm_port = MOUNTPORT;
      +	if (!p.pm_prot)
      +		p.pm_prot = IPPROTO_TCP;
      +	return &p;
      +}
      +
      +static int daemonize(void)
      +{
      +	int fd;
      +	int pid = fork();
      +	if (pid < 0) /* error */
      +		return -errno;
      +	if (pid > 0) /* parent */
      +		return 0;
      +	/* child */
      +	fd = xopen(bb_dev_null, O_RDWR);
      +	dup2(fd, 0);
      +	dup2(fd, 1);
      +	dup2(fd, 2);
      +	if (fd > 2) close(fd);
      +	setsid();
      +	openlog(bb_applet_name, LOG_PID, LOG_DAEMON);
      +	logmode = LOGMODE_SYSLOG;
      +	return 1;
      +}
      +
      +// TODO
      +static inline int we_saw_this_host_before(const char *hostname)
      +{
      +	return 0;
      +}
      +
      +/* RPC strerror analogs are terminally idiotic:
      + * *mandatory* prefix and \n at end.
      + * This hopefully helps. Usage:
      + * error_msg_rpc(clnt_*error*(" ")) */
      +static void error_msg_rpc(const char *msg)
      +{
      +	size_t len;
      +	while (msg[0] == ' ' || msg[0] == ':') msg++;
      +	len = strlen(msg);
      +	while (len && msg[len-1] == '\n') len--;
      +	bb_error_msg("%.*s", len, msg);
      +}
      +
      +static int nfsmount(struct mntent *mp, int vfsflags, char *filteropts)
      +{
      +	CLIENT *mclient;
      +	char *hostname;
      +	char *pathname;
      +	char *mounthost;
      +	struct nfs_mount_data data;
      +	char *opt;
      +	struct hostent *hp;
      +	struct sockaddr_in server_addr;
      +	struct sockaddr_in mount_server_addr;
      +	int msock, fsock;
      +	union {
      +		struct fhstatus nfsv2;
      +		struct mountres3 nfsv3;
      +	} status;
      +	int daemonized;
      +	char *s;
      +	int port;
      +	int mountport;
      +	int proto;
      +	int bg;
      +	int soft;
      +	int intr;
      +	int posix;
      +	int nocto;
      +	int noac;
      +	int nolock;
      +	int retry;
      +	int tcp;
      +	int mountprog;
      +	int mountvers;
      +	int nfsprog;
      +	int nfsvers;
      +	int retval;
      +
      +	find_kernel_nfs_mount_version();
      +
      +	daemonized = 0;
      +	mounthost = NULL;
      +	retval = ETIMEDOUT;
      +	msock = fsock = -1;
      +	mclient = NULL;
      +
      +	/* NB: hostname, mounthost, filteropts must be free()d prior to return */
      +
      +	filteropts = xstrdup(filteropts); /* going to trash it later... */
      +
      +	hostname = xstrdup(mp->mnt_fsname);
      +	/* mount_main() guarantees that ':' is there */
      +	s = strchr(hostname, ':');
      +	pathname = s + 1;
      +	*s = '\0';
      +	/* Ignore all but first hostname in replicated mounts
      +	   until they can be fully supported. (mack@sgi.com) */
      +	s = strchr(hostname, ',');
      +	if (s) {
      +		*s = '\0';
      +		bb_error_msg("warning: multiple hostnames not supported");
      +	}
      +
      +	server_addr.sin_family = AF_INET;
      +	if (!inet_aton(hostname, &server_addr.sin_addr)) {
      +		hp = gethostbyname(hostname);
      +		if (hp == NULL) {
      +			bb_herror_msg("%s", hostname);
      +			goto fail;
      +		}
      +		if (hp->h_length > sizeof(struct in_addr)) {
      +			bb_error_msg("got bad hp->h_length");
      +			hp->h_length = sizeof(struct in_addr);
      +		}
      +		memcpy(&server_addr.sin_addr,
      +				hp->h_addr, hp->h_length);
      +	}
      +
      +	memcpy(&mount_server_addr, &server_addr, sizeof(mount_server_addr));
      +
      +	/* add IP address to mtab options for use when unmounting */
      +
      +	if (!mp->mnt_opts) { /* TODO: actually mp->mnt_opts is never NULL */
      +		mp->mnt_opts = xasprintf("addr=%s", inet_ntoa(server_addr.sin_addr));
      +	} else {
      +		char *tmp = xasprintf("%s%saddr=%s", mp->mnt_opts,
      +					mp->mnt_opts[0] ? "," : "",
      +					inet_ntoa(server_addr.sin_addr));
      +		free(mp->mnt_opts);
      +		mp->mnt_opts = tmp;
      +	}
      +
      +	/* Set default options.
      +	 * rsize/wsize (and bsize, for ver >= 3) are left 0 in order to
      +	 * let the kernel decide.
      +	 * timeo is filled in after we know whether it'll be TCP or UDP. */
      +	memset(&data, 0, sizeof(data));
      +	data.retrans	= 3;
      +	data.acregmin	= 3;
      +	data.acregmax	= 60;
      +	data.acdirmin	= 30;
      +	data.acdirmax	= 60;
      +	data.namlen	= NAME_MAX;
      +
      +	bg = 0;
      +	soft = 0;
      +	intr = 0;
      +	posix = 0;
      +	nocto = 0;
      +	nolock = 0;
      +	noac = 0;
      +	retry = 10000;		/* 10000 minutes ~ 1 week */
      +	tcp = 0;
      +
      +	mountprog = MOUNTPROG;
      +	mountvers = 0;
      +	port = 0;
      +	mountport = 0;
      +	nfsprog = 100003;
      +	nfsvers = 0;
      +
      +	/* parse options */
      +
      +	for (opt = strtok(filteropts, ","); opt; opt = strtok(NULL, ",")) {
      +		char *opteq = strchr(opt, '=');
      +		if (opteq) {
      +			int val = atoi(opteq + 1);
      +			*opteq = '\0';
      +			if (!strcmp(opt, "rsize"))
      +				data.rsize = val;
      +			else if (!strcmp(opt, "wsize"))
      +				data.wsize = val;
      +			else if (!strcmp(opt, "timeo"))
      +				data.timeo = val;
      +			else if (!strcmp(opt, "retrans"))
      +				data.retrans = val;
      +			else if (!strcmp(opt, "acregmin"))
      +				data.acregmin = val;
      +			else if (!strcmp(opt, "acregmax"))
      +				data.acregmax = val;
      +			else if (!strcmp(opt, "acdirmin"))
      +				data.acdirmin = val;
      +			else if (!strcmp(opt, "acdirmax"))
      +				data.acdirmax = val;
      +			else if (!strcmp(opt, "actimeo")) {
      +				data.acregmin = val;
      +				data.acregmax = val;
      +				data.acdirmin = val;
      +				data.acdirmax = val;
      +			}
      +			else if (!strcmp(opt, "retry"))
      +				retry = val;
      +			else if (!strcmp(opt, "port"))
      +				port = val;
      +			else if (!strcmp(opt, "mountport"))
      +				mountport = val;
      +			else if (!strcmp(opt, "mounthost"))
      +				mounthost = xstrndup(opteq+1,
      +						  strcspn(opteq+1," \t\n\r,"));
      +			else if (!strcmp(opt, "mountprog"))
      +				mountprog = val;
      +			else if (!strcmp(opt, "mountvers"))
      +				mountvers = val;
      +			else if (!strcmp(opt, "nfsprog"))
      +				nfsprog = val;
      +			else if (!strcmp(opt, "nfsvers") ||
      +				 !strcmp(opt, "vers"))
      +				nfsvers = val;
      +			else if (!strcmp(opt, "proto")) {
      +				if (!strncmp(opteq+1, "tcp", 3))
      +					tcp = 1;
      +				else if (!strncmp(opteq+1, "udp", 3))
      +					tcp = 0;
      +				else
      +					bb_error_msg("warning: unrecognized proto= option");
      +			} else if (!strcmp(opt, "namlen")) {
      +				if (nfs_mount_version >= 2)
      +					data.namlen = val;
      +				else
      +					bb_error_msg("warning: option namlen is not supported\n");
      +			} else if (!strcmp(opt, "addr"))
      +				/* ignore */;
      +			else {
      +				bb_error_msg("unknown nfs mount parameter: %s=%d", opt, val);
      +				goto fail;
      +			}
      +		}
      +		else {
      +			int val = 1;
      +			if (!strncmp(opt, "no", 2)) {
      +				val = 0;
      +				opt += 2;
      +			}
      +			if (!strcmp(opt, "bg"))
      +				bg = val;
      +			else if (!strcmp(opt, "fg"))
      +				bg = !val;
      +			else if (!strcmp(opt, "soft"))
      +				soft = val;
      +			else if (!strcmp(opt, "hard"))
      +				soft = !val;
      +			else if (!strcmp(opt, "intr"))
      +				intr = val;
      +			else if (!strcmp(opt, "posix"))
      +				posix = val;
      +			else if (!strcmp(opt, "cto"))
      +				nocto = !val;
      +			else if (!strcmp(opt, "ac"))
      +				noac = !val;
      +			else if (!strcmp(opt, "tcp"))
      +				tcp = val;
      +			else if (!strcmp(opt, "udp"))
      +				tcp = !val;
      +			else if (!strcmp(opt, "lock")) {
      +				if (nfs_mount_version >= 3)
      +					nolock = !val;
      +				else
      +					bb_error_msg("warning: option nolock is not supported");
      +			} else {
      +				bb_error_msg("unknown nfs mount option: %s%s", val ? "" : "no", opt);
      +				goto fail;
      +			}
      +		}
      +	}
      +	proto = (tcp) ? IPPROTO_TCP : IPPROTO_UDP;
      +
      +	data.flags = (soft ? NFS_MOUNT_SOFT : 0)
      +		| (intr ? NFS_MOUNT_INTR : 0)
      +		| (posix ? NFS_MOUNT_POSIX : 0)
      +		| (nocto ? NFS_MOUNT_NOCTO : 0)
      +		| (noac ? NFS_MOUNT_NOAC : 0);
      +	if (nfs_mount_version >= 2)
      +		data.flags |= (tcp ? NFS_MOUNT_TCP : 0);
      +	if (nfs_mount_version >= 3)
      +		data.flags |= (nolock ? NFS_MOUNT_NONLM : 0);
      +	if (nfsvers > MAX_NFSPROT || mountvers > MAX_NFSPROT) {
      +		bb_error_msg("NFSv%d not supported", nfsvers);
      +		goto fail;
      +	}
      +	if (nfsvers && !mountvers)
      +		mountvers = (nfsvers < 3) ? 1 : nfsvers;
      +	if (nfsvers && nfsvers < mountvers) {
      +		mountvers = nfsvers;
      +	}
      +
      +	/* Adjust options if none specified */
      +	if (!data.timeo)
      +		data.timeo = tcp ? 70 : 7;
      +
      +#ifdef NFS_MOUNT_DEBUG
      +	printf("rsize = %d, wsize = %d, timeo = %d, retrans = %d\n",
      +		data.rsize, data.wsize, data.timeo, data.retrans);
      +	printf("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)\n",
      +		data.acregmin, data.acregmax, data.acdirmin, data.acdirmax);
      +	printf("port = %d, bg = %d, retry = %d, flags = %.8x\n",
      +		port, bg, retry, data.flags);
      +	printf("mountprog = %d, mountvers = %d, nfsprog = %d, nfsvers = %d\n",
      +		mountprog, mountvers, nfsprog, nfsvers);
      +	printf("soft = %d, intr = %d, posix = %d, nocto = %d, noac = %d\n",
      +		(data.flags & NFS_MOUNT_SOFT) != 0,
      +		(data.flags & NFS_MOUNT_INTR) != 0,
      +		(data.flags & NFS_MOUNT_POSIX) != 0,
      +		(data.flags & NFS_MOUNT_NOCTO) != 0,
      +		(data.flags & NFS_MOUNT_NOAC) != 0);
      +	printf("tcp = %d\n",
      +		(data.flags & NFS_MOUNT_TCP) != 0);
      +#endif
      +
      +	data.version = nfs_mount_version;
      +
      +	if (vfsflags & MS_REMOUNT)
      +		goto do_mount;
      +
      +	/*
      +	 * If the previous mount operation on the same host was
      +	 * backgrounded, and the "bg" for this mount is also set,
      +	 * give up immediately, to avoid the initial timeout.
      +	 */
      +	if (bg && we_saw_this_host_before(hostname)) {
      +		daemonized = daemonize(); /* parent or error */
      +		if (daemonized <= 0) { /* parent or error */
      +			retval = -daemonized;
      +			goto ret;
      +		}
      +	}
      +
      +	/* create mount daemon client */
      +	/* See if the nfs host = mount host. */
      +	if (mounthost) {
      +		if (mounthost[0] >= '0' && mounthost[0] <= '9') {
      +			mount_server_addr.sin_family = AF_INET;
      +			mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
      +		} else {
      +			hp = gethostbyname(mounthost);
      +			if (hp == NULL) {
      +				bb_herror_msg("%s", mounthost);
      +				goto fail;
      +			} else {
      +				if (hp->h_length > sizeof(struct in_addr)) {
      +					bb_error_msg("got bad hp->h_length?");
      +					hp->h_length = sizeof(struct in_addr);
      +				}
      +				mount_server_addr.sin_family = AF_INET;
      +				memcpy(&mount_server_addr.sin_addr,
      +						hp->h_addr, hp->h_length);
      +			}
      +		}
      +	}
      +
      +	/*
      +	 * The following loop implements the mount retries. When the mount
      +	 * times out, and the "bg" option is set, we background ourself
      +	 * and continue trying.
      +	 *
      +	 * The case where the mount point is not present and the "bg"
      +	 * option is set, is treated as a timeout. This is done to
      +	 * support nested mounts.
      +	 *
      +	 * The "retry" count specified by the user is the number of
      +	 * minutes to retry before giving up.
      +	 */
      +	{
      +		struct timeval total_timeout;
      +		struct timeval retry_timeout;
      +		struct pmap* pm_mnt;
      +		time_t t;
      +		time_t prevt;
      +		time_t timeout;
      +
      +		retry_timeout.tv_sec = 3;
      +		retry_timeout.tv_usec = 0;
      +		total_timeout.tv_sec = 20;
      +		total_timeout.tv_usec = 0;
      +		timeout = time(NULL) + 60 * retry;
      +		prevt = 0;
      +		t = 30;
      +retry:
      +		/* be careful not to use too many CPU cycles */
      +		if (t - prevt < 30)
      +			sleep(30);
      +
      +		pm_mnt = get_mountport(&mount_server_addr,
      +				mountprog,
      +				mountvers,
      +				proto,
      +				mountport);
      +		nfsvers = (pm_mnt->pm_vers < 2) ? 2 : pm_mnt->pm_vers;
      +
      +		/* contact the mount daemon via TCP */
      +		mount_server_addr.sin_port = htons(pm_mnt->pm_port);
      +		msock = RPC_ANYSOCK;
      +
      +		switch (pm_mnt->pm_prot) {
      +		case IPPROTO_UDP:
      +			mclient = clntudp_create(&mount_server_addr,
      +						 pm_mnt->pm_prog,
      +						 pm_mnt->pm_vers,
      +						 retry_timeout,
      +						 &msock);
      +			if (mclient)
      +				break;
      +			mount_server_addr.sin_port = htons(pm_mnt->pm_port);
      +			msock = RPC_ANYSOCK;
      +		case IPPROTO_TCP:
      +			mclient = clnttcp_create(&mount_server_addr,
      +						 pm_mnt->pm_prog,
      +						 pm_mnt->pm_vers,
      +						 &msock, 0, 0);
      +			break;
      +		default:
      +			mclient = 0;
      +		}
      +		if (!mclient) {
      +			if (!daemonized && prevt == 0)
      +				error_msg_rpc(clnt_spcreateerror(" "));
      +		} else {
      +			enum clnt_stat clnt_stat;
      +			/* try to mount hostname:pathname */
      +			mclient->cl_auth = authunix_create_default();
      +
      +			/* make pointers in xdr_mountres3 NULL so
      +			 * that xdr_array allocates memory for us
      +			 */
      +			memset(&status, 0, sizeof(status));
      +
      +			if (pm_mnt->pm_vers == 3)
      +				clnt_stat = clnt_call(mclient, MOUNTPROC3_MNT,
      +					      (xdrproc_t) xdr_dirpath,
      +					      (caddr_t) &pathname,
      +					      (xdrproc_t) xdr_mountres3,
      +					      (caddr_t) &status,
      +					      total_timeout);
      +			else
      +				clnt_stat = clnt_call(mclient, MOUNTPROC_MNT,
      +					      (xdrproc_t) xdr_dirpath,
      +					      (caddr_t) &pathname,
      +					      (xdrproc_t) xdr_fhstatus,
      +					      (caddr_t) &status,
      +					      total_timeout);
      +
      +			if (clnt_stat == RPC_SUCCESS)
      +				goto prepare_kernel_data; /* we're done */
      +			if (errno != ECONNREFUSED) {
      +				error_msg_rpc(clnt_sperror(mclient, " "));
      +				goto fail;	/* don't retry */
      +			}
      +			/* Connection refused */
      +			if (!daemonized && prevt == 0) /* print just once */
      +				error_msg_rpc(clnt_sperror(mclient, " "));
      +			auth_destroy(mclient->cl_auth);
      +			clnt_destroy(mclient);
      +			mclient = 0;
      +			close(msock);
      +		}
      +
      +		/* Timeout. We are going to retry... maybe */
      +
      +		if (!bg)
      +			goto fail;
      +		if (!daemonized) {
      +			daemonized = daemonize();
      +			if (daemonized <= 0) { /* parent or error */
      +				retval = -daemonized;
      +				goto ret;
      +			}
      +		}
      +		prevt = t;
      +		t = time(NULL);
      +		if (t >= timeout)
      +			/* TODO error message */
      +			goto fail;
      +
      +		goto retry;
      +	}
      +
      +prepare_kernel_data:
      +
      +	if (nfsvers == 2) {
      +		if (status.nfsv2.fhs_status != 0) {
      +			bb_error_msg("%s:%s failed, reason given by server: %s",
      +				hostname, pathname,
      +				nfs_strerror(status.nfsv2.fhs_status));
      +			goto fail;
      +		}
      +		memcpy(data.root.data,
      +				(char *) status.nfsv2.fhstatus_u.fhs_fhandle,
      +				NFS_FHSIZE);
      +		data.root.size = NFS_FHSIZE;
      +		memcpy(data.old_root.data,
      +				(char *) status.nfsv2.fhstatus_u.fhs_fhandle,
      +				NFS_FHSIZE);
      +	} else {
      +		fhandle3 *my_fhandle;
      +		if (status.nfsv3.fhs_status != 0) {
      +			bb_error_msg("%s:%s failed, reason given by server: %s",
      +				hostname, pathname,
      +				nfs_strerror(status.nfsv3.fhs_status));
      +			goto fail;
      +		}
      +		my_fhandle = &status.nfsv3.mountres3_u.mountinfo.fhandle;
      +		memset(data.old_root.data, 0, NFS_FHSIZE);
      +		memset(&data.root, 0, sizeof(data.root));
      +		data.root.size = my_fhandle->fhandle3_len;
      +		memcpy(data.root.data,
      +				(char *) my_fhandle->fhandle3_val,
      +				my_fhandle->fhandle3_len);
      +
      +		data.flags |= NFS_MOUNT_VER3;
      +	}
      +
      +	/* create nfs socket for kernel */
      +
      +	if (tcp) {
      +		if (nfs_mount_version < 3) {
      +			bb_error_msg("NFS over TCP is not supported");
      +			goto fail;
      +		}
      +		fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
      +	} else
      +		fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
      +	if (fsock < 0) {
      +		bb_perror_msg("nfs socket");
      +		goto fail;
      +	}
      +	if (bindresvport(fsock, 0) < 0) {
      +		bb_perror_msg("nfs bindresvport");
      +		goto fail;
      +	}
      +	if (port == 0) {
      +		server_addr.sin_port = PMAPPORT;
      +		port = pmap_getport(&server_addr, nfsprog, nfsvers,
      +					tcp ? IPPROTO_TCP : IPPROTO_UDP);
      +		if (port == 0)
      +			port = NFS_PORT;
      +#ifdef NFS_MOUNT_DEBUG
      +		else
      +			printf("used portmapper to find NFS port\n");
      +#endif
      +	}
      +#ifdef NFS_MOUNT_DEBUG
      +	printf("using port %d for nfs daemon\n", port);
      +#endif
      +	server_addr.sin_port = htons(port);
      +
      +	/* prepare data structure for kernel */
      +
      +	data.fd = fsock;
      +	memcpy((char *) &data.addr, (char *) &server_addr, sizeof(data.addr));
      +	strncpy(data.hostname, hostname, sizeof(data.hostname));
      +
      +	/* clean up */
      +
      +	auth_destroy(mclient->cl_auth);
      +	clnt_destroy(mclient);
      +	close(msock);
      +
      +	if (bg) {
      +		/* We must wait until mount directory is available */
      +		struct stat statbuf;
      +		int delay = 1;
      +		while (stat(mp->mnt_dir, &statbuf) == -1) {
      +			if (!daemonized) {
      +				daemonized = daemonize();
      +				if (daemonized <= 0) { /* parent or error */
      +					retval = -daemonized;
      +					goto ret;
      +				}
      +			}
      +			sleep(delay);	/* 1, 2, 4, 8, 16, 30, ... */
      +			delay *= 2;
      +			if (delay > 30)
      +				delay = 30;
      +		}
      +	}
      +
      +do_mount: /* perform actual mount */
      +
      +	mp->mnt_type = "nfs";
      +	retval = mount_it_now(mp, vfsflags, (char*)&data);
      +	goto ret;
      +
      +fail:	/* abort */
      +
      +	if (msock != -1) {
      +		if (mclient) {
      +			auth_destroy(mclient->cl_auth);
      +			clnt_destroy(mclient);
      +		}
      +		close(msock);
      +	}
      +	if (fsock != -1)
      +		close(fsock);
      +
      +ret:
      +	free(hostname);
      +	free(mounthost);
      +	free(filteropts);
      +	return retval;
      +}
      +
      +#endif /* ENABLE_FEATURE_MOUNT_NFS */
      Index: util-linux/nfsmount.c
      ===================================================================
      --- util-linux/nfsmount.c	(revision 16119)
      +++ util-linux/nfsmount.c	(revision 16120)
      @@ -1,1022 +0,0 @@
      -/* vi: set sw=4 ts=4: */
      -/*
      - * nfsmount.c -- Linux NFS mount
      - * Copyright (C) 1993 Rick Sladkey 
      - *
      - * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
      - *
      - * Wed Feb  8 12:51:48 1995, biro@yggdrasil.com (Ross Biro): allow all port
      - * numbers to be specified on the command line.
      - *
      - * Fri, 8 Mar 1996 18:01:39, Swen Thuemmler :
      - * Omit the call to connect() for Linux version 1.3.11 or later.
      - *
      - * Wed Oct  1 23:55:28 1997: Dick Streefland 
      - * Implemented the "bg", "fg" and "retry" mount options for NFS.
      - *
      - * 1999-02-22 Arkadiusz Mi¶kiewicz 
      - * - added Native Language Support
      - *
      - * Modified by Olaf Kirch and Trond Myklebust for new NFS code,
      - * plus NFSv3 stuff.
      - */
      -
      -#include "busybox.h"
      -#include 
      -#include 
      -#include 
      -#undef TRUE
      -#undef FALSE
      -#include 
      -#include 
      -#include 
      -
      -/* This is just a warning of a common mistake.  Possibly this should be a
      - * uclibc faq entry rather than in busybox... */
      -#if ENABLE_FEATURE_MOUNT_NFS && defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__)
      -#error "You need to build uClibc with UCLIBC_HAS_RPC for NFS support."
      -#endif
      -
      -/* former nfsmount.h */
      -
      -#define MOUNTPORT 635
      -#define MNTPATHLEN 1024
      -#define MNTNAMLEN 255
      -#define FHSIZE 32
      -#define FHSIZE3 64
      -
      -typedef char fhandle[FHSIZE];
      -
      -typedef struct {
      -	unsigned int fhandle3_len;
      -	char *fhandle3_val;
      -} fhandle3;
      -
      -enum mountstat3 {
      -	MNT_OK = 0,
      -	MNT3ERR_PERM = 1,
      -	MNT3ERR_NOENT = 2,
      -	MNT3ERR_IO = 5,
      -	MNT3ERR_ACCES = 13,
      -	MNT3ERR_NOTDIR = 20,
      -	MNT3ERR_INVAL = 22,
      -	MNT3ERR_NAMETOOLONG = 63,
      -	MNT3ERR_NOTSUPP = 10004,
      -	MNT3ERR_SERVERFAULT = 10006,
      -};
      -typedef enum mountstat3 mountstat3;
      -
      -struct fhstatus {
      -	unsigned int fhs_status;
      -	union {
      -		fhandle fhs_fhandle;
      -	} fhstatus_u;
      -};
      -typedef struct fhstatus fhstatus;
      -
      -struct mountres3_ok {
      -	fhandle3 fhandle;
      -	struct {
      -		unsigned int auth_flavours_len;
      -		char *auth_flavours_val;
      -	} auth_flavours;
      -};
      -typedef struct mountres3_ok mountres3_ok;
      -
      -struct mountres3 {
      -	mountstat3 fhs_status;
      -	union {
      -		mountres3_ok mountinfo;
      -	} mountres3_u;
      -};
      -typedef struct mountres3 mountres3;
      -
      -typedef char *dirpath;
      -
      -typedef char *name;
      -
      -typedef struct mountbody *mountlist;
      -
      -struct mountbody {
      -	name ml_hostname;
      -	dirpath ml_directory;
      -	mountlist ml_next;
      -};
      -typedef struct mountbody mountbody;
      -
      -typedef struct groupnode *groups;
      -
      -struct groupnode {
      -	name gr_name;
      -	groups gr_next;
      -};
      -typedef struct groupnode groupnode;
      -
      -typedef struct exportnode *exports;
      -
      -struct exportnode {
      -	dirpath ex_dir;
      -	groups ex_groups;
      -	exports ex_next;
      -};
      -typedef struct exportnode exportnode;
      -
      -struct ppathcnf {
      -	int pc_link_max;
      -	short pc_max_canon;
      -	short pc_max_input;
      -	short pc_name_max;
      -	short pc_path_max;
      -	short pc_pipe_buf;
      -	u_char pc_vdisable;
      -	char pc_xxx;
      -	short pc_mask[2];
      -};
      -typedef struct ppathcnf ppathcnf;
      -
      -#define MOUNTPROG 100005
      -#define MOUNTVERS 1
      -
      -#define MOUNTPROC_NULL 0
      -#define MOUNTPROC_MNT 1
      -#define MOUNTPROC_DUMP 2
      -#define MOUNTPROC_UMNT 3
      -#define MOUNTPROC_UMNTALL 4
      -#define MOUNTPROC_EXPORT 5
      -#define MOUNTPROC_EXPORTALL 6
      -
      -#define MOUNTVERS_POSIX 2
      -
      -#define MOUNTPROC_PATHCONF 7
      -
      -#define MOUNT_V3 3
      -
      -#define MOUNTPROC3_NULL 0
      -#define MOUNTPROC3_MNT 1
      -#define MOUNTPROC3_DUMP 2
      -#define MOUNTPROC3_UMNT 3
      -#define MOUNTPROC3_UMNTALL 4
      -#define MOUNTPROC3_EXPORT 5
      -
      -/* former nfsmount.h ends */
      -
      -enum {
      -#ifndef NFS_FHSIZE
      -	NFS_FHSIZE = 32,
      -#endif
      -#ifndef NFS_PORT
      -	NFS_PORT = 2049
      -#endif
      -};
      -
      -//enum {
      -//	S_QUOTA = 128,     /* Quota initialized for file/directory/symlink */
      -//};
      -
      -
      -/*
      - * We want to be able to compile mount on old kernels in such a way
      - * that the binary will work well on more recent kernels.
      - * Thus, if necessary we teach nfsmount.c the structure of new fields
      - * that will come later.
      - *
      - * Moreover, the new kernel includes conflict with glibc includes
      - * so it is easiest to ignore the kernel altogether (at compile time).
      - */
      -
      -struct nfs2_fh {
      -	char                    data[32];
      -};
      -struct nfs3_fh {
      -	unsigned short          size;
      -	unsigned char           data[64];
      -};
      -
      -struct nfs_mount_data {
      -	int		version;		/* 1 */
      -	int		fd;			/* 1 */
      -	struct nfs2_fh	old_root;		/* 1 */
      -	int		flags;			/* 1 */
      -	int		rsize;			/* 1 */
      -	int		wsize;			/* 1 */
      -	int		timeo;			/* 1 */
      -	int		retrans;		/* 1 */
      -	int		acregmin;		/* 1 */
      -	int		acregmax;		/* 1 */
      -	int		acdirmin;		/* 1 */
      -	int		acdirmax;		/* 1 */
      -	struct sockaddr_in addr;		/* 1 */
      -	char		hostname[256];		/* 1 */
      -	int		namlen;			/* 2 */
      -	unsigned int	bsize;			/* 3 */
      -	struct nfs3_fh	root;			/* 4 */
      -};
      -
      -/* bits in the flags field */
      -enum {
      -	NFS_MOUNT_SOFT = 0x0001,	/* 1 */
      -	NFS_MOUNT_INTR = 0x0002,	/* 1 */
      -	NFS_MOUNT_SECURE = 0x0004,	/* 1 */
      -	NFS_MOUNT_POSIX = 0x0008,	/* 1 */
      -	NFS_MOUNT_NOCTO = 0x0010,	/* 1 */
      -	NFS_MOUNT_NOAC = 0x0020,	/* 1 */
      -	NFS_MOUNT_TCP = 0x0040,		/* 2 */
      -	NFS_MOUNT_VER3 = 0x0080,	/* 3 */
      -	NFS_MOUNT_KERBEROS = 0x0100,	/* 3 */
      -	NFS_MOUNT_NONLM = 0x0200	/* 3 */
      -};
      -
      -#define HAVE_inet_aton
      -
      -/*
      - * We need to translate between nfs status return values and
      - * the local errno values which may not be the same.
      - *
      - * Andreas Schwab : change errno:
      - * "after #include  the symbol errno is reserved for any use,
      - *  it cannot even be used as a struct tag or field name".
      - */
      -
      -#ifndef EDQUOT
      -#define EDQUOT	ENOSPC
      -#endif
      -
      -// Convert each NFSERR_BLAH into EBLAH
      -
      -static const struct {
      -	int stat;
      -	int errnum;
      -} nfs_errtbl[] = {
      -	{0,0}, {1,EPERM}, {2,ENOENT}, {5,EIO}, {6,ENXIO}, {13,EACCES}, {17,EEXIST},
      -	{19,ENODEV}, {20,ENOTDIR}, {21,EISDIR}, {22,EINVAL}, {27,EFBIG},
      -	{28,ENOSPC}, {30,EROFS}, {63,ENAMETOOLONG}, {66,ENOTEMPTY}, {69,EDQUOT},
      -	{70,ESTALE}, {71,EREMOTE}, {-1,EIO}
      -};
      -
      -static char *nfs_strerror(int status)
      -{
      -	int i;
      -	static char buf[256];
      -
      -	for (i = 0; nfs_errtbl[i].stat != -1; i++) {
      -		if (nfs_errtbl[i].stat == status)
      -			return strerror(nfs_errtbl[i].errnum);
      -	}
      -	sprintf(buf, "unknown nfs status return value: %d", status);
      -	return buf;
      -}
      -
      -static bool_t xdr_fhandle(XDR *xdrs, fhandle objp)
      -{
      -	if (!xdr_opaque(xdrs, objp, FHSIZE))
      -		 return FALSE;
      -	return TRUE;
      -}
      -
      -static bool_t xdr_fhstatus(XDR *xdrs, fhstatus *objp)
      -{
      -	if (!xdr_u_int(xdrs, &objp->fhs_status))
      -		 return FALSE;
      -	switch (objp->fhs_status) {
      -	case 0:
      -		if (!xdr_fhandle(xdrs, objp->fhstatus_u.fhs_fhandle))
      -			 return FALSE;
      -		break;
      -	default:
      -		break;
      -	}
      -	return TRUE;
      -}
      -
      -static bool_t xdr_dirpath(XDR *xdrs, dirpath *objp)
      -{
      -	if (!xdr_string(xdrs, objp, MNTPATHLEN))
      -		 return FALSE;
      -	return TRUE;
      -}
      -
      -static bool_t xdr_fhandle3(XDR *xdrs, fhandle3 *objp)
      -{
      -	if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val, (unsigned int *) &objp->fhandle3_len, FHSIZE3))
      -		 return FALSE;
      -	return TRUE;
      -}
      -
      -static bool_t xdr_mountres3_ok(XDR *xdrs, mountres3_ok *objp)
      -{
      -	if (!xdr_fhandle3(xdrs, &objp->fhandle))
      -		return FALSE;
      -	if (!xdr_array(xdrs, &(objp->auth_flavours.auth_flavours_val), &(objp->auth_flavours.auth_flavours_len), ~0,
      -				sizeof (int), (xdrproc_t) xdr_int))
      -		return FALSE;
      -	return TRUE;
      -}
      -
      -static bool_t xdr_mountstat3(XDR *xdrs, mountstat3 *objp)
      -{
      -	if (!xdr_enum(xdrs, (enum_t *) objp))
      -		 return FALSE;
      -	return TRUE;
      -}
      -
      -static bool_t xdr_mountres3(XDR *xdrs, mountres3 *objp)
      -{
      -	if (!xdr_mountstat3(xdrs, &objp->fhs_status))
      -		return FALSE;
      -	switch (objp->fhs_status) {
      -	case MNT_OK:
      -		if (!xdr_mountres3_ok(xdrs, &objp->mountres3_u.mountinfo))
      -			 return FALSE;
      -		break;
      -	default:
      -		break;
      -	}
      -	return TRUE;
      -}
      -
      -#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
      -
      -/*
      - * nfs_mount_version according to the sources seen at compile time.
      - */
      -static int nfs_mount_version;
      -static int kernel_version;
      -
      -/*
      - * Unfortunately, the kernel prints annoying console messages
      - * in case of an unexpected nfs mount version (instead of
      - * just returning some error).  Therefore we'll have to try
      - * and figure out what version the kernel expects.
      - *
      - * Variables:
      - *	KERNEL_NFS_MOUNT_VERSION: kernel sources at compile time
      - *	NFS_MOUNT_VERSION: these nfsmount sources at compile time
      - *	nfs_mount_version: version this source and running kernel can handle
      - */
      -static void
      -find_kernel_nfs_mount_version(void)
      -{
      -	if (kernel_version)
      -		return;
      -
      -	nfs_mount_version = 4; /* default */
      -
      -	kernel_version = get_linux_version_code();
      -	if (kernel_version) {
      -		if (kernel_version < KERNEL_VERSION(2,1,32))
      -			nfs_mount_version = 1;
      -		else if (kernel_version < KERNEL_VERSION(2,2,18) ||
      -				(kernel_version >= KERNEL_VERSION(2,3,0) &&
      -				 kernel_version < KERNEL_VERSION(2,3,99)))
      -			nfs_mount_version = 3;
      -		/* else v4 since 2.3.99pre4 */
      -	}
      -}
      -
      -static struct pmap *
      -get_mountport(struct sockaddr_in *server_addr,
      -	long unsigned prog,
      -	long unsigned version,
      -	long unsigned proto,
      -	long unsigned port)
      -{
      -	struct pmaplist *pmap;
      -	static struct pmap p = {0, 0, 0, 0};
      -
      -	server_addr->sin_port = PMAPPORT;
      -	pmap = pmap_getmaps(server_addr);
      -
      -	if (version > MAX_NFSPROT)
      -		version = MAX_NFSPROT;
      -	if (!prog)
      -		prog = MOUNTPROG;
      -	p.pm_prog = prog;
      -	p.pm_vers = version;
      -	p.pm_prot = proto;
      -	p.pm_port = port;
      -	
      -	while (pmap) {
      -		if (pmap->pml_map.pm_prog != prog)
      -			goto next;
      -		if (!version && p.pm_vers > pmap->pml_map.pm_vers)
      -			goto next;
      -		if (version > 2 && pmap->pml_map.pm_vers != version)
      -			goto next;
      -		if (version && version <= 2 && pmap->pml_map.pm_vers > 2)
      -			goto next;
      -		if (pmap->pml_map.pm_vers > MAX_NFSPROT ||
      -		    (proto && p.pm_prot && pmap->pml_map.pm_prot != proto) ||
      -		    (port && pmap->pml_map.pm_port != port))
      -			goto next;
      -		memcpy(&p, &pmap->pml_map, sizeof(p));
      -next:
      -		pmap = pmap->pml_next;
      -	}
      -	if (!p.pm_vers)
      -		p.pm_vers = MOUNTVERS;
      -	if (!p.pm_port)
      -		p.pm_port = MOUNTPORT;
      -	if (!p.pm_prot)
      -		p.pm_prot = IPPROTO_TCP;
      -	return &p;
      -}
      -
      -static int daemonize(void)
      -{
      -	int fd;
      -	int pid = fork();
      -	if (pid < 0) /* error */
      -		return -errno;
      -	if (pid > 0) /* parent */
      -		return 0;
      -	/* child */
      -	fd = xopen(bb_dev_null, O_RDWR);
      -	dup2(fd, 0);
      -	dup2(fd, 1);
      -	dup2(fd, 2);
      -	if (fd > 2) close(fd);
      -	setsid();
      -	openlog(bb_applet_name, LOG_PID, LOG_DAEMON);
      -	logmode = LOGMODE_SYSLOG;
      -	return 1;
      -}
      -
      -// TODO
      -static inline int we_saw_this_host_before(const char *hostname)
      -{
      -	return 0;
      -}
      -
      -/* RPC strerror analogs are terminally idiotic:
      - * *mandatory* prefix and \n at end.
      - * This hopefully helps. Usage:
      - * error_msg_rpc(clnt_*error*(" ")) */
      -static void error_msg_rpc(const char *msg)
      -{
      -	size_t len;
      -	while (msg[0] == ' ' || msg[0] == ':') msg++;
      -	len = strlen(msg);
      -	while (len && msg[len-1] == '\n') len--;
      -	bb_error_msg("%.*s", len, msg);
      -}
      -
      -int nfsmount(struct mntent *mp, int vfsflags, char *filteropts)
      -{
      -	CLIENT *mclient;
      -	char *hostname;
      -	char *pathname;
      -	char *mounthost;
      -	struct nfs_mount_data data;
      -	char *opt;
      -	struct hostent *hp;
      -	struct sockaddr_in server_addr;
      -	struct sockaddr_in mount_server_addr;
      -	int msock, fsock;
      -	union {
      -		struct fhstatus nfsv2;
      -		struct mountres3 nfsv3;
      -	} status;
      -	int daemonized;
      -	char *s;
      -	int port;
      -	int mountport;
      -	int proto;
      -	int bg;
      -	int soft;
      -	int intr;
      -	int posix;
      -	int nocto;
      -	int noac;
      -	int nolock;
      -	int retry;
      -	int tcp;
      -	int mountprog;
      -	int mountvers;
      -	int nfsprog;
      -	int nfsvers;
      -	int retval;
      -
      -	find_kernel_nfs_mount_version();
      -
      -	daemonized = 0;
      -	mounthost = NULL;
      -	retval = ETIMEDOUT;
      -	msock = fsock = -1;
      -	mclient = NULL;
      -
      -	/* NB: hostname, mounthost, filteropts must be free()d prior to return */
      -
      -	filteropts = xstrdup(filteropts); /* going to trash it later... */
      -
      -	hostname = xstrdup(mp->mnt_fsname);
      -	/* mount_main() guarantees that ':' is there */
      -	s = strchr(hostname, ':');
      -	pathname = s + 1;
      -	*s = '\0';
      -	/* Ignore all but first hostname in replicated mounts
      -	   until they can be fully supported. (mack@sgi.com) */
      -	s = strchr(hostname, ',');
      -	if (s) {
      -		*s = '\0';
      -		bb_error_msg("warning: multiple hostnames not supported");
      -	}
      -
      -	server_addr.sin_family = AF_INET;
      -#ifdef HAVE_inet_aton
      -	if (!inet_aton(hostname, &server_addr.sin_addr))
      -#endif
      -	{
      -		hp = gethostbyname(hostname);
      -		if (hp == NULL) {
      -			bb_herror_msg("%s", hostname);
      -			goto fail;
      -		}
      -		if (hp->h_length > sizeof(struct in_addr)) {
      -			bb_error_msg("got bad hp->h_length");
      -			hp->h_length = sizeof(struct in_addr);
      -		}
      -		memcpy(&server_addr.sin_addr,
      -				hp->h_addr, hp->h_length);
      -	}
      -
      -	memcpy(&mount_server_addr, &server_addr, sizeof(mount_server_addr));
      -
      -	/* add IP address to mtab options for use when unmounting */
      -
      -	if (!mp->mnt_opts) { /* TODO: actually mp->mnt_opts is never NULL */
      -		mp->mnt_opts = xasprintf("addr=%s", inet_ntoa(server_addr.sin_addr));
      -	} else {
      -		char *tmp = xasprintf("%s%saddr=%s", mp->mnt_opts,
      -					mp->mnt_opts[0] ? "," : "",
      -					inet_ntoa(server_addr.sin_addr));
      -		free(mp->mnt_opts);
      -		mp->mnt_opts = tmp;
      -	}
      -
      -	/* Set default options.
      -	 * rsize/wsize (and bsize, for ver >= 3) are left 0 in order to
      -	 * let the kernel decide.
      -	 * timeo is filled in after we know whether it'll be TCP or UDP. */
      -	memset(&data, 0, sizeof(data));
      -	data.retrans	= 3;
      -	data.acregmin	= 3;
      -	data.acregmax	= 60;
      -	data.acdirmin	= 30;
      -	data.acdirmax	= 60;
      -	data.namlen	= NAME_MAX;
      -
      -	bg = 0;
      -	soft = 0;
      -	intr = 0;
      -	posix = 0;
      -	nocto = 0;
      -	nolock = 0;
      -	noac = 0;
      -	retry = 10000;		/* 10000 minutes ~ 1 week */
      -	tcp = 0;
      -
      -	mountprog = MOUNTPROG;
      -	mountvers = 0;
      -	port = 0;
      -	mountport = 0;
      -	nfsprog = 100003;
      -	nfsvers = 0;
      -
      -	/* parse options */
      -
      -	for (opt = strtok(filteropts, ","); opt; opt = strtok(NULL, ",")) {
      -		char *opteq = strchr(opt, '=');
      -		if (opteq) {
      -			int val = atoi(opteq + 1);
      -			*opteq = '\0';
      -			if (!strcmp(opt, "rsize"))
      -				data.rsize = val;
      -			else if (!strcmp(opt, "wsize"))
      -				data.wsize = val;
      -			else if (!strcmp(opt, "timeo"))
      -				data.timeo = val;
      -			else if (!strcmp(opt, "retrans"))
      -				data.retrans = val;
      -			else if (!strcmp(opt, "acregmin"))
      -				data.acregmin = val;
      -			else if (!strcmp(opt, "acregmax"))
      -				data.acregmax = val;
      -			else if (!strcmp(opt, "acdirmin"))
      -				data.acdirmin = val;
      -			else if (!strcmp(opt, "acdirmax"))
      -				data.acdirmax = val;
      -			else if (!strcmp(opt, "actimeo")) {
      -				data.acregmin = val;
      -				data.acregmax = val;
      -				data.acdirmin = val;
      -				data.acdirmax = val;
      -			}
      -			else if (!strcmp(opt, "retry"))
      -				retry = val;
      -			else if (!strcmp(opt, "port"))
      -				port = val;
      -			else if (!strcmp(opt, "mountport"))
      -				mountport = val;
      -			else if (!strcmp(opt, "mounthost"))
      -				mounthost = xstrndup(opteq+1,
      -						  strcspn(opteq+1," \t\n\r,"));
      -			else if (!strcmp(opt, "mountprog"))
      -				mountprog = val;
      -			else if (!strcmp(opt, "mountvers"))
      -				mountvers = val;
      -			else if (!strcmp(opt, "nfsprog"))
      -				nfsprog = val;
      -			else if (!strcmp(opt, "nfsvers") ||
      -				 !strcmp(opt, "vers"))
      -				nfsvers = val;
      -			else if (!strcmp(opt, "proto")) {
      -				if (!strncmp(opteq+1, "tcp", 3))
      -					tcp = 1;
      -				else if (!strncmp(opteq+1, "udp", 3))
      -					tcp = 0;
      -				else
      -					bb_error_msg("warning: unrecognized proto= option");
      -			} else if (!strcmp(opt, "namlen")) {
      -				if (nfs_mount_version >= 2)
      -					data.namlen = val;
      -				else
      -					bb_error_msg("warning: option namlen is not supported\n");
      -			} else if (!strcmp(opt, "addr"))
      -				/* ignore */;
      -			else {
      -				bb_error_msg("unknown nfs mount parameter: %s=%d", opt, val);
      -				goto fail;
      -			}
      -		}
      -		else {
      -			int val = 1;
      -			if (!strncmp(opt, "no", 2)) {
      -				val = 0;
      -				opt += 2;
      -			}
      -			if (!strcmp(opt, "bg"))
      -				bg = val;
      -			else if (!strcmp(opt, "fg"))
      -				bg = !val;
      -			else if (!strcmp(opt, "soft"))
      -				soft = val;
      -			else if (!strcmp(opt, "hard"))
      -				soft = !val;
      -			else if (!strcmp(opt, "intr"))
      -				intr = val;
      -			else if (!strcmp(opt, "posix"))
      -				posix = val;
      -			else if (!strcmp(opt, "cto"))
      -				nocto = !val;
      -			else if (!strcmp(opt, "ac"))
      -				noac = !val;
      -			else if (!strcmp(opt, "tcp"))
      -				tcp = val;
      -			else if (!strcmp(opt, "udp"))
      -				tcp = !val;
      -			else if (!strcmp(opt, "lock")) {
      -				if (nfs_mount_version >= 3)
      -					nolock = !val;
      -				else
      -					bb_error_msg("warning: option nolock is not supported");
      -			} else {
      -				bb_error_msg("unknown nfs mount option: %s%s", val ? "" : "no", opt);
      -				goto fail;
      -			}
      -		}
      -	}
      -	proto = (tcp) ? IPPROTO_TCP : IPPROTO_UDP;
      -
      -	data.flags = (soft ? NFS_MOUNT_SOFT : 0)
      -		| (intr ? NFS_MOUNT_INTR : 0)
      -		| (posix ? NFS_MOUNT_POSIX : 0)
      -		| (nocto ? NFS_MOUNT_NOCTO : 0)
      -		| (noac ? NFS_MOUNT_NOAC : 0);
      -	if (nfs_mount_version >= 2)
      -		data.flags |= (tcp ? NFS_MOUNT_TCP : 0);
      -	if (nfs_mount_version >= 3)
      -		data.flags |= (nolock ? NFS_MOUNT_NONLM : 0);
      -	if (nfsvers > MAX_NFSPROT || mountvers > MAX_NFSPROT) {
      -		bb_error_msg("NFSv%d not supported", nfsvers);
      -		goto fail;
      -	}
      -	if (nfsvers && !mountvers)
      -		mountvers = (nfsvers < 3) ? 1 : nfsvers;
      -	if (nfsvers && nfsvers < mountvers) {
      -		mountvers = nfsvers;
      -	}
      -
      -	/* Adjust options if none specified */
      -	if (!data.timeo)
      -		data.timeo = tcp ? 70 : 7;
      -
      -#ifdef NFS_MOUNT_DEBUG
      -	printf("rsize = %d, wsize = %d, timeo = %d, retrans = %d\n",
      -		data.rsize, data.wsize, data.timeo, data.retrans);
      -	printf("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)\n",
      -		data.acregmin, data.acregmax, data.acdirmin, data.acdirmax);
      -	printf("port = %d, bg = %d, retry = %d, flags = %.8x\n",
      -		port, bg, retry, data.flags);
      -	printf("mountprog = %d, mountvers = %d, nfsprog = %d, nfsvers = %d\n",
      -		mountprog, mountvers, nfsprog, nfsvers);
      -	printf("soft = %d, intr = %d, posix = %d, nocto = %d, noac = %d\n",
      -		(data.flags & NFS_MOUNT_SOFT) != 0,
      -		(data.flags & NFS_MOUNT_INTR) != 0,
      -		(data.flags & NFS_MOUNT_POSIX) != 0,
      -		(data.flags & NFS_MOUNT_NOCTO) != 0,
      -		(data.flags & NFS_MOUNT_NOAC) != 0);
      -	printf("tcp = %d\n",
      -		(data.flags & NFS_MOUNT_TCP) != 0);
      -#endif
      -
      -	data.version = nfs_mount_version;
      -
      -	if (vfsflags & MS_REMOUNT)
      -		goto do_mount;
      -
      -	/*
      -	 * If the previous mount operation on the same host was
      -	 * backgrounded, and the "bg" for this mount is also set,
      -	 * give up immediately, to avoid the initial timeout.
      -	 */
      -	if (bg && we_saw_this_host_before(hostname)) {
      -		daemonized = daemonize(); /* parent or error */
      -		if (daemonized <= 0) { /* parent or error */
      -			retval = -daemonized;
      -			goto ret;
      -		}
      -	}
      -
      -	/* create mount daemon client */
      -	/* See if the nfs host = mount host. */
      -	if (mounthost) {
      -		if (mounthost[0] >= '0' && mounthost[0] <= '9') {
      -			mount_server_addr.sin_family = AF_INET;
      -			mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
      -		} else {
      -			hp = gethostbyname(mounthost);
      -			if (hp == NULL) {
      -				bb_herror_msg("%s", mounthost);
      -				goto fail;
      -			} else {
      -				if (hp->h_length > sizeof(struct in_addr)) {
      -					bb_error_msg("got bad hp->h_length?");
      -					hp->h_length = sizeof(struct in_addr);
      -				}
      -				mount_server_addr.sin_family = AF_INET;
      -				memcpy(&mount_server_addr.sin_addr,
      -						hp->h_addr, hp->h_length);
      -			}
      -		}
      -	}
      -
      -	/*
      -	 * The following loop implements the mount retries. When the mount
      -	 * times out, and the "bg" option is set, we background ourself
      -	 * and continue trying.
      -	 *
      -	 * The case where the mount point is not present and the "bg"
      -	 * option is set, is treated as a timeout. This is done to
      -	 * support nested mounts.
      -	 *
      -	 * The "retry" count specified by the user is the number of
      -	 * minutes to retry before giving up.
      -	 */
      -	{
      -		struct timeval total_timeout;
      -		struct timeval retry_timeout;
      -		struct pmap* pm_mnt;
      -		time_t t;
      -		time_t prevt;
      -		time_t timeout;
      -
      -		retry_timeout.tv_sec = 3;
      -		retry_timeout.tv_usec = 0;
      -		total_timeout.tv_sec = 20;
      -		total_timeout.tv_usec = 0;
      -		timeout = time(NULL) + 60 * retry;
      -		prevt = 0;
      -		t = 30;
      -retry:
      -		/* be careful not to use too many CPU cycles */
      -		if (t - prevt < 30)
      -			sleep(30);
      -
      -		pm_mnt = get_mountport(&mount_server_addr,
      -				mountprog,
      -				mountvers,
      -				proto,
      -				mountport);
      -		nfsvers = (pm_mnt->pm_vers < 2) ? 2 : pm_mnt->pm_vers;
      -
      -		/* contact the mount daemon via TCP */
      -		mount_server_addr.sin_port = htons(pm_mnt->pm_port);
      -		msock = RPC_ANYSOCK;
      -
      -		switch (pm_mnt->pm_prot) {
      -		case IPPROTO_UDP:
      -			mclient = clntudp_create(&mount_server_addr,
      -						 pm_mnt->pm_prog,
      -						 pm_mnt->pm_vers,
      -						 retry_timeout,
      -						 &msock);
      -			if (mclient)
      -				break;
      -			mount_server_addr.sin_port = htons(pm_mnt->pm_port);
      -			msock = RPC_ANYSOCK;
      -		case IPPROTO_TCP:
      -			mclient = clnttcp_create(&mount_server_addr,
      -						 pm_mnt->pm_prog,
      -						 pm_mnt->pm_vers,
      -						 &msock, 0, 0);
      -			break;
      -		default:
      -			mclient = 0;
      -		}
      -		if (!mclient) {
      -			if (!daemonized && prevt == 0)
      -				error_msg_rpc(clnt_spcreateerror(" "));
      -		} else {
      -			enum clnt_stat clnt_stat;
      -			/* try to mount hostname:pathname */
      -			mclient->cl_auth = authunix_create_default();
      -
      -			/* make pointers in xdr_mountres3 NULL so
      -			 * that xdr_array allocates memory for us
      -			 */
      -			memset(&status, 0, sizeof(status));
      -
      -			if (pm_mnt->pm_vers == 3)
      -				clnt_stat = clnt_call(mclient, MOUNTPROC3_MNT,
      -					      (xdrproc_t) xdr_dirpath,
      -					      (caddr_t) &pathname,
      -					      (xdrproc_t) xdr_mountres3,
      -					      (caddr_t) &status,
      -					      total_timeout);
      -			else
      -				clnt_stat = clnt_call(mclient, MOUNTPROC_MNT,
      -					      (xdrproc_t) xdr_dirpath,
      -					      (caddr_t) &pathname,
      -					      (xdrproc_t) xdr_fhstatus,
      -					      (caddr_t) &status,
      -					      total_timeout);
      -
      -			if (clnt_stat == RPC_SUCCESS)
      -				goto prepare_kernel_data; /* we're done */
      -			if (errno != ECONNREFUSED) {
      -				error_msg_rpc(clnt_sperror(mclient, " "));
      -				goto fail;	/* don't retry */
      -			}
      -			/* Connection refused */
      -			if (!daemonized && prevt == 0) /* print just once */
      -				error_msg_rpc(clnt_sperror(mclient, " "));
      -			auth_destroy(mclient->cl_auth);
      -			clnt_destroy(mclient);
      -			mclient = 0;
      -			close(msock);
      -		}
      -
      -		/* Timeout. We are going to retry... maybe */
      -
      -		if (!bg)
      -			goto fail;
      -		if (!daemonized) {
      -			daemonized = daemonize();
      -			if (daemonized <= 0) { /* parent or error */
      -				retval = -daemonized;
      -				goto ret;
      -			}
      -		}
      -		prevt = t;
      -		t = time(NULL);
      -		if (t >= timeout)
      -			/* TODO error message */
      -			goto fail;
      -
      -		goto retry;
      -	}
      -
      -prepare_kernel_data:
      -
      -	if (nfsvers == 2) {
      -		if (status.nfsv2.fhs_status != 0) {
      -			bb_error_msg("%s:%s failed, reason given by server: %s",
      -				hostname, pathname,
      -				nfs_strerror(status.nfsv2.fhs_status));
      -			goto fail;
      -		}
      -		memcpy(data.root.data,
      -				(char *) status.nfsv2.fhstatus_u.fhs_fhandle,
      -				NFS_FHSIZE);
      -		data.root.size = NFS_FHSIZE;
      -		memcpy(data.old_root.data,
      -				(char *) status.nfsv2.fhstatus_u.fhs_fhandle,
      -				NFS_FHSIZE);
      -	} else {
      -		fhandle3 *my_fhandle;
      -		if (status.nfsv3.fhs_status != 0) {
      -			bb_error_msg("%s:%s failed, reason given by server: %s",
      -				hostname, pathname,
      -				nfs_strerror(status.nfsv3.fhs_status));
      -			goto fail;
      -		}
      -		my_fhandle = &status.nfsv3.mountres3_u.mountinfo.fhandle;
      -		memset(data.old_root.data, 0, NFS_FHSIZE);
      -		memset(&data.root, 0, sizeof(data.root));
      -		data.root.size = my_fhandle->fhandle3_len;
      -		memcpy(data.root.data,
      -				(char *) my_fhandle->fhandle3_val,
      -				my_fhandle->fhandle3_len);
      -
      -		data.flags |= NFS_MOUNT_VER3;
      -	}
      -
      -	/* create nfs socket for kernel */
      -
      -	if (tcp) {
      -		if (nfs_mount_version < 3) {
      -			bb_error_msg("NFS over TCP is not supported");
      -			goto fail;
      -		}
      -		fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
      -	} else
      -		fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
      -	if (fsock < 0) {
      -		bb_perror_msg("nfs socket");
      -		goto fail;
      -	}
      -	if (bindresvport(fsock, 0) < 0) {
      -		bb_perror_msg("nfs bindresvport");
      -		goto fail;
      -	}
      -	if (port == 0) {
      -		server_addr.sin_port = PMAPPORT;
      -		port = pmap_getport(&server_addr, nfsprog, nfsvers,
      -					tcp ? IPPROTO_TCP : IPPROTO_UDP);
      -		if (port == 0)
      -			port = NFS_PORT;
      -#ifdef NFS_MOUNT_DEBUG
      -		else
      -			printf("used portmapper to find NFS port\n");
      -#endif
      -	}
      -#ifdef NFS_MOUNT_DEBUG
      -	printf("using port %d for nfs daemon\n", port);
      -#endif
      -	server_addr.sin_port = htons(port);
      -
      -	/* prepare data structure for kernel */
      -
      -	data.fd = fsock;
      -	memcpy((char *) &data.addr, (char *) &server_addr, sizeof(data.addr));
      -	strncpy(data.hostname, hostname, sizeof(data.hostname));
      -
      -	/* clean up */
      -
      -	auth_destroy(mclient->cl_auth);
      -	clnt_destroy(mclient);
      -	close(msock);
      -
      -	if (bg) {
      -		/* We must wait until mount directory is available */
      -		struct stat statbuf;
      -		int delay = 1;
      -		while (stat(mp->mnt_dir, &statbuf) == -1) {
      -			if (!daemonized) {
      -				daemonized = daemonize();
      -				if (daemonized <= 0) { /* parent or error */
      -					retval = -daemonized;
      -					goto ret;
      -				}
      -			}
      -			sleep(delay);	/* 1, 2, 4, 8, 16, 30, ... */
      -			delay *= 2;
      -			if (delay > 30)
      -				delay = 30;
      -		}
      -	}
      -
      -do_mount: /* perform actual mount */
      -
      -	mp->mnt_type = "nfs";
      -	retval = mount_it_now(mp, vfsflags, (char*)&data);
      -	goto ret;
      -
      -fail:	/* abort */
      -
      -	if (msock != -1) {
      -		if (mclient) {
      -			auth_destroy(mclient->cl_auth);
      -			clnt_destroy(mclient);
      -		}
      -		close(msock);
      -	}
      -	if (fsock != -1)
      -		close(fsock);
      -
      -ret:
      -	free(hostname);
      -	free(mounthost);
      -	free(filteropts);
      -	return retval;
      -}
      
       ------------------------------------------------------------------------
      r16119 | aldot | 2006-09-14 11:07:48 -0400 (Thu, 14 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/scripts/individual
      
      - make sure that the 'build' dir exists even if we are about to build just one applet.
      
       ------------------------------------------------------------------------
      
      Index: scripts/individual
      ===================================================================
      --- scripts/individual	(revision 16118)
      +++ scripts/individual	(revision 16119)
      @@ -13,6 +13,13 @@
       # Make our prerequisites.
       
       make busybox.links include/bb_config.h $(pwd)/{libbb/libbb.a,archival/libunarchive/libunarchive.a,coreutils/libcoreutils/libcoreutils.a,networking/libiproute/libiproute.a}
      +
      +else
      +# Could very well be that we want to build an individual applet but have no
      +# 'build' dir yet..
      +
      +test -d ./build || mkdir build
      +
       fi
       
       # About 3/5 of the applets build from one .c file (with the same name as the
      
       ------------------------------------------------------------------------
      r16118 | aldot | 2006-09-14 11:04:31 -0400 (Thu, 14 Sep 2006) | 3 lines
      Changed paths:
         M /trunk/busybox/scripts/individual
      
      - do away with silly comment and do the Right Thing wrt building the archives.
        You have to provide the absolute path to the objdir/target.ext you want to build, as can be seen in the respective makefiles..
      
       ------------------------------------------------------------------------
      
      Index: scripts/individual
      ===================================================================
      --- scripts/individual	(revision 16117)
      +++ scripts/individual	(revision 16118)
      @@ -12,34 +12,7 @@
       
       # Make our prerequisites.
       
      -make busybox.links include/bb_config.h
      -
      -# Adding "libbb/libbb.a" to the previous line doesn't work, nor does going
      -# "make libbb.a" in the libb directory.  The busybox makefile has layers and
      -# layers of overcomplicated brokenness...
      -
      -cd libbb
      -make
      -cd ..
      -
      -# Same problem.
      -
      -cd archival/libunarchive
      -make
      -cd ../..
      -
      -# And again
      -
      -cd coreutils/libcoreutils
      -make
      -cd ../..
      -
      -# Sensing a pattern here?
      -
      -#cd networking/libiproute
      -#make
      -#cd ../..
      -
      +make busybox.links include/bb_config.h $(pwd)/{libbb/libbb.a,archival/libunarchive/libunarchive.a,coreutils/libcoreutils/libcoreutils.a,networking/libiproute/libiproute.a}
       fi
       
       # About 3/5 of the applets build from one .c file (with the same name as the
      
       ------------------------------------------------------------------------
      r16117 | vda | 2006-09-14 09:19:19 -0400 (Thu, 14 Sep 2006) | 2 lines
      Changed paths:
         M /trunk/busybox/util-linux/mount.c
      
      mount: fix mtab support (but it is still rather buggy)
      
       ------------------------------------------------------------------------
      
      Index: util-linux/mount.c
      ===================================================================
      --- util-linux/mount.c	(revision 16116)
      +++ util-linux/mount.c	(revision 16117)
      @@ -223,6 +223,8 @@
       	 * mtab file by hand, add the new entry to it now. */
       
       	if(ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc) {
      +		char dirbuf[PATH_MAX];
      +		char srcbuf[PATH_MAX];
       		FILE *mountTable = setmntent(bb_path_mtab_file, "a+");
       		int i;
       
      @@ -232,27 +234,39 @@
       		// Add vfs string flags
       
       		for(i=0; mount_options[i].flags != MS_REMOUNT; i++)
      -			if (mount_options[i].flags > 0)
      +			if (mount_options[i].flags > 0 && (mount_options[i].flags&vfsflags))
       				append_mount_options(&(mp->mnt_opts), mount_options[i].name);
       
       		// Remove trailing / (if any) from directory we mounted on
       
      -		i = strlen(mp->mnt_dir);
      -		if(i>1 && mp->mnt_dir[i-1] == '/') mp->mnt_dir[i-1] = 0;
      +		i = strlen(mp->mnt_dir) - 1;
      +		if(i > 0 && mp->mnt_dir[i] == '/') mp->mnt_dir[i] = 0;
       
      +		// Add full pathnames as needed
      +
      +		if (mp->mnt_dir[0] != '/') {
      +			getcwd(dirbuf, sizeof(dirbuf));
      +			i = strlen(dirbuf);
      +			/* strcat() would be unsafe here */
      +			snprintf(dirbuf+i, sizeof(dirbuf)-i, "/%s", mp->mnt_dir);
      +			mp->mnt_dir = dirbuf;
      +		}
      +		if (!mp->mnt_type || !*mp->mnt_type) { /* bind mount */
      +			if (mp->mnt_fsname[0] != '/') {
      +				getcwd(srcbuf, sizeof(srcbuf));
      +				i = strlen(srcbuf);
      +				snprintf(srcbuf+i, sizeof(srcbuf)-i, "/%s",
      +						mp->mnt_fsname);
      +				mp->mnt_fsname = srcbuf;
      +			}
      +			mp->mnt_type = "none";
      +			mp->mnt_freq = mp->mnt_passno = 0;
      +		}
      +
       		// Write and close.
       
      -		if(!mp->mnt_type || !*mp->mnt_type) mp->mnt_type="--bind";
      -//		addmntent(mountTable, mp);
      -if(0) bb_error_msg("buggy: addmntent(fsname='%s' dir='%s' type='%s' opts='%s')",
      -mp->mnt_fsname,
      -mp->mnt_dir,
      -mp->mnt_type,
      -mp->mnt_opts
      -);
      +		addmntent(mountTable, mp);
       		endmntent(mountTable);
      -		if (ENABLE_FEATURE_CLEAN_UP)
      -			if(strcmp(mp->mnt_type,"--bind")) mp->mnt_type = 0;
       	}
       
       	return rc;
      
       ------------------------------------------------------------------------
      r16116 | landley | 2006-09-14 01:59:32 -0400 (Thu, 14 Sep 2006) | 8 lines
      Changed paths:
         M /trunk/busybox/docs/busybox.net/license.html
      
      svn 15355 replaced "BusyBox is licensed under the GNU General Public Public
      License" with "BusyBox is licensed under the GNU General Public
      License version 2 or later... (This is the same license the Linux kernel
      is under...)"  Except that the Linux kernel isn't under GPLv2 or later,
      it's just under GPLv2.
      
      Now they match again.
      
       ------------------------------------------------------------------------
      
      Index: docs/busybox.net/license.html
      ===================================================================
      --- docs/busybox.net/license.html	(revision 16115)
      +++ docs/busybox.net/license.html	(revision 16116)
      @@ -4,7 +4,7 @@
       

      BusyBox is licensed under the GNU General Public License

      BusyBox is licensed under the -GNU General Public License version 2 or later, which is generally +GNU General Public License version 2, which is generally abbreviated as the GPL. (This is the same license the Linux kernel is under, so you may be somewhat familiar with it by now.)

      ------------------------------------------------------------------------ r16115 | landley | 2006-09-14 01:27:28 -0400 (Thu, 14 Sep 2006) | 6 lines Changed paths: M /trunk/busybox/util-linux/fsck_minix.c More code from kernel developers, and therefore licensed under GPLv2 only. Clarify the license boilerplate. On an unrelated note, this could use busyboxification. check_mount() looks reusable and ask() is generic... ------------------------------------------------------------------------ Index: util-linux/fsck_minix.c =================================================================== --- util-linux/fsck_minix.c (revision 16114) +++ util-linux/fsck_minix.c (revision 16115) @@ -2,8 +2,9 @@ /* * fsck.c - a file system consistency checker for Linux. * - * (C) 1991, 1992 Linus Torvalds. This file may be redistributed - * as per the GNU copyleft. + * (C) 1991, 1992 Linus Torvalds. + * + * Licensed under GPLv2, see file LICENSE in this tarball for details. */ /* @@ -86,17 +87,8 @@ * enforced (but it's not much fun on a character device :-). */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "busybox.h" +#include /* * This is the original minix inode layout on disk. ------------------------------------------------------------------------ r16114 | landley | 2006-09-13 15:54:36 -0400 (Wed, 13 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/docs/busybox.net/tinyutils.html Add Larry Doolittle's ntpclient, plus some formatting tweaks. ------------------------------------------------------------------------ Index: docs/busybox.net/tinyutils.html =================================================================== --- docs/busybox.net/tinyutils.html (revision 16113) +++ docs/busybox.net/tinyutils.html (revision 16114) @@ -9,7 +9,7 @@

      - +
      @@ -25,8 +25,14 @@ - + + + + +
      Feature Utilities
      SMTPssmtp is an extremely simple MTA.ssmtp is an extremely simple Mail Transfer Agent.
      ntpntpclient is a +tiny ntp client. BusyBox has rdate to set the date from a remote server, but +if you want a daemon to repeatedly adjust the clock over time, try that.

      In a gui environment, you'll probably want a web browser. @@ -38,7 +44,7 @@

      SCRIPTING LANGUAGES

      Although busybox has built-in support for shell scripts, plenty of other small scripting languages are available on the net. A few examples:

      - +
      ------------------------------------------------------------------------ r16113 | aldot | 2006-09-13 12:39:19 -0400 (Wed, 13 Sep 2006) | 3 lines Changed paths: M /trunk/busybox/coreutils/sum.c M /trunk/busybox/debianutils/readlink.c M /trunk/busybox/debianutils/run_parts.c M /trunk/busybox/debianutils/which.c M /trunk/busybox/findutils/grep.c M /trunk/busybox/libbb/bb_pwd.c M /trunk/busybox/libbb/find_pid_by_name.c M /trunk/busybox/libbb/llist.c M /trunk/busybox/loginutils/su.c M /trunk/busybox/procps/pidof.c M /trunk/busybox/procps/ps.c M /trunk/busybox/util-linux/swaponoff.c - fix copy'n paste errors that got introduced when switching to the shorter boilerplate. No object code changes. ------------------------------------------------------------------------ Index: debianutils/which.c =================================================================== --- debianutils/which.c (revision 16112) +++ debianutils/which.c (revision 16113) @@ -4,7 +4,7 @@ * * Copyright (C) 1999-2004 by Erik Andersen * - * Licensed under the GPL v2, see the file LICENSE in this tarball. + * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. * * Based on which from debianutils */ Index: debianutils/readlink.c =================================================================== --- debianutils/readlink.c (revision 16112) +++ debianutils/readlink.c (revision 16113) @@ -4,7 +4,7 @@ * * Copyright (C) 2000,2001 Matt Kraai * - * Licensed under GPL v2, see file LICENSE in this tarball for details. + * Licensed under GPL v2 or later, see file LICENSE in this tarball for details. */ #include "busybox.h" Index: debianutils/run_parts.c =================================================================== --- debianutils/run_parts.c (revision 16112) +++ debianutils/run_parts.c (revision 16113) @@ -10,7 +10,7 @@ * Copyright (C) 1996-1999 Guy Maor * * - * Licensed under GPL v2, see file LICENSE in this tarball for details. + * Licensed under GPL v2 or later, see file LICENSE in this tarball for details. */ /* This is my first attempt to write a program in C (well, this is my first Index: coreutils/sum.c =================================================================== --- coreutils/sum.c (revision 16112) +++ coreutils/sum.c (revision 16113) @@ -10,7 +10,7 @@ * Written by Kayvan Aghaiepour and David MacKenzie * Taken from coreutils and turned into a busybox applet by Mike Frysinger * - * Licensed under the GPL v2, see the file LICENSE in this tarball. + * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ #include "busybox.h" Index: libbb/llist.c =================================================================== --- libbb/llist.c (revision 16112) +++ libbb/llist.c (revision 16113) @@ -7,7 +7,7 @@ * Copyright (C) 2005 Bernhard Fischer * Copyright (C) 2006 Rob Landley * - * Licensed under the GPL v2, see the file LICENSE in this tarball. + * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ #include Index: libbb/find_pid_by_name.c =================================================================== --- libbb/find_pid_by_name.c (revision 16112) +++ libbb/find_pid_by_name.c (revision 16113) @@ -4,7 +4,7 @@ * * Copyright (C) 1999-2004 by Erik Andersen * - * Licensed under the GPL v2, see the file LICENSE in this tarball. + * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ #include Index: libbb/bb_pwd.c =================================================================== --- libbb/bb_pwd.c (revision 16112) +++ libbb/bb_pwd.c (revision 16113) @@ -4,7 +4,7 @@ * * Copyright (C) 1999-2004 by Erik Andersen * - * Licensed under the GPL v2, see the file LICENSE in this tarball. + * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ Index: loginutils/su.c =================================================================== --- loginutils/su.c (revision 16112) +++ loginutils/su.c (revision 16113) @@ -2,7 +2,7 @@ /* * Mini su implementation for busybox * - * Licensed under the GPL v2, see the file LICENSE in this tarball. + * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ #include "busybox.h" Index: findutils/grep.c =================================================================== --- findutils/grep.c (revision 16112) +++ findutils/grep.c (revision 16113) @@ -5,7 +5,7 @@ * Copyright (C) 1999,2000,2001 by Lineo, inc. and Mark Whitley * Copyright (C) 1999,2000,2001 by Mark Whitley * - * Licensed under the GPL v2, see the file LICENSE in this tarball. + * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ /* BB_AUDIT SUSv3 defects - unsupported option -x. */ /* BB_AUDIT GNU defects - always acts as -a. */ Index: procps/pidof.c =================================================================== --- procps/pidof.c (revision 16112) +++ procps/pidof.c (revision 16113) @@ -4,7 +4,7 @@ * * Copyright (C) 1999-2004 by Erik Andersen * - * Licensed under the GPL v2, see the file LICENSE in this tarball. + * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ #include "busybox.h" Index: procps/ps.c =================================================================== --- procps/ps.c (revision 16112) +++ procps/ps.c (revision 16113) @@ -4,7 +4,7 @@ * * Copyright (C) 1999-2004 by Erik Andersen * - * Licensed under the GPL v2, see the file LICENSE in this tarball. + * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ #include "busybox.h" Index: util-linux/swaponoff.c =================================================================== --- util-linux/swaponoff.c (revision 16112) +++ util-linux/swaponoff.c (revision 16113) @@ -4,7 +4,7 @@ * * Copyright (C) 1999-2004 by Erik Andersen * - * Licensed under the GPL v2, see the file LICENSE in this tarball. + * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ #include "busybox.h" ------------------------------------------------------------------------ r16112 | aldot | 2006-09-13 11:42:47 -0400 (Wed, 13 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/loginutils/login.c - r16075 broke for de-selected FEATURE_UTMP; Partial fix that wants some more cleanup (see FIXME in the patch). ------------------------------------------------------------------------ Index: loginutils/login.c =================================================================== --- loginutils/login.c (revision 16111) +++ loginutils/login.c (revision 16112) @@ -3,23 +3,11 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -#include -#include -#include -#include -#include -#include -#include -#include +#include "busybox.h" #include #include -#include -#include -#include -#include -#include +#include -#include "busybox.h" #ifdef CONFIG_SELINUX #include /* for is_selinux_enabled() */ #include /* for get_default_context() */ @@ -27,12 +15,12 @@ #include #endif -#ifdef CONFIG_FEATURE_UTMP -// import from utmp.c +/* import from utmp.c + * XXX: FIXME: provide empty bodies if ENABLE_FEATURE_UTMP == 0 + */ static struct utmp utent; -static void read_or_build_utent(int picky); -static void write_utent(const char *username); -#endif +static void read_or_build_utent(int); +static void write_utent(const char *); enum { TIMEOUT = 60, @@ -43,12 +31,10 @@ static void die_if_nologin_and_non_root(int amroot); -#if defined CONFIG_FEATURE_SECURETTY +#if ENABLE_FEATURE_SECURETTY static int check_securetty(void); - #else static inline int check_securetty(void) { return 1; } - #endif static void get_username_or_die(char *buf, int size_buf); @@ -84,9 +70,6 @@ int flag; int count = 0; struct passwd *pw; -#ifdef CONFIG_WHEEL_GROUP - struct group *grp; -#endif int opt_preserve = 0; int opt_fflag = 0; char *opt_host = 0; @@ -321,7 +304,7 @@ puts("\r\n[Disconnect bypassed -- root login allowed.]\r"); } -#ifdef CONFIG_FEATURE_SECURETTY +#if ENABLE_FEATURE_SECURETTY static int check_securetty(void) { @@ -367,7 +350,7 @@ } -#ifdef CONFIG_FEATURE_UTMP +#if ENABLE_FEATURE_UTMP /* vv Taken from tinylogin utmp.c vv */ /* @@ -432,7 +415,7 @@ setutent(); pututline(&utent); endutent(); -#ifdef CONFIG_FEATURE_WTMP +#if ENABLE_FEATURE_WTMP if (access(bb_path_wtmp_file, R_OK|W_OK) == -1) { close(creat(bb_path_wtmp_file, 0664)); } ------------------------------------------------------------------------ r16111 | landley | 2006-09-12 18:42:03 -0400 (Tue, 12 Sep 2006) | 12 lines Changed paths: M /trunk/busybox/include/platform.h Revert duplicate patch. I don't know why patch decided to apply this even though it was already in the tree. I thought the other hunks failed because they were totally unrelated leakage from Bernhard's tree (which they are; was the a reason for bundling them in with this fix? Do they have something to do with the GCC 2.95 fix? I suspect they prevent me from backporting this patch to 1.2.2 because the header consolidation into libbb.h hadn't been done yet, and no I'm not fixing it up: if that's the case then this patch won't be in 1.2.2 due to extraneous changes bundled with it that prevent a clean backport without rolling a new patch). ------------------------------------------------------------------------ Index: include/platform.h =================================================================== --- include/platform.h (revision 16110) +++ include/platform.h (revision 16111) @@ -83,14 +83,6 @@ # endif #endif -/* gcc-2.95 had no va_copy but only __va_copy. */ -#if !__GNUC_PREREQ (3,0) -# include -# if !defined va_copy && defined __va_copy -# define va_copy(d,s) __va_copy((d),(s)) -# endif -#endif - /* ---- Endian Detection ------------------------------------ */ #if (defined __digital__ && defined __unix__) ------------------------------------------------------------------------ r16110 | landley | 2006-09-12 17:42:17 -0400 (Tue, 12 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/archival/gunzip.c M /trunk/busybox/archival/uncompress.c M /trunk/busybox/include/libbb.h M /trunk/busybox/libbb/xfuncs.c M /trunk/busybox/loginutils/deluser.c M /trunk/busybox/util-linux/swaponoff.c Remove pointless "const". Bloatcheck says 0 bytes difference. ------------------------------------------------------------------------ Index: archival/uncompress.c =================================================================== --- archival/uncompress.c (revision 16109) +++ archival/uncompress.c (revision 16110) @@ -19,8 +19,8 @@ flags = bb_getopt_ulflags(argc, argv, "cf"); while (optind < argc) { - const char *compressed_file = argv[optind++]; - const char *delete_path = NULL; + char *compressed_file = argv[optind++]; + char *delete_path = NULL; char *uncompressed_file = NULL; int src_fd; int dst_fd; Index: archival/gunzip.c =================================================================== --- archival/gunzip.c (revision 16109) +++ archival/gunzip.c (revision 16110) @@ -48,8 +48,8 @@ do { struct stat stat_buf; - const char *old_path = argv[optind]; - const char *delete_path = NULL; + char *old_path = argv[optind]; + char *delete_path = NULL; char *new_path = NULL; int src_fd; int dst_fd; Index: libbb/xfuncs.c =================================================================== --- libbb/xfuncs.c (revision 16109) +++ libbb/xfuncs.c (revision 16110) @@ -490,7 +490,7 @@ #ifdef L_xstat /* xstat() - a stat() which dies on failure with meaningful error message */ -void xstat(const char * const name, struct stat *stat_buf) +void xstat(char *name, struct stat *stat_buf) { if (stat(name, stat_buf)) bb_perror_msg_and_die("Can't stat '%s'", name); Index: include/libbb.h =================================================================== --- include/libbb.h (revision 16109) +++ include/libbb.h (revision 16110) @@ -189,7 +189,7 @@ extern int bb_fclose_nonstdin(FILE *f); extern void bb_fflush_stdout_and_exit(int retval) ATTRIBUTE_NORETURN; -extern void xstat(const char * const filename, struct stat *buf); +extern void xstat(char *filename, struct stat *buf); extern int xsocket(int domain, int type, int protocol); extern pid_t spawn(char **argv); extern pid_t xspawn(char **argv); Index: loginutils/deluser.c =================================================================== --- loginutils/deluser.c (revision 16109) +++ loginutils/deluser.c (revision 16110) @@ -60,7 +60,8 @@ if ((passwd = bb_wfopen(filename, "r"))) { - xstat(filename, &statbuf); + // Remove pointless const. + xstat((char *)filename, &statbuf); buffer = (char *) xmalloc(statbuf.st_size * sizeof(char)); fread(buffer, statbuf.st_size, sizeof(char), passwd); fclose(passwd); Index: util-linux/swaponoff.c =================================================================== --- util-linux/swaponoff.c (revision 16109) +++ util-linux/swaponoff.c (revision 16110) @@ -15,7 +15,7 @@ #include -static int swap_enable_disable(const char *device) +static int swap_enable_disable(char *device) { int status; struct stat st; ------------------------------------------------------------------------ r16109 | landley | 2006-09-12 16:29:22 -0400 (Tue, 12 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/include/platform.h Fix from Bernhard for somebody trying to limp along with gcc 2.95.4. ------------------------------------------------------------------------ Index: include/platform.h =================================================================== --- include/platform.h (revision 16108) +++ include/platform.h (revision 16109) @@ -83,6 +83,14 @@ # endif #endif +/* gcc-2.95 had no va_copy but only __va_copy. */ +#if !__GNUC_PREREQ (3,0) +# include +# if !defined va_copy && defined __va_copy +# define va_copy(d,s) __va_copy((d),(s)) +# endif +#endif + /* ---- Endian Detection ------------------------------------ */ #if (defined __digital__ && defined __unix__) ------------------------------------------------------------------------ r16108 | landley | 2006-09-12 16:28:34 -0400 (Tue, 12 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/procps/kill.c Random cleanup hanging around my tree. ------------------------------------------------------------------------ Index: procps/kill.c =================================================================== --- procps/kill.c (revision 16107) +++ procps/kill.c (revision 16108) @@ -9,14 +9,6 @@ */ #include "busybox.h" -#include -#include -#include -#include -#include -#include -#include -#include int kill_main(int argc, char **argv) { ------------------------------------------------------------------------ r16107 | aldot | 2006-09-12 09:27:55 -0400 (Tue, 12 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/include/platform.h M /trunk/busybox/libbb/verror_msg.c M /trunk/busybox/libbb/vherror_msg.c M /trunk/busybox/libbb/vinfo_msg.c M /trunk/busybox/libbb/vperror_msg.c - small trivia to be gentle to gcc-2.95.x which had no va_copy but only __va_copy. ------------------------------------------------------------------------ Index: libbb/verror_msg.c =================================================================== --- libbb/verror_msg.c (revision 16106) +++ libbb/verror_msg.c (revision 16107) @@ -7,12 +7,8 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -#include -#include -#include -#include -#include #include "libbb.h" +#include int logmode = LOGMODE_STDIO; const char *msg_eol = "\n"; Index: libbb/vherror_msg.c =================================================================== --- libbb/vherror_msg.c (revision 16106) +++ libbb/vherror_msg.c (revision 16107) @@ -7,13 +7,8 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -#include -#include -#include - #include "libbb.h" - void bb_vherror_msg(const char *s, va_list p) { bb_verror_msg(s, p, hstrerror(h_errno)); Index: libbb/vperror_msg.c =================================================================== --- libbb/vperror_msg.c (revision 16106) +++ libbb/vperror_msg.c (revision 16107) @@ -7,10 +7,6 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -#include -#include -#include -#include #include "libbb.h" void bb_vperror_msg(const char *s, va_list p) Index: libbb/vinfo_msg.c =================================================================== --- libbb/vinfo_msg.c (revision 16106) +++ libbb/vinfo_msg.c (revision 16107) @@ -7,12 +7,8 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -#include -#include -#include -#include -#include #include "libbb.h" +#include void bb_vinfo_msg(const char *s, va_list p) { Index: include/platform.h =================================================================== --- include/platform.h (revision 16106) +++ include/platform.h (revision 16107) @@ -75,6 +75,14 @@ # endif #endif +/* gcc-2.95 had no va_copy but only __va_copy. */ +#if !__GNUC_PREREQ (3,0) +# include +# if !defined va_copy && defined __va_copy +# define va_copy(d,s) __va_copy((d),(s)) +# endif +#endif + /* ---- Endian Detection ------------------------------------ */ #if (defined __digital__ && defined __unix__) ------------------------------------------------------------------------ r16106 | aldot | 2006-09-12 09:25:16 -0400 (Tue, 12 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/libbb/run_parts.c - fix warning about discarding qualifiers in initialization ------------------------------------------------------------------------ Index: libbb/run_parts.c =================================================================== --- libbb/run_parts.c (revision 16105) +++ libbb/run_parts.c (revision 16106) @@ -27,7 +27,7 @@ */ static int valid_name(const struct dirent *d) { - char *c = d->d_name; + const char *c = d->d_name; while (*c) { if (!isalnum(*c) && (*c != '_') && (*c != '-')) { ------------------------------------------------------------------------ r16102 | vda | 2006-09-11 13:42:44 -0400 (Mon, 11 Sep 2006) | 8 lines Changed paths: M /trunk/busybox/include/libbb.h M /trunk/busybox/util-linux/mount.c M /trunk/busybox/util-linux/nfsmount.c nfsmount: sanitize it. It had a rather peculiar idea of implementing "bg" option - it was going to return a special flag back to caller and expecting caller to call it again with special parameter! Also caller was charged with calling mount() syscall... mount: mtab support was non-functional. Enabling it revealed serious bug which is not fixed yet. ------------------------------------------------------------------------ Index: include/libbb.h =================================================================== --- include/libbb.h (revision 16101) +++ include/libbb.h (revision 16102) @@ -303,8 +303,8 @@ extern int vdprintf(int d, const char *format, va_list ap); #endif -int nfsmount(const char *spec, const char *node, int *flags, - char **mount_opts, int running_bg); +int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts); +int nfsmount(struct mntent *mp, int vfsflags, char *filteropts); /* Include our own copy of struct sysinfo to avoid binary compatibility * problems with Linux 2.4, which changed things. Grumble, grumble. */ Index: util-linux/mount.c =================================================================== --- util-linux/mount.c (revision 16101) +++ util-linux/mount.c (revision 16102) @@ -102,7 +102,7 @@ } /* Use the mount_options list to parse options into flags. - * Return list of unrecognized options in *strflags if strflags!=NULL */ + * Also return list of unrecognized options if unrecognized!=NULL */ static int parse_mount_options(char *options, char **unrecognized) { int flags = MS_SILENT; @@ -188,7 +188,7 @@ #endif #if ENABLE_FEATURE_MTAB_SUPPORT -static int useMtab; +static int useMtab = 1; static int fakeIt; #else #define useMtab 0 @@ -196,8 +196,7 @@ #endif // Perform actual mount of specific filesystem at specific location. - -static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts) +int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts) { int rc; @@ -228,7 +227,7 @@ int i; if(!mountTable) - bb_error_msg("No %s",bb_path_mtab_file); + bb_error_msg("no %s",bb_path_mtab_file); // Add vfs string flags @@ -244,7 +243,13 @@ // Write and close. if(!mp->mnt_type || !*mp->mnt_type) mp->mnt_type="--bind"; - addmntent(mountTable, mp); +// addmntent(mountTable, mp); +if(0) bb_error_msg("buggy: addmntent(fsname='%s' dir='%s' type='%s' opts='%s')", +mp->mnt_fsname, +mp->mnt_dir, +mp->mnt_type, +mp->mnt_opts +); endmntent(mountTable); if (ENABLE_FEATURE_CLEAN_UP) if(strcmp(mp->mnt_type,"--bind")) mp->mnt_type = 0; @@ -319,13 +324,7 @@ (!mp->mnt_type || !strcmp(mp->mnt_type,"nfs")) && strchr(mp->mnt_fsname, ':') != NULL) { - if (nfsmount(mp->mnt_fsname, mp->mnt_dir, &vfsflags, &filteropts, 1)) { - bb_perror_msg("nfsmount failed"); - } else { - // Strangely enough, nfsmount() doesn't actually mount() anything. - mp->mnt_type = "nfs"; - rc = mount_it_now(mp, vfsflags, filteropts); - } + rc = nfsmount(mp, vfsflags, filteropts); goto report_error; } @@ -400,7 +399,8 @@ if (rc && errno == EBUSY && ignore_busy) rc = 0; if (rc < 0) - bb_perror_msg("mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir); + /* perror here sometimes says "mounting ... on ... failed: Success" */ + bb_error_msg("mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir); return rc; } Index: util-linux/nfsmount.c =================================================================== --- util-linux/nfsmount.c (revision 16101) +++ util-linux/nfsmount.c (revision 16102) @@ -22,6 +22,8 @@ */ #include "busybox.h" +#include +#include #include #undef TRUE #undef FALSE @@ -332,15 +334,8 @@ return TRUE; } - #define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2) -enum { - EX_FAIL = 32, /* mount failure */ - EX_BG = 256 /* retry in background (internal only) */ -}; - - /* * nfs_mount_version according to the sources seen at compile time. */ @@ -426,50 +421,62 @@ return &p; } -int nfsmount(const char *spec, const char *node, int *flags, - char **mount_opts, int running_bg) +static int daemonize(void) { - /* prev_bg_host is a -o bg support: - * "bg: if the first NFS mount attempt times out, - * retry the mount in the background. - * After a mount operation is backgrounded, - * all subsequent mounts on the same NFS server - * will be backgrounded immediately, without first - * attempting the mount. A missing mount point is treated - * as a timeout, to allow for nested NFS mounts." - * - * But current implementation is a dirty hack - - * it works only if all mounts are to one host! - * IOW: think what will happen if you have this sequence: - * mount a.a.a.a:/dir /mnt/a -o bg - * mount b.b.b.b:/dir /mnt/b -o bg - * mount a.a.a.a:/dir /mnt/a -o bg - * mount b.b.b.b:/dir /mnt/b -o bg - */ + int fd; + int pid = fork(); + if (pid < 0) /* error */ + return -errno; + if (pid > 0) /* parent */ + return 0; + /* child */ + fd = xopen(bb_dev_null, O_RDWR); + dup2(fd, 0); + dup2(fd, 1); + dup2(fd, 2); + if (fd > 2) close(fd); + setsid(); + openlog(bb_applet_name, LOG_PID, LOG_DAEMON); + logmode = LOGMODE_SYSLOG; + return 1; +} - static char *prev_bg_host; - char *hostdir; +// TODO +static inline int we_saw_this_host_before(const char *hostname) +{ + return 0; +} + +/* RPC strerror analogs are terminally idiotic: + * *mandatory* prefix and \n at end. + * This hopefully helps. Usage: + * error_msg_rpc(clnt_*error*(" ")) */ +static void error_msg_rpc(const char *msg) +{ + size_t len; + while (msg[0] == ' ' || msg[0] == ':') msg++; + len = strlen(msg); + while (len && msg[len-1] == '\n') len--; + bb_error_msg("%.*s", len, msg); +} + +int nfsmount(struct mntent *mp, int vfsflags, char *filteropts) +{ CLIENT *mclient; char *hostname; char *pathname; - char *old_opts; char *mounthost; - struct timeval total_timeout; - enum clnt_stat clnt_stat; struct nfs_mount_data data; - char *opt, *opteq; - int val; + char *opt; struct hostent *hp; struct sockaddr_in server_addr; struct sockaddr_in mount_server_addr; - struct pmap* pm_mnt; int msock, fsock; - struct timeval retry_timeout; union { struct fhstatus nfsv2; struct mountres3 nfsv3; } status; - struct stat statbuf; + int daemonized; char *s; int port; int mountport; @@ -488,29 +495,27 @@ int nfsprog; int nfsvers; int retval; - time_t t; - time_t prevt; - time_t timeout; find_kernel_nfs_mount_version(); - /* NB: old_opts and hostdir must be free()d prior to return! */ - - old_opts = NULL; + daemonized = 0; mounthost = NULL; - retval = EX_FAIL; + retval = ETIMEDOUT; msock = fsock = -1; mclient = NULL; - hostdir = xstrdup(spec); + /* NB: hostname, mounthost, filteropts must be free()d prior to return */ + + filteropts = xstrdup(filteropts); /* going to trash it later... */ + + hostname = xstrdup(mp->mnt_fsname); /* mount_main() guarantees that ':' is there */ - s = strchr(hostdir, ':'); - hostname = hostdir; + s = strchr(hostname, ':'); pathname = s + 1; *s = '\0'; /* Ignore all but first hostname in replicated mounts until they can be fully supported. (mack@sgi.com) */ - s = strchr(hostdir, ','); + s = strchr(hostname, ','); if (s) { *s = '\0'; bb_error_msg("warning: multiple hostnames not supported"); @@ -538,12 +543,15 @@ /* add IP address to mtab options for use when unmounting */ - s = inet_ntoa(server_addr.sin_addr); - old_opts = *mount_opts; - if (!old_opts) - old_opts = xstrdup(""); - *mount_opts = xasprintf("%s%saddr=%s", - old_opts, *old_opts ? "," : "", s); + if (!mp->mnt_opts) { /* TODO: actually mp->mnt_opts is never NULL */ + mp->mnt_opts = xasprintf("addr=%s", inet_ntoa(server_addr.sin_addr)); + } else { + char *tmp = xasprintf("%s%saddr=%s", mp->mnt_opts, + mp->mnt_opts[0] ? "," : "", + inet_ntoa(server_addr.sin_addr)); + free(mp->mnt_opts); + mp->mnt_opts = tmp; + } /* Set default options. * rsize/wsize (and bsize, for ver >= 3) are left 0 in order to @@ -576,10 +584,10 @@ /* parse options */ - for (opt = strtok(old_opts, ","); opt; opt = strtok(NULL, ",")) { - opteq = strchr(opt, '='); + for (opt = strtok(filteropts, ","); opt; opt = strtok(NULL, ",")) { + char *opteq = strchr(opt, '='); if (opteq) { - val = atoi(opteq + 1); + int val = atoi(opteq + 1); *opteq = '\0'; if (!strcmp(opt, "rsize")) data.rsize = val; @@ -641,7 +649,7 @@ } } else { - val = 1; + int val = 1; if (!strncmp(opt, "no", 2)) { val = 0; opt += 2; @@ -723,19 +731,20 @@ data.version = nfs_mount_version; - if (*flags & MS_REMOUNT) - goto copy_data_and_return; + if (vfsflags & MS_REMOUNT) + goto do_mount; /* * If the previous mount operation on the same host was * backgrounded, and the "bg" for this mount is also set, * give up immediately, to avoid the initial timeout. */ - if (bg && !running_bg && - prev_bg_host && strcmp(hostname, prev_bg_host) == 0) { - if (retry > 0) - retval = EX_BG; - goto ret; + if (bg && we_saw_this_host_before(hostname)) { + daemonized = daemonize(); /* parent or error */ + if (daemonized <= 0) { /* parent or error */ + retval = -daemonized; + goto ret; + } } /* create mount daemon client */ @@ -745,7 +754,8 @@ mount_server_addr.sin_family = AF_INET; mount_server_addr.sin_addr.s_addr = inet_addr(hostname); } else { - if ((hp = gethostbyname(mounthost)) == NULL) { + hp = gethostbyname(mounthost); + if (hp == NULL) { bb_herror_msg("%s", mounthost); goto fail; } else { @@ -761,11 +771,9 @@ } /* - * The following loop implements the mount retries. On the first - * call, "running_bg" is 0. When the mount times out, and the - * "bg" option is set, the exit status EX_BG will be returned. - * For a backgrounded mount, there will be a second call by the - * child process with "running_bg" set to 1. + * The following loop implements the mount retries. When the mount + * times out, and the "bg" option is set, we background ourself + * and continue trying. * * The case where the mount point is not present and the "bg" * option is set, is treated as a timeout. This is done to @@ -773,116 +781,123 @@ * * The "retry" count specified by the user is the number of * minutes to retry before giving up. - * - * Only the first error message will be displayed. */ - retry_timeout.tv_sec = 3; - retry_timeout.tv_usec = 0; - total_timeout.tv_sec = 20; - total_timeout.tv_usec = 0; - timeout = time(NULL) + 60 * retry; - prevt = 0; - t = 30; - val = 1; - for (;;) { - if (bg && stat(node, &statbuf) == -1) { - if (running_bg) { - sleep(val); /* 1, 2, 4, 8, 16, 30, ... */ - val *= 2; - if (val > 30) - val = 30; - } - } else { - /* be careful not to use too many CPU cycles */ - if (t - prevt < 30) - sleep(30); + { + struct timeval total_timeout; + struct timeval retry_timeout; + struct pmap* pm_mnt; + time_t t; + time_t prevt; + time_t timeout; - pm_mnt = get_mountport(&mount_server_addr, - mountprog, - mountvers, - proto, - mountport); + retry_timeout.tv_sec = 3; + retry_timeout.tv_usec = 0; + total_timeout.tv_sec = 20; + total_timeout.tv_usec = 0; + timeout = time(NULL) + 60 * retry; + prevt = 0; + t = 30; +retry: + /* be careful not to use too many CPU cycles */ + if (t - prevt < 30) + sleep(30); - /* contact the mount daemon via TCP */ - mount_server_addr.sin_port = htons(pm_mnt->pm_port); - msock = RPC_ANYSOCK; + pm_mnt = get_mountport(&mount_server_addr, + mountprog, + mountvers, + proto, + mountport); + nfsvers = (pm_mnt->pm_vers < 2) ? 2 : pm_mnt->pm_vers; - switch (pm_mnt->pm_prot) { - case IPPROTO_UDP: - mclient = clntudp_create(&mount_server_addr, + /* contact the mount daemon via TCP */ + mount_server_addr.sin_port = htons(pm_mnt->pm_port); + msock = RPC_ANYSOCK; + + switch (pm_mnt->pm_prot) { + case IPPROTO_UDP: + mclient = clntudp_create(&mount_server_addr, pm_mnt->pm_prog, pm_mnt->pm_vers, retry_timeout, &msock); - if (mclient) - break; - mount_server_addr.sin_port = htons(pm_mnt->pm_port); - msock = RPC_ANYSOCK; - case IPPROTO_TCP: - mclient = clnttcp_create(&mount_server_addr, + if (mclient) + break; + mount_server_addr.sin_port = htons(pm_mnt->pm_port); + msock = RPC_ANYSOCK; + case IPPROTO_TCP: + mclient = clnttcp_create(&mount_server_addr, pm_mnt->pm_prog, pm_mnt->pm_vers, &msock, 0, 0); - break; - default: - mclient = 0; - } - if (mclient) { - /* try to mount hostname:pathname */ - mclient->cl_auth = authunix_create_default(); + break; + default: + mclient = 0; + } + if (!mclient) { + if (!daemonized && prevt == 0) + error_msg_rpc(clnt_spcreateerror(" ")); + } else { + enum clnt_stat clnt_stat; + /* try to mount hostname:pathname */ + mclient->cl_auth = authunix_create_default(); - /* make pointers in xdr_mountres3 NULL so - * that xdr_array allocates memory for us - */ - memset(&status, 0, sizeof(status)); + /* make pointers in xdr_mountres3 NULL so + * that xdr_array allocates memory for us + */ + memset(&status, 0, sizeof(status)); - if (pm_mnt->pm_vers == 3) - clnt_stat = clnt_call(mclient, MOUNTPROC3_MNT, - (xdrproc_t) xdr_dirpath, - (caddr_t) &pathname, - (xdrproc_t) xdr_mountres3, - (caddr_t) &status, - total_timeout); - else - clnt_stat = clnt_call(mclient, MOUNTPROC_MNT, - (xdrproc_t) xdr_dirpath, - (caddr_t) &pathname, - (xdrproc_t) xdr_fhstatus, - (caddr_t) &status, - total_timeout); + if (pm_mnt->pm_vers == 3) + clnt_stat = clnt_call(mclient, MOUNTPROC3_MNT, + (xdrproc_t) xdr_dirpath, + (caddr_t) &pathname, + (xdrproc_t) xdr_mountres3, + (caddr_t) &status, + total_timeout); + else + clnt_stat = clnt_call(mclient, MOUNTPROC_MNT, + (xdrproc_t) xdr_dirpath, + (caddr_t) &pathname, + (xdrproc_t) xdr_fhstatus, + (caddr_t) &status, + total_timeout); - if (clnt_stat == RPC_SUCCESS) - break; /* we're done */ - if (errno != ECONNREFUSED) { - clnt_perror(mclient, "mount"); - goto fail; /* don't retry */ - } - if (!running_bg && prevt == 0) - clnt_perror(mclient, "mount"); - auth_destroy(mclient->cl_auth); - clnt_destroy(mclient); - mclient = 0; - close(msock); - } else { - if (!running_bg && prevt == 0) - clnt_pcreateerror("mount"); + if (clnt_stat == RPC_SUCCESS) + goto prepare_kernel_data; /* we're done */ + if (errno != ECONNREFUSED) { + error_msg_rpc(clnt_sperror(mclient, " ")); + goto fail; /* don't retry */ } - prevt = t; + /* Connection refused */ + if (!daemonized && prevt == 0) /* print just once */ + error_msg_rpc(clnt_sperror(mclient, " ")); + auth_destroy(mclient->cl_auth); + clnt_destroy(mclient); + mclient = 0; + close(msock); } + + /* Timeout. We are going to retry... maybe */ + if (!bg) goto fail; - if (!running_bg) { - prev_bg_host = xstrdup(hostname); - if (retry > 0) - retval = EX_BG; - goto fail; + if (!daemonized) { + daemonized = daemonize(); + if (daemonized <= 0) { /* parent or error */ + retval = -daemonized; + goto ret; + } } + prevt = t; t = time(NULL); if (t >= timeout) + /* TODO error message */ goto fail; + + goto retry; } - nfsvers = (pm_mnt->pm_vers < 2) ? 2 : pm_mnt->pm_vers; +prepare_kernel_data: + if (nfsvers == 2) { if (status.nfsv2.fhs_status != 0) { bb_error_msg("%s:%s failed, reason given by server: %s", @@ -927,17 +942,17 @@ } else fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (fsock < 0) { - perror("nfs socket"); + bb_perror_msg("nfs socket"); goto fail; } if (bindresvport(fsock, 0) < 0) { - perror("nfs bindresvport"); + bb_perror_msg("nfs bindresvport"); goto fail; } if (port == 0) { server_addr.sin_port = PMAPPORT; port = pmap_getport(&server_addr, nfsprog, nfsvers, - tcp ? IPPROTO_TCP : IPPROTO_UDP); + tcp ? IPPROTO_TCP : IPPROTO_UDP); if (port == 0) port = NFS_PORT; #ifdef NFS_MOUNT_DEBUG @@ -961,16 +976,34 @@ auth_destroy(mclient->cl_auth); clnt_destroy(mclient); close(msock); -copy_data_and_return: - *mount_opts = xrealloc(*mount_opts, sizeof(data)); - memcpy(*mount_opts, &data, sizeof(data)); - retval = 0; + if (bg) { + /* We must wait until mount directory is available */ + struct stat statbuf; + int delay = 1; + while (stat(mp->mnt_dir, &statbuf) == -1) { + if (!daemonized) { + daemonized = daemonize(); + if (daemonized <= 0) { /* parent or error */ + retval = -daemonized; + goto ret; + } + } + sleep(delay); /* 1, 2, 4, 8, 16, 30, ... */ + delay *= 2; + if (delay > 30) + delay = 30; + } + } + +do_mount: /* perform actual mount */ + + mp->mnt_type = "nfs"; + retval = mount_it_now(mp, vfsflags, (char*)&data); goto ret; - /* abort */ +fail: /* abort */ -fail: if (msock != -1) { if (mclient) { auth_destroy(mclient->cl_auth); @@ -982,7 +1015,8 @@ close(fsock); ret: - free(hostdir); - free(old_opts); + free(hostname); + free(mounthost); + free(filteropts); return retval; } ------------------------------------------------------------------------ r16101 | aldot | 2006-09-11 12:01:40 -0400 (Mon, 11 Sep 2006) | 17 lines Changed paths: M /trunk/busybox/archival/gzip.c M /trunk/busybox/archival/unzip.c M /trunk/busybox/miscutils/crontab.c M /trunk/busybox/miscutils/mt.c M /trunk/busybox/miscutils/rx.c M /trunk/busybox/networking/vconfig.c M /trunk/busybox/util-linux/mkfs_minix.c - convert a few xopen3(,,0) into xopen(,). Also peruse the fact that xopen defaults to 0777 on it's own, so we don't need to xopen3(,,0777). Saves a few bytes: $ size busybox.old busybox text data bss dec hex filename 839676 8780 243592 1092048 10a9d0 busybox.old 839660 8780 243592 1092032 10a9c0 busybox $ make CC=gcc-4.2-HEAD bloatcheck function old new delta static.vconfig_main 281 279 -2 static.rx_main 1076 1074 -2 static.mt_main 294 292 -2 static.gzip_main 753 751 -2 static.mkfs_minix_main 4034 4030 -4 static.unzip_main 1771 1766 -5 static.crontab_main 1513 1507 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/7 up/down: 0/-23) Total: -23 bytes ------------------------------------------------------------------------ Index: networking/vconfig.c =================================================================== --- networking/vconfig.c (revision 16100) +++ networking/vconfig.c (revision 16101) @@ -118,7 +118,7 @@ /* Don't bother closing the filedes. It will be closed on cleanup. */ /* Will die if 802.1q is not present */ - xopen3(conf_file_name, O_RDONLY, 0); + xopen(conf_file_name, O_RDONLY); memset(&ifr, 0, sizeof(struct vlan_ioctl_args)); Index: archival/unzip.c =================================================================== --- archival/unzip.c (revision 16100) +++ archival/unzip.c (revision 16101) @@ -333,7 +333,7 @@ overwrite = o_always; case 'y': /* Open file and fall into unzip */ unzip_create_leading_dirs(dst_fn); - dst_fd = xopen3(dst_fn, O_WRONLY | O_CREAT | O_TRUNC, 0777); + dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC); case -1: /* Unzip */ if (verbosity == v_normal) { printf(" inflating: %s\n", dst_fn); Index: archival/gzip.c =================================================================== --- archival/gzip.c (revision 16100) +++ archival/gzip.c (revision 16101) @@ -1206,7 +1206,7 @@ inFileNum = STDIN_FILENO; outFileNum = STDOUT_FILENO; } else { - inFileNum = xopen3(argv[i], O_RDONLY, 0); + inFileNum = xopen(argv[i], O_RDONLY); if (fstat(inFileNum, &statBuf) < 0) bb_perror_msg_and_die("%s", argv[i]); time_stamp = statBuf.st_ctime; Index: miscutils/mt.c =================================================================== --- miscutils/mt.c (revision 16100) +++ miscutils/mt.c (revision 16101) @@ -101,7 +101,7 @@ break; } - fd = xopen3(file, mode, 0); + fd = xopen(file, mode); switch (code->value) { case MTTELL: Index: miscutils/crontab.c =================================================================== --- miscutils/crontab.c (revision 16100) +++ miscutils/crontab.c (revision 16101) @@ -266,7 +266,7 @@ exit(0); bb_default_error_retval = 0; - fd = xopen3(file, O_RDONLY, 0); + fd = xopen(file, O_RDONLY); buf[0] = 0; write(filedes[1], buf, 1); while ((n = read(fd, buf, sizeof(buf))) > 0) { Index: miscutils/rx.c =================================================================== --- miscutils/rx.c (revision 16100) +++ miscutils/rx.c (revision 16101) @@ -262,7 +262,7 @@ bb_show_usage(); fn = argv[1]; - ttyfd = xopen3(CURRENT_TTY, O_RDWR, 0); + ttyfd = xopen(CURRENT_TTY, O_RDWR); filefd = xopen3(fn, O_RDWR|O_CREAT|O_TRUNC, 0666); if (tcgetattr(ttyfd, &tty) < 0) Index: util-linux/mkfs_minix.c =================================================================== --- util-linux/mkfs_minix.c (revision 16100) +++ util-linux/mkfs_minix.c (revision 16101) @@ -292,7 +292,7 @@ int fd; long size; - fd = xopen3(file, O_RDWR, 0); + fd = xopen(file, O_RDWR); if (ioctl(fd, BLKGETSIZE, &size) >= 0) { close(fd); return (size * 512); @@ -805,7 +805,7 @@ tmp += dirsize; *(short *) tmp = 2; strcpy(tmp + 2, ".badblocks"); - DEV = xopen3(device_name, O_RDWR, 0); + DEV = xopen(device_name, O_RDWR); if (fstat(DEV, &statbuf) < 0) bb_error_msg_and_die("unable to stat %s", device_name); if (!S_ISBLK(statbuf.st_mode)) ------------------------------------------------------------------------ r16100 | aldot | 2006-09-11 05:18:09 -0400 (Mon, 11 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/include/libbb.h M /trunk/busybox/libbb/Makefile.in M /trunk/busybox/libbb/xfuncs.c D /trunk/busybox/libbb/xstat.c - merge xstat.c into xfuncs.c ------------------------------------------------------------------------ Index: libbb/Makefile.in =================================================================== --- libbb/Makefile.in (revision 16099) +++ libbb/Makefile.in (revision 16100) @@ -29,7 +29,7 @@ safe_strncpy.c setup_environment.c sha1.c simplify_path.c \ trim.c u_signal_names.c vdprintf.c verror_msg.c \ info_msg.c vinfo_msg.c \ - vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c xstat.c \ + vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c \ xgethostbyname.c xgethostbyname2.c xreadlink.c xgetlarg.c \ get_terminal_width_height.c fclose_nonstdin.c fflush_stdout_and_exit.c \ getopt_ulflags.c default_error_retval.c wfopen_input.c speed_table.c \ Index: libbb/xfuncs.c =================================================================== --- libbb/xfuncs.c (revision 16099) +++ libbb/xfuncs.c (revision 16100) @@ -487,3 +487,13 @@ if (listen(s, backlog)) bb_perror_msg_and_die("listen"); } #endif + +#ifdef L_xstat +/* xstat() - a stat() which dies on failure with meaningful error message */ +void xstat(const char * const name, struct stat *stat_buf) +{ + if (stat(name, stat_buf)) + bb_perror_msg_and_die("Can't stat '%s'", name); +} +#endif + Index: libbb/xstat.c =================================================================== --- libbb/xstat.c (revision 16099) +++ libbb/xstat.c (revision 16100) @@ -1,12 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * xstat.c - a stat() which dies on failure with meaningful error message - */ -#include -#include "libbb.h" - -void xstat(const char *name, struct stat *stat_buf) -{ - if (stat(name, stat_buf)) - bb_perror_msg_and_die("Can't stat '%s'", name); -} Index: include/libbb.h =================================================================== --- include/libbb.h (revision 16099) +++ include/libbb.h (revision 16100) @@ -189,7 +189,7 @@ extern int bb_fclose_nonstdin(FILE *f); extern void bb_fflush_stdout_and_exit(int retval) ATTRIBUTE_NORETURN; -extern void xstat(const char *filename, struct stat *buf); +extern void xstat(const char * const filename, struct stat *buf); extern int xsocket(int domain, int type, int protocol); extern pid_t spawn(char **argv); extern pid_t xspawn(char **argv); ------------------------------------------------------------------------ r16099 | aldot | 2006-09-11 05:16:12 -0400 (Mon, 11 Sep 2006) | 2 lines Changed paths: A /trunk/busybox/e2fsprogs/blkid/list.c - Tito pointed out that Rob forgot to add e2fsprogs/blkid/list.c ------------------------------------------------------------------------ Index: e2fsprogs/blkid/list.c =================================================================== --- e2fsprogs/blkid/list.c (revision 0) +++ e2fsprogs/blkid/list.c (revision 16099) @@ -0,0 +1,110 @@ +/* vi: set sw=4 ts=4: */ + +#include "list.h" + +/* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +void __list_add(struct list_head * add, + struct list_head * prev, + struct list_head * next) +{ + next->prev = add; + add->next = next; + add->prev = prev; + prev->next = add; +} + +/* + * list_add - add a new entry + * @add: new entry to be added + * @head: list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + */ +void list_add(struct list_head *add, struct list_head *head) +{ + __list_add(add, head, head->next); +} + +/* + * list_add_tail - add a new entry + * @add: new entry to be added + * @head: list head to add it before + * + * Insert a new entry before the specified head. + * This is useful for implementing queues. + */ +void list_add_tail(struct list_head *add, struct list_head *head) +{ + __list_add(add, head->prev, head); +} + +/* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +void __list_del(struct list_head * prev, struct list_head * next) +{ + next->prev = prev; + prev->next = next; +} + +/* + * list_del - deletes entry from list. + * @entry: the element to delete from the list. + * + * list_empty() on @entry does not return true after this, @entry is + * in an undefined state. + */ +void list_del(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); +} + +/* + * list_del_init - deletes entry from list and reinitialize it. + * @entry: the element to delete from the list. + */ +void list_del_init(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); + INIT_LIST_HEAD(entry); +} + +/* + * list_empty - tests whether a list is empty + * @head: the list to test. + */ +int list_empty(struct list_head *head) +{ + return head->next == head; +} + +/* + * list_splice - join two lists + * @list: the new list to add. + * @head: the place to add it in the first list. + */ +void list_splice(struct list_head *list, struct list_head *head) +{ + struct list_head *first = list->next; + + if (first != list) { + struct list_head *last = list->prev; + struct list_head *at = head->next; + + first->prev = head; + head->next = first; + + last->next = at; + at->prev = last; + } +} ------------------------------------------------------------------------ r16098 | landley | 2006-09-10 21:34:21 -0400 (Sun, 10 Sep 2006) | 2 lines Changed paths: M /trunk/busybox/e2fsprogs/Makefile.in M /trunk/busybox/e2fsprogs/blkid/list.h M /trunk/busybox/e2fsprogs/e2fsck.c M /trunk/busybox/e2fsprogs/e2fsck.h M /trunk/busybox/networking/udhcp/dhcpc.c M /trunk/busybox/sysklogd/syslogd.c Build fixes for gcc 4.0 with -Werror, from Tito. ------------------------------------------------------------------------ Index: networking/udhcp/dhcpc.c =================================================================== --- networking/udhcp/dhcpc.c (revision 16097) +++ networking/udhcp/dhcpc.c (revision 16098) @@ -144,7 +144,7 @@ { uint8_t *temp, *message; unsigned long t1 = 0, t2 = 0, xid = 0; - unsigned long start = 0, lease; + unsigned long start = 0, lease = 0; fd_set rfds; int retval; struct timeval tv; Index: sysklogd/syslogd.c =================================================================== --- sysklogd/syslogd.c (revision 16097) +++ sysklogd/syslogd.c (revision 16098) @@ -258,7 +258,7 @@ static void message(char *fmt, ...) __attribute__ ((format(printf, 1, 2))); static void message(char *fmt, ...) { - int fd; + int fd = -1; struct flock fl; va_list arguments; Index: e2fsprogs/Makefile.in =================================================================== --- e2fsprogs/Makefile.in (revision 16097) +++ e2fsprogs/Makefile.in (revision 16098) @@ -12,7 +12,7 @@ E2FSPROGS_CFLAGS := -include $(E2FSPROGS_SRC)/e2fsbb.h BLKID_SRC := cache.c dev.c devname.c devno.c blkid_getsize.c \ - probe.c read.c resolve.c save.c tag.c + probe.c read.c resolve.c save.c tag.c list.c BLKID_SRCS := $(patsubst %,blkid/%, $(BLKID_SRC)) BLKID_OBJS := $(patsubst %.c,%.o, $(BLKID_SRCS)) Index: e2fsprogs/blkid/list.h =================================================================== --- e2fsprogs/blkid/list.h (revision 16097) +++ e2fsprogs/blkid/list.h (revision 16098) @@ -6,12 +6,6 @@ extern "C" { #endif -#ifdef __GNUC__ -#define _INLINE_ static __inline__ -#else /* For Watcom C */ -#define _INLINE_ static inline -#endif - /* * Simple doubly linked list implementation. * @@ -35,115 +29,16 @@ (ptr)->next = (ptr); (ptr)->prev = (ptr); \ } while (0) -/* - * Insert a new entry between two known consecutive entries. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -_INLINE_ void __list_add(struct list_head * add, - struct list_head * prev, - struct list_head * next) -{ - next->prev = add; - add->next = next; - add->prev = prev; - prev->next = add; -} +void __list_add(struct list_head * add, struct list_head * prev, struct list_head * next); +void list_add(struct list_head *add, struct list_head *head); +void list_add_tail(struct list_head *add, struct list_head *head); +void __list_del(struct list_head * prev, struct list_head * next); +void list_del(struct list_head *entry); +void list_del_init(struct list_head *entry); +int list_empty(struct list_head *head); +void list_splice(struct list_head *list, struct list_head *head); /** - * list_add - add a new entry - * @add: new entry to be added - * @head: list head to add it after - * - * Insert a new entry after the specified head. - * This is good for implementing stacks. - */ -_INLINE_ void list_add(struct list_head *add, struct list_head *head) -{ - __list_add(add, head, head->next); -} - -/** - * list_add_tail - add a new entry - * @add: new entry to be added - * @head: list head to add it before - * - * Insert a new entry before the specified head. - * This is useful for implementing queues. - */ -_INLINE_ void list_add_tail(struct list_head *add, struct list_head *head) -{ - __list_add(add, head->prev, head); -} - -/* - * Delete a list entry by making the prev/next entries - * point to each other. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -_INLINE_ void __list_del(struct list_head * prev, - struct list_head * next) -{ - next->prev = prev; - prev->next = next; -} - -/** - * list_del - deletes entry from list. - * @entry: the element to delete from the list. - * - * list_empty() on @entry does not return true after this, @entry is - * in an undefined state. - */ -_INLINE_ void list_del(struct list_head *entry) -{ - __list_del(entry->prev, entry->next); -} - -/** - * list_del_init - deletes entry from list and reinitialize it. - * @entry: the element to delete from the list. - */ -_INLINE_ void list_del_init(struct list_head *entry) -{ - __list_del(entry->prev, entry->next); - INIT_LIST_HEAD(entry); -} - -/** - * list_empty - tests whether a list is empty - * @head: the list to test. - */ -_INLINE_ int list_empty(struct list_head *head) -{ - return head->next == head; -} - -/** - * list_splice - join two lists - * @list: the new list to add. - * @head: the place to add it in the first list. - */ -_INLINE_ void list_splice(struct list_head *list, struct list_head *head) -{ - struct list_head *first = list->next; - - if (first != list) { - struct list_head *last = list->prev; - struct list_head *at = head->next; - - first->prev = head; - head->next = first; - - last->next = at; - at->prev = last; - } -} - -/** * list_entry - get the struct for this entry * @ptr: the &struct list_head pointer. * @type: the type of the struct this is embedded in. @@ -171,8 +66,6 @@ for (pos = (head)->next, pnext = pos->next; pos != (head); \ pos = pnext, pnext = pos->next) -#undef _INLINE_ - #ifdef __cplusplus } #endif Index: e2fsprogs/e2fsck.c =================================================================== --- e2fsprogs/e2fsck.c (revision 16097) +++ e2fsprogs/e2fsck.c (revision 16098) @@ -726,7 +726,7 @@ /* * Return the count of number of directories in the dir_info structure */ -static inline int e2fsck_get_num_dirinfo(e2fsck_t ctx) +static int e2fsck_get_num_dirinfo(e2fsck_t ctx) { return ctx->dir_info_count; } @@ -1363,7 +1363,7 @@ return error; } -static inline const char *ehandler_operation(const char *op) +static const char *ehandler_operation(const char *op) { const char *ret = operation; @@ -1491,7 +1491,7 @@ } } -static inline void mark_buffer_dirty(struct buffer_head *bh) +static void mark_buffer_dirty(struct buffer_head *bh) { bh->b_dirty = 1; } @@ -1508,7 +1508,7 @@ ext2fs_free_mem(&bh); } -static inline int buffer_uptodate(struct buffer_head *bh) +static int buffer_uptodate(struct buffer_head *bh) { return bh->b_uptodate; } @@ -11074,7 +11074,7 @@ /* Utility functions to maintain the revoke table */ /* Borrowed from buffer.c: this is a tried and tested block hash function */ -static inline int hash(journal_t *journal, unsigned long block) +static int hash(journal_t *journal, unsigned long block) { struct jbd_revoke_table_s *table = journal->j_revoke; int hash_shift = table->hash_shift; Index: e2fsprogs/e2fsck.h =================================================================== --- e2fsprogs/e2fsck.h (revision 16097) +++ e2fsprogs/e2fsck.h (revision 16098) @@ -629,13 +629,8 @@ }; +#define tid_gt(x, y) ((x - y) > 0) -static inline int tid_gt(tid_t x, tid_t y) -{ - int difference = (x - y); - return (difference > 0); -} - static inline int tid_geq(tid_t x, tid_t y) { int difference = (x - y);