A number of cleanups. Now compiles with libc5, glibc, and uClibc. Fix a few

shadowed variables.  Move (almost) all syscalls to libbb/syscalls.c, so I can
handle them sanely and all at once.
 -Erik
This commit is contained in:
Eric Andersen 2001-04-05 03:14:39 +00:00
parent 3c0364f391
commit e76c3b08e1
33 changed files with 168 additions and 204 deletions

View File

@ -44,7 +44,14 @@
#include <sys/types.h> #include <sys/types.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#if __GNU_LIBRARY__ < 5
#include <sys/timex.h> #include <sys/timex.h>
extern int adjtimex(struct timex *buf);
#else
#include <sys/timex.h>
#endif
#ifdef BB_VER #ifdef BB_VER
#include "busybox.h" #include "busybox.h"
#endif #endif
@ -163,7 +170,7 @@ int main(int argc, char ** argv)
" return value: %d (%s)\n", " return value: %d (%s)\n",
txc.constant, txc.constant,
txc.precision, txc.tolerance, txc.tick, txc.precision, txc.tolerance, txc.tick,
txc.time.tv_sec, txc.time.tv_usec, ret, descript); (long)txc.time.tv_sec, (long)txc.time.tv_usec, ret, descript);
} }
return (ret<0); return (ret<0);
} }

View File

@ -12,14 +12,6 @@
#include "busybox.h" #include "busybox.h"
/* Stupid libc doesn't have a reliable way for use to know
* that libc5 is being used. Assume this is good enough */
#if !defined __GLIBC__ && !defined __UCLIBC__
#error It looks like you are using libc5, which does not support
#error tfind(). tfind() is used by busybox dpkg.
#error Please disable BB_DPKG. Sorry.
#endif
#define DEPENDSMAX 64 /* maximum number of depends we can handle */ #define DEPENDSMAX 64 /* maximum number of depends we can handle */
/* Should we do full dependency checking? */ /* Should we do full dependency checking? */
@ -591,6 +583,7 @@ static int dpkg_dounpack(package_t *pkg)
char *adminscripts[] = { "/prerm", "/postrm", "/preinst", "/postinst", char *adminscripts[] = { "/prerm", "/postrm", "/preinst", "/postinst",
"/conffiles", "/md5sums", "/shlibs", "/templates" }; "/conffiles", "/md5sums", "/shlibs", "/templates" };
char buf[1024], buf2[1024]; char buf[1024], buf2[1024];
FILE *myfile = stdout;
DPRINTF("Unpacking %s\n", pkg->package); DPRINTF("Unpacking %s\n", pkg->package);
@ -622,9 +615,9 @@ static int dpkg_dounpack(package_t *pkg)
strcpy(lst_file, infodir); strcpy(lst_file, infodir);
strcat(lst_file, pkg->package); strcat(lst_file, pkg->package);
strcat(lst_file, ".list"); strcat(lst_file, ".list");
outfp = freopen(lst_file, "w", stdout); outfp = freopen(lst_file, "w", myfile);
deb_extract(dpkg_deb_list, NULL, pkg->file); deb_extract(dpkg_deb_list, NULL, pkg->file);
stdout = freopen(NULL, "w", outfp); myfile = freopen(NULL, "w", outfp);
printf("done\n"); printf("done\n");
getchar(); getchar();

View File

@ -151,8 +151,8 @@ int dd_main(int argc, char **argv)
out_part++; out_part++;
} }
fprintf(statusfp, "%d+%d records in\n", in_full, in_part); fprintf(statusfp, "%ld+%ld records in\n", (long)in_full, (long)in_part);
fprintf(statusfp, "%d+%d records out\n", out_full, out_part); fprintf(statusfp, "%ld+%ld records out\n", (long)out_full, (long)out_part);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -626,7 +626,7 @@ static int list_single(struct dnode *dn)
column += 10; column += 10;
break; break;
case LIST_NLINKS: case LIST_NLINKS:
printf("%4d ", dn->dstat.st_nlink); printf("%4ld ", (long)dn->dstat.st_nlink);
column += 10; column += 10;
break; break;
case LIST_ID_NAME: case LIST_ID_NAME:

4
dd.c
View File

