Reworked the source so it will compile and run under glibc 2.0.7
authorErik Andersen <andersen@codepoet.org>
Fri, 17 Dec 1999 18:44:15 +0000 (18:44 -0000)
committerErik Andersen <andersen@codepoet.org>
Fri, 17 Dec 1999 18:44:15 +0000 (18:44 -0000)
and linux kernel 2.0.36 (though the dubious reasons why someone
would want to do that defy imagination ;)
 -Erik

19 files changed:
Changelog
Makefile
archival/gunzip.c
archival/gzip.c
busybox.spec
coreutils/dd.c
coreutils/du.c
coreutils/tail.c
dd.c
du.c
examples/busybox.spec
fbset.c
gunzip.c
gzip.c
init.c
init/init.c
tail.c
util-linux/fbset.c
utility.c

index 5bf8a5f720ba789402774720ee362925c9716ef2..2d2972c9055245d09760463d4552311437b5b003 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,10 +1,12 @@
 0.40
        * Added the -s option to du -beppu
        * Fixed an embarrasing segfault in head -beppu
+       * Fixed an bug in syslogd causing it to stop logging after 20 minutes. -erik
        * New Apps: lsmod, rmmod -erik
        * New Apps: fbset contributed by Randolph Chung <tausq@debian.org>.
-       * Fixed an bug in syslogd causing it to stop logging after 20 minutes. -erik
        * Fixed the embarrasing failure of the -p opition in the logger app. -erik
+       * Re-worked the whole source tree a bit so it will compile under glibc 2.0.7 
+           with the 2.0.x Linux kernel.
 
        -Erik Andersen
 
index 29ee190357eda99990da3bd5f4eaabb2d3b59140..b50c645bc344b5839e0ffbe9bf853320510414a6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@
 
 
 PROG=busybox
-VERSION=0.39
+VERSION=0.40
 BUILDTIME=$(shell date "+%Y%m%d-%H%M")
 
 # Comment out the following to make a debuggable build
@@ -31,8 +31,8 @@ DOSTATIC=false
 #This will choke on a non-debian system
 ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'`
 
-GCCMAJVERSION=`$(CC) --version | sed -n "s/^\([0-9]\)\.\([0-9].*\)[\.].*/\1/p"`
-GCCMINVERSION=`$(CC) --version | sed -n "s/^\([0-9]\)\.\([0-9].*\)[\.].*/\2/p"`
+GCCMAJVERSION=$(shell $(CC) --version | sed -n "s/^\([^\.]*\).*/\1/p" )
+GCCMINVERSION=$(shell $(CC) --version | sed -n "s/^[^\.]*\.\([^\.]*\)[\.].*/\1/p" )
 
 GCCSUPPORTSOPTSIZE=$(shell \
 if ( test $(GCCMAJVERSION) -eq 2 ) ; then \
index a809fed682a7d0bce512a712bd9d526045c45edf..61391a33f79e0f3e9b83b6a2cd4feeaa2d10963f 100644 (file)
@@ -805,7 +805,11 @@ int gunzip_main (int argc, char** argv)
        }
 
        /* Open output fille */
+#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
        outFileNum=open( ofname, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW);
