* busyboxed by Erik Andersen
*/
#include "internal.h"
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <linux/vt.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+/* From <linux/vt.h> */
+#define VT_ACTIVATE 0x5606 /* make vt active */
+#define VT_WAITACTIVE 0x5607 /* wait for vt active */
+
int chvt_main(int argc, char **argv)
{
* busyboxed by Erik Andersen
*/
#include "internal.h"
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <linux/vt.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+/* From <linux/vt.h> */
+#define VT_ACTIVATE 0x5606 /* make vt active */
+#define VT_WAITACTIVE 0x5607 /* wait for vt active */
+
int chvt_main(int argc, char **argv)
{
*/
#include "internal.h"
#include <stdlib.h>
+#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
-#include <linux/vt.h>
-#include <stdio.h>
+
+/* From <linux/vt.h> */
+#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
+
char *progname;
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
-#include <linux/kd.h>
-#include <linux/keyboard.h>
#include <sys/ioctl.h>
+/* From <linux/kd.h> */
+struct kbentry {
+ unsigned char kb_table;
+ unsigned char kb_index;
+ unsigned short kb_value;
+};
+#define KDSKBENT 0x4B47 /* sets one entry in translation table */
+
+/* From <linux/keyboard.h> */
+#define NR_KEYS 128
+#define MAX_NR_KEYMAPS 256
+
static const char loadkmap_usage[] = "loadkmap\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
-#include <linux/kd.h>
+
+
+/* From <linux/kd.h> */
+struct kbkeycode {
+ unsigned int scancode, keycode;
+};
+#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */
+
static const char setkeycodes_usage[] =
"setkeycodes SCANCODE KEYCODE ...\n"
/************************************************************************/
#include "internal.h"
-#if !defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
-# include <linux/types.h>
-#else
+//#if !defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
+//# include <linux/types.h>
+//#else
# include <sys/types.h>
-#endif
+//#endif
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>
*/
#include "internal.h"
#include <stdlib.h>
+#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
-#include <linux/vt.h>
-#include <stdio.h>
+
+/* From <linux/vt.h> */
+#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
+
char *progname;
*/
#include "internal.h"
-#include <linux/unistd.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef __alpha__
# define __NR_klogctl __NR_syslog
+#include <linux/unistd.h>
static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
#else /* __alpha__ */
#define klogctl syslog
#include "internal.h"
#include <stdio.h>
#include <sys/ioctl.h>
-#include <linux/fd.h>
#include <fcntl.h>
+/* From <linux/fd.h> */
+#define FDFLUSH _IO(2,0x4b)
extern int fdflush_main(int argc, char **argv)
{
#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 <linux/vt.h> /* for vt_stat */
#include <sys/fcntl.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
# include <sys/syslog.h>
#endif
+/* From <linux/vt.h> */
+struct vt_stat {
+ unsigned short v_active; /* active vt */
+ unsigned short v_signal; /* signal to send */
+ unsigned short v_state; /* vt bitmask */
+};
+#define VT_GETSTATE 0x5603 /* get global vt state info */
+
+/* From <linux/serial.h> */
+struct serial_struct {
+ int type;
+ int line;
+ int port;
+ int irq;
+ int flags;
+ int xmit_fifo_size;
+ int custom_divisor;
+ int baud_base;
+ unsigned short close_delay;
+ char reserved_char[2];
+ int hub6;
+ unsigned short closing_wait; /* time to wait before closing */
+ unsigned short closing_wait2; /* no longer used... */
+ int reserved[4];
+};
+
+
#ifndef RB_HALT_SYSTEM
#define RB_HALT_SYSTEM 0xcdef0123
#include <sys/time.h>
#endif
-#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
-#endif
#if defined(__GLIBC__)
#include <sys/kdaemon.h>
#else
+#include <linux/unistd.h> /* for _syscall() macro */
static _syscall2(int, bdflush, int, func, int, data);
#endif /* __GLIBC__ */
run_lastAction();
sync();
- if (kernelVersion > 0 && kernelVersion <= 2 * 65536 + 2 * 256 + 11) {
+ if (kernelVersion > 0 && kernelVersion <= KERNEL_VERSION(2,2,11)) {
/* bdflush, kupdate not needed for kernels >2.2.11 */
bdflush(1, 0);
sync();
/* allow time for last message to reach serial console */
sleep(2);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- if (sig == SIGUSR2)
+ if (sig == SIGUSR2 && kernelVersion >= KERNEL_VERSION(2,2,0))
init_reboot(RB_POWER_OFF);
else
-#endif
init_reboot(RB_HALT_SYSTEM);
exit(0);
}
#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 <linux/vt.h> /* for vt_stat */
#include <sys/fcntl.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
# include <sys/syslog.h>
#endif
+/* From <linux/vt.h> */
+struct vt_stat {
+ unsigned short v_active; /* active vt */
+ unsigned short v_signal; /* signal to send */
+ unsigned short v_state; /* vt bitmask */
+};
+#define VT_GETSTATE 0x5603 /* get global vt state info */
+
+/* From <linux/serial.h> */
+struct serial_struct {
+ int type;
+ int line;
+ int port;
+ int irq;
+ int flags;
+ int xmit_fifo_size;
+ int custom_divisor;
+ int baud_base;
+ unsigned short close_delay;
+ char reserved_char[2];
+ int hub6;
+ unsigned short closing_wait; /* time to wait before closing */
+ unsigned short closing_wait2; /* no longer used... */
+ int reserved[4];
+};
+
+
#ifndef RB_HALT_SYSTEM
#define RB_HALT_SYSTEM 0xcdef0123
#include <sys/time.h>
#endif
-#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
-#endif
#if defined(__GLIBC__)
#include <sys/kdaemon.h>
#else
+#include <linux/unistd.h> /* for _syscall() macro */
static _syscall2(int, bdflush, int, func, int, data);
#endif /* __GLIBC__ */
run_lastAction();
sync();
- if (kernelVersion > 0 && kernelVersion <= 2 * 65536 + 2 * 256 + 11) {
+ if (kernelVersion > 0 && kernelVersion <= KERNEL_VERSION(2,2,11)) {
/* bdflush, kupdate not needed for kernels >2.2.11 */
bdflush(1, 0);
sync();
/* allow time for last message to reach serial console */
sleep(2);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- if (sig == SIGUSR2)
+ if (sig == SIGUSR2 && kernelVersion >= KERNEL_VERSION(2,2,0))
init_reboot(RB_POWER_OFF);
else
-#endif
init_reboot(RB_HALT_SYSTEM);
exit(0);
}
#ifndef MODUTILS_MODULE_H
#define MODUTILS_MODULE_H 1
-#ident "$Id: insmod.c,v 1.11 2000/06/26 11:16:22 andersen Exp $"
+#ident "$Id: insmod.c,v 1.12 2000/07/08 18:55:24 andersen Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
#ifndef MODUTILS_OBJ_H
#define MODUTILS_OBJ_H 1
-#ident "$Id: insmod.c,v 1.11 2000/06/26 11:16:22 andersen Exp $"
+#ident "$Id: insmod.c,v 1.12 2000/07/08 18:55:24 andersen Exp $"
/* The relocatable object is manipulated using elfin types. */
_syscall5(int, old_sys_init_module, const char *, name, char *, code,
unsigned, codesize, struct old_mod_routines *, routines,
struct old_symbol_table *, symtab)
+#ifndef __NR_query_module
+#define __NR_query_module 167
+#endif
_syscall5(int, query_module, const char *, name, int, which,
void *, buf, size_t, bufsize, size_t*, ret);
#ifndef BB_RMMOD
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
-#include <linux/kd.h>
-#include <linux/keyboard.h>
#include <sys/ioctl.h>
+/* From <linux/kd.h> */
+struct kbentry {
+ unsigned char kb_table;
+ unsigned char kb_index;
+ unsigned short kb_value;
+};
+#define KDSKBENT 0x4B47 /* sets one entry in translation table */
+
+/* From <linux/keyboard.h> */
+#define NR_KEYS 128
+#define MAX_NR_KEYMAPS 256
+
static const char loadkmap_usage[] = "loadkmap\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
/************************************************************************/
#include "internal.h"
-#if !defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
-# include <linux/types.h>
-#else
+//#if !defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
+//# include <linux/types.h>
+//#else
# include <sys/types.h>
-#endif
+//#endif
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>
#ifndef MODUTILS_MODULE_H
#define MODUTILS_MODULE_H 1
-#ident "$Id: insmod.c,v 1.11 2000/06/26 11:16:22 andersen Exp $"
+#ident "$Id: insmod.c,v 1.12 2000/07/08 18:55:24 andersen Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
#ifndef MODUTILS_OBJ_H
#define MODUTILS_OBJ_H 1
-#ident "$Id: insmod.c,v 1.11 2000/06/26 11:16:22 andersen Exp $"
+#ident "$Id: insmod.c,v 1.12 2000/07/08 18:55:24 andersen Exp $"
/* The relocatable object is manipulated using elfin types. */
_syscall5(int, old_sys_init_module, const char *, name, char *, code,
unsigned, codesize, struct old_mod_routines *, routines,
struct old_symbol_table *, symtab)
+#ifndef __NR_query_module
+#define __NR_query_module 167
+#endif
_syscall5(int, query_module, const char *, name, int, which,
void *, buf, size_t, bufsize, size_t*, ret);
#ifndef BB_RMMOD
#if defined BB_FEATURE_USE_DEVPS_PATCH
#include <linux/devmtab.h>
#endif
-#ifndef MS_RDONLY
-#include <linux/fs.h>
+
+/* 2.0.x. kernels don't know about MS_NODIRATIME */
+#ifndef MS_NODIRATIME
+#define MS_NODIRATIME 2048 /* Do not update directory access times */
#endif
+
#if defined BB_FEATURE_MOUNT_LOOP
#include <fcntl.h>
#include <sys/ioctl.h>
-#include <linux/loop.h>
static int use_loop = FALSE;
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
-#include <linux/kd.h>
+
+
+/* From <linux/kd.h> */
+struct kbkeycode {
+ unsigned int scancode, keycode;
+};
+#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */
+
static const char setkeycodes_usage[] =
"setkeycodes SCANCODE KEYCODE ...\n"
#include <stdio.h>
#include <mntent.h>
#include <errno.h>
+#include <sys/mount.h>
#include <linux/unistd.h>
-//#include <sys/mount.h>
-/* Include our own version of sys/mount.h, since libc5 doesn't
- * know about umount2 */
-static _syscall1(int, umount, const char *, special_file);
-static _syscall2(int, umount2, const char *, special_file, int, flags);
-static _syscall5(int, mount, const char *, special_file, const char *, dir,
- const char *, fstype, unsigned long int, rwflag, const void *, data);
+/* Include our own version of umount2 if we need it... */
+#ifndef __NR_umount2
+#define __NR_umount2 52
#define MNT_FORCE 1
-#define MS_MGC_VAL 0xc0ed0000 /* Magic flag number to indicate "new" flags */
-#define MS_REMOUNT 32 /* Alter flags of a mounted FS. */
-#define MS_RDONLY 1 /* Mount read-only. */
+#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
+#define MS_REMOUNT 32 /* Alter flags of a mounted FS. */
+#define MS_RDONLY 1 /* Mount read-only. */
+
+#endif
+static _syscall2(int, umount2, const char *, special_file, int, flags);
static const char umount_usage[] =
*/
#include "internal.h"
-#include <linux/unistd.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef __alpha__
# define __NR_klogctl __NR_syslog
+#include <linux/unistd.h>
static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
#else /* __alpha__ */
#define klogctl syslog
#include "internal.h"
#include <stdio.h>
#include <sys/ioctl.h>
-#include <linux/fd.h>
#include <fcntl.h>
+/* From <linux/fd.h> */
+#define FDFLUSH _IO(2,0x4b)
extern int fdflush_main(int argc, char **argv)
{
#if defined BB_FEATURE_USE_DEVPS_PATCH
#include <linux/devmtab.h>
#endif
-#ifndef MS_RDONLY
-#include <linux/fs.h>
+
+/* 2.0.x. kernels don't know about MS_NODIRATIME */
+#ifndef MS_NODIRATIME
+#define MS_NODIRATIME 2048 /* Do not update directory access times */
#endif
+
#if defined BB_FEATURE_MOUNT_LOOP
#include <fcntl.h>
#include <sys/ioctl.h>
-#include <linux/loop.h>
static int use_loop = FALSE;
#include <stdio.h>
#include <mntent.h>
#include <errno.h>
+#include <sys/mount.h>
#include <linux/unistd.h>
-//#include <sys/mount.h>
-/* Include our own version of sys/mount.h, since libc5 doesn't
- * know about umount2 */
-static _syscall1(int, umount, const char *, special_file);
-static _syscall2(int, umount2, const char *, special_file, int, flags);
-static _syscall5(int, mount, const char *, special_file, const char *, dir,
- const char *, fstype, unsigned long int, rwflag, const void *, data);
+/* Include our own version of umount2 if we need it... */
+#ifndef __NR_umount2
+#define __NR_umount2 52
#define MNT_FORCE 1
-#define MS_MGC_VAL 0xc0ed0000 /* Magic flag number to indicate "new" flags */
-#define MS_REMOUNT 32 /* Alter flags of a mounted FS. */
-#define MS_RDONLY 1 /* Mount read-only. */
+#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
+#define MS_REMOUNT 32 /* Alter flags of a mounted FS. */
+#define MS_RDONLY 1 /* Mount read-only. */
+
+#endif
+static _syscall2(int, umount2, const char *, special_file, int, flags);
static const char umount_usage[] =
#include <dirent.h>
#include <time.h>
#include <utime.h>
-#include <sys/stat.h>
#include <unistd.h>
#include <ctype.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
#include <sys/utsname.h> /* for uname(2) */
#if defined BB_FEATURE_MOUNT_LOOP
#include <fcntl.h>
-#include <sys/ioctl.h>
#include <linux/loop.h>
#endif
#if (defined BB_CHVT) || (defined BB_DEALLOCVT) || (defined BB_SETKEYCODES)
-
-#include <linux/kd.h>
-#include <sys/ioctl.h>
+/* From <linux/kd.h> */
+#define KDGKBTYPE 0x4B33 /* get keyboard type */
+#define KB_84 0x01
+#define KB_101 0x02 /* this is what we always answer */
int is_a_console(int fd)
{