@ -151,8 +151,8 @@ int dd_main(int argc, char **argv)
out_part++; out_part++;
} }
fprintf(statusfp, "%d+%d records in\n", in_full, in_part); fprintf(statusfp, "%ld+%ld records in\n", (long)in_full, (long)in_part);
fprintf(statusfp, "%d+%d records out\n", out_full, out_part); fprintf(statusfp, "%ld+%ld records out\n", (long)out_full, (long)out_part);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -20,18 +20,13 @@
#include <getopt.h> #include <getopt.h>
#if __GNU_LIBRARY__ < 5 #if __GNU_LIBRARY__ < 5
#include <sys/syscall.h> # ifdef __alpha__
#include <linux/unistd.h>
#ifndef __alpha__
# define __NR_klogctl __NR_syslog
static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
#else /* __alpha__ */
# define klogctl syslog # define klogctl syslog
# endif # endif
#else #else
# include <sys/klog.h> # include <sys/klog.h>
#endif #endif
#include "busybox.h" #include "busybox.h"
int dmesg_main(int argc, char **argv) int dmesg_main(int argc, char **argv)

13
dpkg.c
View File

@ -12,14 +12,6 @@
#include "busybox.h" #include "busybox.h"
/* Stupid libc doesn't have a reliable way for use to know
* that libc5 is being used. Assume this is good enough */
#if !defined __GLIBC__ && !defined __UCLIBC__
#error It looks like you are using libc5, which does not support
#error tfind(). tfind() is used by busybox dpkg.
#error Please disable BB_DPKG. Sorry.
#endif
#define DEPENDSMAX 64 /* maximum number of depends we can handle */ #define DEPENDSMAX 64 /* maximum number of depends we can handle */
/* Should we do full dependency checking? */ /* Should we do full dependency checking? */
@ -591,6 +583,7 @@ static int dpkg_dounpack(package_t *pkg)
char *adminscripts[] = { "/prerm", "/postrm", "/preinst", "/postinst", char *adminscripts[] = { "/prerm", "/postrm", "/preinst", "/postinst",
"/conffiles", "/md5sums", "/shlibs", "/templates" }; "/conffiles", "/md5sums", "/shlibs", "/templates" };
char buf[1024], buf2[1024]; char buf[1024], buf2[1024];
FILE *myfile = stdout;
DPRINTF("Unpacking %s\n", pkg->package); DPRINTF("Unpacking %s\n", pkg->package);
@ -622,9 +615,9 @@ static int dpkg_dounpack(package_t *pkg)
strcpy(lst_file, infodir); strcpy(lst_file, infodir);
strcat(lst_file, pkg->package); strcat(lst_file, pkg->package);
strcat(lst_file, ".list"); strcat(lst_file, ".list");
outfp = freopen(lst_file, "w", stdout); outfp = freopen(lst_file, "w", myfile);
deb_extract(dpkg_deb_list, NULL, pkg->file); deb_extract(dpkg_deb_list, NULL, pkg->file);
stdout = freopen(NULL, "w", outfp); myfile = freopen(NULL, "w", outfp);
printf("done\n"); printf("done\n");
getchar(); getchar();

View File

@ -211,5 +211,6 @@ enum {
}; };
int ask_confirmation(void); int ask_confirmation(void);
int klogctl(int type, char * b, int len);
#endif /* __LIBBB_H__ */ #endif /* __LIBBB_H__ */

4
init.c
View File

@ -115,9 +115,7 @@ static const int RB_AUTOBOOT = 0x01234567;
#if defined(__GLIBC__) #if defined(__GLIBC__)
#include <sys/kdaemon.h> #include <sys/kdaemon.h>
#else #else
#include <sys/syscall.h> extern int bdflush (int func, long int data);
#include <linux/unistd.h>
static _syscall2(int, bdflush, int, func, int, data);
#endif /* __GLIBC__ */ #endif /* __GLIBC__ */

View File

@ -115,9 +115,7 @@ static const int RB_AUTOBOOT = 0x01234567;
#if defined(__GLIBC__) #if defined(__GLIBC__)
#include <sys/kdaemon.h> #include <sys/kdaemon.h>
#else #else
#include <sys/syscall.h> extern int bdflush (int func, long int data);
#include <linux/unistd.h>
static _syscall2(int, bdflush, int, func, int, data);
#endif /* __GLIBC__ */ #endif /* __GLIBC__ */

