summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Andersen2000-04-28 00:18:56 +0000
committerErik Andersen2000-04-28 00:18:56 +0000
commit4f3f757d56fbf420ea5030dcf7ea971b3da3ab47 (patch)
treed986e9bb9f03bf1f83465c274c35c0d58ed544e4
parent227a59b05d6df9b4be5990915646249d6f548822 (diff)
downloadbusybox-4f3f757d56fbf420ea5030dcf7ea971b3da3ab47.zip
busybox-4f3f757d56fbf420ea5030dcf7ea971b3da3ab47.tar.gz
Latest and greatest. Some effort at libc5 (aiming towards newlib)
compatability. -Erik
-rw-r--r--Makefile7
-rw-r--r--applets/busybox.c7
-rw-r--r--archival/gunzip.c5
-rw-r--r--archival/gzip.c1
-rw-r--r--archival/tar.c1
-rw-r--r--busybox.c7
-rw-r--r--busybox.def.h5
-rw-r--r--chvt.c2
-rw-r--r--console-tools/chvt.c2
-rw-r--r--console-tools/deallocvt.c1
-rw-r--r--coreutils/du.c7
-rw-r--r--coreutils/ln.c13
-rw-r--r--coreutils/ls.c2
-rw-r--r--coreutils/mkdir.c5
-rw-r--r--coreutils/pwd.c3
-rw-r--r--cp_mv.c18
-rw-r--r--deallocvt.c1
-rw-r--r--docs/busybox.pod24
-rw-r--r--du.c7
-rw-r--r--dutmp.c12
-rw-r--r--freeramdisk.c3
-rw-r--r--fsck_minix.c9
-rw-r--r--gunzip.c5
-rw-r--r--gzip.c1
-rw-r--r--init.c61
-rw-r--r--init/init.c61
-rw-r--r--insmod.c6
-rw-r--r--internal.h63
-rw-r--r--ln.c13
-rw-r--r--ls.c2
-rw-r--r--miscutils/dutmp.c12
-rw-r--r--mkdir.c5
-rw-r--r--mkfs_minix.c4
-rw-r--r--modutils/insmod.c6
-rw-r--r--more.c12
-rw-r--r--mount.c3
-rw-r--r--pwd.c3
-rw-r--r--sysklogd/syslogd.c4
-rw-r--r--syslogd.c4
-rw-r--r--tar.c1
-rw-r--r--util-linux/freeramdisk.c3
-rw-r--r--util-linux/fsck_minix.c9
-rw-r--r--util-linux/mkfs_minix.c4
-rw-r--r--util-linux/more.c12
-rw-r--r--util-linux/mount.c3
-rw-r--r--utility.c13
46 files changed, 280 insertions, 172 deletions
diff --git a/Makefile b/Makefile
index 8332583..7a0752e 100644
--- a/Makefile
+++ b/Makefile
@@ -37,8 +37,8 @@ ARCH := $(shell uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/')
CC = gcc
-GCCMAJVERSION = $(shell $(CC) --version | sed -n "s/^[^0-9]*\([0-9]\)\.\([0-9].*\)[\.].*/\1/p")
-GCCMINVERSION = $(shell $(CC) --version | sed -n "s/^[^0-9]*\([0-9]\)\.\([0-9].*\)[\.].*/\2/p")
+GCCMAJVERSION = $(shell $(CC) --version | cut -f1 -d'.')
+GCCMINVERSION = $(shell $(CC) --version | cut -f2 -d'.')
GCCSUPPORTSOPTSIZE = $(shell \
@@ -68,6 +68,7 @@ ifndef $(STRIPTOOL)
STRIPTOOL = strip
endif
+#also to try -- use --prefix=/usr/my-libc2.0.7-stuff
# -D_GNU_SOURCE is needed because environ is used in init.c
ifeq ($(DODEBUG),true)
@@ -77,6 +78,8 @@ ifeq ($(DODEBUG),true)
else
CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
LDFLAGS = -s
+ #CFLAGS += -nostdinc -I/home/andersen/apps/newlib/src/newlib/libc/include -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
+ #LDFLAGS = -nostdlib -s -L/home/andersen/apps/newlib/src/newlib/libc.a
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
#Only staticly link when _not_ debugging
ifeq ($(DOSTATIC),true)
diff --git a/applets/busybox.c b/applets/busybox.c
index 4a6f928..ca76758 100644
--- a/applets/busybox.c
+++ b/applets/busybox.c
@@ -248,12 +248,15 @@ static const struct Applet applets[] = {
#ifdef BB_SED
{"sed", sed_main, _BB_DIR_BIN},
#endif
-#ifdef BB_SH
- {"sh", shell_main, _BB_DIR_BIN},
+#ifdef BB_SETKEYCODES
+ {"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_SFDISK
{"sfdisk", sfdisk_main, _BB_DIR_SBIN},
#endif
+#ifdef BB_SH
+ {"sh", shell_main, _BB_DIR_BIN},
+#endif
#ifdef BB_SLEEP
{"sleep", sleep_main, _BB_DIR_BIN},
#endif
diff --git a/archival/gunzip.c b/archival/gunzip.c
index 1a5cdba..97ab84e 100644
--- a/archival/gunzip.c
+++ b/archival/gunzip.c
@@ -102,7 +102,6 @@ static char *license_msg[] = {
#include <signal.h>
#include <sys/stat.h>
#include <errno.h>
-#include <sys/param.h> /* for PATH_MAX */
/* #include "tailor.h" */
@@ -641,8 +640,8 @@ typedef RETSIGTYPE(*sig_type) (int);
#define RW_USER (S_IRUSR | S_IWUSR) /* creation mode for open() */
#ifndef MAX_PATH_LEN /* max pathname length */
-# ifdef PATH_MAX
-# define MAX_PATH_LEN PATH_MAX
+# ifdef BUFSIZ
+# define MAX_PATH_LEN BUFSIZ
# else
# define MAX_PATH_LEN 1024
# endif
diff --git a/archival/gzip.c b/archival/gzip.c
index a9d34ae..cc6868b 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -2272,7 +2272,6 @@ local void set_file_type (void);
* used.
*/
-#define MAX(a,b) (a >= b ? a : b)
/* the arguments must not have side effects */
/* ===========================================================================
diff --git a/archival/tar.c b/archival/tar.c
index 0177d51..e205763 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -49,7 +49,6 @@
#include <utime.h>
#include <sys/types.h>
#include <sys/sysmacros.h>
-#include <sys/param.h> /* for PATH_MAX */
static const char tar_usage[] =
diff --git a/busybox.c b/busybox.c
index 4a6f928..ca76758 100644
--- a/busybox.c
+++ b/busybox.c
@@ -248,12 +248,15 @@ static const struct Applet applets[] = {
#ifdef BB_SED
{"sed", sed_main, _BB_DIR_BIN},
#endif
-#ifdef BB_SH
- {"sh", shell_main, _BB_DIR_BIN},
+#ifdef BB_SETKEYCODES
+ {"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_SFDISK
{"sfdisk", sfdisk_main, _BB_DIR_SBIN},
#endif
+#ifdef BB_SH
+ {"sh", shell_main, _BB_DIR_BIN},
+#endif
#ifdef BB_SLEEP
{"sleep", sleep_main, _BB_DIR_BIN},
#endif
diff --git a/busybox.def.h b/busybox.def.h
index 3012b0c..c10c1a3 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -75,6 +75,7 @@
#define BB_RMDIR
#define BB_RMMOD
#define BB_SED
+#define BB_SETKEYCODES
#define BB_SFDISK
#define BB_SH
#define BB_SLEEP
@@ -136,7 +137,7 @@
//#define BB_FEATURE_TRIVIAL_HELP
//
// Use termios to manipulate the screen ('more' is prettier with this on)
-#define BB_FEATURE_USE_TERMIOS
+//#define BB_FEATURE_USE_TERMIOS
//
// calculate terminal & column widths (for more and ls)
#define BB_FEATURE_AUTOWIDTH
@@ -193,7 +194,7 @@
#define BB_FEATURE_SORT_REVERSE
//
// Enable command line editing in the shell
-#define BB_FEATURE_SH_COMMAND_EDITING
+//#define BB_FEATURE_SH_COMMAND_EDITING
//
// Enable tab completion in the shell (not yet
// working very well -- so don't turn this on)
diff --git a/chvt.c b/chvt.c
index bf1ed60..37fd21a 100644
--- a/chvt.c
+++ b/chvt.c
@@ -12,8 +12,6 @@
#include <stdlib.h>
#include <fcntl.h>
-extern int getfd(void);
-
int chvt_main(int argc, char **argv)
{
int fd, num;
diff --git a/console-tools/chvt.c b/console-tools/chvt.c
index bf1ed60..37fd21a 100644
--- a/console-tools/chvt.c
+++ b/console-tools/chvt.c
@@ -12,8 +12,6 @@
#include <stdlib.h>
#include <fcntl.h>
-extern int getfd(void);
-
int chvt_main(int argc, char **argv)
{
int fd, num;
diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c
index 141062e..ee85879 100644
--- a/console-tools/deallocvt.c
+++ b/console-tools/deallocvt.c
@@ -11,7 +11,6 @@
#include <linux/vt.h>
#include <stdio.h>
-extern int getfd(void);
char *progname;
int deallocvt_main(int argc, char *argv[])
diff --git a/coreutils/du.c b/coreutils/du.c
index 8745380..c4fb3a3 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -32,7 +32,6 @@
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
-#include <sys/param.h> /* for PATH_MAX */
typedef void (Display) (long, char *);
@@ -97,7 +96,7 @@ static long du(char *filename)
filename[--len] = '\0';
while ((entry = readdir(dir))) {
- char newfile[PATH_MAX + 1];
+ char newfile[BUFSIZ + 1];
char *name = entry->d_name;
if ((strcmp(name, "..") == 0)
@@ -105,7 +104,7 @@ static long du(char *filename)
continue;
}
- if (len + strlen(name) + 1 > PATH_MAX) {
+ if (len + strlen(name) + 1 > BUFSIZ) {
fprintf(stderr, name_too_long, "du");
du_depth--;
return 0;
@@ -182,7 +181,7 @@ int du_main(int argc, char **argv)
exit(0);
}
-/* $Id: du.c,v 1.17 2000/04/13 01:18:56 erik Exp $ */
+/* $Id: du.c,v 1.18 2000/04/28 00:18:56 erik Exp $ */
/*
Local Variables:
c-file-style: "linux"
diff --git a/coreutils/ln.c b/coreutils/ln.c
index 4be6062..eb7c996 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -30,7 +30,6 @@
#include <stdio.h>
#include <dirent.h>
#include <errno.h>
-#include <sys/param.h> /* for PATH_MAX */
static const char ln_usage[] =
"ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n\n"
@@ -78,7 +77,7 @@ extern int ln_main(int argc, char **argv)
linkName = argv[argc - 1];
- if (strlen(linkName) > PATH_MAX) {
+ if (strlen(linkName) > BUFSIZ) {
fprintf(stderr, name_too_long, "ln");
exit FALSE;
}
@@ -91,10 +90,10 @@ extern int ln_main(int argc, char **argv)
}
while (argc-- >= 2) {
- char srcName[PATH_MAX + 1];
+ char srcName[BUFSIZ + 1];
int nChars, status;
- if (strlen(*argv) > PATH_MAX) {
+ if (strlen(*argv) > BUFSIZ) {
fprintf(stderr, name_too_long, "ln");
exit FALSE;
}
@@ -102,9 +101,9 @@ extern int ln_main(int argc, char **argv)
if (followLinks == FALSE) {
strcpy(srcName, *argv);
} else {
- /* Warning! This can silently truncate if > PATH_MAX, but
- I don't think that there can be one > PATH_MAX anyway. */
- nChars = readlink(*argv, srcName, PATH_MAX);
+ /* Warning! This can silently truncate if > BUFSIZ, but
+ I don't think that there can be one > BUFSIZ anyway. */
+ nChars = readlink(*argv, srcName, BUFSIZ);
srcName[nChars] = '\0';
}
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 0c7f652..3c518ab 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -183,7 +183,7 @@ static char append_char(mode_t mode)
static void list_single(const char *name, struct stat *info,
const char *fullname)
{
- char scratch[PATH_MAX + 1];
+ char scratch[BUFSIZ + 1];
short len = strlen(name);
#ifdef BB_FEATURE_LS_FILETYPES
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index b0a2d57..54d9b72 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -28,7 +28,6 @@
#include <stdio.h>
#include <errno.h>
-#include <sys/param.h> /* for PATH_MAX */
static const char mkdir_usage[] =
"mkdir [OPTION] DIRECTORY...\n\n"
@@ -86,9 +85,9 @@ extern int mkdir_main(int argc, char **argv)
while (argc > 0) {
int status;
struct stat statBuf;
- char buf[PATH_MAX + 1];
+ char buf[BUFSIZ + 1];
- if (strlen(*argv) > PATH_MAX - 1) {
+ if (strlen(*argv) > BUFSIZ - 1) {
fprintf(stderr, name_too_long, "mkdir");
exit FALSE;
}
diff --git a/coreutils/pwd.c b/coreutils/pwd.c
index 0016317..e77a0ca 100644
--- a/coreutils/pwd.c
+++ b/coreutils/pwd.c
@@ -24,11 +24,10 @@
#include "internal.h"
#include <stdio.h>
#include <dirent.h>
-#include <sys/param.h>
extern int pwd_main(int argc, char **argv)
{
- char buf[PATH_MAX + 1];
+ char buf[BUFSIZ + 1];
if (getcwd(buf, sizeof(buf)) == NULL) {
perror("get working directory");
diff --git a/cp_mv.c b/cp_mv.c
index f4104e5..b43a6d3 100644
--- a/cp_mv.c
+++ b/cp_mv.c
@@ -74,7 +74,7 @@ static const char *baseSrcName;
static int srcDirFlag;
static struct stat srcStatBuf;
-static char baseDestName[PATH_MAX + 1];
+static char baseDestName[BUFSIZ + 1];
static size_t baseDestLen;
static int destDirFlag;
static struct stat destStatBuf;
@@ -97,12 +97,12 @@ fill_baseDest_buf(char *_buf, size_t * _buflen) {
if ((srcBasename = strrchr(baseSrcName, '/')) == NULL) {
srcBasename = baseSrcName;
if (_buf[*_buflen - 1] != '/') {
- if (++(*_buflen) > PATH_MAX)
+ if (++(*_buflen) > BUFSIZ)
name_too_long__exit();
strcat(_buf, "/");
}
}
- if (*_buflen + strlen(srcBasename) > PATH_MAX)
+ if (*_buflen + strlen(srcBasename) > BUFSIZ)
name_too_long__exit();
strcat(_buf, srcBasename);
return;
@@ -112,7 +112,7 @@ fill_baseDest_buf(char *_buf, size_t * _buflen) {
static int
cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
{
- char destName[PATH_MAX + 1];
+ char destName[BUFSIZ + 1];
size_t destLen;
const char *srcBasename;
char *name;
@@ -128,7 +128,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
srcBasename = (strstr(fileName, baseSrcName)
+ strlen(baseSrcName));
- if (destLen + strlen(srcBasename) > PATH_MAX) {
+ if (destLen + strlen(srcBasename) > BUFSIZ) {
fprintf(stderr, name_too_long, dz);
return FALSE;
}
@@ -230,7 +230,7 @@ extern int cp_mv_main(int argc, char **argv)
followLinks = FALSE;
}
- if (strlen(argv[argc - 1]) > PATH_MAX) {
+ if (strlen(argv[argc - 1]) > BUFSIZ) {
fprintf(stderr, name_too_long, "cp");
goto exit_false;
}
@@ -252,7 +252,7 @@ extern int cp_mv_main(int argc, char **argv)
baseSrcName = *(argv++);
- if ((srcLen = strlen(baseSrcName)) > PATH_MAX)
+ if ((srcLen = strlen(baseSrcName)) > BUFSIZ)
name_too_long__exit();
if (srcLen == 0) continue; /* "" */
@@ -266,7 +266,7 @@ extern int cp_mv_main(int argc, char **argv)
int state = 0;
char *pushd, *d, *p;
- if ((pushd = getcwd(NULL, PATH_MAX + 1)) == NULL) {
+ if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) {
fprintf(stderr, "%s: getcwd(): %s\n", dz, strerror(errno));
continue;
}
@@ -274,7 +274,7 @@ extern int cp_mv_main(int argc, char **argv)
fprintf(stderr, "%s: chdir(%s): %s\n", dz, baseSrcName, strerror(errno));
continue;
}
- if ((d = getcwd(NULL, PATH_MAX + 1)) == NULL) {
+ if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
fprintf(stderr, "%s: getcwd(): %s\n", dz, strerror(errno));
continue;
}
diff --git a/deallocvt.c b/deallocvt.c
index 141062e..ee85879 100644
--- a/deallocvt.c
+++ b/deallocvt.c
@@ -11,7 +11,6 @@
#include <linux/vt.h>
#include <stdio.h>
-extern int getfd(void);
char *progname;
int deallocvt_main(int argc, char *argv[])
diff --git a/docs/busybox.pod b/docs/busybox.pod
index 6fd8289..c331c65 100644
--- a/docs/busybox.pod
+++ b/docs/busybox.pod
@@ -61,9 +61,9 @@ 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,
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, [
+reboot, rm, rmdir, rmmod, sed, setkeycodes, 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
@@ -1336,6 +1336,22 @@ Example:
-------------------------------
+=item setkeycodes
+
+Usage: setkeycodes SCANCODE KEYCODE ...
+
+Set entries into the kernel's scancode-to-keycode map,
+allowing unusual keyboards to generate usable keycodes.
+
+SCANCODE may be either xx or e0xx (hexadecimal),
+and KEYCODE is given in decimal
+
+Example:
+
+ # setkeycodes e030 127
+
+-------------------------------
+
=item sh
Usage: sh
@@ -1833,4 +1849,4 @@ Enrique Zanardi <ezanardi@ull.es>
=cut
-# $Id: busybox.pod,v 1.23 2000/04/25 23:24:55 erik Exp $
+# $Id: busybox.pod,v 1.24 2000/04/28 00:18:56 erik Exp $
diff --git a/du.c b/du.c
index 8745380..c4fb3a3 100644
--- a/du.c
+++ b/du.c
@@ -32,7 +32,6 @@
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
-#include <sys/param.h> /* for PATH_MAX */
typedef void (Display) (long, char *);
@@ -97,7 +96,7 @@ static long du(char *filename)
filename[--len] = '\0';
while ((entry = readdir(dir))) {
- char newfile[PATH_MAX + 1];
+ char newfile[BUFSIZ + 1];
char *name = entry->d_name;
if ((strcmp(name, "..") == 0)
@@ -105,7 +104,7 @@ static long du(char *filename)
continue;
}
- if (len + strlen(name) + 1 > PATH_MAX) {
+ if (len + strlen(name) + 1 > BUFSIZ) {
fprintf(stderr, name_too_long, "du");
du_depth--;
return 0;
@@ -182,7 +181,7 @@ int du_main(int argc, char **argv)
exit(0);
}
-/* $Id: du.c,v 1.17 2000/04/13 01:18:56 erik Exp $ */
+/* $Id: du.c,v 1.18 2000/04/28 00:18:56 erik Exp $ */
/*
Local Variables:
c-file-style: "linux"
diff --git a/dutmp.c b/dutmp.c
index 1629067..886d788 100644
--- a/dutmp.c
+++ b/dutmp.c
@@ -14,11 +14,17 @@
#include "internal.h"
#include <stdio.h>
#include <errno.h>
-#include <utmp.h>
#define BB_DECLARE_EXTERN
#define bb_need_io_error
#include "messages.c"
+#if defined(__GLIBC__)
+#include <utmp.h>
+#else
+#include <utmp-wrap.h>
+#define utmp new_utmp
+#endif
+
static const char dutmp_usage[] = "dutmp [FILE]\n\n"
"Dump utmp file format (pipe delimited) from FILE\n"
"or stdin to stdout. (i.e. 'dutmp /var/run/utmp')\n";
@@ -45,8 +51,8 @@ extern int dutmp_main(int argc, char **argv)
ut.ut_type, ut.ut_pid, ut.ut_line,
ut.ut_id, ut.ut_user, ut.ut_host,
ut.ut_exit.e_termination, ut.ut_exit.e_exit,
- ut.ut_session,
- ut.ut_tv.tv_sec, ut.ut_tv.tv_usec, ut.ut_addr);
+ ut.ut_session, ut.ut_tv.tv_sec, ut.ut_tv.tv_usec,
+ ut.ut_addr_v6[0]);
}
exit(TRUE);
diff --git a/freeramdisk.c b/freeramdisk.c
index 9636dbd..d373bcb 100644
--- a/freeramdisk.c
+++ b/freeramdisk.c
@@ -23,7 +23,7 @@
#include <stdio.h>
#include <string.h>
-#include <sys/mount.h>
+#include <linux/fs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -32,6 +32,7 @@
#include "internal.h"
+
static const char freeramdisk_usage[] =
"freeramdisk DEVICE\n\n"
"Free all memory used by the specified ramdisk.\n";
diff --git a/fsck_minix.c b/fsck_minix.c
index aa0a824..c890dff 100644
--- a/fsck_minix.c
+++ b/fsck_minix.c
@@ -97,7 +97,6 @@
#include <termios.h>
#include <mntent.h>
#include <sys/stat.h>
-#include <sys/param.h> /* for PATH_MAX */
#include <linux/fs.h>
#include <linux/minix_fs.h>
@@ -145,7 +144,7 @@ static int termios_set = 0;
/* File-name data */
#define MAX_DEPTH 32
static int name_depth = 0;
-// static char name_list[MAX_DEPTH][PATH_MAX + 1];
+// static char name_list[MAX_DEPTH][BUFSIZ + 1];
static char **name_list = NULL;
static char *inode_buffer = NULL;
@@ -178,8 +177,8 @@ static unsigned char *zone_count = NULL;
static void recursive_check(unsigned int ino);
static void recursive_check2(unsigned int ino);
-#define inode_in_use(x) (bit(inode_map,(x)))
-#define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1))
+#define inode_in_use(x) (isset(inode_map,(x)))
+#define zone_in_use(x) (isset(zone_map,(x)-FIRSTZONE+1))
#define mark_inode(x) (setbit(inode_map,(x)),changed=1)
#define unmark_inode(x) (clrbit(inode_map,(x)),changed=1)
@@ -1239,7 +1238,7 @@ static void alloc_name_list(void)
name_list = xmalloc(sizeof(char *) * MAX_DEPTH);
for (i = 0; i < MAX_DEPTH; i++)
- name_list[i] = xmalloc(sizeof(char) * PATH_MAX + 1);
+ name_list[i] = xmalloc(sizeof(char) * BUFSIZ + 1);
}
#if 0
diff --git a/gunzip.c b/gunzip.c
index 1a5cdba..97ab84e 100644
--- a/gunzip.c
+++ b/gunzip.c
@@ -102,7 +102,6 @@ static char *license_msg[] = {
#include <signal.h>
#include <sys/stat.h>
#include <errno.h>
-#include <sys/param.h> /* for PATH_MAX */
/* #include "tailor.h" */
@@ -641,8 +640,8 @@ typedef RETSIGTYPE(*sig_type) (int);
#define RW_USER (S_IRUSR | S_IWUSR) /* creation mode for open() */
#ifndef MAX_PATH_LEN /* max pathname length */
-# ifdef PATH_MAX
-# define MAX_PATH_LEN PATH_MAX
+# ifdef BUFSIZ
+# define MAX_PATH_LEN BUFSIZ
# else
# define MAX_PATH_LEN 1024
# endif
diff --git a/gzip.c b/gzip.c
index a9d34ae..cc6868b 100644
--- a/gzip.c
+++ b/gzip.c
@@ -2272,7 +2272,6 @@ local void set_file_type (void);
* used.
*/
-#define MAX(a,b) (a >= b ? a : b)
/* the arguments must not have side effects */
/* ===========================================================================
diff --git a/init.c b/init.c
index af10f98..29d8f48 100644
--- a/init.c
+++ b/init.c
@@ -28,31 +28,50 @@
*/
#include "internal.h"
-#include <asm/types.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <errno.h>
-#include <linux/serial.h> /* for serial_struct */
-#include <linux/version.h>
#include <paths.h>
#include <signal.h>
#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
+#include <termios.h>
+#include <unistd.h>
+#include <asm/types.h>
+#include <linux/serial.h> /* for serial_struct */
+#include <linux/version.h>
+#include <linux/reboot.h>
+#include <linux/unistd.h>
+#include <sys/sysinfo.h> /* For check_free_memory() */
#include <sys/fcntl.h>
#include <sys/ioctl.h>
-#include <sys/kdaemon.h>
#include <sys/mount.h>
-#include <sys/reboot.h>
-#include <sys/sysinfo.h> /* For check_free_memory() */
-#ifdef BB_SYSLOGD
-# include <sys/syslog.h>
-#endif
#include <sys/sysmacros.h>
#include <sys/types.h>
#include <sys/vt.h> /* for vt_stat */
#include <sys/wait.h>
-#include <termios.h>
-#include <unistd.h>
+#ifdef BB_SYSLOGD
+# include <sys/syslog.h>
+#endif
+
+
+#ifndef RB_HALT_SYSTEM
+#define RB_HALT_SYSTEM 0xcdef0123
+#define RB_ENABLE_CAD 0x89abcdef
+#define RB_DISABLE_CAD 0
+#define RB_POWER_OFF 0x4321fedc
+#define RB_AUTOBOOT 0x01234567
+#if defined(__GLIBC__)
+#include <sys/reboot.h>
+ #define init_reboot(magic) reboot(magic)
+#else
+ #define init_reboot(magic) reboot(0xfee1dead, 672274793, magic)
+#endif
+#endif
+
+#ifndef _PATH_STDPATH
+#define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
+#endif
#if defined BB_FEATURE_INIT_COREDUMPS
@@ -71,6 +90,12 @@
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#endif
+#if defined(__GLIBC__)
+#include <sys/kdaemon.h>
+#else
+_syscall2(int, bdflush, int, func, int, data);
+#endif /* __GLIBC__ */
+
#define VT_PRIMARY "/dev/tty1" /* Primary virtual console */
#define VT_SECONDARY "/dev/tty2" /* Virtual console */
@@ -510,7 +535,7 @@ static void shutdown_system(void)
signal(SIGHUP, SIG_DFL);
/* Allow Ctrl-Alt-Del to reboot system. */
- reboot(RB_ENABLE_CAD);
+ init_reboot(RB_ENABLE_CAD);
message(CONSOLE|LOG, "\r\nThe system is going down NOW !!\r\n");
sync();
@@ -550,10 +575,10 @@ static void halt_signal(int sig)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
if (sig == SIGUSR2)
- reboot(RB_POWER_OFF);
+ init_reboot(RB_POWER_OFF);
else
#endif
- reboot(RB_HALT_SYSTEM);
+ init_reboot(RB_HALT_SYSTEM);
exit(0);
}
@@ -566,7 +591,7 @@ static void reboot_signal(int sig)
/* allow time for last message to reach serial console */
sleep(2);
- reboot(RB_AUTOBOOT);
+ init_reboot(RB_AUTOBOOT);
exit(0);
}
@@ -852,7 +877,7 @@ extern int init_main(int argc, char **argv)
/* Turn off rebooting via CTL-ALT-DEL -- we get a
* SIGINT on CAD so we can shut things down gracefully... */
- reboot(RB_DISABLE_CAD);
+ init_reboot(RB_DISABLE_CAD);
#endif
/* Figure out what kernel this is running */
diff --git a/init/init.c b/init/init.c
index af10f98..29d8f48 100644
--- a/init/init.c
+++ b/init/init.c
@@ -28,31 +28,50 @@
*/
#include "internal.h"
-#include <asm/types.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <errno.h>
-#include <linux/serial.h> /* for serial_struct */
-#include <linux/version.h>
#include <paths.h>
#include <signal.h>
#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
+#include <termios.h>
+#include <unistd.h>
+#include <asm/types.h>
+#include <linux/serial.h> /* for serial_struct */
+#include <linux/version.h>
+#include <linux/reboot.h>
+#include <linux/unistd.h>
+#include <sys/sysinfo.h> /* For check_free_memory() */
#include <sys/fcntl.h>
#include <sys/ioctl.h>
-#include <sys/kdaemon.h>
#include <sys/mount.h>
-#include <sys/reboot.h>
-#include <sys/sysinfo.h> /* For check_free_memory() */
-#ifdef BB_SYSLOGD
-# include <sys/syslog.h>
-#endif
#include <sys/sysmacros.h>
#include <sys/types.h>
#include <sys/vt.h> /* for vt_stat */
#include <sys/wait.h>
-#include <termios.h>
-#include <unistd.h>
+#ifdef BB_SYSLOGD
+# include <sys/syslog.h>
+#endif
+
+
+#ifndef RB_HALT_SYSTEM
+#define RB_HALT_SYSTEM 0xcdef0123
+#define RB_ENABLE_CAD 0x89abcdef
+#define RB_DISABLE_CAD 0
+#define RB_POWER_OFF 0x4321fedc
+#define RB_AUTOBOOT 0x01234567
+#if defined(__GLIBC__)
+#include <sys/reboot.h>
+ #define init_reboot(magic) reboot(magic)
+#else
+ #define init_reboot(magic) reboot(0xfee1dead, 672274793, magic)
+#endif
+#endif
+
+#ifndef _PATH_STDPATH
+#define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
+#endif
#if defined BB_FEATURE_INIT_COREDUMPS
@@ -71,6 +90,12 @@
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#endif
+#if defined(__GLIBC__)
+#include <sys/kdaemon.h>
+#else
+_syscall2(int, bdflush, int, func, int, data);
+#endif /* __GLIBC__ */
+
#define VT_PRIMARY "/dev/tty1" /* Primary virtual console */
#define VT_SECONDARY "/dev/tty2" /* Virtual console */
@@ -510,7 +535,7 @@ static void shutdown_system(void)
signal(SIGHUP, SIG_DFL);
/* Allow Ctrl-Alt-Del to reboot system. */
- reboot(RB_ENABLE_CAD);
+ init_reboot(RB_ENABLE_CAD);
message(CONSOLE|LOG, "\r\nThe system is going down NOW !!\r\n");
sync();
@@ -550,10 +575,10 @@ static void halt_signal(int sig)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
if (sig == SIGUSR2)
- reboot(RB_POWER_OFF);
+ init_reboot(RB_POWER_OFF);
else
#endif
- reboot(RB_HALT_SYSTEM);
+ init_reboot(RB_HALT_SYSTEM);
exit(0);
}
@@ -566,7 +591,7 @@ static void reboot_signal(int sig)
/* allow time for last message to reach serial console */
sleep(2);
- reboot(RB_AUTOBOOT);
+ init_reboot(RB_AUTOBOOT);
exit(0);
}
@@ -852,7 +877,7 @@ extern int init_main(int argc, char **argv)
/* Turn off rebooting via CTL-ALT-DEL -- we get a
* SIGINT on CAD so we can shut things down gracefully... */
- reboot(RB_DISABLE_CAD);
+ init_reboot(RB_DISABLE_CAD);
#endif
/* Figure out what kernel this is running */
diff --git a/insmod.c b/insmod.c
index 1ee96f1..eafec7d 100644
--- a/insmod.c
+++ b/insmod.c
@@ -67,8 +67,8 @@ unsigned long create_module(const char *name, size_t size)
#else
_syscall2(unsigned long, create_module, const char *, name, size_t, size)
#endif
-static char m_filename[PATH_MAX + 1] = "\0";
-static char m_fullName[PATH_MAX + 1] = "\0";
+static char m_filename[BUFSIZ + 1] = "\0";
+static char m_fullName[BUFSIZ + 1] = "\0";
static const char insmod_usage[] =
"insmod [OPTION]... MODULE [symbol=value]...\n\n"
"Loads the specified kernel modules into the kernel.\n\n"
@@ -103,7 +103,7 @@ extern int insmod_main(int argc, char **argv)
{
int len;
char *tmp;
- char m_name[PATH_MAX + 1] = "\0";
+ char m_name[BUFSIZ + 1] = "\0";
FILE *fp;
if (argc <= 1) {
diff --git a/internal.h b/internal.h
index 1c267cb..a81651b 100644
--- a/internal.h
+++ b/internal.h
@@ -31,7 +31,7 @@
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
-//#include <sys/param.h>
+#include <sys/param.h>
#include <mntent.h>
@@ -52,6 +52,36 @@
#define isOctal(ch) (((ch) >= '0') && ((ch) <= '7'))
#define isWildCard(ch) (((ch) == '*') || ((ch) == '?') || ((ch) == '['))
+/* Macros for min/max. */
+#ifndef MIN
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#endif
+
+#ifndef MAX
+#define MAX(a,b) (((a)>(b))?(a):(b))
+#endif
+
+
+/* I don't like nested includes, but the string and io functions are used
+ * too often
+ */
+#include <stdio.h>
+#if !defined(NO_STRING_H) || defined(STDC_HEADERS)
+# include <string.h>
+# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__)
+# include <memory.h>
+# endif
+# define memzero(s, n) memset ((void *)(s), 0, (n))
+#else
+# include <strings.h>
+# define strchr index
+# define strrchr rindex
+# define memcpy(d, s, n) bcopy((s), (d), (n))
+# define memcmp(s1, s2, n) bcmp((s1), (s2), (n))
+# define memzero(s, n) bzero((s), (n))
+#endif
+
+
enum Location {
_BB_DIR_ROOT = 0,
_BB_DIR_BIN,
@@ -136,6 +166,7 @@ extern int rmdir_main(int argc, char **argv);
extern int rmmod_main(int argc, char** argv);
extern int sed_main(int argc, char** argv);
extern int sfdisk_main(int argc, char** argv);
+extern int setkeycodes_main(int argc, char** argv);
extern int shell_main(int argc, char** argv);
extern int sleep_main(int argc, char** argv);
extern int sort_main(int argc, char** argv);
@@ -243,27 +274,15 @@ int nfsmount(const char *spec, const char *node, unsigned long *flags,
#endif
#if defined (BB_FSCK_MINIX) || defined (BB_MKFS_MINIX)
-
-static inline int bit(char * addr,unsigned int nr)
-{
- return (addr[nr >> 3] & (1<<(nr & 7))) != 0;
-}
-
-static inline int setbit(char * addr,unsigned int nr)
-{
- int __res = bit(addr, nr);
- addr[nr >> 3] |= (1<<(nr & 7));
- return __res != 0;
-}
-
-static inline int clrbit(char * addr,unsigned int nr)
-{
- int __res = bit(addr, nr);
- addr[nr >> 3] &= ~(1<<(nr & 7));
- return __res != 0;
-}
-
-#endif /* inline bitops junk */
+/* Bit map related macros. */
+#ifndef setbit
+#define CHAR_BITS 8 /* Number of bits in a `char'. */
+#define setbit(a,i) ((a)[(i)/CHAR_BITS] |= 1<<((i)%CHAR_BITS))
+#define clrbit(a,i) ((a)[(i)/CHAR_BITS] &= ~(1<<((i)%CHAR_BITS)))
+#define isset(a,i) ((a)[(i)/CHAR_BITS] & (1<<((i)%CHAR_BITS)))
+#define isclr(a,i) (((a)[(i)/CHAR_BITS] & (1<<((i)%CHAR_BITS))) == 0)
+#endif
+#endif
#ifndef RB_POWER_OFF
diff --git a/ln.c b/ln.c
index 4be6062..eb7c996 100644
--- a/ln.c
+++ b/ln.c
@@ -30,7 +30,6 @@
#include <stdio.h>
#include <dirent.h>
#include <errno.h>
-#include <sys/param.h> /* for PATH_MAX */
static const char ln_usage[] =
"ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n\n"
@@ -78,7 +77,7 @@ extern int ln_main(int argc, char **argv)
linkName = argv[argc - 1];
- if (strlen(linkName) > PATH_MAX) {
+ if (strlen(linkName) > BUFSIZ) {
fprintf(stderr, name_too_long, "ln");
exit FALSE;
}
@@ -91,10 +90,10 @@ extern int ln_main(int argc, char **argv)
}
while (argc-- >= 2) {
- char srcName[PATH_MAX + 1];
+ char srcName[BUFSIZ + 1];
int nChars, status;
- if (strlen(*argv) > PATH_MAX) {
+ if (strlen(*argv) > BUFSIZ) {
fprintf(stderr, name_too_long, "ln");
exit FALSE;
}
@@ -102,9 +101,9 @@ extern int ln_main(int argc, char **argv)
if (followLinks == FALSE) {
strcpy(srcName, *argv);
} else {
- /* Warning! This can silently truncate if > PATH_MAX, but
- I don't think that there can be one > PATH_MAX anyway. */
- nChars = readlink(*argv, srcName, PATH_MAX);
+ /* Warning! This can silently truncate if > BUFSIZ, but
+ I don't think that there can be one > BUFSIZ anyway. */
+ nChars = readlink(*argv, srcName, BUFSIZ);
srcName[nChars] = '\0';
}
diff --git a/ls.c b/ls.c
index 0c7f652..3c518ab 100644
--- a/ls.c
+++ b/ls.c
@@ -183,7 +183,7 @@ static char append_char(mode_t mode)
static void list_single(const char *name, struct stat *info,
const char *fullname)
{
- char scratch[PATH_MAX + 1];
+ char scratch[BUFSIZ + 1];
short len = strlen(name);
#ifdef BB_FEATURE_LS_FILETYPES
diff --git a/miscutils/dutmp.c b/miscutils/dutmp.c
index 1629067..886d788 100644
--- a/miscutils/dutmp.c
+++ b/miscutils/dutmp.c
@@ -14,11 +14,17 @@
#include "internal.h"
#include <stdio.h>
#include <errno.h>
-#include <utmp.h>
#define BB_DECLARE_EXTERN
#define bb_need_io_error
#include "messages.c"
+#if defined(__GLIBC__)
+#include <utmp.h>
+#else
+#include <utmp-wrap.h>
+#define utmp new_utmp
+#endif
+
static const char dutmp_usage[] = "dutmp [FILE]\n\n"
"Dump utmp file format (pipe delimited) from FILE\n"
"or stdin to stdout. (i.e. 'dutmp /var/run/utmp')\n";
@@ -45,8 +51,8 @@ extern int dutmp_main(int argc, char **argv)
ut.ut_type, ut.ut_pid, ut.ut_line,
ut.ut_id, ut.ut_user, ut.ut_host,
ut.ut_exit.e_termination, ut.ut_exit.e_exit,
- ut.ut_session,
- ut.ut_tv.tv_sec, ut.ut_tv.tv_usec, ut.ut_addr);
+ ut.ut_session, ut.ut_tv.tv_sec, ut.ut_tv.tv_usec,
+ ut.ut_addr_v6[0]);
}
exit(TRUE);
diff --git a/mkdir.c b/mkdir.c
index b0a2d57..54d9b72 100644
--- a/mkdir.c
+++ b/mkdir.c
@@ -28,7 +28,6 @@
#include <stdio.h>
#include <errno.h>
-#include <sys/param.h> /* for PATH_MAX */
static const char mkdir_usage[] =
"mkdir [OPTION] DIRECTORY...\n\n"
@@ -86,9 +85,9 @@ extern int mkdir_main(int argc, char **argv)
while (argc > 0) {
int status;
struct stat statBuf;
- char buf[PATH_MAX + 1];
+ char buf[BUFSIZ + 1];
- if (strlen(*argv) > PATH_MAX - 1) {
+ if (strlen(*argv) > BUFSIZ - 1) {
fprintf(stderr, name_too_long, "mkdir");
exit FALSE;
}
diff --git a/mkfs_minix.c b/mkfs_minix.c
index 1ee3d4c..be180a4 100644
--- a/mkfs_minix.c
+++ b/mkfs_minix.c
@@ -154,8 +154,8 @@ static unsigned short good_blocks_table[MAX_GOOD_BLOCKS];
static int used_good_blocks = 0;
static unsigned long req_nr_inodes = 0;
-#define inode_in_use(x) (bit(inode_map,(x)))
-#define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1))
+#define inode_in_use(x) (isset(inode_map,(x)))
+#define zone_in_use(x) (isset(zone_map,(x)-FIRSTZONE+1))
#define mark_inode(x) (setbit(inode_map,(x)))
#define unmark_inode(x) (clrbit(inode_map,(x)))
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 1ee96f1..eafec7d 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -67,8 +67,8 @@ unsigned long create_module(const char *name, size_t size)
#else
_syscall2(unsigned long, create_module, const char *, name, size_t, size)
#endif
-static char m_filename[PATH_MAX + 1] = "\0";
-static char m_fullName[PATH_MAX + 1] = "\0";
+static char m_filename[BUFSIZ + 1] = "\0";
+static char m_fullName[BUFSIZ + 1] = "\0";
static const char insmod_usage[] =
"insmod [OPTION]... MODULE [symbol=value]...\n\n"
"Loads the specified kernel modules into the kernel.\n\n"
@@ -103,7 +103,7 @@ extern int insmod_main(int argc, char **argv)
{
int len;
char *tmp;
- char m_name[PATH_MAX + 1] = "\0";
+ char m_name[BUFSIZ + 1] = "\0";
FILE *fp;
if (argc <= 1) {
diff --git a/more.c b/more.c
index 909ed28..30d2757 100644
--- a/more.c
+++ b/more.c
@@ -48,6 +48,7 @@ static const char more_usage[] = "more [file ...]\n";
#endif
FILE *cin;
+
struct termios initial_settings, new_settings;
void gotsig(int sig)
@@ -65,7 +66,10 @@ void gotsig(int sig)
#if defined BB_FEATURE_AUTOWIDTH
-static int terminal_width = 0, terminal_height = 0;
+#ifdef BB_FEATURE_USE_TERMIOS
+static int terminal_width = 0;
+#endif
+static int terminal_height = 0;
#else
#define terminal_width TERMINAL_WIDTH
#define terminal_height TERMINAL_HEIGHT
@@ -80,7 +84,7 @@ extern int more_main(int argc, char **argv)
struct stat st;
FILE *file;
-#ifdef BB_FEATURE_AUTOWIDTH
+#if defined BB_FEATURE_AUTOWIDTH && defined BB_FEATURE_USE_TERMIOS
struct winsize win = { 0, 0 };
#endif
@@ -151,7 +155,11 @@ extern int more_main(int argc, char **argv)
);
fflush(stdout);
+#ifdef BB_FEATURE_USE_TERMIOS
input = getc(cin);
+#else
+ input = getc(stdin);
+#endif
#ifdef BB_FEATURE_USE_TERMIOS
/* Erase the "More" message */
diff --git a/mount.c b/mount.c
index 972e506..456e452 100644
--- a/mount.c
+++ b/mount.c
@@ -48,6 +48,9 @@
#if defined BB_FEATURE_USE_DEVPS_PATCH
#include <linux/devmtab.h>
#endif
+#ifndef MS_RDONLY
+#include <linux/fs.h>
+#endif
#if defined BB_FEATURE_MOUNT_LOOP
diff --git a/pwd.c b/pwd.c
index 0016317..e77a0ca 100644
--- a/pwd.c
+++ b/pwd.c
@@ -24,11 +24,10 @@
#include "internal.h"
#include <stdio.h>
#include <dirent.h>
-#include <sys/param.h>
extern int pwd_main(int argc, char **argv)
{
- char buf[PATH_MAX + 1];
+ char buf[BUFSIZ + 1];
if (getcwd(buf, sizeof(buf)) == NULL) {
perror("get working directory");
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 0d400e5..cacb629 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -53,7 +53,7 @@ extern int ksyslog(int type, char *buf, int len);
#define __LOG_FILE "/var/log/messages"
/* Path to the unix socket */
-char lfile[PATH_MAX] = "";
+char lfile[BUFSIZ] = "";
static char *logFilePath = __LOG_FILE;
@@ -177,7 +177,7 @@ static void doSyslogd (void)
int sock_fd;
fd_set fds;
- char lfile[PATH_MAX];
+ char lfile[BUFSIZ];
/* Set up signal handlers. */
signal (SIGINT, quit_signal);
diff --git a/syslogd.c b/syslogd.c
index 0d400e5..cacb629 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -53,7 +53,7 @@ extern int ksyslog(int type, char *buf, int len);
#define __LOG_FILE "/var/log/messages"
/* Path to the unix socket */
-char lfile[PATH_MAX] = "";
+char lfile[BUFSIZ] = "";
static char *logFilePath = __LOG_FILE;
@@ -177,7 +177,7 @@ static void doSyslogd (void)
int sock_fd;
fd_set fds;
- char lfile[PATH_MAX];
+ char lfile[BUFSIZ];
/* Set up signal handlers. */
signal (SIGINT, quit_signal);
diff --git a/tar.c b/tar.c
index 0177d51..e205763 100644
--- a/tar.c
+++ b/tar.c
@@ -49,7 +49,6 @@
#include <utime.h>
#include <sys/types.h>
#include <sys/sysmacros.h>
-#include <sys/param.h> /* for PATH_MAX */
static const char tar_usage[] =
diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c
index 9636dbd..d373bcb 100644
--- a/util-linux/freeramdisk.c
+++ b/util-linux/freeramdisk.c
@@ -23,7 +23,7 @@
#include <stdio.h>
#include <string.h>
-#include <sys/mount.h>
+#include <linux/fs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -32,6 +32,7 @@
#include "internal.h"
+
static const char freeramdisk_usage[] =
"freeramdisk DEVICE\n\n"
"Free all memory used by the specified ramdisk.\n";
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index aa0a824..c890dff 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -97,7 +97,6 @@
#include <termios.h>
#include <mntent.h>
#include <sys/stat.h>
-#include <sys/param.h> /* for PATH_MAX */
#include <linux/fs.h>
#include <linux/minix_fs.h>
@@ -145,7 +144,7 @@ static int termios_set = 0;
/* File-name data */
#define MAX_DEPTH 32
static int name_depth = 0;
-// static char name_list[MAX_DEPTH][PATH_MAX + 1];
+// static char name_list[MAX_DEPTH][BUFSIZ + 1];
static char **name_list = NULL;
static char *inode_buffer = NULL;
@@ -178,8 +177,8 @@ static unsigned char *zone_count = NULL;
static void recursive_check(unsigned int ino);
static void recursive_check2(unsigned int ino);
-#define inode_in_use(x) (bit(inode_map,(x)))
-#define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1))
+#define inode_in_use(x) (isset(inode_map,(x)))
+#define zone_in_use(x) (isset(zone_map,(x)-FIRSTZONE+1))
#define mark_inode(x) (setbit(inode_map,(x)),changed=1)
#define unmark_inode(x) (clrbit(inode_map,(x)),changed=1)
@@ -1239,7 +1238,7 @@ static void alloc_name_list(void)
name_list = xmalloc(sizeof(char *) * MAX_DEPTH);
for (i = 0; i < MAX_DEPTH; i++)
- name_list[i] = xmalloc(sizeof(char) * PATH_MAX + 1);
+ name_list[i] = xmalloc(sizeof(char) * BUFSIZ + 1);
}
#if 0
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index 1ee3d4c..be180a4 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -154,8 +154,8 @@ static unsigned short good_blocks_table[MAX_GOOD_BLOCKS];
static int used_good_blocks = 0;
static unsigned long req_nr_inodes = 0;
-#define inode_in_use(x) (bit(inode_map,(x)))
-#define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1))
+#define inode_in_use(x) (isset(inode_map,(x)))
+#define zone_in_use(x) (isset(zone_map,(x)-FIRSTZONE+1))
#define mark_inode(x) (setbit(inode_map,(x)))
#define unmark_inode(x) (clrbit(inode_map,(x)))
diff --git a/util-linux/more.c b/util-linux/more.c
index 909ed28..30d2757 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -48,6 +48,7 @@ static const char more_usage[] = "more [file ...]\n";
#endif
FILE *cin;
+
struct termios initial_settings, new_settings;
void gotsig(int sig)
@@ -65,7 +66,10 @@ void gotsig(int sig)
#if defined BB_FEATURE_AUTOWIDTH
-static int terminal_width = 0, terminal_height = 0;
+#ifdef BB_FEATURE_USE_TERMIOS
+static int terminal_width = 0;
+#endif
+static int terminal_height = 0;
#else
#define terminal_width TERMINAL_WIDTH
#define terminal_height TERMINAL_HEIGHT
@@ -80,7 +84,7 @@ extern int more_main(int argc, char **argv)
struct stat st;
FILE *file;
-#ifdef BB_FEATURE_AUTOWIDTH
+#if defined BB_FEATURE_AUTOWIDTH && defined BB_FEATURE_USE_TERMIOS
struct winsize win = { 0, 0 };
#endif
@@ -151,7 +155,11 @@ extern int more_main(int argc, char **argv)
);
fflush(stdout);
+#ifdef BB_FEATURE_USE_TERMIOS
input = getc(cin);
+#else
+ input = getc(stdin);
+#endif
#ifdef BB_FEATURE_USE_TERMIOS
/* Erase the "More" message */
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 972e506..456e452 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -48,6 +48,9 @@
#if defined BB_FEATURE_USE_DEVPS_PATCH
#include <linux/devmtab.h>
#endif
+#ifndef MS_RDONLY
+#include <linux/fs.h>
+#endif
#if defined BB_FEATURE_MOUNT_LOOP
diff --git a/utility.c b/utility.c
index a49b8a0..e6c87fc 100644
--- a/utility.c
+++ b/utility.c
@@ -47,7 +47,6 @@
#include <sys/stat.h>
#include <unistd.h>
#include <ctype.h>
-#include <sys/param.h> /* for PATH_MAX */
#include <sys/utsname.h> /* for uname(2) */
#if defined BB_FEATURE_MOUNT_LOOP
@@ -289,12 +288,12 @@ copyFile(const char *srcName, const char *destName,
return FALSE;
}
} else if (S_ISLNK(srcStatBuf.st_mode)) {
- char link_val[PATH_MAX + 1];
+ char link_val[BUFSIZ + 1];
int link_size;
//fprintf(stderr, "copying link %s to %s\n", srcName, destName);
- /* Warning: This could possibly truncate silently, to PATH_MAX chars */
- link_size = readlink(srcName, &link_val[0], PATH_MAX);
+ /* Warning: This could possibly truncate silently, to BUFSIZ chars */
+ link_size = readlink(srcName, &link_val[0], BUFSIZ);
if (link_size < 0) {
perror(srcName);
return FALSE;
@@ -602,13 +601,13 @@ int recursiveAction(const char *fileName,
}
}
while ((next = readdir(dir)) != NULL) {
- char nextFile[PATH_MAX + 1];
+ char nextFile[BUFSIZ + 1];
if ((strcmp(next->d_name, "..") == 0)
|| (strcmp(next->d_name, ".") == 0)) {
continue;
}
- if (strlen(fileName) + strlen(next->d_name) + 1 > PATH_MAX) {
+ if (strlen(fileName) + strlen(next->d_name) + 1 > BUFSIZ) {
fprintf(stderr, name_too_long, "ftw");
return FALSE;
}
@@ -658,7 +657,7 @@ extern int createPath(const char *name, int mode)
{
char *cp;
char *cpOld;
- char buf[PATH_MAX + 1];
+ char buf[BUFSIZ + 1];
int retVal = 0;
strcpy(buf, name);