Update files to reduce dependance on kernel version...

-Erik
This commit is contained in:
Eric Andersen 2000-07-08 18:55:24 +00:00
parent 877a71bbf0
commit bd22ed8067
23 changed files with 184 additions and 87 deletions

10
chvt.c
View File

@ -5,12 +5,16 @@
* 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)
{

View File

@ -5,12 +5,16 @@
* 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)
{

View File

@ -5,11 +5,14 @@
*/
#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;

View File

@ -24,10 +24,20 @@
#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

View File

@ -27,7 +27,14 @@
#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"

View File

@ -49,11 +49,11 @@
/************************************************************************/
#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>

View File

@ -5,11 +5,14 @@
*/
#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;

View File

@ -16,7 +16,6 @@
*/
#include "internal.h"
#include <linux/unistd.h>
#include <stdio.h>
#include <stdlib.h>
@ -24,6 +23,7 @@
#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

View File

@ -24,9 +24,10 @@
#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)
{

42
init.c
View File

@ -37,12 +37,6 @@
#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>
@ -52,6 +46,33 @@
# 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
@ -84,13 +105,12 @@
#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__ */
@ -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);
}

View File

@ -37,12 +37,6 @@
#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>
@ -52,6 +46,33 @@
# 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
@ -84,13 +105,12 @@
#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__ */
@ -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);
}

View File

@ -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

View File

@ -24,10 +24,20 @@
#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

8
ls.c
View File

@ -49,11 +49,11 @@
/************************************************************************/
#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>

View File

@ -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

View File

@ -48,15 +48,17 @@
#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;

View File

@ -27,7 +27,14 @@
#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"

View File

@ -26,21 +26,21 @@
#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_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[] =
"umount [flags] filesystem|directory\n"

View File

@ -16,7 +16,6 @@
*/
#include "internal.h"
#include <linux/unistd.h>
#include <stdio.h>
#include <stdlib.h>
@ -24,6 +23,7 @@
#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

View File

@ -24,9 +24,10 @@
#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)
{

View File

@ -48,15 +48,17 @@
#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;

View File

@ -26,21 +26,21 @@
#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_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[] =
"umount [flags] filesystem|directory\n"

View File

@ -45,14 +45,14 @@
#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
@ -904,9 +904,10 @@ unsigned long my_getpwnamegid(char *name)
#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)
{