compatability.
-Erik
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 \
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)
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)
#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
#include <signal.h>
#include <sys/stat.h>
#include <errno.h>
-#include <sys/param.h> /* for PATH_MAX */
/* #include "tailor.h" */
#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
* used.
*/
-#define MAX(a,b) (a >= b ? a : b)
/* the arguments must not have side effects */
/* ===========================================================================
#include <utime.h>
#include <sys/types.h>
#include <sys/sysmacros.h>
-#include <sys/param.h> /* for PATH_MAX */
static const char tar_usage[] =
#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
#define BB_RMDIR
#define BB_RMMOD
#define BB_SED
+#define BB_SETKEYCODES
#define BB_SFDISK
#define BB_SH
#define BB_SLEEP
//#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
#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)
#include <stdlib.h>
#include <fcntl.h>
-extern int getfd(void);
-
int chvt_main(int argc, char **argv)
{
int fd, num;
#include <stdlib.h>
#include <fcntl.h>
-extern int getfd(void);
-
int chvt_main(int argc, char **argv)
{
int fd, num;
#include <linux/vt.h>
#include <stdio.h>
-extern int getfd(void);
char *progname;
int deallocvt_main(int argc, char *argv[])
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
-#include <sys/param.h> /* for PATH_MAX */
typedef void (Display) (long, char *);
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)
continue;
}
- if (len + strlen(name) + 1 > PATH_MAX) {
+ if (len + strlen(name) + 1 > BUFSIZ) {
fprintf(stderr, name_too_long, "du");
du_depth--;
return 0;
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"
#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"
linkName = argv[argc - 1];
- if (strlen(linkName) > PATH_MAX) {
+ if (strlen(linkName) > BUFSIZ) {
fprintf(stderr, name_too_long, "ln");
exit FALSE;
}
}
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;
}
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';
}
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
#include <stdio.h>
#include <errno.h>
-#include <sys/param.h> /* for PATH_MAX */
static const char mkdir_usage[] =
"mkdir [OPTION] DIRECTORY...\n\n"
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;
}
#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");
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;
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;
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;
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;
}
followLinks = FALSE;
}
- if (strlen(argv[argc - 1]) > PATH_MAX) {
+ if (strlen(argv[argc - 1]) > BUFSIZ) {
fprintf(stderr, name_too_long, "cp");
goto exit_false;
}
baseSrcName = *(argv++);
- if ((srcLen = strlen(baseSrcName)) > PATH_MAX)
+ if ((srcLen = strlen(baseSrcName)) > BUFSIZ)
name_too_long__exit();
if (srcLen == 0) continue; /* "" */
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;
}
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;
}
#include <linux/vt.h>
#include <stdio.h>
-extern int getfd(void);
char *progname;
int deallocvt_main(int argc, char *argv[])
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
-------------------------------
+=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
=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 $
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
-#include <sys/param.h> /* for PATH_MAX */
typedef void (Display) (long, char *);
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)
continue;
}
- if (len + strlen(name) + 1 > PATH_MAX) {
+ if (len + strlen(name) + 1 > BUFSIZ) {
fprintf(stderr, name_too_long, "du");
du_depth--;
return 0;
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"
#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";
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);
#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>
#include "internal.h"
+
static const char freeramdisk_usage[] =
"freeramdisk DEVICE\n\n"
"Free all memory used by the specified ramdisk.\n";
#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>
/* 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;
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)
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
#include <signal.h>
#include <sys/stat.h>
#include <errno.h>
-#include <sys/param.h> /* for PATH_MAX */
/* #include "tailor.h" */
#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
* used.
*/
-#define MAX(a,b) (a >= b ? a : b)
/* the arguments must not have side effects */
/* ===========================================================================
*/
#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
#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 */
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();
#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);
}
/* allow time for last message to reach serial console */
sleep(2);
- reboot(RB_AUTOBOOT);
+ init_reboot(RB_AUTOBOOT);
exit(0);
}
/* 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 */
*/
#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
#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 */
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();
#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);
}
/* allow time for last message to reach serial console */
sleep(2);
- reboot(RB_AUTOBOOT);
+ init_reboot(RB_AUTOBOOT);
exit(0);
}
/* 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 */
#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"
{
int len;
char *tmp;
- char m_name[PATH_MAX + 1] = "\0";
+ char m_name[BUFSIZ + 1] = "\0";
FILE *fp;
if (argc <= 1) {
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
-//#include <sys/param.h>
+#include <sys/param.h>
#include <mntent.h>
#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,
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);
#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
#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"
linkName = argv[argc - 1];
- if (strlen(linkName) > PATH_MAX) {
+ if (strlen(linkName) > BUFSIZ) {
fprintf(stderr, name_too_long, "ln");
exit FALSE;
}
}
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;
}
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';
}
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
#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";
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);
#include <stdio.h>
#include <errno.h>
-#include <sys/param.h> /* for PATH_MAX */
static const char mkdir_usage[] =
"mkdir [OPTION] DIRECTORY...\n\n"
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;
}
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)))
#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"
{
int len;
char *tmp;
- char m_name[PATH_MAX + 1] = "\0";
+ char m_name[BUFSIZ + 1] = "\0";
FILE *fp;
if (argc <= 1) {
#endif
FILE *cin;
+
struct termios initial_settings, new_settings;
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
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
);
fflush(stdout);
+#ifdef BB_FEATURE_USE_TERMIOS
input = getc(cin);
+#else
+ input = getc(stdin);
+#endif
#ifdef BB_FEATURE_USE_TERMIOS
/* Erase the "More" message */
#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
#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");
#define __LOG_FILE "/var/log/messages"
/* Path to the unix socket */
-char lfile[PATH_MAX] = "";
+char lfile[BUFSIZ] = "";
static char *logFilePath = __LOG_FILE;
int sock_fd;
fd_set fds;
- char lfile[PATH_MAX];
+ char lfile[BUFSIZ];
/* Set up signal handlers. */
signal (SIGINT, quit_signal);
#define __LOG_FILE "/var/log/messages"
/* Path to the unix socket */
-char lfile[PATH_MAX] = "";
+char lfile[BUFSIZ] = "";
static char *logFilePath = __LOG_FILE;
int sock_fd;
fd_set fds;
- char lfile[PATH_MAX];
+ char lfile[BUFSIZ];
/* Set up signal handlers. */
signal (SIGINT, quit_signal);
#include <utime.h>
#include <sys/types.h>
#include <sys/sysmacros.h>
-#include <sys/param.h> /* for PATH_MAX */
static const char tar_usage[] =
#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>
#include "internal.h"
+
static const char freeramdisk_usage[] =
"freeramdisk DEVICE\n\n"
"Free all memory used by the specified ramdisk.\n";
#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>
/* 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;
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)
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
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)))
#endif
FILE *cin;
+
struct termios initial_settings, new_settings;
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
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
);
fflush(stdout);
+#ifdef BB_FEATURE_USE_TERMIOS
input = getc(cin);
+#else
+ input = getc(stdin);
+#endif
#ifdef BB_FEATURE_USE_TERMIOS
/* Erase the "More" message */
#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
#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
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;
}
}
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;
}
{
char *cp;
char *cpOld;
- char buf[PATH_MAX + 1];
+ char buf[BUFSIZ + 1];
int retVal = 0;
strcpy(buf, name);