+#else
+       outFileNum=open( ofname, O_RDWR|O_CREAT|O_EXCL);
+#endif
        if (outFileNum < 0) {
            perror(ofname);
            do_exit(WARNING);
index 983f673e15eb7c847b69590de845c3f95d8d95fd..76df3ad9ae1a08d1dac0b9035a13c8d80406413d 100644 (file)
@@ -1877,7 +1877,11 @@ int gzip_main(int argc, char ** argv)
 
 
        /* Open output fille */
+#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
        outFileNum=open( ofname, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW);
+#else
+       outFileNum=open( ofname, O_RDWR|O_CREAT|O_EXCL);
+#endif
        if (outFileNum < 0) {
            perror(ofname);
            do_exit(WARNING);
index 5e9df9d0e649ac2cf68e3c021d73b230860dcd38..a0351a08e873176b52ae7dfc784066223a997566 100644 (file)
@@ -1,5 +1,5 @@
 Name: busybox
-Version: 0.39
+Version: 0.40
 Release: 1
 Group: System/Utilities
 Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
index 90c1004fa28f02bcca9466f0e921fb6a62fafa0d..bc01eedbfaab9e4dfc5df26387ac05ae3dcdc3b9 100644 (file)
@@ -33,7 +33,7 @@
 #include <stdio.h>
 #include <fcntl.h>
 #include <errno.h>
-#if (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)
+#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
 #include <inttypes.h>
 #else
 typedef unsigned long long int uintmax_t;
index ed90bc445dc45b1fa7bea6c45791033a267d5898..ec03afd9589a84ae56ac1367c142518d83cfe728 100644 (file)
@@ -43,9 +43,6 @@ static int    du_depth = 0;
 
 static Display *print;
 
-static void
-print_null(size_t size, char *filename) { }
-
 static void
 print_normal(size_t size, char *filename)
 {
@@ -143,4 +140,4 @@ du_main(int argc, char **argv)
     exit(0);
 }
 
-/* $Id: du.c,v 1.7 1999/12/16 21:16:47 beppu Exp $ */
+/* $Id: du.c,v 1.8 1999/12/17 18:44:15 erik Exp $ */
index 7a64c4ca3734618f2ca7a8de63e424bc82fc3765..697177dc7b611203828f6fc44e91c2b1083d4b05 100644 (file)
@@ -27,6 +27,7 @@
 #include "internal.h"
 
 #include <stdio.h>
+#include <stdarg.h>
 #include <assert.h>
 #include <errno.h>
 #include <sys/types.h>
diff --git a/dd.c b/dd.c
index 90c1004fa28f02bcca9466f0e921fb6a62fafa0d..bc01eedbfaab9e4dfc5df26387ac05ae3dcdc3b9 100644 (file)
--- a/dd.c
+++ b/dd.c
@@ -33,7 +33,7 @@
 #include <stdio.h>
 #include <fcntl.h>
 #include <errno.h>
-#if (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)
+#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
 #include <inttypes.h>
 #else
 typedef unsigned long long int uintmax_t;
diff --git a/du.c b/du.c
index ed90bc445dc45b1fa7bea6c45791033a267d5898..ec03afd9589a84ae56ac1367c142518d83cfe728 100644 (file)
--- a/du.c
+++ b/du.c
@@ -43,9 +43,6 @@ static int    du_depth = 0;
 
 static Display *print;
 
-static void
-print_null(size_t size, char *filename) { }
-
 static void
 print_normal(size_t size, char *filename)
 {
@@ -143,4 +140,4 @@ du_main(int argc, char **argv)
     exit(0);
 }
 
-/* $Id: du.c,v 1.7 1999/12/16 21:16:47 beppu Exp $ */
+/* $Id: du.c,v 1.8 1999/12/17 18:44:15 erik Exp $ */
index 5e9df9d0e649ac2cf68e3c021d73b230860dcd38..a0351a08e873176b52ae7dfc784066223a997566 100644 (file)
@@ -1,5 +1,5 @@
 Name: busybox
-Version: 0.39
+Version: 0.40
 Release: 1
 Group: System/Utilities
 Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
diff --git a/fbset.c b/fbset.c
index 3f7e4552af89f3bc15db94e8b14063f44172d39e..c29145e5148a341ad26d6757da562785d9b084be 100644 (file)
--- a/fbset.c
+++ b/fbset.c
 #include <ctype.h>
 #include <sys/ioctl.h>
 #include <linux/fb.h>
+#include <linux/version.h>
 
 #define PERROR(ctx)   do { perror(ctx); exit(1); } while(0)
 
+#ifndef KERNEL_VERSION
+#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#endif
+
 #define DEFAULTFBDEV  "/dev/fb0"
 #define DEFAULTFBMODE "/etc/fb.modes"
 
@@ -185,10 +190,16 @@ static void showmode(struct fb_var_screeninfo *v)
 #endif
     printf("\tgeometry %u %u %u %u %u\n", v->xres, v->yres, 
            v->xres_virtual, v->yres_virtual, v->bits_per_pixel);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
     printf("\ttimings %u %u %u %u %u %u %u\n", v->pixclock, v->left_margin, 
            v->right_margin, v->upper_margin, v->lower_margin, v->hsync_len,
           v->vsync_len);
     printf("\taccel %s\n", (v->accel_flags > 0 ? "true" : "false"));
+#else
+    printf("\ttimings %lu %lu %lu %lu %lu %lu %lu\n", v->pixclock, v->left_margin, 
+           v->right_margin, v->upper_margin, v->lower_margin, v->hsync_len,
+          v->vsync_len);
+#endif
     printf("\trgba %u/%u,%u/%u,%u/%u,%u/%u\n", v->red.length, v->red.offset,
            v->green.length, v->green.offset, v->blue.length, v->blue.offset,
           v->transp.length, v->transp.offset);
@@ -215,7 +226,6 @@ extern int fbset_main(int argc, char **argv)
 #endif
 {
     struct fb_var_screeninfo var, varset;
-    struct fb_fix_screeninfo fix;
     int fh, i;    
     char *fbdev = DEFAULTFBDEV;
     char *modefile = DEFAULTFBMODE;
index a809fed682a7d0bce512a712bd9d526045c45edf..61391a33f79e0f3e9b83b6a2cd4feeaa2d10963f 100644 (file)
--- a/gunzip.c
+++ b/gunzip.c
@@ -805,7 +805,11 @@ int gunzip_main (int argc, char** argv)
        }
 
        /* Open output fille */
+#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
        outFileNum=open( ofname, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW);
+#else
+       outFileNum=open( ofname, O_RDWR|O_CREAT|O_EXCL);
+#endif
        if (outFileNum < 0) {
            perror(ofname);
            do_exit(WARNING);
diff --git a/gzip.c b/gzip.c
index 983f673e15eb7c847b69590de845c3f95d8d95fd..76df3ad9ae1a08d1dac0b9035a13c8d80406413d 100644 (file)
--- a/gzip.c
+++ b/gzip.c
@@ -1877,7 +1877,11 @@ int gzip_main(int argc, char ** argv)
 
 
        /* Open output fille */
+#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
        outFileNum=open( ofname, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW);
+#else
+       outFileNum=open( ofname, O_RDWR|O_CREAT|O_EXCL);
+#endif
        if (outFileNum < 0) {
            perror(ofname);
            do_exit(WARNING);
diff --git a/init.c b/init.c
index 5203713ca756aba2abfa6d74a7a5e478e543e4ef..ba65f51fd6f2c53e6e56df14519075ca4acb9ddf 100644 (file)
--- a/init.c
+++ b/init.c
@@ -41,6 +41,7 @@
 #include <linux/serial.h>      /* for serial_struct */
 #include <sys/vt.h>            /* for vt_stat */
 #include <sys/ioctl.h>
+#include <linux/version.h>
 #ifdef BB_SYSLOGD
 #include <sys/syslog.h>
 #endif
 #error Sorry, I depend on the /proc filesystem right now.
 #endif
 
+#ifndef KERNEL_VERSION
+#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#endif
+
 
 #define VT_PRIMARY      "/dev/tty1"    /* Primary virtual console */
 #define VT_SECONDARY    "/dev/tty2"    /* Virtual console */
@@ -418,9 +423,11 @@ static void halt_signal(int sig)
            "The system is halted. Press CTRL-ALT-DEL or turn off power\r\n");
     sync();
 #ifndef DEBUG_INIT
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
     if (sig == SIGUSR2)
        reboot(RB_POWER_OFF);
     else
+#endif
        reboot(RB_HALT_SYSTEM);
 #endif
     exit(0);
index 5203713ca756aba2abfa6d74a7a5e478e543e4ef..ba65f51fd6f2c53e6e56df14519075ca4acb9ddf 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/serial.h>      /* for serial_struct */
 #include <sys/vt.h>            /* for vt_stat */
 #include <sys/ioctl.h>
+#include <linux/version.h>
 #ifdef BB_SYSLOGD
 #include <sys/syslog.h>
 #endif
 #error Sorry, I depend on the /proc filesystem right now.
 #endif
 
+#ifndef KERNEL_VERSION
+#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#endif
+
 
 #define VT_PRIMARY      "/dev/tty1"    /* Primary virtual console */
 #define VT_SECONDARY    "/dev/tty2"    /* Virtual console */
@@ -418,9 +423,11 @@ static void halt_signal(int sig)
            "The system is halted. Press CTRL-ALT-DEL or turn off power\r\n");
     sync();
 #ifndef DEBUG_INIT
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
     if (sig == SIGUSR2)
        reboot(RB_POWER_OFF);
     else
+#endif
        reboot(RB_HALT_SYSTEM);
 #endif
     exit(0);
diff --git a/tail.c b/tail.c
index 7a64c4ca3734618f2ca7a8de63e424bc82fc3765..697177dc7b611203828f6fc44e91c2b1083d4b05 100644 (file)
--- a/tail.c
+++ b/tail.c
@@ -27,6 +27,7 @@
 #include "internal.h"
 
 #include <stdio.h>
+#include <stdarg.h>
 #include <assert.h>
 #include <errno.h>
 #include <sys/types.h>
index 3f7e4552af89f3bc15db94e8b14063f44172d39e..c29145e5148a341ad26d6757da562785d9b084be 100644 (file)
 #include <ctype.h>
 #include <sys/ioctl.h>
 #include <linux/fb.h>
+#include <linux/version.h>
 
 #define PERROR(ctx)   do { perror(ctx); exit(1); } while(0)
 
+#ifndef KERNEL_VERSION
+#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#endif
+
 #define DEFAULTFBDEV  "/dev/fb0"
 #define DEFAULTFBMODE "/etc/fb.modes"
 
@@ -185,10 +190,16 @@ static void showmode(struct fb_var_screeninfo *v)
 #endif
     printf("\tgeometry %u %u %u %u %u\n", v->xres, v->yres, 
            v->xres_virtual, v->yres_virtual, v->bits_per_pixel);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
     printf("\ttimings %u %u %u %u %u %u %u\n", v->pixclock, v->left_margin, 
            v->right_margin, v->upper_margin, v->lower_margin, v->hsync_len,
           v->vsync_len);
     printf("\taccel %s\n", (v->accel_flags > 0 ? "true" : "false"));
+#else
+    printf("\ttimings %lu %lu %lu %lu %lu %lu %lu\n", v->pixclock, v->left_margin, 
+           v->right_margin, v->upper_margin, v->lower_margin, v->hsync_len,
+          v->vsync_len);
+#endif
     printf("\trgba %u/%u,%u/%u,%u/%u,%u/%u\n", v->red.length, v->red.offset,
            v->green.length, v->green.offset, v->blue.length, v->blue.offset,
           v->transp.length, v->transp.offset);
@@ -215,7 +226,6 @@ extern int fbset_main(int argc, char **argv)
 #endif
 {
     struct fb_var_screeninfo var, varset;
-    struct fb_fix_screeninfo fix;
     int fh, i;    
     char *fbdev = DEFAULTFBDEV;
     char *modefile = DEFAULTFBMODE;
index 74df632b9a7cf1ce9c71ad1b00ab55e9c60adf9a..e5c177ad5d2f9c398ac0dca38736597168b3c3e7 100644 (file)
--- a/utility.c
+++ b/utility.c
@@ -217,10 +217,12 @@ copyFile( const char *srcName, const char *destName,
     if (setModes == TRUE) {
        //fprintf(stderr, "Setting permissions for %s\n", destName);
        chmod(destName, srcStatBuf.st_mode);
-       if (followLinks == TRUE)
-           chown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
-       else
+#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
+       if (followLinks == FALSE)
            lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
+       else
+#endif
+           chown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
 
        times.actime = srcStatBuf.st_atime;
        times.modtime = srcStatBuf.st_mtime;