aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-05-19 11:54:02 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-05-19 11:54:02 +0000
commite2e56c7c4129de7d20df42e8239fd304c81ef29b (patch)
tree0f9eb8281fac2f87c79a888dac49b27a1965b366
parente3c150bc67cb158ee854ffb498f0066c79cd842c (diff)
downloadbusybox-w32-e2e56c7c4129de7d20df42e8239fd304c81ef29b.tar.gz
busybox-w32-e2e56c7c4129de7d20df42e8239fd304c81ef29b.tar.bz2
busybox-w32-e2e56c7c4129de7d20df42e8239fd304c81ef29b.zip
- single KERNEL_VERSION(a,b,c) macro in platform.h
- rename get_kernel_revision() to get_linux_version_code from Robert P. J. Day
-rw-r--r--e2fsprogs/mke2fs.c4
-rw-r--r--include/libbb.h2
-rw-r--r--include/platform.h7
-rw-r--r--libbb/kernel_version.c7
-rw-r--r--modutils/rmmod.c2
-rw-r--r--networking/interface.c3
-rw-r--r--util-linux/mkswap.c10
-rw-r--r--util-linux/nfsmount.c13
8 files changed, 27 insertions, 21 deletions
diff --git a/e2fsprogs/mke2fs.c b/e2fsprogs/mke2fs.c
index 787f28ebf..0ecbd0551 100644
--- a/e2fsprogs/mke2fs.c
+++ b/e2fsprogs/mke2fs.c
@@ -833,8 +833,8 @@ static int PRS(int argc, char *argv[])
833#endif 833#endif
834 834
835#ifdef __linux__ 835#ifdef __linux__
836 linux_version_code = get_kernel_revision(); 836 linux_version_code = get_linux_version_code();
837 if (linux_version_code && linux_version_code < (2*65536 + 2*256)) { 837 if (linux_version_code && linux_version_code < KERNEL_VERSION(2,2,0)) {
838 param.s_rev_level = 0; 838 param.s_rev_level = 0;
839 param.s_feature_incompat = 0; 839 param.s_feature_incompat = 0;
840 param.s_feature_compat = 0; 840 param.s_feature_compat = 0;
diff --git a/include/libbb.h b/include/libbb.h
index 02927cd77..461c28fcb 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -120,7 +120,7 @@ extern long bb_xgetlarg(const char *arg, int base, long lower, long upper);
120extern unsigned long bb_baud_to_value(speed_t speed); 120extern unsigned long bb_baud_to_value(speed_t speed);
121extern speed_t bb_value_to_baud(unsigned long value); 121extern speed_t bb_value_to_baud(unsigned long value);
122 122
123extern int get_kernel_revision(void); 123extern int get_linux_version_code(void);
124 124
125extern int get_console_fd(void); 125extern int get_console_fd(void);
126extern struct mntent *find_mount_point(const char *name, const char *table); 126extern struct mntent *find_mount_point(const char *name, const char *table);
diff --git a/include/platform.h b/include/platform.h
index 257ddb260..6b3b3f78e 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -91,6 +91,13 @@
91# include <netinet/in.h> 91# include <netinet/in.h>
92#endif 92#endif
93 93
94/*----- Kernel versioning ------------------------------------*/
95#ifdef __linux__
96#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
97#else
98#error implement KERNEL_VERSION for your platform
99#endif
100
94/* ---- miscellaneous --------------------------------------- */ 101/* ---- miscellaneous --------------------------------------- */
95/* NLS stuff */ 102/* NLS stuff */
96/* THIS SHOULD BE CLEANED OUT OF THE TREE ENTIRELY */ 103/* THIS SHOULD BE CLEANED OUT OF THE TREE ENTIRELY */
diff --git a/libbb/kernel_version.c b/libbb/kernel_version.c
index 5f5d36df2..310da2fa0 100644
--- a/libbb/kernel_version.c
+++ b/libbb/kernel_version.c
@@ -26,11 +26,12 @@
26 26
27#include "libbb.h" 27#include "libbb.h"
28 28
29/* Returns kernel version encoded as major*65536 + minor*256 + patch, 29/* Returns current kernel version encoded as major*65536 + minor*256 + patch,
30 * so, for example, to check if the kernel is greater than 2.2.11: 30 * so, for example, to check if the kernel is greater than 2.2.11:
31 * if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> } 31 *
32 * if (get_linux_version_code() > KERNEL_VERSION(2,2,11)) { <stuff> }
32 */ 33 */
33int get_kernel_revision(void) 34int get_linux_version_code(void)
34{ 35{
35 struct utsname name; 36 struct utsname name;
36 char *s; 37 char *s;
diff --git a/modutils/rmmod.c b/modutils/rmmod.c
index 5302ab222..36bea3486 100644
--- a/modutils/rmmod.c
+++ b/modutils/rmmod.c
@@ -38,7 +38,7 @@ static inline void filename2modname(char *modname, const char *afterslash)
38 38
39#if ENABLE_FEATURE_2_4_MODULES 39#if ENABLE_FEATURE_2_4_MODULES
40 int kr_chk = 1; 40 int kr_chk = 1;
41 if (get_kernel_revision() <= 2*65536+6*256) 41 if (get_linux_version_code() <= KERNEL_VERSION(2,6,0))
42 kr_chk = 0; 42 kr_chk = 0;
43#else 43#else
44#define kr_chk 1 44#define kr_chk 1
diff --git a/networking/interface.c b/networking/interface.c
index eec696fef..878452236 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -78,7 +78,6 @@
78#define _PATH_PROCNET_DEV "/proc/net/dev" 78#define _PATH_PROCNET_DEV "/proc/net/dev"
79#define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6" 79#define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6"
80#define new(p) ((p) = xcalloc(1,sizeof(*(p)))) 80#define new(p) ((p) = xcalloc(1,sizeof(*(p))))
81#define KRELEASE(maj,min,patch) ((maj) * 65536 + (min)*256 + (patch))
82 81
83#ifdef HAVE_HWSLIP 82#ifdef HAVE_HWSLIP
84#include <net/if_slip.h> 83#include <net/if_slip.h>
@@ -713,7 +712,7 @@ static int sockets_open(int family)
713 712
714 if (force < 0) { 713 if (force < 0) {
715 force = 0; 714 force = 0;
716 if (get_kernel_revision() < KRELEASE(2, 1, 0)) 715 if (get_linux_version_code() < KERNEL_VERSION(2,1,0))
717 force = 1; 716 force = 1;
718 if (access("/proc/net", R_OK)) 717 if (access("/proc/net", R_OK))
719 force = 1; 718 force = 1;
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c
index 44d809a36..0054eca24 100644
--- a/util-linux/mkswap.c
+++ b/util-linux/mkswap.c
@@ -61,14 +61,14 @@ static int check = 0;
61static int badpages = 0; 61static int badpages = 0;
62#if ENABLE_FEATURE_MKSWAP_V0 62#if ENABLE_FEATURE_MKSWAP_V0
63static int version = -1; 63static int version = -1;
64#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
65#else 64#else
66#define version 1 65#define version 1
67/* and make sure that we optimize away anything which would deal with checking 66/* and make sure that we optimize away anything which would deal with checking
68 * the kernel revision as we have v1 support only anyway. 67 * the kernel revision as we have v1 support only anyway.
69 */ 68 */
70#define MAKE_VERSION(p,q,r) 1 69#undef KERNEL_VERSION
71#define get_kernel_revision() 1 70#define KERNEL_VERSION(p,q,r) 1
71#define get_linux_version_code() 1
72#endif 72#endif
73 73
74/* 74/*
@@ -293,7 +293,7 @@ int mkswap_main(int argc, char **argv)
293 if (sz & 4) { 293 if (sz & 4) {
294 version = bb_xgetlarg(tmp, 10, 0, 1); 294 version = bb_xgetlarg(tmp, 10, 0, 1);
295 } else { 295 } else {
296 if (get_kernel_revision() < MAKE_VERSION(2, 1, 117)) 296 if (get_linux_version_code() < KERNEL_VERSION(2, 1, 117))
297 version = 0; 297 version = 0;
298 else 298 else
299 version = 1; 299 version = 1;
@@ -327,7 +327,7 @@ int mkswap_main(int argc, char **argv)
327#else 327#else
328 if (!version) 328 if (!version)
329 maxpages = V0_MAX_PAGES; 329 maxpages = V0_MAX_PAGES;
330 else if (get_kernel_revision() >= MAKE_VERSION(2, 2, 1)) 330 else if (get_linux_version_code() >= KERNEL_VERSION(2,2,1))
331 maxpages = V1_MAX_PAGES; 331 maxpages = V1_MAX_PAGES;
332 else { 332 else {
333 maxpages = V1_OLD_MAX_PAGES; 333 maxpages = V1_OLD_MAX_PAGES;
diff --git a/util-linux/nfsmount.c b/util-linux/nfsmount.c
index be0c87f71..7b742cb5f 100644
--- a/util-linux/nfsmount.c
+++ b/util-linux/nfsmount.c
@@ -214,7 +214,6 @@ enum {
214 214
215static char *nfs_strerror(int status); 215static char *nfs_strerror(int status);
216 216
217#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
218#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2) 217#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
219 218
220enum { 219enum {
@@ -249,13 +248,13 @@ find_kernel_nfs_mount_version(void)
249 248
250 nfs_mount_version = NFS_MOUNT_VERSION; /* default */ 249 nfs_mount_version = NFS_MOUNT_VERSION; /* default */
251 250
252 kernel_version = get_kernel_revision(); 251 kernel_version = get_linux_version_code();
253 if (kernel_version) { 252 if (kernel_version) {
254 if (kernel_version < MAKE_VERSION(2,1,32)) 253 if (kernel_version < KERNEL_VERSION(2,1,32))
255 nfs_mount_version = 1; 254 nfs_mount_version = 1;
256 else if (kernel_version < MAKE_VERSION(2,2,18) || 255 else if (kernel_version < KERNEL_VERSION(2,2,18) ||
257 (kernel_version >= MAKE_VERSION(2,3,0) && 256 (kernel_version >= KERNEL_VERSION(2,3,0) &&
258 kernel_version < MAKE_VERSION(2,3,99))) 257 kernel_version < KERNEL_VERSION(2,3,99)))
259 nfs_mount_version = 3; 258 nfs_mount_version = 3;
260 else 259 else
261 nfs_mount_version = 4; /* since 2.3.99pre4 */ 260 nfs_mount_version = 4; /* since 2.3.99pre4 */
@@ -844,7 +843,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
844 * to avoid problems with multihomed hosts. 843 * to avoid problems with multihomed hosts.
845 * --Swen 844 * --Swen
846 */ 845 */
847 if (get_kernel_revision() <= 66314 846 if (get_linux_version_code() <= KERNEL_VERSION(2,3,10)
848 && connect(fsock, (struct sockaddr *) &server_addr, 847 && connect(fsock, (struct sockaddr *) &server_addr,
849 sizeof (server_addr)) < 0) { 848 sizeof (server_addr)) < 0) {
850 perror(_("nfs connect")); 849 perror(_("nfs connect"));