aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-07-08 18:55:24 +0000
committerEric Andersen <andersen@codepoet.org>2000-07-08 18:55:24 +0000
commitbd22ed806782eec76929bcd2ec556717e79d24c7 (patch)
treee225367aaef198eacec8ed0b530d36a9d888d92f
parent877a71bbf0b8386add4631c08f7101259ad2dc07 (diff)
downloadbusybox-w32-bd22ed806782eec76929bcd2ec556717e79d24c7.tar.gz
busybox-w32-bd22ed806782eec76929bcd2ec556717e79d24c7.tar.bz2
busybox-w32-bd22ed806782eec76929bcd2ec556717e79d24c7.zip
Update files to reduce dependance on kernel version...
-Erik
-rw-r--r--chvt.c10
-rw-r--r--console-tools/chvt.c10
-rw-r--r--console-tools/deallocvt.c7
-rw-r--r--console-tools/loadkmap.c14
-rw-r--r--console-tools/setkeycodes.c9
-rw-r--r--coreutils/ls.c8
-rw-r--r--deallocvt.c7
-rw-r--r--dmesg.c2
-rw-r--r--fdflush.c3
-rw-r--r--init.c42
-rw-r--r--init/init.c42
-rw-r--r--insmod.c7
-rw-r--r--loadkmap.c14
-rw-r--r--ls.c8
-rw-r--r--modutils/insmod.c7
-rw-r--r--mount.c8
-rw-r--r--setkeycodes.c9
-rw-r--r--umount.c20
-rw-r--r--util-linux/dmesg.c2
-rw-r--r--util-linux/fdflush.c3
-rw-r--r--util-linux/mount.c8
-rw-r--r--util-linux/umount.c20
-rw-r--r--utility.c11
23 files changed, 184 insertions, 87 deletions
diff --git a/chvt.c b/chvt.c
index 45a04397a..c5c86b613 100644
--- a/chvt.c
+++ b/chvt.c
@@ -5,12 +5,16 @@
5 * busyboxed by Erik Andersen 5 * busyboxed by Erik Andersen
6 */ 6 */
7#include "internal.h" 7#include "internal.h"
8#include <sys/types.h>
9#include <sys/ioctl.h>
10#include <linux/vt.h>
11#include <stdio.h> 8#include <stdio.h>
12#include <stdlib.h> 9#include <stdlib.h>
13#include <fcntl.h> 10#include <fcntl.h>
11#include <sys/types.h>
12#include <sys/ioctl.h>
13
14/* From <linux/vt.h> */
15#define VT_ACTIVATE 0x5606 /* make vt active */
16#define VT_WAITACTIVE 0x5607 /* wait for vt active */
17
14 18
15int chvt_main(int argc, char **argv) 19int chvt_main(int argc, char **argv)
16{ 20{
diff --git a/console-tools/chvt.c b/console-tools/chvt.c
index 45a04397a..c5c86b613 100644
--- a/console-tools/chvt.c
+++ b/console-tools/chvt.c
@@ -5,12 +5,16 @@
5 * busyboxed by Erik Andersen 5 * busyboxed by Erik Andersen
6 */ 6 */
7#include "internal.h" 7#include "internal.h"
8#include <sys/types.h>
9#include <sys/ioctl.h>
10#include <linux/vt.h>
11#include <stdio.h> 8#include <stdio.h>
12#include <stdlib.h> 9#include <stdlib.h>
13#include <fcntl.h> 10#include <fcntl.h>
11#include <sys/types.h>
12#include <sys/ioctl.h>
13
14/* From <linux/vt.h> */
15#define VT_ACTIVATE 0x5606 /* make vt active */
16#define VT_WAITACTIVE 0x5607 /* wait for vt active */
17
14 18
15int chvt_main(int argc, char **argv) 19int chvt_main(int argc, char **argv)
16{ 20{
diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c
index b65f7b098..0cad7717b 100644
--- a/console-tools/deallocvt.c
+++ b/console-tools/deallocvt.c
@@ -5,11 +5,14 @@
5 */ 5 */
6#include "internal.h" 6#include "internal.h"
7#include <stdlib.h> 7#include <stdlib.h>
8#include <stdio.h>
8#include <fcntl.h> 9#include <fcntl.h>
9#include <sys/types.h> 10#include <sys/types.h>
10#include <sys/ioctl.h> 11#include <sys/ioctl.h>
11#include <linux/vt.h> 12
12#include <stdio.h> 13/* From <linux/vt.h> */
14#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
15
13 16
14char *progname; 17char *progname;
15 18
diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c
index 905741467..0e8c090d2 100644
--- a/console-tools/loadkmap.c
+++ b/console-tools/loadkmap.c
@@ -24,10 +24,20 @@
24#include <errno.h> 24#include <errno.h>
25#include <fcntl.h> 25#include <fcntl.h>
26#include <stdio.h> 26#include <stdio.h>
27#include <linux/kd.h>
28#include <linux/keyboard.h>
29#include <sys/ioctl.h> 27#include <sys/ioctl.h>
30 28
29/* From <linux/kd.h> */
30struct kbentry {
31 unsigned char kb_table;
32 unsigned char kb_index;
33 unsigned short kb_value;
34};
35#define KDSKBENT 0x4B47 /* sets one entry in translation table */
36
37/* From <linux/keyboard.h> */
38#define NR_KEYS 128
39#define MAX_NR_KEYMAPS 256
40
31 41
32static const char loadkmap_usage[] = "loadkmap\n" 42static const char loadkmap_usage[] = "loadkmap\n"
33#ifndef BB_FEATURE_TRIVIAL_HELP 43#ifndef BB_FEATURE_TRIVIAL_HELP
diff --git a/console-tools/setkeycodes.c b/console-tools/setkeycodes.c
index 9062caf75..1bdb909ea 100644
--- a/console-tools/setkeycodes.c
+++ b/console-tools/setkeycodes.c
@@ -27,7 +27,14 @@
27#include <stdlib.h> 27#include <stdlib.h>
28#include <fcntl.h> 28#include <fcntl.h>
29#include <sys/ioctl.h> 29#include <sys/ioctl.h>
30#include <linux/kd.h> 30
31
32/* From <linux/kd.h> */
33struct kbkeycode {
34 unsigned int scancode, keycode;
35};
36#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */
37
31 38
32static const char setkeycodes_usage[] = 39static const char setkeycodes_usage[] =
33 "setkeycodes SCANCODE KEYCODE ...\n" 40 "setkeycodes SCANCODE KEYCODE ...\n"
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 75fa65421..98ccbeddb 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -49,11 +49,11 @@
49/************************************************************************/ 49/************************************************************************/
50 50
51#include "internal.h" 51#include "internal.h"
52#if !defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) 52//#if !defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
53# include <linux/types.h> 53//# include <linux/types.h>
54#else 54//#else
55# include <sys/types.h> 55# include <sys/types.h>
56#endif 56//#endif
57#include <sys/stat.h> 57#include <sys/stat.h>
58#include <stdio.h> 58#include <stdio.h>
59#include <unistd.h> 59#include <unistd.h>
diff --git a/deallocvt.c b/deallocvt.c
index b65f7b098..0cad7717b 100644
--- a/deallocvt.c
+++ b/deallocvt.c
@@ -5,11 +5,14 @@
5 */ 5 */
6#include "internal.h" 6#include "internal.h"
7#include <stdlib.h> 7#include <stdlib.h>
8#include <stdio.h>
8#include <fcntl.h> 9#include <fcntl.h>
9#include <sys/types.h> 10#include <sys/types.h>
10#include <sys/ioctl.h> 11#include <sys/ioctl.h>
11#include <linux/vt.h> 12
12#include <stdio.h> 13/* From <linux/vt.h> */
14#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
15
13 16
14char *progname; 17char *progname;
15 18
diff --git a/dmesg.c b/dmesg.c
index 20846f7c6..e88f549ca 100644
--- a/dmesg.c
+++ b/dmesg.c
@@ -16,7 +16,6 @@
16 */ 16 */
17 17
18#include "internal.h" 18#include "internal.h"
19#include <linux/unistd.h>
20#include <stdio.h> 19#include <stdio.h>
21#include <stdlib.h> 20#include <stdlib.h>
22 21
@@ -24,6 +23,7 @@
24 23
25#ifndef __alpha__ 24#ifndef __alpha__
26# define __NR_klogctl __NR_syslog 25# define __NR_klogctl __NR_syslog
26#include <linux/unistd.h>
27static inline _syscall3(int, klogctl, int, type, char *, b, int, len); 27static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
28#else /* __alpha__ */ 28#else /* __alpha__ */
29#define klogctl syslog 29#define klogctl syslog
diff --git a/fdflush.c b/fdflush.c
index 81f0472c6..d9937355f 100644
--- a/fdflush.c
+++ b/fdflush.c
@@ -24,9 +24,10 @@
24#include "internal.h" 24#include "internal.h"
25#include <stdio.h> 25#include <stdio.h>
26#include <sys/ioctl.h> 26#include <sys/ioctl.h>
27#include <linux/fd.h>
28#include <fcntl.h> 27#include <fcntl.h>
29 28
29/* From <linux/fd.h> */
30#define FDFLUSH _IO(2,0x4b)
30 31
31extern int fdflush_main(int argc, char **argv) 32extern int fdflush_main(int argc, char **argv)
32{ 33{
diff --git a/init.c b/init.c
index 35f2255b5..b368c00ed 100644
--- a/init.c
+++ b/init.c
@@ -37,12 +37,6 @@
37#include <string.h> 37#include <string.h>
38#include <termios.h> 38#include <termios.h>
39#include <unistd.h> 39#include <unistd.h>
40#include <asm/types.h>
41#include <linux/serial.h> /* for serial_struct */
42#include <linux/version.h>
43#include <linux/reboot.h>
44#include <linux/unistd.h>
45#include <linux/vt.h> /* for vt_stat */
46#include <sys/fcntl.h> 40#include <sys/fcntl.h>
47#include <sys/ioctl.h> 41#include <sys/ioctl.h>
48#include <sys/mount.h> 42#include <sys/mount.h>
@@ -52,6 +46,33 @@
52# include <sys/syslog.h> 46# include <sys/syslog.h>
53#endif 47#endif
54 48
49/* From <linux/vt.h> */
50struct vt_stat {
51 unsigned short v_active; /* active vt */
52 unsigned short v_signal; /* signal to send */
53 unsigned short v_state; /* vt bitmask */
54};
55#define VT_GETSTATE 0x5603 /* get global vt state info */
56
57/* From <linux/serial.h> */
58struct serial_struct {
59 int type;
60 int line;
61 int port;
62 int irq;
63 int flags;
64 int xmit_fifo_size;
65 int custom_divisor;
66 int baud_base;
67 unsigned short close_delay;
68 char reserved_char[2];
69 int hub6;
70 unsigned short closing_wait; /* time to wait before closing */
71 unsigned short closing_wait2; /* no longer used... */
72 int reserved[4];
73};
74
75
55 76
56#ifndef RB_HALT_SYSTEM 77#ifndef RB_HALT_SYSTEM
57#define RB_HALT_SYSTEM 0xcdef0123 78#define RB_HALT_SYSTEM 0xcdef0123
@@ -84,13 +105,12 @@
84#include <sys/time.h> 105#include <sys/time.h>
85#endif 106#endif
86 107
87#ifndef KERNEL_VERSION
88#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 108#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
89#endif
90 109
91#if defined(__GLIBC__) 110#if defined(__GLIBC__)
92#include <sys/kdaemon.h> 111#include <sys/kdaemon.h>
93#else 112#else
113#include <linux/unistd.h> /* for _syscall() macro */
94static _syscall2(int, bdflush, int, func, int, data); 114static _syscall2(int, bdflush, int, func, int, data);
95#endif /* __GLIBC__ */ 115#endif /* __GLIBC__ */
96 116
@@ -568,7 +588,7 @@ static void shutdown_system(void)
568 run_lastAction(); 588 run_lastAction();
569 589
570 sync(); 590 sync();
571 if (kernelVersion > 0 && kernelVersion <= 2 * 65536 + 2 * 256 + 11) { 591 if (kernelVersion > 0 && kernelVersion <= KERNEL_VERSION(2,2,11)) {
572 /* bdflush, kupdate not needed for kernels >2.2.11 */ 592 /* bdflush, kupdate not needed for kernels >2.2.11 */
573 bdflush(1, 0); 593 bdflush(1, 0);
574 sync(); 594 sync();
@@ -587,11 +607,9 @@ static void halt_signal(int sig)
587 /* allow time for last message to reach serial console */ 607 /* allow time for last message to reach serial console */
588 sleep(2); 608 sleep(2);
589 609
590#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) 610 if (sig == SIGUSR2 && kernelVersion >= KERNEL_VERSION(2,2,0))
591 if (sig == SIGUSR2)
592 init_reboot(RB_POWER_OFF); 611 init_reboot(RB_POWER_OFF);
593 else 612 else
594#endif
595 init_reboot(RB_HALT_SYSTEM); 613 init_reboot(RB_HALT_SYSTEM);
596 exit(0); 614 exit(0);
597} 615}
diff --git a/init/init.c b/init/init.c
index 35f2255b5..b368c00ed 100644
--- a/init/init.c
+++ b/init/init.c
@@ -37,12 +37,6 @@
37#include <string.h> 37#include <string.h>
38#include <termios.h> 38#include <termios.h>
39#include <unistd.h> 39#include <unistd.h>
40#include <asm/types.h>
41#include <linux/serial.h> /* for serial_struct */
42#include <linux/version.h>
43#include <linux/reboot.h>
44#include <linux/unistd.h>
45#include <linux/vt.h> /* for vt_stat */
46#include <sys/fcntl.h> 40#include <sys/fcntl.h>
47#include <sys/ioctl.h> 41#include <sys/ioctl.h>
48#include <sys/mount.h> 42#include <sys/mount.h>
@@ -52,6 +46,33 @@
52# include <sys/syslog.h> 46# include <sys/syslog.h>
53#endif 47#endif
54 48
49/* From <linux/vt.h> */
50struct vt_stat {
51 unsigned short v_active; /* active vt */
52 unsigned short v_signal; /* signal to send */
53 unsigned short v_state; /* vt bitmask */
54};
55#define VT_GETSTATE 0x5603 /* get global vt state info */
56
57/* From <linux/serial.h> */
58struct serial_struct {
59 int type;
60 int line;
61 int port;
62 int irq;
63 int flags;
64 int xmit_fifo_size;
65 int custom_divisor;
66 int baud_base;
67 unsigned short close_delay;
68 char reserved_char[2];
69 int hub6;
70 unsigned short closing_wait; /* time to wait before closing */
71 unsigned short closing_wait2; /* no longer used... */
72 int reserved[4];
73};
74
75
55 76
56#ifndef RB_HALT_SYSTEM 77#ifndef RB_HALT_SYSTEM
57#define RB_HALT_SYSTEM 0xcdef0123 78#define RB_HALT_SYSTEM 0xcdef0123
@@ -84,13 +105,12 @@
84#include <sys/time.h> 105#include <sys/time.h>
85#endif 106#endif
86 107
87#ifndef KERNEL_VERSION
88#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 108#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
89#endif
90 109
91#if defined(__GLIBC__) 110#if defined(__GLIBC__)
92#include <sys/kdaemon.h> 111#include <sys/kdaemon.h>
93#else 112#else
113#include <linux/unistd.h> /* for _syscall() macro */
94static _syscall2(int, bdflush, int, func, int, data); 114static _syscall2(int, bdflush, int, func, int, data);
95#endif /* __GLIBC__ */ 115#endif /* __GLIBC__ */
96 116
@@ -568,7 +588,7 @@ static void shutdown_system(void)
568 run_lastAction(); 588 run_lastAction();
569 589
570 sync(); 590 sync();
571 if (kernelVersion > 0 && kernelVersion <= 2 * 65536 + 2 * 256 + 11) { 591 if (kernelVersion > 0 && kernelVersion <= KERNEL_VERSION(2,2,11)) {
572 /* bdflush, kupdate not needed for kernels >2.2.11 */ 592 /* bdflush, kupdate not needed for kernels >2.2.11 */
573 bdflush(1, 0); 593 bdflush(1, 0);
574 sync(); 594 sync();
@@ -587,11 +607,9 @@ static void halt_signal(int sig)
587 /* allow time for last message to reach serial console */ 607 /* allow time for last message to reach serial console */
588 sleep(2); 608 sleep(2);
589 609
590#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) 610 if (sig == SIGUSR2 && kernelVersion >= KERNEL_VERSION(2,2,0))
591 if (sig == SIGUSR2)
592 init_reboot(RB_POWER_OFF); 611 init_reboot(RB_POWER_OFF);
593 else 612 else
594#endif
595 init_reboot(RB_HALT_SYSTEM); 613 init_reboot(RB_HALT_SYSTEM);
596 exit(0); 614 exit(0);
597} 615}
diff --git a/insmod.c b/insmod.c
index 006468877..75058b959 100644
--- a/insmod.c
+++ b/insmod.c
@@ -71,7 +71,7 @@
71#ifndef MODUTILS_MODULE_H 71#ifndef MODUTILS_MODULE_H
72#define MODUTILS_MODULE_H 1 72#define MODUTILS_MODULE_H 1
73 73
74#ident "$Id: insmod.c,v 1.11 2000/06/26 11:16:22 andersen Exp $" 74#ident "$Id: insmod.c,v 1.12 2000/07/08 18:55:24 andersen Exp $"
75 75
76/* This file contains the structures used by the 2.0 and 2.1 kernels. 76/* This file contains the structures used by the 2.0 and 2.1 kernels.
77 We do not use the kernel headers directly because we do not wish 77 We do not use the kernel headers directly because we do not wish
@@ -277,7 +277,7 @@ int delete_module(const char *);
277#ifndef MODUTILS_OBJ_H 277#ifndef MODUTILS_OBJ_H
278#define MODUTILS_OBJ_H 1 278#define MODUTILS_OBJ_H 1
279 279
280#ident "$Id: insmod.c,v 1.11 2000/06/26 11:16:22 andersen Exp $" 280#ident "$Id: insmod.c,v 1.12 2000/07/08 18:55:24 andersen Exp $"
281 281
282/* The relocatable object is manipulated using elfin types. */ 282/* The relocatable object is manipulated using elfin types. */
283 283
@@ -530,6 +530,9 @@ _syscall2(int, new_sys_init_module, const char *, name,
530_syscall5(int, old_sys_init_module, const char *, name, char *, code, 530_syscall5(int, old_sys_init_module, const char *, name, char *, code,
531 unsigned, codesize, struct old_mod_routines *, routines, 531 unsigned, codesize, struct old_mod_routines *, routines,
532 struct old_symbol_table *, symtab) 532 struct old_symbol_table *, symtab)
533#ifndef __NR_query_module
534#define __NR_query_module 167
535#endif
533_syscall5(int, query_module, const char *, name, int, which, 536_syscall5(int, query_module, const char *, name, int, which,
534 void *, buf, size_t, bufsize, size_t*, ret); 537 void *, buf, size_t, bufsize, size_t*, ret);
535#ifndef BB_RMMOD 538#ifndef BB_RMMOD
diff --git a/loadkmap.c b/loadkmap.c
index 905741467..0e8c090d2 100644
--- a/loadkmap.c
+++ b/loadkmap.c
@@ -24,10 +24,20 @@
24#include <errno.h> 24#include <errno.h>
25#include <fcntl.h> 25#include <fcntl.h>
26#include <stdio.h> 26#include <stdio.h>
27#include <linux/kd.h>
28#include <linux/keyboard.h>
29#include <sys/ioctl.h> 27#include <sys/ioctl.h>
30 28
29/* From <linux/kd.h> */
30struct kbentry {
31 unsigned char kb_table;
32 unsigned char kb_index;
33 unsigned short kb_value;
34};
35#define KDSKBENT 0x4B47 /* sets one entry in translation table */
36
37/* From <linux/keyboard.h> */
38#define NR_KEYS 128
39#define MAX_NR_KEYMAPS 256
40
31 41
32static const char loadkmap_usage[] = "loadkmap\n" 42static const char loadkmap_usage[] = "loadkmap\n"
33#ifndef BB_FEATURE_TRIVIAL_HELP 43#ifndef BB_FEATURE_TRIVIAL_HELP
diff --git a/ls.c b/ls.c
index 75fa65421..98ccbeddb 100644
--- a/ls.c
+++ b/ls.c
@@ -49,11 +49,11 @@
49/************************************************************************/ 49/************************************************************************/
50 50
51#include "internal.h" 51#include "internal.h"
52#if !defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) 52//#if !defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
53# include <linux/types.h> 53//# include <linux/types.h>
54#else 54//#else
55# include <sys/types.h> 55# include <sys/types.h>
56#endif 56//#endif
57#include <sys/stat.h> 57#include <sys/stat.h>
58#include <stdio.h> 58#include <stdio.h>
59#include <unistd.h> 59#include <unistd.h>
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 006468877..75058b959 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -71,7 +71,7 @@
71#ifndef MODUTILS_MODULE_H 71#ifndef MODUTILS_MODULE_H
72#define MODUTILS_MODULE_H 1 72#define MODUTILS_MODULE_H 1
73 73
74#ident "$Id: insmod.c,v 1.11 2000/06/26 11:16:22 andersen Exp $" 74#ident "$Id: insmod.c,v 1.12 2000/07/08 18:55:24 andersen Exp $"
75 75
76/* This file contains the structures used by the 2.0 and 2.1 kernels. 76/* This file contains the structures used by the 2.0 and 2.1 kernels.
77 We do not use the kernel headers directly because we do not wish 77 We do not use the kernel headers directly because we do not wish
@@ -277,7 +277,7 @@ int delete_module(const char *);
277#ifndef MODUTILS_OBJ_H 277#ifndef MODUTILS_OBJ_H
278#define MODUTILS_OBJ_H 1 278#define MODUTILS_OBJ_H 1
279 279
280#ident "$Id: insmod.c,v 1.11 2000/06/26 11:16:22 andersen Exp $" 280#ident "$Id: insmod.c,v 1.12 2000/07/08 18:55:24 andersen Exp $"
281 281
282/* The relocatable object is manipulated using elfin types. */ 282/* The relocatable object is manipulated using elfin types. */
283 283
@@ -530,6 +530,9 @@ _syscall2(int, new_sys_init_module, const char *, name,
530_syscall5(int, old_sys_init_module, const char *, name, char *, code, 530_syscall5(int, old_sys_init_module, const char *, name, char *, code,
531 unsigned, codesize, struct old_mod_routines *, routines, 531 unsigned, codesize, struct old_mod_routines *, routines,
532 struct old_symbol_table *, symtab) 532 struct old_symbol_table *, symtab)
533#ifndef __NR_query_module
534#define __NR_query_module 167
535#endif
533_syscall5(int, query_module, const char *, name, int, which, 536_syscall5(int, query_module, const char *, name, int, which,
534 void *, buf, size_t, bufsize, size_t*, ret); 537 void *, buf, size_t, bufsize, size_t*, ret);
535#ifndef BB_RMMOD 538#ifndef BB_RMMOD
diff --git a/mount.c b/mount.c
index 76f048b1c..01e9b3d67 100644
--- a/mount.c
+++ b/mount.c
@@ -48,15 +48,17 @@
48#if defined BB_FEATURE_USE_DEVPS_PATCH 48#if defined BB_FEATURE_USE_DEVPS_PATCH
49#include <linux/devmtab.h> 49#include <linux/devmtab.h>
50#endif 50#endif
51#ifndef MS_RDONLY 51
52#include <linux/fs.h> 52/* 2.0.x. kernels don't know about MS_NODIRATIME */
53#ifndef MS_NODIRATIME
54#define MS_NODIRATIME 2048 /* Do not update directory access times */
53#endif 55#endif
54 56
55 57
58
56#if defined BB_FEATURE_MOUNT_LOOP 59#if defined BB_FEATURE_MOUNT_LOOP
57#include <fcntl.h> 60#include <fcntl.h>
58#include <sys/ioctl.h> 61#include <sys/ioctl.h>
59#include <linux/loop.h>
60 62
61 63
62static int use_loop = FALSE; 64static int use_loop = FALSE;
diff --git a/setkeycodes.c b/setkeycodes.c
index 9062caf75..1bdb909ea 100644
--- a/setkeycodes.c
+++ b/setkeycodes.c
@@ -27,7 +27,14 @@
27#include <stdlib.h> 27#include <stdlib.h>
28#include <fcntl.h> 28#include <fcntl.h>
29#include <sys/ioctl.h> 29#include <sys/ioctl.h>
30#include <linux/kd.h> 30
31
32/* From <linux/kd.h> */
33struct kbkeycode {
34 unsigned int scancode, keycode;
35};
36#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */
37
31 38
32static const char setkeycodes_usage[] = 39static const char setkeycodes_usage[] =
33 "setkeycodes SCANCODE KEYCODE ...\n" 40 "setkeycodes SCANCODE KEYCODE ...\n"
diff --git a/umount.c b/umount.c
index 61f7f9028..d790d68ff 100644
--- a/umount.c
+++ b/umount.c
@@ -26,20 +26,20 @@
26#include <stdio.h> 26#include <stdio.h>
27#include <mntent.h> 27#include <mntent.h>
28#include <errno.h> 28#include <errno.h>
29#include <sys/mount.h>
29#include <linux/unistd.h> 30#include <linux/unistd.h>
30 31
31 32
32//#include <sys/mount.h> 33/* Include our own version of umount2 if we need it... */
33/* Include our own version of sys/mount.h, since libc5 doesn't 34#ifndef __NR_umount2
34 * know about umount2 */ 35#define __NR_umount2 52
35static _syscall1(int, umount, const char *, special_file);
36static _syscall2(int, umount2, const char *, special_file, int, flags);
37static _syscall5(int, mount, const char *, special_file, const char *, dir,
38 const char *, fstype, unsigned long int, rwflag, const void *, data);
39#define MNT_FORCE 1 36#define MNT_FORCE 1
40#define MS_MGC_VAL 0xc0ed0000 /* Magic flag number to indicate "new" flags */ 37#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
41#define MS_REMOUNT 32 /* Alter flags of a mounted FS. */ 38#define MS_REMOUNT 32 /* Alter flags of a mounted FS. */
42#define MS_RDONLY 1 /* Mount read-only. */ 39#define MS_RDONLY 1 /* Mount read-only. */
40
41#endif
42static _syscall2(int, umount2, const char *, special_file, int, flags);
43 43
44 44
45static const char umount_usage[] = 45static const char umount_usage[] =
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index 20846f7c6..e88f549ca 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -16,7 +16,6 @@
16 */ 16 */
17 17
18#include "internal.h" 18#include "internal.h"
19#include <linux/unistd.h>
20#include <stdio.h> 19#include <stdio.h>
21#include <stdlib.h> 20#include <stdlib.h>
22 21
@@ -24,6 +23,7 @@
24 23
25#ifndef __alpha__ 24#ifndef __alpha__
26# define __NR_klogctl __NR_syslog 25# define __NR_klogctl __NR_syslog
26#include <linux/unistd.h>
27static inline _syscall3(int, klogctl, int, type, char *, b, int, len); 27static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
28#else /* __alpha__ */ 28#else /* __alpha__ */
29#define klogctl syslog 29#define klogctl syslog
diff --git a/util-linux/fdflush.c b/util-linux/fdflush.c
index 81f0472c6..d9937355f 100644
--- a/util-linux/fdflush.c
+++ b/util-linux/fdflush.c
@@ -24,9 +24,10 @@
24#include "internal.h" 24#include "internal.h"
25#include <stdio.h> 25#include <stdio.h>
26#include <sys/ioctl.h> 26#include <sys/ioctl.h>
27#include <linux/fd.h>
28#include <fcntl.h> 27#include <fcntl.h>
29 28
29/* From <linux/fd.h> */
30#define FDFLUSH _IO(2,0x4b)
30 31
31extern int fdflush_main(int argc, char **argv) 32extern int fdflush_main(int argc, char **argv)
32{ 33{
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 76f048b1c..01e9b3d67 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -48,15 +48,17 @@
48#if defined BB_FEATURE_USE_DEVPS_PATCH 48#if defined BB_FEATURE_USE_DEVPS_PATCH
49#include <linux/devmtab.h> 49#include <linux/devmtab.h>
50#endif 50#endif
51#ifndef MS_RDONLY 51
52#include <linux/fs.h> 52/* 2.0.x. kernels don't know about MS_NODIRATIME */
53#ifndef MS_NODIRATIME
54#define MS_NODIRATIME 2048 /* Do not update directory access times */
53#endif 55#endif
54 56
55 57
58
56#if defined BB_FEATURE_MOUNT_LOOP 59#if defined BB_FEATURE_MOUNT_LOOP
57#include <fcntl.h> 60#include <fcntl.h>
58#include <sys/ioctl.h> 61#include <sys/ioctl.h>
59#include <linux/loop.h>
60 62
61 63
62static int use_loop = FALSE; 64static int use_loop = FALSE;
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 61f7f9028..d790d68ff 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -26,20 +26,20 @@
26#include <stdio.h> 26#include <stdio.h>
27#include <mntent.h> 27#include <mntent.h>
28#include <errno.h> 28#include <errno.h>
29#include <sys/mount.h>
29#include <linux/unistd.h> 30#include <linux/unistd.h>
30 31
31 32
32//#include <sys/mount.h> 33/* Include our own version of umount2 if we need it... */
33/* Include our own version of sys/mount.h, since libc5 doesn't 34#ifndef __NR_umount2
34 * know about umount2 */ 35#define __NR_umount2 52
35static _syscall1(int, umount, const char *, special_file);
36static _syscall2(int, umount2, const char *, special_file, int, flags);
37static _syscall5(int, mount, const char *, special_file, const char *, dir,
38 const char *, fstype, unsigned long int, rwflag, const void *, data);
39#define MNT_FORCE 1 36#define MNT_FORCE 1
40#define MS_MGC_VAL 0xc0ed0000 /* Magic flag number to indicate "new" flags */ 37#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
41#define MS_REMOUNT 32 /* Alter flags of a mounted FS. */ 38#define MS_REMOUNT 32 /* Alter flags of a mounted FS. */
42#define MS_RDONLY 1 /* Mount read-only. */ 39#define MS_RDONLY 1 /* Mount read-only. */
40
41#endif
42static _syscall2(int, umount2, const char *, special_file, int, flags);
43 43
44 44
45static const char umount_usage[] = 45static const char umount_usage[] =
diff --git a/utility.c b/utility.c
index e1e0f71a5..271b101ec 100644
--- a/utility.c
+++ b/utility.c
@@ -45,14 +45,14 @@
45#include <dirent.h> 45#include <dirent.h>
46#include <time.h> 46#include <time.h>
47#include <utime.h> 47#include <utime.h>
48#include <sys/stat.h>
49#include <unistd.h> 48#include <unistd.h>
50#include <ctype.h> 49#include <ctype.h>
50#include <sys/stat.h>
51#include <sys/ioctl.h>
51#include <sys/utsname.h> /* for uname(2) */ 52#include <sys/utsname.h> /* for uname(2) */
52 53
53#if defined BB_FEATURE_MOUNT_LOOP 54#if defined BB_FEATURE_MOUNT_LOOP
54#include <fcntl.h> 55#include <fcntl.h>
55#include <sys/ioctl.h>
56#include <linux/loop.h> 56#include <linux/loop.h>
57#endif 57#endif
58 58
@@ -904,9 +904,10 @@ unsigned long my_getpwnamegid(char *name)
904 904
905#if (defined BB_CHVT) || (defined BB_DEALLOCVT) || (defined BB_SETKEYCODES) 905#if (defined BB_CHVT) || (defined BB_DEALLOCVT) || (defined BB_SETKEYCODES)
906 906
907 907/* From <linux/kd.h> */
908#include <linux/kd.h> 908#define KDGKBTYPE 0x4B33 /* get keyboard type */
909#include <sys/ioctl.h> 909#define KB_84 0x01
910#define KB_101 0x02 /* this is what we always answer */
910 911
911int is_a_console(int fd) 912int is_a_console(int fd)
912{ 913{