- single KERNEL_VERSION(a,b,c) macro in platform.h
- rename get_kernel_revision() to get_linux_version_code from Robert P. J. Day
This commit is contained in:
parent
e3c150bc67
commit
e2e56c7c41
@ -833,8 +833,8 @@ static int PRS(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
linux_version_code = get_kernel_revision();
|
linux_version_code = get_linux_version_code();
|
||||||
if (linux_version_code && linux_version_code < (2*65536 + 2*256)) {
|
if (linux_version_code && linux_version_code < KERNEL_VERSION(2,2,0)) {
|
||||||
param.s_rev_level = 0;
|
param.s_rev_level = 0;
|
||||||
param.s_feature_incompat = 0;
|
param.s_feature_incompat = 0;
|
||||||
param.s_feature_compat = 0;
|
param.s_feature_compat = 0;
|
||||||
|
@ -120,7 +120,7 @@ extern long bb_xgetlarg(const char *arg, int base, long lower, long upper);
|
|||||||
extern unsigned long bb_baud_to_value(speed_t speed);
|
extern unsigned long bb_baud_to_value(speed_t speed);
|
||||||
extern speed_t bb_value_to_baud(unsigned long value);
|
extern speed_t bb_value_to_baud(unsigned long value);
|
||||||
|
|
||||||
extern int get_kernel_revision(void);
|
extern int get_linux_version_code(void);
|
||||||
|
|
||||||
extern int get_console_fd(void);
|
extern int get_console_fd(void);
|
||||||
extern struct mntent *find_mount_point(const char *name, const char *table);
|
extern struct mntent *find_mount_point(const char *name, const char *table);
|
||||||
|
@ -91,6 +91,13 @@
|
|||||||
# include <netinet/in.h>
|
# include <netinet/in.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*----- Kernel versioning ------------------------------------*/
|
||||||
|
#ifdef __linux__
|
||||||
|
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
|
||||||
|
#else
|
||||||
|
#error implement KERNEL_VERSION for your platform
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ---- miscellaneous --------------------------------------- */
|
/* ---- miscellaneous --------------------------------------- */
|
||||||
/* NLS stuff */
|
/* NLS stuff */
|
||||||
/* THIS SHOULD BE CLEANED OUT OF THE TREE ENTIRELY */
|
/* THIS SHOULD BE CLEANED OUT OF THE TREE ENTIRELY */
|
||||||
|
@ -26,11 +26,12 @@
|
|||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
|
||||||
/* Returns kernel version encoded as major*65536 + minor*256 + patch,
|
/* Returns current kernel version encoded as major*65536 + minor*256 + patch,
|
||||||
* so, for example, to check if the kernel is greater than 2.2.11:
|
* so, for example, to check if the kernel is greater than 2.2.11:
|
||||||
* if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> }
|
*
|
||||||
|
* if (get_linux_version_code() > KERNEL_VERSION(2,2,11)) { <stuff> }
|
||||||
*/
|
*/
|
||||||
int get_kernel_revision(void)
|
int get_linux_version_code(void)
|
||||||
{
|
{
|
||||||
struct utsname name;
|
struct utsname name;
|
||||||
char *s;
|
char *s;
|
||||||
|
@ -38,7 +38,7 @@ static inline void filename2modname(char *modname, const char *afterslash)
|
|||||||
|
|
||||||
#if ENABLE_FEATURE_2_4_MODULES
|
#if ENABLE_FEATURE_2_4_MODULES
|
||||||
int kr_chk = 1;
|
int kr_chk = 1;
|
||||||
if (get_kernel_revision() <= 2*65536+6*256)
|
if (get_linux_version_code() <= KERNEL_VERSION(2,6,0))
|
||||||
kr_chk = 0;
|
kr_chk = 0;
|
||||||
#else
|
#else
|
||||||
#define kr_chk 1
|
#define kr_chk 1
|
||||||
|
@ -78,7 +78,6 @@
|
|||||||
#define _PATH_PROCNET_DEV "/proc/net/dev"
|
#define _PATH_PROCNET_DEV "/proc/net/dev"
|
||||||
#define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6"
|
#define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6"
|
||||||
#define new(p) ((p) = xcalloc(1,sizeof(*(p))))
|
#define new(p) ((p) = xcalloc(1,sizeof(*(p))))
|
||||||
#define KRELEASE(maj,min,patch) ((maj) * 65536 + (min)*256 + (patch))
|
|
||||||
|
|
||||||
#ifdef HAVE_HWSLIP
|
#ifdef HAVE_HWSLIP
|
||||||
#include <net/if_slip.h>
|
#include <net/if_slip.h>
|
||||||
@ -713,7 +712,7 @@ static int sockets_open(int family)
|
|||||||
|
|
||||||
if (force < 0) {
|
if (force < 0) {
|
||||||
force = 0;
|
force = 0;
|
||||||
if (get_kernel_revision() < KRELEASE(2, 1, 0))
|
if (get_linux_version_code() < KERNEL_VERSION(2,1,0))
|
||||||
force = 1;
|
force = 1;
|
||||||
if (access("/proc/net", R_OK))
|
if (access("/proc/net", R_OK))
|
||||||
force = 1;
|
force = 1;
|
||||||
|
@ -61,14 +61,14 @@ static int check = 0;
|
|||||||
static int badpages = 0;
|
static int badpages = 0;
|
||||||
#if ENABLE_FEATURE_MKSWAP_V0
|
#if ENABLE_FEATURE_MKSWAP_V0
|
||||||
static int version = -1;
|
static int version = -1;
|
||||||
#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
|
|
||||||
#else
|
#else
|
||||||
#define version 1
|
#define version 1
|
||||||
/* and make sure that we optimize away anything which would deal with checking
|
/* and make sure that we optimize away anything which would deal with checking
|
||||||
* the kernel revision as we have v1 support only anyway.
|
* the kernel revision as we have v1 support only anyway.
|
||||||
*/
|
*/
|
||||||
#define MAKE_VERSION(p,q,r) 1
|
#undef KERNEL_VERSION
|
||||||
#define get_kernel_revision() 1
|
#define KERNEL_VERSION(p,q,r) 1
|
||||||
|
#define get_linux_version_code() 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -293,7 +293,7 @@ int mkswap_main(int argc, char **argv)
|
|||||||
if (sz & 4) {
|
if (sz & 4) {
|
||||||
version = bb_xgetlarg(tmp, 10, 0, 1);
|
version = bb_xgetlarg(tmp, 10, 0, 1);
|
||||||
} else {
|
} else {
|
||||||
if (get_kernel_revision() < MAKE_VERSION(2, 1, 117))
|
if (get_linux_version_code() < KERNEL_VERSION(2, 1, 117))
|
||||||
version = 0;
|
version = 0;
|
||||||
else
|
else
|
||||||
version = 1;
|
version = 1;
|
||||||
@ -327,7 +327,7 @@ int mkswap_main(int argc, char **argv)
|
|||||||
#else
|
#else
|
||||||
if (!version)
|
if (!version)
|
||||||
maxpages = V0_MAX_PAGES;
|
maxpages = V0_MAX_PAGES;
|
||||||
else if (get_kernel_revision() >= MAKE_VERSION(2, 2, 1))
|
else if (get_linux_version_code() >= KERNEL_VERSION(2,2,1))
|
||||||
maxpages = V1_MAX_PAGES;
|
maxpages = V1_MAX_PAGES;
|
||||||
else {
|
else {
|
||||||
maxpages = V1_OLD_MAX_PAGES;
|
maxpages = V1_OLD_MAX_PAGES;
|
||||||
|
@ -214,7 +214,6 @@ enum {
|
|||||||
|
|
||||||
static char *nfs_strerror(int status);
|
static char *nfs_strerror(int status);
|
||||||
|
|
||||||
#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
|
|
||||||
#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
|
#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -249,13 +248,13 @@ find_kernel_nfs_mount_version(void)
|
|||||||
|
|
||||||
nfs_mount_version = NFS_MOUNT_VERSION; /* default */
|
nfs_mount_version = NFS_MOUNT_VERSION; /* default */
|
||||||
|
|
||||||
kernel_version = get_kernel_revision();
|
kernel_version = get_linux_version_code();
|
||||||
if (kernel_version) {
|
if (kernel_version) {
|
||||||
if (kernel_version < MAKE_VERSION(2,1,32))
|
if (kernel_version < KERNEL_VERSION(2,1,32))
|
||||||
nfs_mount_version = 1;
|
nfs_mount_version = 1;
|
||||||
else if (kernel_version < MAKE_VERSION(2,2,18) ||
|
else if (kernel_version < KERNEL_VERSION(2,2,18) ||
|
||||||
(kernel_version >= MAKE_VERSION(2,3,0) &&
|
(kernel_version >= KERNEL_VERSION(2,3,0) &&
|
||||||
kernel_version < MAKE_VERSION(2,3,99)))
|
kernel_version < KERNEL_VERSION(2,3,99)))
|
||||||
nfs_mount_version = 3;
|
nfs_mount_version = 3;
|
||||||
else
|
else
|
||||||
nfs_mount_version = 4; /* since 2.3.99pre4 */
|
nfs_mount_version = 4; /* since 2.3.99pre4 */
|
||||||
@ -844,7 +843,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
|
|||||||
* to avoid problems with multihomed hosts.
|
* to avoid problems with multihomed hosts.
|
||||||
* --Swen
|
* --Swen
|
||||||
*/
|
*/
|
||||||
if (get_kernel_revision() <= 66314
|
if (get_linux_version_code() <= KERNEL_VERSION(2,3,10)
|
||||||
&& connect(fsock, (struct sockaddr *) &server_addr,
|
&& connect(fsock, (struct sockaddr *) &server_addr,
|
||||||
sizeof (server_addr)) < 0) {
|
sizeof (server_addr)) < 0) {
|
||||||
perror(_("nfs connect"));
|
perror(_("nfs connect"));
|
||||||
|
Loading…
Reference in New Issue
Block a user