View File

@ -119,7 +119,7 @@
#ifndef MODUTILS_MODULE_H #ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1; static const int MODUTILS_MODULE_H = 1;
#ident "$Id: insmod.c,v 1.53 2001/03/22 19:01:16 andersen Exp $" #ident "$Id: insmod.c,v 1.54 2001/04/05 03:14:39 andersen Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels. /* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish We do not use the kernel headers directly because we do not wish
@ -325,7 +325,7 @@ int delete_module(const char *);
#ifndef MODUTILS_OBJ_H #ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1; static const int MODUTILS_OBJ_H = 1;
#ident "$Id: insmod.c,v 1.53 2001/03/22 19:01:16 andersen Exp $" #ident "$Id: insmod.c,v 1.54 2001/04/05 03:14:39 andersen Exp $"
/* The relocatable object is manipulated using elfin types. */ /* The relocatable object is manipulated using elfin types. */
@ -1210,18 +1210,18 @@ int arch_create_got(struct obj_file *f)
#if defined(BB_USE_GOT_ENTRIES) #if defined(BB_USE_GOT_ENTRIES)
if (got_offset) { if (got_offset) {
struct obj_section* relsec = obj_find_section(f, ".got"); struct obj_section* myrelsec = obj_find_section(f, ".got");
if (relsec) { if (myrelsec) {
obj_extend_section(relsec, got_offset); obj_extend_section(myrelsec, got_offset);
} else { } else {
relsec = obj_create_alloced_section(f, ".got", myrelsec = obj_create_alloced_section(f, ".got",
BB_GOT_ENTRY_SIZE, BB_GOT_ENTRY_SIZE,
got_offset); got_offset);
assert(relsec); assert(myrelsec);
} }
ifile->got = relsec; ifile->got = myrelsec;
} }
#endif #endif
@ -1748,19 +1748,19 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv)
while (*q++ == ','); while (*q++ == ',');
} else { } else {
char *contents = f->sections[sym->secidx]->contents; char *contents = f->sections[sym->secidx]->contents;
char *loc = contents + sym->value; char *myloc = contents + sym->value;
char *r; /* To search for commas */ char *r; /* To search for commas */
/* Break the string with comas */ /* Break the string with comas */
while ((r = strchr(q, ',')) != (char *) NULL) { while ((r = strchr(q, ',')) != (char *) NULL) {
*r++ = '\0'; *r++ = '\0';
obj_string_patch(f, sym->secidx, loc - contents, q); obj_string_patch(f, sym->secidx, myloc - contents, q);
loc += sizeof(char *); myloc += sizeof(char *);
q = r; q = r;
} }
/* last part */ /* last part */
obj_string_patch(f, sym->secidx, loc - contents, q); obj_string_patch(f, sym->secidx, myloc - contents, q);
} }
argc--, argv++; argc--, argv++;

12
klogd.c
View File

@ -40,20 +40,14 @@
#include <ctype.h> #include <ctype.h>
#include <sys/syslog.h> #include <sys/syslog.h>
#if ! defined __GLIBC__ && ! defined __UCLIBC__ #if __GNU_LIBRARY__ < 5
#include <sys/syscall.h> # ifdef __alpha__
#include <linux/unistd.h>
#ifndef __alpha__
# define __NR_klogctl __NR_syslog
static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
#else /* __alpha__ */
# define klogctl syslog # define klogctl syslog
# endif # endif
#else #else
# include <sys/klog.h> # include <sys/klog.h>
#endif #endif
#include "busybox.h" #include "busybox.h"
static void klogd_signal(int sig) static void klogd_signal(int sig)

View File

@ -211,5 +211,6 @@ enum {
}; };
int ask_confirmation(void); int ask_confirmation(void);
int klogctl(int type, char * b, int len);
#endif /* __LIBBB_H__ */ #endif /* __LIBBB_H__ */

View File

