From bd22ed806782eec76929bcd2ec556717e79d24c7 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Sat, 8 Jul 2000 18:55:24 +0000 Subject: Update files to reduce dependance on kernel version... -Erik --- chvt.c | 10 +++++++--- console-tools/chvt.c | 10 +++++++--- console-tools/deallocvt.c | 7 +++++-- console-tools/loadkmap.c | 14 ++++++++++++-- console-tools/setkeycodes.c | 9 ++++++++- coreutils/ls.c | 8 ++++---- deallocvt.c | 7 +++++-- dmesg.c | 2 +- fdflush.c | 3 ++- init.c | 42 ++++++++++++++++++++++++++++++------------ init/init.c | 42 ++++++++++++++++++++++++++++++------------ insmod.c | 7 +++++-- loadkmap.c | 14 ++++++++++++-- ls.c | 8 ++++---- modutils/insmod.c | 7 +++++-- mount.c | 8 +++++--- setkeycodes.c | 9 ++++++++- umount.c | 20 ++++++++++---------- util-linux/dmesg.c | 2 +- util-linux/fdflush.c | 3 ++- util-linux/mount.c | 8 +++++--- util-linux/umount.c | 20 ++++++++++---------- utility.c | 11 ++++++----- 23 files changed, 184 insertions(+), 87 deletions(-) diff --git a/chvt.c b/chvt.c index 45a0439..c5c86b6 100644 --- a/chvt.c +++ b/chvt.c @@ -5,12 +5,16 @@ * busyboxed by Erik Andersen */ #include "internal.h" -#include -#include -#include #include #include #include +#include +#include + +/* From */ +#define VT_ACTIVATE 0x5606 /* make vt active */ +#define VT_WAITACTIVE 0x5607 /* wait for vt active */ + int chvt_main(int argc, char **argv) { diff --git a/console-tools/chvt.c b/console-tools/chvt.c index 45a0439..c5c86b6 100644 --- a/console-tools/chvt.c +++ b/console-tools/chvt.c @@ -5,12 +5,16 @@ * busyboxed by Erik Andersen */ #include "internal.h" -#include -#include -#include #include #include #include +#include +#include + +/* From */ +#define VT_ACTIVATE 0x5606 /* make vt active */ +#define VT_WAITACTIVE 0x5607 /* wait for vt active */ + int chvt_main(int argc, char **argv) { diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c index b65f7b0..0cad771 100644 --- a/console-tools/deallocvt.c +++ b/console-tools/deallocvt.c @@ -5,11 +5,14 @@ */ #include "internal.h" #include +#include #include #include #include -#include -#include + +/* From */ +#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */ + char *progname; diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c index 9057414..0e8c090 100644 --- a/console-tools/loadkmap.c +++ b/console-tools/loadkmap.c @@ -24,10 +24,20 @@ #include #include #include -#include -#include #include +/* From */ +struct kbentry { + unsigned char kb_table; + unsigned char kb_index; + unsigned short kb_value; +}; +#define KDSKBENT 0x4B47 /* sets one entry in translation table */ + +/* From */ +#define NR_KEYS 128 +#define MAX_NR_KEYMAPS 256 + static const char loadkmap_usage[] = "loadkmap\n" #ifndef BB_FEATURE_TRIVIAL_HELP diff --git a/console-tools/setkeycodes.c b/console-tools/setkeycodes.c index 9062caf..1bdb909 100644 --- a/console-tools/setkeycodes.c +++ b/console-tools/setkeycodes.c @@ -27,7 +27,14 @@ #include #include #include -#include + + +/* From */ +struct kbkeycode { + unsigned int scancode, keycode; +}; +#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */ + static const char setkeycodes_usage[] = "setkeycodes SCANCODE KEYCODE ...\n" diff --git a/coreutils/ls.c b/coreutils/ls.c index 75fa654..98ccbed 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c @@ -49,11 +49,11 @@ /************************************************************************/ #include "internal.h" -#if !defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) -# include -#else +//#if !defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) +//# include +//#else # include -#endif +//#endif #include #include #include diff --git a/deallocvt.c b/deallocvt.c index b65f7b0..0cad771 100644 --- a/deallocvt.c +++ b/deallocvt.c @@ -5,11 +5,14 @@ */ #include "internal.h" #include +#include #include #include #include -#include -#include + +/* From */ +#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */ + char *progname; diff --git a/dmesg.c b/dmesg.c index 20846f7..e88f549 100644 --- a/dmesg.c +++ b/dmesg.c @@ -16,7 +16,6 @@ */ #include "internal.h" -#include #include #include @@ -24,6 +23,7 @@ #ifndef __alpha__ # define __NR_klogctl __NR_syslog +#include static inline _syscall3(int, klogctl, int, type, char *, b, int, len); #else /* __alpha__ */ #define klogctl syslog diff --git a/fdflush.c b/fdflush.c index 81f0472..d993735 100644 --- a/fdflush.c +++ b/fdflush.c @@ -24,9 +24,10 @@ #include "internal.h" #include #include -#include #include +/* From */ +#define FDFLUSH _IO(2,0x4b) extern int fdflush_main(int argc, char **argv) { diff --git a/init.c b/init.c index 35f2255..b368c00 100644 --- a/init.c +++ b/init.c @@ -37,12 +37,6 @@ #include #include #include -#include -#include /* for serial_struct */ -#include -#include -#include -#include /* for vt_stat */ #include #include #include @@ -52,6 +46,33 @@ # include #endif +/* From */ +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 */ +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 @@ -84,13 +105,12 @@ #include #endif -#ifndef KERNEL_VERSION #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#endif #if defined(__GLIBC__) #include #else +#include /* for _syscall() macro */ static _syscall2(int, bdflush, int, func, int, data); #endif /* __GLIBC__ */ @@ -568,7 +588,7 @@ static void shutdown_system(void) 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(); @@ -587,11 +607,9 @@ static void halt_signal(int sig) /* 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); } diff --git a/init/init.c b/init/init.c index 35f2255..b368c00 100644 --- a/init/init.c +++ b/init/init.c @@ -37,12 +37,6 @@ #include #include #include -#include -#include /* for serial_struct */ -#include -#include -#include -#include /* for vt_stat */ #include #include #include @@ -52,6 +46,33 @@ # include #endif +/* From */ +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 */ +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 @@ -84,13 +105,12 @@ #include #endif -#ifndef KERNEL_VERSION #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#endif #if defined(__GLIBC__) #include #else +#include /* for _syscall() macro */ static _syscall2(int, bdflush, int, func, int, data); #endif /* __GLIBC__ */ @@ -568,7 +588,7 @@ static void shutdown_system(void) 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(); @@ -587,11 +607,9 @@ static void halt_signal(int sig) /* 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); } diff --git a/insmod.c b/insmod.c index 0064688..75058b9 100644 --- a/insmod.c +++ b/insmod.c @@ -71,7 +71,7 @@ #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 @@ -277,7 +277,7 @@ int delete_module(const char *); #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. */ @@ -530,6 +530,9 @@ _syscall2(int, new_sys_init_module, const char *, name, _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 diff --git a/loadkmap.c b/loadkmap.c index 9057414..0e8c090 100644 --- a/loadkmap.c +++ b/loadkmap.c @@ -24,10 +24,20 @@ #include #include #include -#include -#include #include +/* From */ +struct kbentry { + unsigned char kb_table; + unsigned char kb_index; + unsigned short kb_value; +}; +#define KDSKBENT 0x4B47 /* sets one entry in translation table */ + +/* From */ +#define NR_KEYS 128 +#define MAX_NR_KEYMAPS 256 + static const char loadkmap_usage[] = "loadkmap\n" #ifndef BB_FEATURE_TRIVIAL_HELP diff --git a/ls.c b/ls.c index 75fa654..98ccbed 100644 --- a/ls.c +++ b/ls.c @@ -49,11 +49,11 @@ /************************************************************************/ #include "internal.h" -#if !defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) -# include -#else +//#if !defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) +//# include +//#else # include -#endif +//#endif #include #include #include diff --git a/modutils/insmod.c b/modutils/insmod.c index 0064688..75058b9 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c @@ -71,7 +71,7 @@ #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 @@ -277,7 +277,7 @@ int delete_module(const char *); #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. */ @@ -530,6 +530,9 @@ _syscall2(int, new_sys_init_module, const char *, name, _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 diff --git a/mount.c b/mount.c index 76f048b..01e9b3d 100644 --- a/mount.c +++ b/mount.c @@ -48,15 +48,17 @@ #if defined BB_FEATURE_USE_DEVPS_PATCH #include #endif -#ifndef MS_RDONLY -#include + +/* 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 #include -#include static int use_loop = FALSE; diff --git a/setkeycodes.c b/setkeycodes.c index 9062caf..1bdb909 100644 --- a/setkeycodes.c +++ b/setkeycodes.c @@ -27,7 +27,14 @@ #include #include #include -#include + + +/* From */ +struct kbkeycode { + unsigned int scancode, keycode; +}; +#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */ + static const char setkeycodes_usage[] = "setkeycodes SCANCODE KEYCODE ...\n" diff --git a/umount.c b/umount.c index 61f7f90..d790d68 100644 --- a/umount.c +++ b/umount.c @@ -26,20 +26,20 @@ #include #include #include +#include #include -//#include -/* 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[] = diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c index 20846f7..e88f549 100644 --- a/util-linux/dmesg.c +++ b/util-linux/dmesg.c @@ -16,7 +16,6 @@ */ #include "internal.h" -#include #include #include @@ -24,6 +23,7 @@ #ifndef __alpha__ # define __NR_klogctl __NR_syslog +#include static inline _syscall3(int, klogctl, int, type, char *, b, int, len); #else /* __alpha__ */ #define klogctl syslog diff --git a/util-linux/fdflush.c b/util-linux/fdflush.c index 81f0472..d993735 100644 --- a/util-linux/fdflush.c +++ b/util-linux/fdflush.c @@ -24,9 +24,10 @@ #include "internal.h" #include #include -#include #include +/* From */ +#define FDFLUSH _IO(2,0x4b) extern int fdflush_main(int argc, char **argv) { diff --git a/util-linux/mount.c b/util-linux/mount.c index 76f048b..01e9b3d 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -48,15 +48,17 @@ #if defined BB_FEATURE_USE_DEVPS_PATCH #include #endif -#ifndef MS_RDONLY -#include + +/* 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 #include -#include static int use_loop = FALSE; diff --git a/util-linux/umount.c b/util-linux/umount.c index 61f7f90..d790d68 100644 --- a/util-linux/umount.c +++ b/util-linux/umount.c @@ -26,20 +26,20 @@ #include #include #include +#include #include -//#include -/* 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[] = diff --git a/utility.c b/utility.c index e1e0f71..271b101 100644 --- a/utility.c +++ b/utility.c @@ -45,14 +45,14 @@ #include #include #include -#include #include #include +#include +#include #include /* for uname(2) */ #if defined BB_FEATURE_MOUNT_LOOP #include -#include #include #endif @@ -904,9 +904,10 @@ unsigned long my_getpwnamegid(char *name) #if (defined BB_CHVT) || (defined BB_DEALLOCVT) || (defined BB_SETKEYCODES) - -#include -#include +/* From */ +#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) { -- cgit v1.1