Reworked the source so it will compile and run under glibc 2.0.7

and linux kernel 2.0.36 (though the dubious reasons why someone
would want to do that defy imagination ;)
 -Erik
This commit is contained in:
Erik Andersen 1999-12-17 18:44:15 +00:00
parent 6da0ae8183
commit 4d1d0113fd
19 changed files with 71 additions and 21 deletions

View File

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

View File

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

View 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);

View 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);

View 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.

View 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;

View 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 $ */

View File

@ -27,6 +27,7 @@
#include "internal.h"
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <errno.h>
#include <sys/types.h>

2
dd.c
View 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;

5
du.c
View 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 $ */

View 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.

12
fbset.c
View File

@ -32,9 +32,14 @@
#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;

View 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);

4
gzip.c
View 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);

7
init.c
View 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
@ -49,6 +50,10 @@
#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);

View 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
@ -49,6 +50,10 @@
#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);

1
tail.c
View File

@ -27,6 +27,7 @@
#include "internal.h"
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <errno.h>
#include <sys/types.h>

View File

@ -32,9 +32,14 @@
#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;

View File

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