@ -32,18 +32,63 @@
#include "libbb.h" #include "libbb.h"
_syscall3(int, sysfs, int, option, unsigned int, fs_index, char *, buf);
_syscall1(int, sysinfo, struct sysinfo *, info); #ifndef __NR_pivot_root
#warning This kernel does not support the pivot_root syscall
#warning -> The pivot_root system call is being stubbed out...
int pivot_root(const char * new_root,const char * put_old)
{
/* BusyBox was compiled against a kernel that did not support
* the pivot_root system call. To make this application work,
* you will need to recompile with a kernel supporting the
* pivot_root system call.
*/
fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
fprintf(stderr, "with a kernel supporting the pivot_root system call. -Erik\n\n");
errno=ENOSYS;
return -1;
}
#else
_syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
#endif
/* Include our own version of <sys/mount.h>, since libc5 doesn't
* know about umount2 */
extern _syscall1(int, umount, const char *, special_file);
extern _syscall5(int, mount, const char *, special_file, const char *, dir, #if __GNU_LIBRARY__ < 5
const char *, fstype, unsigned long int, rwflag, const void *, data); /* These syscalls are not included as part of libc5 */
_syscall2(int, bdflush, int, func, int, data);
_syscall1(int, delete_module, const char *, name)
#ifndef __NR_query_module
#warning This kernel does not support the query_module syscall
#warning -> The query_module system call is being stubbed out...
int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret)
{
/* BusyBox was compiled against a kernel that did not support
* the query_module system call. To make this application work,
* you will need to recompile with a kernel supporting the
* query_module system call.
*/
fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
fprintf(stderr, "with a kernel supporting the query_module system call. -Erik\n\n");
errno=ENOSYS;
return -1;
}
#else
_syscall5(int, query_module, const char *, name, int, which,
void *, buf, size_t, bufsize, size_t*, ret);
#endif
#ifndef __alpha__
# define __NR_klogctl __NR_syslog
_syscall3(int, klogctl, int, type, char *, b, int, len);
#endif
#ifndef __NR_umount2 #ifndef __NR_umount2
# warning This kernel does not support the umount2 syscall # warning This kernel does not support the umount2 syscall
# warning The umount2 system call is being stubbed out... # warning -> The umount2 system call is being stubbed out...
int umount2(const char * special_file, int flags) int umount2(const char * special_file, int flags)
{ {
/* BusyBox was compiled against a kernel that did not support /* BusyBox was compiled against a kernel that did not support
@ -57,14 +102,17 @@ int umount2(const char * special_file, int flags)
return -1; return -1;
} }
# else # else
extern _syscall2(int, umount2, const char *, special_file, int, flags); _syscall2(int, umount2, const char *, special_file, int, flags);
#endif #endif
#ifndef __NR_query_module
static const int __NR_query_module = 167; #endif /* __GNU_LIBRARY__ < 5 */
#if 0
_syscall1(int, sysinfo, struct sysinfo *, info);
#endif #endif
_syscall5(int, query_module, const char *, name, int, which,
void *, buf, size_t, bufsize, size_t*, ret);
/* END CODE */ /* END CODE */
/* /*

2
ls.c
View File

@ -626,7 +626,7 @@ static int list_single(struct dnode *dn)
column += 10; column += 10;
break; break;
case LIST_NLINKS: case LIST_NLINKS:
printf("%4d ", dn->dstat.st_nlink); printf("%4ld ", (long)dn->dstat.st_nlink);
column += 10; column += 10;
break; break;
case LIST_ID_NAME: case LIST_ID_NAME:

View File

@ -52,8 +52,7 @@ struct module_info
}; };
int query_module(const char *name, int which, void *buf, size_t bufsize, int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret);
size_t *ret);
/* Values for query_module's which. */ /* Values for query_module's which. */
static const int QM_MODULES = 1; static const int QM_MODULES = 1;

View File

@ -44,7 +44,14 @@
#include <sys/types.h> #include <sys/types.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#if __GNU_LIBRARY__ < 5
#include <sys/timex.h> #include <sys/timex.h>
extern int adjtimex(struct timex *buf);
#else
#include <sys/timex.h>
#endif
#ifdef BB_VER #ifdef BB_VER
#include "busybox.h" #include "busybox.h"
#endif #endif
@ -163,7 +170,7 @@ int main(int argc, char ** argv)
" return value: %d (%s)\n", " return value: %d (%s)\n",
txc.constant, txc.constant,
txc.precision, txc.tolerance, txc.tick, txc.precision, txc.tolerance, txc.tick,
txc.time.tv_sec, txc.time.tv_usec, ret, descript); (long)txc.time.tv_sec, (long)txc.time.tv_usec, ret, descript);
} }
return (ret<0); return (ret<0);
} }

