Группа :: Система/Ядро и оборудование
Пакет: mkinitrd-busybox
Главная Изменения Спек Патчи Загрузить Bugs and FR
Патч: busybox-1.00-dietlibc.patch
--- busybox-1.00/coreutils/tail.c.dietlibc 2004-09-30 04:24:21 +0400
+++ busybox-1.00/coreutils/tail.c 2005-02-07 17:33:17 +0300
@@ -62,7 +62,13 @@ static int status
static void tail_xprint_header(const char *fmt, const char *filename)
{
/* If we get an output error, there is really no sense in continuing. */
- if (dprintf(STDOUT_FILENO, fmt, filename) < 0) {
+ if (bb_full_write(STDOUT_FILENO, "\n===> ", 6) < 0) {
+ bb_perror_nomsg_and_die();
+ }
+ if (bb_full_write(STDOUT_FILENO, filename, strlen(filename)) < 0) {
+ bb_perror_nomsg_and_die();
+ }
+ if (bb_full_write(STDOUT_FILENO, " <===\n", 6) < 0) {
bb_perror_nomsg_and_die();
}
}
--- busybox-1.00/include/libbb.h.dietlibc 2004-09-15 07:04:07 +0400
+++ busybox-1.00/include/libbb.h 2005-02-07 17:33:17 +0300
@@ -34,6 +34,9 @@
#include <stdint.h>
#include <netdb.h>
+#ifdef __dietlibc__
+#include <netinet/in.h>
+#endif
#ifdef DMALLOC
#include <dmalloc.h>
--- busybox-1.00/libbb/printf.c.dietlibc 2004-04-14 21:51:15 +0400
+++ busybox-1.00/libbb/printf.c 2005-02-07 17:33:17 +0300
@@ -120,7 +120,23 @@
* you can extract the information you need from dietstdio.h. See the
* other library implementations for examples.
*/
-#error dietlibc is currently not supported. Please see the commented source.
+
+struct __stdio_file {
+ int fd;
+ int flags;
+ unsigned int bs; /* read: bytes in buffer */
+ unsigned int bm; /* position in buffer */
+ unsigned int buflen; /* length of buf */
+ char *buf;
+ struct __stdio_file *next; /* for fflush */
+ pid_t popen_kludge;
+ unsigned char ungetbuf;
+ char ungotten;
+};
+
+#define ERRORINDICATOR 1
+
+#define SET_FERROR_UNLOCKED(S) (((struct __stdio_file *)S)->flags |= ERRORINDICATOR)
#else /* some other lib */
/* Please see the comments for the above supported libraries for examples
--- busybox-1.00/networking/ping.c.dietlibc 2004-03-15 11:28:48 +0300
+++ busybox-1.00/networking/ping.c 2005-02-07 17:33:17 +0300
@@ -51,6 +51,83 @@
#include <stdlib.h>
#include "busybox.h"
+#ifdef __dietlibc__
+/* Dietlibc is missing the BSD definition 'struct icmp' */
+/*
+ * Internal of an ICMP Router Advertisement
+ */
+struct icmp_ra_addr
+{
+ uint32_t ira_addr;
+ uint32_t ira_preference;
+};
+
+struct icmp
+{
+ uint8_t icmp_type; /* type of message, see below */
+ uint8_t icmp_code; /* type sub code */
+ uint16_t icmp_cksum; /* ones complement checksum of struct */
+ union
+ {
+ uint8_t ih_pptr; /* ICMP_PARAMPROB */
+ struct in_addr ih_gwaddr; /* gateway address */
+ struct ih_idseq /* echo datagram */
+ {
+ uint16_t icd_id;
+ uint16_t icd_seq;
+ } ih_idseq;
+ uint32_t ih_void;
+
+ /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
+ struct ih_pmtu
+ {
+ uint16_t ipm_void;
+ uint16_t ipm_nextmtu;
+ } ih_pmtu;
+
+ struct ih_rtradv
+ {
+ uint8_t irt_num_addrs;
+ uint8_t irt_wpa;
+ uint16_t irt_lifetime;
+ } ih_rtradv;
+ } icmp_hun;
+#define icmp_pptr icmp_hun.ih_pptr
+#define icmp_gwaddr icmp_hun.ih_gwaddr
+#define icmp_id icmp_hun.ih_idseq.icd_id
+#define icmp_seq icmp_hun.ih_idseq.icd_seq
+#define icmp_void icmp_hun.ih_void
+#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
+#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
+#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
+#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
+#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
+ union
+ {
+ struct
+ {
+ uint32_t its_otime;
+ uint32_t its_rtime;
+ uint32_t its_ttime;
+ } id_ts;
+ struct
+ {
+ struct ip idi_ip;
+ /* options and then 64 bits of data */
+ } id_ip;
+ struct icmp_ra_addr id_radv;
+ uint32_t id_mask;
+ uint8_t id_data[1];
+ } icmp_dun;
+#define icmp_otime icmp_dun.id_ts.its_otime
+#define icmp_rtime icmp_dun.id_ts.its_rtime
+#define icmp_ttime icmp_dun.id_ts.its_ttime
+#define icmp_ip icmp_dun.id_ip.idi_ip
+#define icmp_radv icmp_dun.id_radv
+#define icmp_mask icmp_dun.id_mask
+#define icmp_data icmp_dun.id_data
+};
+#endif /* __dietlibc__ */
static const int DEFDATALEN = 56;
static const int MAXIPLEN = 60;
--- busybox-1.00/shell/ash.c.dietlibc 2004-10-08 13:43:34 +0400
+++ busybox-1.00/shell/ash.c 2005-02-07 17:55:50 +0300
@@ -61,9 +61,11 @@
#define PROFILE 0
+#ifndef __dietlibc__
#ifdef DEBUG
#define _GNU_SOURCE
#endif
+#endif
#include <sys/types.h>
#include <sys/cdefs.h>
@@ -122,6 +124,29 @@ static int *dash_errno;
#error "Do not even bother, ash will not run on uClinux"
#endif
+#ifdef __dietlibc__
+#define dprintf fdprintf
+
+static void *mempcpy(void *to, const void *from, size_t size)
+{
+ return (char *)memcpy(to, from, size) + size;
+}
+
+static char *strchrnul(const char *p, int c)
+{
+ register char ch = c;
+ for (;;) {
+ if (*p == ch)
+ break;
+ if (!*p)
+ break;
+ ++p;
+ }
+ return (char *) p;
+}
+
+#endif
+
#ifdef DEBUG
#define _DIAGASSERT(assert_expr) assert(assert_expr)
#else
@@ -2561,9 +2586,17 @@ exraise(int e)
static void
onint(void) {
int i;
+#ifdef __dietlibc__
+ sigset_t signals;
+#endif
intpending = 0;
+#ifndef __dietlibc__
sigsetmask(0);
+#else
+ sigemptyset(&signals);
+ sigprocmask(SIG_SETMASK,&signals,NULL);
+#endif
i = EXSIG;
if (gotsig[SIGINT - 1] && !trap[SIGINT]) {
if (!(rootshell && iflag)) {
@@ -6396,6 +6429,10 @@ static unsigned njobs;
/* pgrp of shell on invocation */
static int initialpgrp;
static int ttyfd = -1;
+#ifndef _PATH_TTY
+/* dietlibc has no _PATH_TTY defined */
+#define _PATH_TTY "/dev/tty"
+#endif
#endif
/* current job */
static struct job *curjob;
@@ -6716,7 +6753,15 @@ sprint_status(char *s, int status, int s
#endif
}
st &= 0x7f;
+#ifdef _GNU_SOURCE
col = fmtstr(s, 32, strsignal(st));
+#else
+ if (st < NSIG && sys_siglist[st]) {
+ col += fmtstr(s, 32, sys_siglist[st]);
+ } else {
+ col += fmtstr(s, 64, "Signal %d", st );
+ }
+#endif
if (WCOREDUMP(status)) {
col += fmtstr(s + col, 16, " (core dumped)");
}
--- busybox-1.00/sysdeps/linux/Config.in.dietlibc 2004-05-25 15:30:22 +0400
+++ busybox-1.00/sysdeps/linux/Config.in 2005-02-07 17:33:17 +0300
@@ -143,9 +143,19 @@ endmenu
menu 'Build Options'
+config CONFIG_DIETLIBC
+ bool "Build BusyBox as a static binary against DietLibc"
+ default n
+ help
+ If you want to build a static BusyBox binary linked against
+ dietlibc (e.g. for initrd or initramfs), then enable this option.
+
+ Most people will leave this set to 'N'.
+
config CONFIG_STATIC
bool "Build BusyBox as a static binary (no shared libs)"
default n
+ depends on CONFIG_DIETLIBC = 'n'
help
If you want to build a static BusyBox binary, which does not
use or require any shared libraries, then enable this option.
--- busybox-1.00/Rules.mak.dietlibc 2005-02-07 17:31:54 +0300
+++ busybox-1.00/Rules.mak 2005-02-07 17:33:17 +0300
@@ -139,6 +139,15 @@ OPTIMIZATIONS=$(OPTIMIZATION) -fomit-fra
# prone to casual user adjustment.
#
+ifeq ($(strip $(CONFIG_DIETLIBC)),y)
+ # For dietlibc support
+ CC=diet gcc
+ # Dietlibc is roughly BSD
+ CFLAGS+=-D_BSD_SOURCE
+ LIBRARIES:=-lcompat -lrpc
+else
+ CFLAGS+=-D_GNU_SOURCE
+endif
ifeq ($(strip $(CONFIG_LFS)),y)
# For large file summit support
CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
@@ -153,11 +162,11 @@ else
endif
endif
ifeq ($(strip $(CONFIG_DEBUG)),y)
- CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE
+ CFLAGS +=$(WARNINGS) -g
LDFLAGS +=-Wl,-warn-common
STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging
else
- CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG
+ CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -DNDEBUG
LDFLAGS += -s -Wl,-warn-common
STRIPCMD:=$(STRIP) --remove-section=.note --remove-section=.comment
endif