summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Andersen2000-04-25 23:24:55 +0000
committerErik Andersen2000-04-25 23:24:55 +0000
commit227a59b05d6df9b4be5990915646249d6f548822 (patch)
tree36b29c39d4740003b9b77c098a634bac8a6dcb45
parentf93a95de6960b1d1977a934aafd3e9a8b8ea1765 (diff)
downloadbusybox-227a59b05d6df9b4be5990915646249d6f548822.zip
busybox-227a59b05d6df9b4be5990915646249d6f548822.tar.gz
Several more updates
-Erik
-rw-r--r--AUTHORS3
-rw-r--r--Changelog4
-rw-r--r--applets/busybox.c3
-rw-r--r--busybox.c3
-rw-r--r--busybox.def.h3
-rw-r--r--docs/busybox.pod26
-rw-r--r--internal.h1
-rw-r--r--miscutils/mktemp.c43
-rw-r--r--mktemp.c43
-rw-r--r--networking/ping.c38
-rw-r--r--ping.c38
-rw-r--r--procps/ps.c6
-rw-r--r--ps.c6
13 files changed, 189 insertions, 28 deletions
diff --git a/AUTHORS b/AUTHORS
index a5acec2..b36a4cd 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -42,3 +42,6 @@ Enrique Zanardi <ezanardi@ull.es>
Karl M. Hegbloom <karlheg@debian.org>
cp_mv.c, the test suite, various fixes to utility.c, &c.
+
+Daniel Jacobowitz <dan@debian.org>
+ mktemp.c
diff --git a/Changelog b/Changelog
index 823f9ee..b7e40e6 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,10 @@
0.44
* added the -v option (inverted search) to grep,
updated docs/busybox.pod accordingly. -beppu
+ * Added mktemp, contributed by Daniel Jacobowitz <dan@debian.org>
+ * Fix for ping warnings from Sascha Ziemann <szi@aibon.ping.de>
+ * More doc updates
+
0.43
* Major update to the provided documentation.
diff --git a/applets/busybox.c b/applets/busybox.c
index f4260e9..4a6f928 100644
--- a/applets/busybox.c
+++ b/applets/busybox.c
@@ -197,6 +197,9 @@ static const struct Applet applets[] = {
#ifdef BB_MKSWAP
{"mkswap", mkswap_main, _BB_DIR_SBIN},
#endif
+#ifdef BB_MKTEMP
+ {"mktemp", mktemp_main, _BB_DIR_BIN},
+#endif
#ifdef BB_MNC
{"mnc", mnc_main, _BB_DIR_USR_BIN},
#endif
diff --git a/busybox.c b/busybox.c
index f4260e9..4a6f928 100644
--- a/busybox.c
+++ b/busybox.c
@@ -197,6 +197,9 @@ static const struct Applet applets[] = {
#ifdef BB_MKSWAP
{"mkswap", mkswap_main, _BB_DIR_SBIN},
#endif
+#ifdef BB_MKTEMP
+ {"mktemp", mktemp_main, _BB_DIR_BIN},
+#endif
#ifdef BB_MNC
{"mnc", mnc_main, _BB_DIR_USR_BIN},
#endif
diff --git a/busybox.def.h b/busybox.def.h
index 77ee5b0..3012b0c 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -52,12 +52,13 @@
#define BB_LS
#define BB_LSMOD
#define BB_MAKEDEVS
-#define BB_MKFS_MINIX
#define BB_MATH
#define BB_MKDIR
#define BB_MKFIFO
+#define BB_MKFS_MINIX
#define BB_MKNOD
#define BB_MKSWAP
+#define BB_MKTEMP
#define BB_MNC
#define BB_MORE
#define BB_MOUNT
diff --git a/docs/busybox.pod b/docs/busybox.pod
index 71444c0..6fd8289 100644
--- a/docs/busybox.pod
+++ b/docs/busybox.pod
@@ -60,10 +60,10 @@ dirname, dmesg, du, dutmp, echo, false, fbset, fdflush, find, free,
freeramdisk, deallocvt, fsck.minix, grep, gunzip, gzip, halt, head, hostid,
hostname, init, kill, killall, length, ln, loadacm, loadfont, loadkmap, logger,
logname, ls, lsmod, makedevs, math, mkdir, mkfifo, mkfs.minix, mknod, mkswap,
-mnc, more, mount, mt, mv, nslookup, ping, poweroff, printf, ps, pwd, reboot,
-rm, rmdir, rmmod, sed, sh, sfdisk, sleep, sort, sync, syslogd, swapon, swapoff,
-tail, tar, test, tee, touch, tr, true, tty, umount, uname, uniq, update,
-uptime, usleep, wc, whoami, yes, zcat, [
+mktemp, mnc, more, mount, mt, mv, nslookup, ping, poweroff, printf, ps, pwd,
+reboot, rm, rmdir, rmmod, sed, sh, sfdisk, sleep, sort, sync, syslogd, swapon,
+swapoff, tail, tar, test, tee, touch, tr, true, tty, umount, uname, uniq,
+update, uptime, usleep, wc, whoami, yes, zcat, [
=over 4
@@ -1050,6 +1050,22 @@ Options:
-------------------------------
+=item mktemp
+
+Usage: mktemp [-q] TEMPLATE
+
+Creates a temporary file with its name based on TEMPLATE.
+TEMPLATE is any name with six `Xs' (i.e. /tmp/temp.XXXXXX).
+
+Example:
+
+ $ mktemp /tmp/temp.XXXXXX
+ /tmp/temp.mWiLjM
+ $ ls -la /tmp/temp.mWiLjM
+ -rw------- 1 andersen andersen 0 Apr 25 17:10 /tmp/temp.mWiLjM
+
+-------------------------------
+
=item mnc
Usage: mnc [IP] [port]
@@ -1817,4 +1833,4 @@ Enrique Zanardi <ezanardi@ull.es>
=cut
-# $Id: busybox.pod,v 1.22 2000/04/24 18:07:30 beppu Exp $
+# $Id: busybox.pod,v 1.23 2000/04/25 23:24:55 erik Exp $
diff --git a/internal.h b/internal.h
index 8c97a09..1c267cb 100644
--- a/internal.h
+++ b/internal.h
@@ -119,6 +119,7 @@ extern int mkfifo_main(int argc, char **argv);
extern int mkfs_minix_main(int argc, char **argv);
extern int mknod_main(int argc, char** argv);
extern int mkswap_main(int argc, char** argv);
+extern int mktemp_main(int argc, char **argv);
extern int mnc_main(int argc, char** argv);
extern int more_main(int argc, char** argv);
extern int mount_main(int argc, char** argv);
diff --git a/miscutils/mktemp.c b/miscutils/mktemp.c
new file mode 100644
index 0000000..b30b9a0
--- /dev/null
+++ b/miscutils/mktemp.c
@@ -0,0 +1,43 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Mini mktemp implementation for busybox
+ *
+ *
+ * Copyright (C) 2000 by Daniel Jacobowitz
+ * Written by Daniel Jacobowitz <dan@debian.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "internal.h"
+#include <stdio.h>
+#include <errno.h>
+
+
+extern int mktemp_main(int argc, char **argv)
+{
+ if (argc != 2 && (argc != 3 || strcmp(argv[1], "-q")))
+ usage ("mktemp [-q] TEMPLATE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreates a temporary file with its name based on TEMPLATE.\n"
+ "TEMPLATE is any name with six `Xs' (i.e. /tmp/temp.XXXXXX).\n"
+#endif
+ );
+ if(mkstemp(argv[argc-1]) < 0)
+ exit(FALSE);
+ (void) puts(argv[argc-1]);
+ exit(TRUE);
+}
diff --git a/mktemp.c b/mktemp.c
new file mode 100644
index 0000000..b30b9a0
--- /dev/null
+++ b/mktemp.c
@@ -0,0 +1,43 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Mini mktemp implementation for busybox
+ *
+ *
+ * Copyright (C) 2000 by Daniel Jacobowitz
+ * Written by Daniel Jacobowitz <dan@debian.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "internal.h"
+#include <stdio.h>
+#include <errno.h>
+
+
+extern int mktemp_main(int argc, char **argv)
+{
+ if (argc != 2 && (argc != 3 || strcmp(argv[1], "-q")))
+ usage ("mktemp [-q] TEMPLATE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreates a temporary file with its name based on TEMPLATE.\n"
+ "TEMPLATE is any name with six `Xs' (i.e. /tmp/temp.XXXXXX).\n"
+#endif
+ );
+ if(mkstemp(argv[argc-1]) < 0)
+ exit(FALSE);
+ (void) puts(argv[argc-1]);
+ exit(TRUE);
+}
diff --git a/networking/ping.c b/networking/ping.c
index dca4c3c..9f83002 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.13 2000/04/21 01:26:49 erik Exp $
+ * $Id: ping.c,v 1.14 2000/04/25 23:24:55 erik Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -262,6 +262,26 @@ static void sendping(int ign)
}
}
+static char *icmp_type_name (int id)
+{
+ switch (id) {
+ case ICMP_ECHOREPLY: return "Echo Reply";
+ case ICMP_DEST_UNREACH: return "Destination Unreachable";
+ case ICMP_SOURCE_QUENCH: return "Source Quench";
+ case ICMP_REDIRECT: return "Redirect (change route)";
+ case ICMP_ECHO: return "Echo Request";
+ case ICMP_TIME_EXCEEDED: return "Time Exceeded";
+ case ICMP_PARAMETERPROB: return "Parameter Problem";
+ case ICMP_TIMESTAMP: return "Timestamp Request";
+ case ICMP_TIMESTAMPREPLY: return "Timestamp Reply";
+ case ICMP_INFO_REQUEST: return "Information Request";
+ case ICMP_INFO_REPLY: return "Information Reply";
+ case ICMP_ADDRESS: return "Address Mask Request";
+ case ICMP_ADDRESSREPLY: return "Address Mask Reply";
+ default: return "unknown ICMP type";
+ }
+}
+
static void unpack(char *buf, int sz, struct sockaddr_in *from)
{
struct icmp *icmppkt;
@@ -282,10 +302,11 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from)
sz -= hlen;
icmppkt = (struct icmp *) (buf + hlen);
+ if (icmppkt->icmp_id != myid)
+ return; /* not our ping */
+
if (icmppkt->icmp_type == ICMP_ECHOREPLY) {
- if (icmppkt->icmp_id != myid)
- return; /* not our ping */
- ++nreceived;
+ ++nreceived;
tp = (struct timeval *) icmppkt->icmp_data;
if ((tv.tv_usec -= tp->tv_usec) < 0) {
@@ -321,10 +342,11 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from)
if (dupflag)
printf(" (DUP!)");
printf("\n");
- } else {
- fprintf(stderr,
- "Warning: unknown ICMP packet received (not echo-reply)\n");
- }
+ } else
+ if (icmppkt->icmp_type != ICMP_ECHO)
+ fprintf(stderr,
+ "Warning: Got ICMP %d (%s)\n",
+ icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type));
}
static void ping(char *host)
diff --git a/ping.c b/ping.c
index dca4c3c..9f83002 100644
--- a/ping.c
+++ b/ping.c
@@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.13 2000/04/21 01:26:49 erik Exp $
+ * $Id: ping.c,v 1.14 2000/04/25 23:24:55 erik Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -262,6 +262,26 @@ static void sendping(int ign)
}
}
+static char *icmp_type_name (int id)
+{
+ switch (id) {
+ case ICMP_ECHOREPLY: return "Echo Reply";
+ case ICMP_DEST_UNREACH: return "Destination Unreachable";
+ case ICMP_SOURCE_QUENCH: return "Source Quench";
+ case ICMP_REDIRECT: return "Redirect (change route)";
+ case ICMP_ECHO: return "Echo Request";
+ case ICMP_TIME_EXCEEDED: return "Time Exceeded";
+ case ICMP_PARAMETERPROB: return "Parameter Problem";
+ case ICMP_TIMESTAMP: return "Timestamp Request";
+ case ICMP_TIMESTAMPREPLY: return "Timestamp Reply";
+ case ICMP_INFO_REQUEST: return "Information Request";
+ case ICMP_INFO_REPLY: return "Information Reply";
+ case ICMP_ADDRESS: return "Address Mask Request";
+ case ICMP_ADDRESSREPLY: return "Address Mask Reply";
+ default: return "unknown ICMP type";
+ }
+}
+
static void unpack(char *buf, int sz, struct sockaddr_in *from)
{
struct icmp *icmppkt;
@@ -282,10 +302,11 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from)
sz -= hlen;
icmppkt = (struct icmp *) (buf + hlen);
+ if (icmppkt->icmp_id != myid)
+ return; /* not our ping */
+
if (icmppkt->icmp_type == ICMP_ECHOREPLY) {
- if (icmppkt->icmp_id != myid)
- return; /* not our ping */
- ++nreceived;
+ ++nreceived;
tp = (struct timeval *) icmppkt->icmp_data;
if ((tv.tv_usec -= tp->tv_usec) < 0) {
@@ -321,10 +342,11 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from)
if (dupflag)
printf(" (DUP!)");
printf("\n");
- } else {
- fprintf(stderr,
- "Warning: unknown ICMP packet received (not echo-reply)\n");
- }
+ } else
+ if (icmppkt->icmp_type != ICMP_ECHO)
+ fprintf(stderr,
+ "Warning: Got ICMP %d (%s)\n",
+ icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type));
}
static void ping(char *host)
diff --git a/procps/ps.c b/procps/ps.c
index 8d59700..f8cf33b 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -163,13 +163,13 @@ extern int ps_main(int argc, char **argv)
if (*groupName == '\0')
sprintf(groupName, "%d", p.rgid);
- len = fprintf(stdout, "%5d %-8s %-8s %c ", p.pid, uidName, groupName,
- p.state);
sprintf(path, "/proc/%s/cmdline", entry->d_name);
file = fopen(path, "r");
if (file == NULL)
- fatalError("Can't open %s: %s\n", path, strerror(errno));
+ continue;
i = 0;
+ len = fprintf(stdout, "%5d %-8s %-8s %c ", p.pid, uidName, groupName,
+ p.state);
while (((c = getc(file)) != EOF) && (i < (terminal_width-len))) {
i++;
if (c == '\0')
diff --git a/ps.c b/ps.c
index 8d59700..f8cf33b 100644
--- a/ps.c
+++ b/ps.c
@@ -163,13 +163,13 @@ extern int ps_main(int argc, char **argv)
if (*groupName == '\0')
sprintf(groupName, "%d", p.rgid);
- len = fprintf(stdout, "%5d %-8s %-8s %c ", p.pid, uidName, groupName,
- p.state);
sprintf(path, "/proc/%s/cmdline", entry->d_name);
file = fopen(path, "r");
if (file == NULL)
- fatalError("Can't open %s: %s\n", path, strerror(errno));
+ continue;
i = 0;
+ len = fprintf(stdout, "%5d %-8s %-8s %c ", p.pid, uidName, groupName,
+ p.state);
while (((c = getc(file)) != EOF) && (i < (terminal_width-len))) {
i++;
if (c == '\0')