View File

@ -33,14 +33,12 @@
#include <unistd.h> /* for getopt() */ #include <unistd.h> /* for getopt() */
#include <stdlib.h> #include <stdlib.h>
#if defined(__GLIBC__) #if defined(__GLIBC__)
#include <sys/kdaemon.h> #include <sys/kdaemon.h>
#else #else
#include <sys/syscall.h> extern int bdflush (int func, long int data);
#include <linux/unistd.h>
static _syscall2(int, bdflush, int, func, int, data);
#endif /* __GLIBC__ */ #endif /* __GLIBC__ */
#include "busybox.h" #include "busybox.h"
static unsigned int sync_duration = 30; static unsigned int sync_duration = 30;

View File

@ -119,7 +119,7 @@
#ifndef MODUTILS_MODULE_H #ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1; static const int MODUTILS_MODULE_H = 1;
#ident "$Id: insmod.c,v 1.53 2001/03/22 19:01:16 andersen Exp $" #ident "$Id: insmod.c,v 1.54 2001/04/05 03:14:39 andersen Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels. /* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish We do not use the kernel headers directly because we do not wish
@ -325,7 +325,7 @@ int delete_module(const char *);
#ifndef MODUTILS_OBJ_H #ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1; static const int MODUTILS_OBJ_H = 1;
#ident "$Id: insmod.c,v 1.53 2001/03/22 19:01:16 andersen Exp $" #ident "$Id: insmod.c,v 1.54 2001/04/05 03:14:39 andersen Exp $"
/* The relocatable object is manipulated using elfin types. */ /* The relocatable object is manipulated using elfin types. */
@ -1210,18 +1210,18 @@ int arch_create_got(struct obj_file *f)
#if defined(BB_USE_GOT_ENTRIES) #if defined(BB_USE_GOT_ENTRIES)
if (got_offset) { if (got_offset) {
struct obj_section* relsec = obj_find_section(f, ".got"); struct obj_section* myrelsec = obj_find_section(f, ".got");
if (relsec) { if (myrelsec) {
obj_extend_section(relsec, got_offset); obj_extend_section(myrelsec, got_offset);
} else { } else {
relsec = obj_create_alloced_section(f, ".got", myrelsec = obj_create_alloced_section(f, ".got",
BB_GOT_ENTRY_SIZE, BB_GOT_ENTRY_SIZE,
got_offset); got_offset);
assert(relsec); assert(myrelsec);
} }
ifile->got = relsec; ifile->got = myrelsec;
} }
#endif #endif
@ -1748,19 +1748,19 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv)
while (*q++ == ','); while (*q++ == ',');
} else { } else {
char *contents = f->sections[sym->secidx]->contents; char *contents = f->sections[sym->secidx]->contents;
char *loc = contents + sym->value; char *myloc = contents + sym->value;
char *r; /* To search for commas */ char *r; /* To search for commas */
/* Break the string with comas */ /* Break the string with comas */
while ((r = strchr(q, ',')) != (char *) NULL) { while ((r = strchr(q, ',')) != (char *) NULL) {
*r++ = '\0'; *r++ = '\0';
obj_string_patch(f, sym->secidx, loc - contents, q); obj_string_patch(f, sym->secidx, myloc - contents, q);
loc += sizeof(char *); myloc += sizeof(char *);
q = r; q = r;
} }
/* last part */ /* last part */
obj_string_patch(f, sym->secidx, loc - contents, q); obj_string_patch(f, sym->secidx, myloc - contents, q);
} }
argc--, argv++; argc--, argv++;

View File

@ -52,8 +52,7 @@ struct module_info
}; };
int query_module(const char *name, int which, void *buf, size_t bufsize, int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret);
size_t *ret);
/* Values for query_module's which. */ /* Values for query_module's which. */
static const int QM_MODULES = 1; static const int QM_MODULES = 1;

View File

@ -26,16 +26,11 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <getopt.h> #include <getopt.h>
#include <sys/syscall.h>
#include <linux/unistd.h>
#include "busybox.h" #include "busybox.h"
#define __LIBRARY__
extern int delete_module(const char * name);
/* And the system call of the day is... */
_syscall1(int, delete_module, const char *, name)
extern int rmmod_main(int argc, char **argv) extern int rmmod_main(int argc, char **argv)
{ {
int n, ret = EXIT_SUCCESS; int n, ret = EXIT_SUCCESS;

View File

@ -84,11 +84,7 @@ extern int mount (__const char *__special_file, __const char *__dir,
extern int umount (__const char *__special_file); extern int umount (__const char *__special_file);
extern int umount2 (__const char *__special_file, int __flags); extern int umount2 (__const char *__special_file, int __flags);
#include <sys/syscall.h> extern int sysfs( int option, unsigned int fs_index, char * buf);
#include <linux/unistd.h>
static int sysfs( int option, unsigned int fs_index, char * buf);
_syscall3(int, sysfs, int, option, unsigned int, fs_index, char *, buf);
extern const char mtab_file[]; /* Defined in utility.c */ extern const char mtab_file[]; /* Defined in utility.c */

View File

@ -116,7 +116,7 @@ static inline int tftp(int cmd, struct hostent *host,
len = sizeof(sa); len = sizeof(sa);
memset(&sa, 0, len); memset(&sa, 0, len);
bind(socketfd, &sa, len); bind(socketfd, (struct sockaddr *)&sa, len);
sa.sin_family = host->h_addrtype; sa.sin_family = host->h_addrtype;
sa.sin_port = htons(port); sa.sin_port = htons(port);

View File

@ -9,30 +9,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <sys/syscall.h>
#include <linux/unistd.h>
#include "busybox.h" #include "busybox.h"
#ifndef __NR_pivot_root extern int pivot_root(const char * new_root,const char * put_old);
#warning This kernel does not support the pivot_root syscall
#warning The pivot_root system call is being stubbed out...
int pivot_root(const char * new_root,const char * put_old)
{
/* BusyBox was compiled against a kernel that did not support
* the pivot_root system call. To make this application work,
* you will need to recompile with a kernel supporting the
* pivot_root system call.
*/
fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
fprintf(stderr, "with a kernel supporting the pivot_root system call. -Erik\n\n");
errno=ENOSYS;
return -1;
}
#else
static _syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
#endif
int pivot_root_main(int argc, char **argv) int pivot_root_main(int argc, char **argv)
{ {

View File

@ -26,16 +26,11 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <getopt.h> #include <getopt.h>
#include <sys/syscall.h>
#include <linux/unistd.h>
#include "busybox.h" #include "busybox.h"
#define __LIBRARY__
extern int delete_module(const char * name);
/* And the system call of the day is... */
_syscall1(int, delete_module, const char *, name)
extern int rmmod_main(int argc, char **argv) extern int rmmod_main(int argc, char **argv)
{ {
int n, ret = EXIT_SUCCESS; int n, ret = EXIT_SUCCESS;

View File

@ -29,14 +29,17 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/syscall.h>
#include <linux/unistd.h> #if __GNU_LIBRARY__ < 5
/* libc5 doesn't have sys/swap.h, define these here. */
extern int swapon (__const char *__path, int __flags);
extern int swapoff (__const char *__path);
#else
#include <sys/swap.h>
#endif
#include "busybox.h" #include "busybox.h"
static _syscall2(int, swapon, const char *, path, int, flags);
static _syscall1(int, swapoff, const char *, path);
static int whichApp; static int whichApp;
static const int SWAPON_APP = 1; static const int SWAPON_APP = 1;

View File

@ -40,20 +40,14 @@
#include <ctype.h> #include <ctype.h>
#include <sys/syslog.h> #include <sys/syslog.h>
#if ! defined __GLIBC__ && ! defined __UCLIBC__ #if __GNU_LIBRARY__ < 5
#include <sys/syscall.h> # ifdef __alpha__
#include <linux/unistd.h>
#ifndef __alpha__
# define __NR_klogctl __NR_syslog
static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
#else /* __alpha__ */
# define klogctl syslog # define klogctl syslog
# endif # endif
#else #else
# include <sys/klog.h> # include <sys/klog.h>
#endif #endif
#include "busybox.h" #include "busybox.h"
static void klogd_signal(int sig) static void klogd_signal(int sig)

2
tftp.c
View File

@ -116,7 +116,7 @@ static inline int tftp(int cmd, struct hostent *host,
len = sizeof(sa); len = sizeof(sa);
memset(&sa, 0, len); memset(&sa, 0, len);
bind(socketfd, &sa, len); bind(socketfd, (struct sockaddr *)&sa, len);
sa.sin_family = host->h_addrtype; sa.sin_family = host->h_addrtype;
sa.sin_port = htons(port); sa.sin_port = htons(port);

View File

@ -33,14 +33,12 @@
#include <unistd.h> /* for getopt() */ #include <unistd.h> /* for getopt() */
#include <stdlib.h> #include <stdlib.h>
#if defined(__GLIBC__) #if defined(__GLIBC__)
#include <sys/kdaemon.h> #include <sys/kdaemon.h>
#else #else
#include <sys/syscall.h> extern int bdflush (int func, long int data);
#include <linux/unistd.h>
static _syscall2(int, bdflush, int, func, int, data);
#endif /* __GLIBC__ */ #endif /* __GLIBC__ */
#include "busybox.h" #include "busybox.h"
static unsigned int sync_duration = 30; static unsigned int sync_duration = 30;

View File

@ -20,18 +20,13 @@
#include <getopt.h> #include <getopt.h>
#if __GNU_LIBRARY__ < 5 #if __GNU_LIBRARY__ < 5
#include <sys/syscall.h> # ifdef __alpha__
#include <linux/unistd.h>
#ifndef __alpha__
# define __NR_klogctl __NR_syslog
static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
#else /* __alpha__ */
# define klogctl syslog # define klogctl syslog
# endif # endif
#else #else
# include <sys/klog.h> # include <sys/klog.h>
#endif #endif
#include "busybox.h" #include "busybox.h"
int dmesg_main(int argc, char **argv) int dmesg_main(int argc, char **argv)

View File

@ -84,11 +84,7 @@ extern int mount (__const char *__special_file, __const char *__dir,
extern int umount (__const char *__special_file); extern int umount (__const char *__special_file);
extern int umount2 (__const char *__special_file, int __flags); extern int umount2 (__const char *__special_file, int __flags);
#include <sys/syscall.h> extern int sysfs( int option, unsigned int fs_index, char * buf);
#include <linux/unistd.h>
static int sysfs( int option, unsigned int fs_index, char * buf);
_syscall3(int, sysfs, int, option, unsigned int, fs_index, char *, buf);
extern const char mtab_file[]; /* Defined in utility.c */ extern const char mtab_file[]; /* Defined in utility.c */

View File

@ -9,30 +9,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <sys/syscall.h>
#include <linux/unistd.h>
#include "busybox.h" #include "busybox.h"
#ifndef __NR_pivot_root extern int pivot_root(const char * new_root,const char * put_old);
#warning This kernel does not support the pivot_root syscall
#warning The pivot_root system call is being stubbed out...
int pivot_root(const char * new_root,const char * put_old)
{
/* BusyBox was compiled against a kernel that did not support
* the pivot_root system call. To make this application work,
* you will need to recompile with a kernel supporting the
* pivot_root system call.
*/
fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
fprintf(stderr, "with a kernel supporting the pivot_root system call. -Erik\n\n");
errno=ENOSYS;
return -1;
}
#else
static _syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
#endif
int pivot_root_main(int argc, char **argv) int pivot_root_main(int argc, char **argv)
{ {

View File

@ -29,14 +29,17 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/syscall.h>
#include <linux/unistd.h> #if __GNU_LIBRARY__ < 5
/* libc5 doesn't have sys/swap.h, define these here. */
extern int swapon (__const char *__path, int __flags);
extern int swapoff (__const char *__path);
#else
#include <sys/swap.h>
#endif
#include "busybox.h" #include "busybox.h"
static _syscall2(int, swapon, const char *, path, int, flags);
static _syscall1(int, swapoff, const char *, path);
static int whichApp; static int whichApp;
static const int SWAPON_APP = 1; static const int SWAPON_APP = 1;