diff -Naur ../tags/mkinitrd-6_3_5/klibc/klcc/klcc.in mkinitrd-magellan/klibc/klcc/klcc.in --- ../tags/mkinitrd-6_3_5/klibc/klcc/klcc.in 2011-11-24 01:38:55.000000000 +0100 +++ mkinitrd-magellan/klibc/klcc/klcc.in 2011-11-24 01:44:48.000000000 +0100 @@ -159,6 +159,9 @@ # gcc options, that force preprocessing mode push(@ccopt, $a); $operation = 'E'; + } elsif ( $a eq '--param' ) { + push(@ccopt, $a); + push(@ccopt, shift(@ARGV)); } elsif ( $a =~ /^-[gp]/ || $a eq '-p' ) { # Debugging options to gcc push(@ccopt, $a); diff -Naur ../tags/mkinitrd-6_3_5/klibc/klibc.spec mkinitrd-magellan/klibc/klibc.spec --- ../tags/mkinitrd-6_3_5/klibc/klibc.spec 2011-11-24 01:38:54.000000000 +0100 +++ mkinitrd-magellan/klibc/klibc.spec 2011-11-24 01:44:48.000000000 +0100 @@ -1,6 +1,6 @@ Summary: A minimal libc subset for use with initramfs. Name: klibc -Version: 1.5.19 +Version: 1.5.22 Release: 1 License: BSD/GPL Group: Development/Libraries diff -Naur ../tags/mkinitrd-6_3_5/klibc/Makefile mkinitrd-magellan/klibc/Makefile --- ../tags/mkinitrd-6_3_5/klibc/Makefile 2011-11-24 01:38:55.000000000 +0100 +++ mkinitrd-magellan/klibc/Makefile 2011-11-24 01:44:48.000000000 +0100 @@ -91,7 +91,7 @@ .PHONY: all klcc klibc all: klcc klibc -$(objtree)/.config: $(srctree)/defconfig $(KLIBCKERNELOBJ) +$(objtree)/.config: $(srctree)/defconfig @echo "defconfig has changed, please remove or edit .config" @false diff -Naur ../tags/mkinitrd-6_3_5/klibc/scripts/basic/fixdep.c mkinitrd-magellan/klibc/scripts/basic/fixdep.c --- ../tags/mkinitrd-6_3_5/klibc/scripts/basic/fixdep.c 2011-11-24 01:38:54.000000000 +0100 +++ mkinitrd-magellan/klibc/scripts/basic/fixdep.c 2011-11-24 01:44:48.000000000 +0100 @@ -364,10 +364,11 @@ void traps(void) { static char test[] __attribute__((aligned(sizeof(int)))) = "CONF"; + int *p = (int *)test; - if (*(int *)test != INT_CONF) { + if (*p != INT_CONF) { fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n", - *(int *)test); + *p); exit(2); } } diff -Naur ../tags/mkinitrd-6_3_5/klibc/scripts/Kbuild.klibc mkinitrd-magellan/klibc/scripts/Kbuild.klibc --- ../tags/mkinitrd-6_3_5/klibc/scripts/Kbuild.klibc 2011-11-24 01:38:55.000000000 +0100 +++ mkinitrd-magellan/klibc/scripts/Kbuild.klibc 2011-11-24 01:44:48.000000000 +0100 @@ -93,11 +93,16 @@ KLIBCLD := $(LD) KLIBCCC := $(CC) KLIBCAR := $(AR) -KLIBCRANLIB := $(RANLIB) + +# klibc-ar is a macro that invokes KLIBCAR and takes 2 arguments of ar commands. +# The second will be used for reproducible builds, the first otherwise. +klibc-ar = $(KLIBCAR) $(if $(KBUILD_REPRODUCIBLE),$(2),$(1)) + +KLIBCRANLIB := $(call klibc-ar,s,Ds) KLIBCSTRIP := $(STRIP) KLIBCNM := $(NM) -KLIBCOBJCOPY := $(OBJCOPY) -KLIBCOBJDUMP := $(OBJDUMP) +KLIBCOBJCOPY := $(OBJCOPY) +KLIBCOBJDUMP := $(OBJDUMP) # klibc include paths KLIBCCPPFLAGS := -nostdinc -iwithprefix include \ @@ -265,8 +270,8 @@ quiet_cmd_link_o_target = LD $@ # If the list of objects to link is empty, just create an empty lib.a cmd_link_o_target = $(if $(strip $(lib-y)),\ - rm -f $@; $(KLIBCAR) cru $@ $(filter $(lib-y), $^),\ - rm -f $@; $(KLIBCAR) crs $@) + rm -f $@; $(call klibc-ar,cru,Dcr) $@ $(filter $(lib-y), $^),\ + rm -f $@; $(call klibc-ar,crs,Dcrs) $@) $(lib-target): $(lib-y) FORCE $(call if_changed,link_o_target) diff -Naur ../tags/mkinitrd-6_3_5/klibc/scripts/Makefile.host mkinitrd-magellan/klibc/scripts/Makefile.host --- ../tags/mkinitrd-6_3_5/klibc/scripts/Makefile.host 2011-11-24 01:38:54.000000000 +0100 +++ mkinitrd-magellan/klibc/scripts/Makefile.host 2011-11-24 01:44:48.000000000 +0100 @@ -5,7 +5,7 @@ # # Both C and C++ is supported, but preferred language is C for such utilities. # -# Samle syntax (see Documentation/kbuild/makefile.txt for reference) +# Sample syntax (see Documentation/kbuild/makefile.txt for reference) # hostprogs-y := bin2hex # Will compile bin2hex.c and create an executable named bin2hex # diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/include/arch/arm/klibc/archconfig.h mkinitrd-magellan/klibc/usr/include/arch/arm/klibc/archconfig.h --- ../tags/mkinitrd-6_3_5/klibc/usr/include/arch/arm/klibc/archconfig.h 2011-11-24 01:38:47.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/include/arch/arm/klibc/archconfig.h 2011-11-24 01:44:45.000000000 +0100 @@ -9,6 +9,10 @@ #ifndef _KLIBC_ARCHCONFIG_H #define _KLIBC_ARCHCONFIG_H -/* All defaults */ +/* newer arm arch support bx instruction */ +#if (!defined(__ARM_ARCH_2__) && !defined(__ARM_ARCH_3__) \ + && !defined(__ARM_ARCH_3M__) && !defined(__ARM_ARCH_4__)) +# define _KLIBC_ARM_USE_BX 1 +#endif #endif /* _KLIBC_ARCHCONFIG_H */ diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/include/arch/arm/klibc/asmmacros.h mkinitrd-magellan/klibc/usr/include/arch/arm/klibc/asmmacros.h --- ../tags/mkinitrd-6_3_5/klibc/usr/include/arch/arm/klibc/asmmacros.h 2011-11-24 01:38:47.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/include/arch/arm/klibc/asmmacros.h 2011-11-24 01:44:45.000000000 +0100 @@ -7,24 +7,10 @@ #ifndef _KLIBC_ASMMACROS_H #define _KLIBC_ASMMACROS_H -/* An immediate in ARM can be any 8-bit value rotated by an even number of bits */ - -#define ARM_VALID_IMM(x) \ - ((((x) & ~0x000000ff) == 0) || \ - (((x) & ~0x000003fc) == 0) || \ - (((x) & ~0x00000ff0) == 0) || \ - (((x) & ~0x00003fc0) == 0) || \ - (((x) & ~0x0000ff00) == 0) || \ - (((x) & ~0x0003fc00) == 0) || \ - (((x) & ~0x000ff000) == 0) || \ - (((x) & ~0x003fc000) == 0) || \ - (((x) & ~0x00ff0000) == 0) || \ - (((x) & ~0x03fc0000) == 0) || \ - (((x) & ~0x0ff00000) == 0) || \ - (((x) & ~0x3fc00000) == 0) || \ - (((x) & ~0xff000000) == 0) || \ - (((x) & ~0xfc000003) == 0) || \ - (((x) & ~0xf000000f) == 0) || \ - (((x) & ~0xc000003f) == 0)) +#if _KLIBC_ARM_USE_BX +# define BX(x) bx x +#else +# define BX(x) mov pc, x +#endif #endif /* _KLIBC_ASMMACROS_H */ diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/include/arch/i386/klibc/archconfig.h mkinitrd-magellan/klibc/usr/include/arch/i386/klibc/archconfig.h --- ../tags/mkinitrd-6_3_5/klibc/usr/include/arch/i386/klibc/archconfig.h 2011-11-24 01:38:47.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/include/arch/i386/klibc/archconfig.h 2011-11-24 01:44:45.000000000 +0100 @@ -9,7 +9,7 @@ #ifndef _KLIBC_ARCHCONFIG_H #define _KLIBC_ARCHCONFIG_H -/* On i386, only half the signals are accessible using the legacy calls. */ -#define _KLIBC_USE_RT_SIG 1 +/* The i386 is still not clean enough for this... */ +#define _KLIBC_USE_RT_SIG 0 #endif /* _KLIBC_ARCHCONFIG_H */ diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/include/ctype.h mkinitrd-magellan/klibc/usr/include/ctype.h --- ../tags/mkinitrd-6_3_5/klibc/usr/include/ctype.h 2011-11-24 01:38:49.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/include/ctype.h 2011-11-24 01:44:46.000000000 +0100 @@ -133,7 +133,7 @@ __extern int X(int); #else #define __CTYPEFUNC(X) \ - __extern inline int X(int __c) \ + __extern_inline int X(int __c) \ { \ return __ctype_##X(__c); \ } diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/include/klibc/compiler.h mkinitrd-magellan/klibc/usr/include/klibc/compiler.h --- ../tags/mkinitrd-6_3_5/klibc/usr/include/klibc/compiler.h 2011-11-24 01:38:49.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/include/klibc/compiler.h 2011-11-24 01:44:46.000000000 +0100 @@ -20,16 +20,38 @@ # define __cdecl /* Meaningless on non-i386 */ #endif +/* + * How to declare a function which should be inlined or instantiated locally + */ +#ifdef __GNUC__ +# ifdef __GNUC_STDC_INLINE__ +# define __static_inline static __inline__ __attribute__((__gnu_inline__)) +# else +# define __static_inline static __inline__ +# endif +#else +# define __static_inline inline /* Just hope this works... */ +#endif + +/* + * How to declare a function which should be inlined or have a call to + * an external module + */ +#ifdef __GNUC__ +# ifdef __GNUC_STDC_INLINE__ +# define __extern_inline extern __inline__ __attribute__((__gnu_inline__)) +# else +# define __extern_inline extern __inline__ +# endif +#else +# define __extern_inline inline /* Just hope this works... */ +#endif + /* How to declare a function that *must* be inlined */ /* Use "extern inline" even in the gcc3+ case to avoid warnings in ctype.h */ #ifdef __GNUC__ # if __GNUC__ >= 3 -# ifdef __GNUC_STDC_INLINE__ -# define __must_inline extern __inline__ \ - __attribute__((__gnu_inline__,__always_inline__)) -# else -# define __must_inline extern __inline__ __attribute__((__always_inline__)) -# endif +# define __must_inline __extern_inline __attribute__((__always_inline__)) # else # define __must_inline extern __inline__ # endif diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/include/klibc/sysconfig.h mkinitrd-magellan/klibc/usr/include/klibc/sysconfig.h --- ../tags/mkinitrd-6_3_5/klibc/usr/include/klibc/sysconfig.h 2011-11-24 01:38:49.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/include/klibc/sysconfig.h 2011-11-24 01:44:46.000000000 +0100 @@ -169,7 +169,7 @@ * * mips has it's own definition of statfs, which is * different from any other 32 bit arch. - */ + */ #ifndef _KLIBC_STATFS_F_TYPE_32B # define _KLIBC_STATFS_F_TYPE_32B 0 #endif @@ -196,4 +196,13 @@ # define _KLIBC_SYS_SOCKETCALL 0 #endif +/* + * _KLIBC_ARM_USE_BX + * + * This arm architecture supports bx instruction. + */ +#ifndef _KLIBC_ARM_USE_BX +# define _KLIBC_ARM_USE_BX 0 +#endif + #endif /* _KLIBC_SYSCONFIG_H */ diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/include/stdio.h mkinitrd-magellan/klibc/usr/include/stdio.h --- ../tags/mkinitrd-6_3_5/klibc/usr/include/stdio.h 2011-11-24 01:38:49.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/include/stdio.h 2011-11-24 01:44:45.000000000 +0100 @@ -49,22 +49,22 @@ __extern FILE *fopen(const char *, const char *); -static __inline__ FILE *fdopen(int __fd, const char *__m) +__static_inline FILE *fdopen(int __fd, const char *__m) { (void)__m; return __create_file(__fd); } -static __inline__ int fclose(FILE * __f) +__static_inline int fclose(FILE * __f) { extern int close(int); return close(fileno(__f)); } -static __inline__ int fseek(FILE * __f, off_t __o, int __w) +__static_inline int fseek(FILE * __f, off_t __o, int __w) { extern off_t lseek(int, off_t, int); return (lseek(fileno(__f), __o, __w) == (off_t) - 1) ? -1 : 0; } -static __inline__ off_t ftell(FILE * __f) +__static_inline off_t ftell(FILE * __f) { extern off_t lseek(int, off_t, int); return lseek(fileno(__f), 0, SEEK_CUR); @@ -85,12 +85,13 @@ __extern size_t _fwrite(const void *, size_t, FILE *); #ifndef __NO_FREAD_FWRITE_INLINES -extern __inline__ size_t fread(void *__p, size_t __s, size_t __n, FILE * __f) +__extern_inline size_t +fread(void *__p, size_t __s, size_t __n, FILE * __f) { return _fread(__p, __s * __n, __f) / __s; } -extern __inline__ size_t +__extern_inline size_t fwrite(const void *__p, size_t __s, size_t __n, FILE * __f) { return _fwrite(__p, __s * __n, __f) / __s; @@ -109,14 +110,14 @@ __extern int vasprintf(char **, const char *, va_list); /* No buffering, so no flushing needed */ -static __inline__ int fflush(FILE * __f) +__static_inline int fflush(FILE * __f) { (void)__f; return 0; } /* stream errors are not kept track of by klibc implementation */ -static __inline__ int ferror(FILE * __f) +__static_inline int ferror(FILE * __f) { (void)__f; return 0; diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/include/sys/socket.h mkinitrd-magellan/klibc/usr/include/sys/socket.h --- ../tags/mkinitrd-6_3_5/klibc/usr/include/sys/socket.h 2011-11-24 01:38:49.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/include/sys/socket.h 2011-11-24 01:44:46.000000000 +0100 @@ -5,6 +5,7 @@ #ifndef _SYS_SOCKET_H #define _SYS_SOCKET_H +#include #include #include #include diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/do_mounts.c mkinitrd-magellan/klibc/usr/kinit/do_mounts.c --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/do_mounts.c 2011-11-24 01:38:47.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/do_mounts.c 2011-11-24 01:44:45.000000000 +0100 @@ -1,4 +1,3 @@ -#include #include #include #include @@ -7,7 +6,6 @@ #include #include #include -#include #include #include "do_mounts.h" diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/do_mounts_md.c mkinitrd-magellan/klibc/usr/kinit/do_mounts_md.c --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/do_mounts_md.c 2011-11-24 01:38:46.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/do_mounts_md.c 2011-11-24 01:44:45.000000000 +0100 @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/fstype/main.c mkinitrd-magellan/klibc/usr/kinit/fstype/main.c --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/fstype/main.c 2011-11-24 01:38:47.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/fstype/main.c 2011-11-24 01:44:45.000000000 +0100 @@ -16,7 +16,6 @@ #include #include #include -#include #include #include "fstype.h" diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/fstype/reiser4_fs.h mkinitrd-magellan/klibc/usr/kinit/fstype/reiser4_fs.h --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/fstype/reiser4_fs.h 2011-11-24 01:38:47.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/fstype/reiser4_fs.h 2011-11-24 01:44:45.000000000 +0100 @@ -8,7 +8,7 @@ * Master super block structure. It is the same for all reiser4 filesystems, * so, we can declare it here. It contains common for all format fields like * block size etc. - */ + */ struct reiser4_master_sb { /* Master super block magic. */ char ms_magic[SS_MAGIC_SIZE]; diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/ipconfig/bootp_proto.c mkinitrd-magellan/klibc/usr/kinit/ipconfig/bootp_proto.c --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/ipconfig/bootp_proto.c 2011-11-24 01:38:46.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/ipconfig/bootp_proto.c 2011-11-24 01:44:45.000000000 +0100 @@ -169,9 +169,9 @@ }; int ret; - ret = packet_recv(iov, 3); + ret = packet_recv(dev, iov, 3); if (ret <= 0) - return -1; + return ret; if (ret < sizeof(struct bootp_hdr) || bootp.op != BOOTP_REPLY || /* RFC951 7.5 */ diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/ipconfig/dhcp_proto.c mkinitrd-magellan/klibc/usr/kinit/ipconfig/dhcp_proto.c --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/ipconfig/dhcp_proto.c 2011-11-24 01:38:46.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/ipconfig/dhcp_proto.c 2011-11-24 01:44:45.000000000 +0100 @@ -147,9 +147,9 @@ }; int ret; - ret = packet_recv(iov, 3); - if (ret == 0) - return -1; + ret = packet_recv(dev, iov, 3); + if (ret <= 0) + return ret; dprintf("\n dhcp xid %08x ", dev->bootp.xid); diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/ipconfig/main.c mkinitrd-magellan/klibc/usr/kinit/ipconfig/main.c --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/ipconfig/main.c 2011-11-24 01:38:47.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/ipconfig/main.c 2011-11-24 01:44:45.000000000 +0100 @@ -1,4 +1,3 @@ -#include #include #include #include @@ -96,6 +95,30 @@ dev->hostname, dev->name); } +/* + * Escape shell varialbes in git style: + * Always start with a single quote ('), then leave all characters + * except ' and ! unchanged. + */ +static void write_option(FILE* f, const char* name, const char* chr) +{ + + fprintf(f, "%s='", name); + while (*chr) { + switch (*chr) { + case '!': + case '\'': + fprintf(f, "'\\%c'", *chr); + break; + default: + fprintf(f, "%c", *chr); + break; + } + ++chr; + } + fprintf(f, "'\n"); +} + static void dump_device_config(struct netdev *dev) { char fn[40]; @@ -104,22 +127,26 @@ snprintf(fn, sizeof(fn), "/tmp/net-%s.conf", dev->name); f = fopen(fn, "w"); if (f) { - fprintf(f, "DEVICE=%s\n", dev->name); - fprintf(f, "IPV4ADDR=%s\n", my_inet_ntoa(dev->ip_addr)); - fprintf(f, "IPV4BROADCAST=%s\n", - my_inet_ntoa(dev->ip_broadcast)); - fprintf(f, "IPV4NETMASK=%s\n", my_inet_ntoa(dev->ip_netmask)); - fprintf(f, "IPV4GATEWAY=%s\n", my_inet_ntoa(dev->ip_gateway)); - fprintf(f, "IPV4DNS0=%s\n", - my_inet_ntoa(dev->ip_nameserver[0])); - fprintf(f, "IPV4DNS1=%s\n", - my_inet_ntoa(dev->ip_nameserver[1])); - fprintf(f, "HOSTNAME=%s\n", dev->hostname); - fprintf(f, "DNSDOMAIN=%s\n", dev->dnsdomainname); - fprintf(f, "NISDOMAIN=%s\n", dev->nisdomainname); - fprintf(f, "ROOTSERVER=%s\n", my_inet_ntoa(dev->ip_server)); - fprintf(f, "ROOTPATH=%s\n", dev->bootpath); - fprintf(f, "filename=\"%s\"\n", dev->filename); + write_option(f, "DEVICE", dev->name); + write_option(f, "IPV4ADDR", + my_inet_ntoa(dev->ip_addr)); + write_option(f, "IPV4BROADCAST", + my_inet_ntoa(dev->ip_broadcast)); + write_option(f, "IPV4NETMASK", + my_inet_ntoa(dev->ip_netmask)); + write_option(f, "IPV4GATEWAY", + my_inet_ntoa(dev->ip_gateway)); + write_option(f, "IPV4DNS0", + my_inet_ntoa(dev->ip_nameserver[0])); + write_option(f, "IPV4DNS1", + my_inet_ntoa(dev->ip_nameserver[1])); + write_option(f, "HOSTNAME", dev->hostname); + write_option(f, "DNSDOMAIN", dev->dnsdomainname); + write_option(f, "NISDOMAIN", dev->nisdomainname); + write_option(f, "ROOTSERVER", + my_inet_ntoa(dev->ip_server)); + write_option(f, "ROOTPATH", dev->bootpath); + write_option(f, "filename", dev->filename); fclose(f); } } @@ -171,7 +198,7 @@ /* * Returns: - * 0 = Not handled, the packet is still in the queue + * 0 = Not handled, try again later * 1 = Handled */ static int process_receive_event(struct state *s, time_t now) @@ -179,12 +206,20 @@ int handled = 1; switch (s->state) { + case DEVST_ERROR: + return 0; /* Not handled */ + case DEVST_COMPLETE: + return 0; /* Not handled as already configured */ + case DEVST_BOOTP: s->restart_state = DEVST_BOOTP; switch (bootp_recv_reply(s->dev)) { case -1: s->state = DEVST_ERROR; break; + case 0: + handled = 0; + break; case 1: s->state = DEVST_COMPLETE; dprintf("\n bootp reply\n"); @@ -198,6 +233,9 @@ case -1: s->state = DEVST_ERROR; break; + case 0: + handled = 0; + break; case DHCPOFFER: /* Offer received */ s->state = DEVST_DHCPREQ; dhcp_send_request(s->dev); @@ -211,6 +249,9 @@ case -1: /* error */ s->state = DEVST_ERROR; break; + case 0: + handled = 0; + break; case DHCPACK: /* ACK received */ s->state = DEVST_COMPLETE; break; @@ -297,28 +338,17 @@ /* * Returns: - * 0 = Error, packet not received or discarded + * 0 = No dhcp/bootp packet was received * 1 = A packet was received and handled */ static int do_pkt_recv(int pkt_fd, time_t now) { - int ifindex, ret; + int ret; struct state *s; - ret = packet_peek(&ifindex); - if (ret == 0) - return ret; - for (s = slist; s; s = s->next) { - if (s->dev->ifindex == ifindex) { - ret = process_receive_event(s, now); - break; - } + ret |= process_receive_event(s, now); } - - if (ret == 0) - packet_discard(); - return ret; } @@ -328,7 +358,7 @@ struct pollfd fds[NR_FDS]; struct state *s; int pkt_fd; - int nr = 0; + int nr = 0, rc = 0; struct timeval now, prev; time_t start; @@ -393,6 +423,7 @@ now.tv_sec - start >= loop_timeout) { printf("IP-Config: no response after %d " "secs - giving up\n", loop_timeout); + rc = -1; goto bail; } @@ -407,7 +438,7 @@ bail: packet_close(); - return 0; + return rc; } static int add_one_dev(struct netdev *dev) @@ -480,7 +511,7 @@ static int parse_device(struct netdev *dev, const char *ip) { char *cp; - int i, opt; + int opt; int is_ip = 0; dprintf("IP-Config: parse_device: \"%s\"\n", ip); @@ -502,7 +533,7 @@ dev->name = ip; } } else { - for (i = opt = 0; ip && *ip; ip = cp, opt++) { + for (opt = 0; ip && *ip; ip = cp, opt++) { if ((cp = strchr(ip, ':'))) { *cp++ = '\0'; } @@ -533,7 +564,7 @@ case 4: strncpy(dev->hostname, ip, SYS_NMLN - 1); dev->hostname[SYS_NMLN - 1] = '\0'; - memcpy(dev->reqhostname, dev->hostname, + memcpy(dev->reqhostname, dev->hostname, SYS_NMLN); break; case 5: @@ -721,7 +752,7 @@ { struct netdev *dev; int c, port; - int err; + int err = 0; /* If progname is set we're invoked from another program */ if (!progname) { @@ -799,8 +830,8 @@ "dest to %d\n", cfg_local_port, cfg_remote_port); } - loop(); + err = loop(); } - return 0; + return err; } diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/ipconfig/packet.c mkinitrd-magellan/klibc/usr/kinit/ipconfig/packet.c --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/ipconfig/packet.c 2011-11-24 01:38:46.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/ipconfig/packet.c 2011-11-24 01:44:45.000000000 +0100 @@ -166,47 +166,14 @@ return sendmsg(pkt_fd, &msg, 0); } -/* - * Fetches a bootp packet, but doesn't remove it. - * Returns: - * 0 = Error - * >0 = A packet of size "ret" is available for interface ifindex - */ -int packet_peek(int *ifindex) -{ - struct sockaddr_ll sll; - struct iphdr iph; - int ret, sllen = sizeof(struct sockaddr_ll); - - /* - * Peek at the IP header. - */ - ret = recvfrom(pkt_fd, &iph, sizeof(struct iphdr), - MSG_PEEK, (struct sockaddr *)&sll, &sllen); - if (ret == -1) - return 0; - - if (sll.sll_family != AF_PACKET) - goto discard_pkt; - - if (iph.ihl < 5 || iph.version != IPVERSION) - goto discard_pkt; - - *ifindex = sll.sll_ifindex; - - return ret; - -discard_pkt: - packet_discard(); - return 0; -} - -void packet_discard(void) +void packet_discard(struct netdev *dev) { struct iphdr iph; struct sockaddr_ll sll; socklen_t sllen = sizeof(sll); + sll.sll_ifindex = dev->ifindex; + recvfrom(pkt_fd, &iph, sizeof(iph), 0, (struct sockaddr *)&sll, &sllen); } @@ -215,10 +182,11 @@ * Receive a bootp packet. The options are listed in iov[1...iov_len]. * iov[0] must point to the bootp packet header. * Returns: - * 0 = Error, try again later + * -1 = Error, try again later +* 0 = Discarded packet (non-DHCP/BOOTP traffic) * >0 = Size of packet */ -int packet_recv(struct iovec *iov, int iov_len) +int packet_recv(struct netdev* dev, struct iovec *iov, int iov_len) { struct iphdr *ip, iph; struct udphdr *udp; @@ -232,11 +200,17 @@ .msg_flags = 0 }; int ret, iphl; + struct sockaddr_ll sll; + socklen_t sllen = sizeof(sll); + + sll.sll_ifindex = dev->ifindex; + msg.msg_name = &sll; + msg.msg_namelen = sllen; ret = recvfrom(pkt_fd, &iph, sizeof(struct iphdr), - MSG_PEEK, NULL, NULL); + MSG_PEEK, (struct sockaddr *)&sll, &sllen); if (ret == -1) - return 0; + return -1; if (iph.ihl < 5 || iph.version != IPVERSION) goto discard_pkt; @@ -292,6 +266,6 @@ discard_pkt: dprintf("discarded\n"); - packet_discard(); + packet_discard(dev); return 0; } diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/ipconfig/packet.h mkinitrd-magellan/klibc/usr/kinit/ipconfig/packet.h --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/ipconfig/packet.h 2011-11-24 01:38:47.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/ipconfig/packet.h 2011-11-24 01:44:45.000000000 +0100 @@ -6,8 +6,7 @@ int packet_open(void); void packet_close(void); int packet_send(struct netdev *dev, struct iovec *iov, int iov_len); -int packet_peek(int *ifindex); -void packet_discard(void); -int packet_recv(struct iovec *iov, int iov_len); +void packet_discard(struct netdev *dev); +int packet_recv(struct netdev *dev, struct iovec *iov, int iov_len); #endif /* IPCONFIG_PACKET_H */ diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/name_to_dev.c mkinitrd-magellan/klibc/usr/kinit/name_to_dev.c --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/name_to_dev.c 2011-11-24 01:38:47.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/name_to_dev.c 2011-11-24 01:44:45.000000000 +0100 @@ -1,5 +1,4 @@ #include -#include #include #include #include diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/nfsmount/dummypmap.c mkinitrd-magellan/klibc/usr/kinit/nfsmount/dummypmap.c --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/nfsmount/dummypmap.c 2011-11-24 01:38:47.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/nfsmount/dummypmap.c 2011-11-24 01:44:45.000000000 +0100 @@ -249,6 +249,7 @@ if (errno == EINVAL || errno == EADDRINUSE) return 0; /* Assume not needed */ else { + fclose(portmap_filep); fprintf(stderr, "%s: portmap spoofing failed\n", progname); return -1; @@ -257,6 +258,7 @@ spoof_portmap = fork(); if (spoof_portmap == -1) { + fclose(portmap_filep); fprintf(stderr, "%s: cannot fork\n", progname); return -1; } else if (spoof_portmap == 0) { diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/nfsmount/mount.c mkinitrd-magellan/klibc/usr/kinit/nfsmount/mount.c --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/nfsmount/mount.c 2011-11-24 01:38:47.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/nfsmount/mount.c 2011-11-24 01:44:45.000000000 +0100 @@ -44,6 +44,11 @@ #define MNT_REPLY_MINSIZE (sizeof(struct rpc_reply) + sizeof(uint32_t)) +#ifndef MNTPROC_MNT +# define MNTPROC_MNT 1 +# define MNTPROC_UMNT 3 +#endif /* MNTPROC_MNT */ + static int get_ports(uint32_t server, const struct nfs_mount_data *data) { uint32_t nfs_ver, mount_ver; diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/nfsmount/sunrpc.c mkinitrd-magellan/klibc/usr/kinit/nfsmount/sunrpc.c --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/nfsmount/sunrpc.c 2011-11-24 01:38:47.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/nfsmount/sunrpc.c 2011-11-24 01:44:45.000000000 +0100 @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/ramdisk_load.c mkinitrd-magellan/klibc/usr/kinit/ramdisk_load.c --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/ramdisk_load.c 2011-11-24 01:38:46.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/ramdisk_load.c 2011-11-24 01:44:45.000000000 +0100 @@ -1,4 +1,3 @@ -#include #include #include #include @@ -243,6 +242,8 @@ (fssize == 0 && !(is_gzip = !strcmp(fstype, "gzip")))) { fprintf(stderr, "Failure loading ramdisk: unknown filesystem type\n"); + close(rfd); + fclose(wfd); return 0; } diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/resume/resumelib.c mkinitrd-magellan/klibc/usr/kinit/resume/resumelib.c --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/resume/resumelib.c 2011-11-24 01:38:47.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/resume/resumelib.c 2011-11-24 01:44:45.000000000 +0100 @@ -2,7 +2,6 @@ * Handle resume from suspend-to-disk */ -#include #include #include #include diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/kinit/run-init/runinitlib.c mkinitrd-magellan/klibc/usr/kinit/run-init/runinitlib.c --- ../tags/mkinitrd-6_3_5/klibc/usr/kinit/run-init/runinitlib.c 2011-11-24 01:38:47.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/kinit/run-init/runinitlib.c 2011-11-24 01:44:45.000000000 +0100 @@ -40,7 +40,6 @@ * On failure, returns a human-readable error message. */ -#include #include #include #include @@ -157,7 +156,7 @@ const char *run_init(const char *realroot, const char *console, const char *init, char **initargs) { - struct stat rst, cst, ist; + struct stat rst, cst; struct statfs sfs; int confd; @@ -176,10 +175,6 @@ if (rst.st_dev == cst.st_dev) return "current directory on the same filesystem as the root"; - /* The initramfs should have /init */ - if (stat("/init", &ist) || !S_ISREG(ist.st_mode)) - return "can't find /init on initramfs"; - /* Make sure we're on a ramfs */ if (statfs("/", &sfs)) return "statfs /"; diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/arch/arm/setjmp.S mkinitrd-magellan/klibc/usr/klibc/arch/arm/setjmp.S --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/arch/arm/setjmp.S 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/arch/arm/setjmp.S 2011-11-24 01:44:46.000000000 +0100 @@ -4,6 +4,8 @@ # setjmp/longjmp for the ARM architecture # +#include + #ifndef __thumb__ # @@ -29,7 +31,7 @@ setjmp: stmia r0, {r4, r5, r6, r7, r8, r9, r10, fp, sp, lr} mov r0, #0 - mov pc, lr + BX(lr) .size setjmp,.-setjmp .text @@ -39,7 +41,7 @@ longjmp: ldmia r0, {r4, r5, r6, r7, r8, r9, r10, fp, sp, lr} mov r0, r1 - mov pc, lr + BX(lr) .size longjmp,.-longjmp #else /* __thumb__ */ @@ -75,7 +77,7 @@ mov r7, sp stmia r0!, {r3, r4, r5, r6, r7} mov r0, #0 - mov pc, lr + BX(lr) .size setjmp,.-setjmp .text @@ -96,7 +98,7 @@ mov r0, r1 bne 1f mov r0, #1 -1: mov pc, r3 +1: BX(r3) .size longjmp,.-longjmp #endif /* __thumb__ */ diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/arch/arm/sysstub.ph mkinitrd-magellan/klibc/usr/klibc/arch/arm/sysstub.ph --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/arch/arm/sysstub.ph 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/arch/arm/sysstub.ph 2011-11-24 01:44:46.000000000 +0100 @@ -52,7 +52,7 @@ print OUT "#endif /* __thumb__*/\n"; - print OUT " .size __syscall${i},.-__syscall${i}\n"; + print OUT " .size ${fname},.-${fname}\n"; } 1; diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/arch/arm/vfork.S mkinitrd-magellan/klibc/usr/klibc/arch/arm/vfork.S --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/arch/arm/vfork.S 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/arch/arm/vfork.S 2011-11-24 01:44:46.000000000 +0100 @@ -4,6 +4,7 @@ * vfork - nasty system call which must not use the stack. */ +#include #include .type vfork,#function @@ -25,7 +26,7 @@ ldrcs r3, 1f mvncs r0, #0 strcs r2, [r3] - mov pc, lr + BX(lr) .balign 4 1: @@ -49,7 +50,7 @@ str r2, [r1] neg r0, r0 1: - mov pc, lr + BX(lr) .balign 4 2: diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/CAVEATS mkinitrd-magellan/klibc/usr/klibc/CAVEATS --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/CAVEATS 2011-11-24 01:38:54.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/CAVEATS 2011-11-24 01:44:48.000000000 +0100 @@ -1,5 +1,5 @@ ------------------------------------------------- - Please note the following caveats to using klibc: + Please note the following caveats when using klibc: ------------------------------------------------- optimization: diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/execv.c mkinitrd-magellan/klibc/usr/klibc/execv.c --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/execv.c 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/execv.c 2011-11-24 01:44:46.000000000 +0100 @@ -2,7 +2,6 @@ * execv.c */ -#include #include int execv(const char *path, char *const *argv) diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/execvp.c mkinitrd-magellan/klibc/usr/klibc/execvp.c --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/execvp.c 2011-11-24 01:38:53.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/execvp.c 2011-11-24 01:44:48.000000000 +0100 @@ -2,7 +2,6 @@ * execvp.c */ -#include #include int execvp(const char *path, char *const *argv) diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/fgetc.c mkinitrd-magellan/klibc/usr/klibc/fgetc.c --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/fgetc.c 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/fgetc.c 2011-11-24 01:44:46.000000000 +0100 @@ -9,7 +9,6 @@ #include #include #include -#include int fgetc(FILE *f) { diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/getpt.c mkinitrd-magellan/klibc/usr/klibc/getpt.c --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/getpt.c 2011-11-24 01:38:53.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/getpt.c 2011-11-24 01:44:47.000000000 +0100 @@ -9,7 +9,6 @@ #include #include #include -#include int getpt(void) { diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/Kbuild mkinitrd-magellan/klibc/usr/klibc/Kbuild --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/Kbuild 2011-11-24 01:38:53.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/Kbuild 2011-11-24 01:44:47.000000000 +0100 @@ -109,7 +109,7 @@ targets += libc.a __static_init.o quiet_cmd_libc = KLIBCAR $@ cmd_libc = rm -f $@; \ - $(KLIBCAR) cq $@ \ + $(call klibc-ar,cq,Dcq) $@ \ $(call objectify,__static_init.o) $(klib-o-files); \ $(KLIBCRANLIB) $@ diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/posix_openpt.c mkinitrd-magellan/klibc/usr/klibc/posix_openpt.c --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/posix_openpt.c 2011-11-24 01:38:54.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/posix_openpt.c 2011-11-24 01:44:48.000000000 +0100 @@ -7,7 +7,6 @@ #include #include #include -#include int posix_openpt(int oflag) { diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/README.klibc mkinitrd-magellan/klibc/usr/klibc/README.klibc --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/README.klibc 2011-11-24 01:38:54.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/README.klibc 2011-11-24 01:44:48.000000000 +0100 @@ -1,6 +1,6 @@ This is klibc, what is intended to be a minimalistic libc subset for use with initramfs. It is deliberately written for small size, -minimal entaglement, and portability, not speed. It is definitely a +minimal entanglement, and portability, not speed. It is definitely a work in progress, and a lot of things are still missing. diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/socketcalls/Kbuild mkinitrd-magellan/klibc/usr/klibc/socketcalls/Kbuild --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/socketcalls/Kbuild 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/socketcalls/Kbuild 2011-11-24 01:44:46.000000000 +0100 @@ -48,3 +48,5 @@ $(obj)/SOCKETCALLS.i \ $(src)/socketcommon.h $(call cmd,socketcalls) + +PHONY += FORCE diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/syscalls/Kbuild mkinitrd-magellan/klibc/usr/klibc/syscalls/Kbuild --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/syscalls/Kbuild 2011-11-24 01:38:53.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/syscalls/Kbuild 2011-11-24 01:44:47.000000000 +0100 @@ -95,3 +95,5 @@ $(src)/syscommon.h $(obj)/syscalls.nrs \ $(obj)/typesize.bin FORCE $(call if_changed,syscalls) + +PHONY += FORCE diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/system.c mkinitrd-magellan/klibc/usr/klibc/system.c --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/system.c 2011-11-24 01:38:53.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/system.c 2011-11-24 01:44:48.000000000 +0100 @@ -7,7 +7,6 @@ * present. */ -#include #include #include #include diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/fcntl.c mkinitrd-magellan/klibc/usr/klibc/tests/fcntl.c --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/fcntl.c 2011-11-24 01:38:53.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/tests/fcntl.c 2011-11-24 01:44:47.000000000 +0100 @@ -5,7 +5,6 @@ #include #include #include -#include #include #include @@ -46,5 +45,6 @@ /* Eventually, fork and try to conflict with this lock... */ + close(fd); return 0; } diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/fnmatch.c mkinitrd-magellan/klibc/usr/klibc/tests/fnmatch.c --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/fnmatch.c 2011-11-24 01:38:53.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/tests/fnmatch.c 2011-11-24 01:44:47.000000000 +0100 @@ -11,5 +11,3 @@ return match; } - - diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/getoptlong.c mkinitrd-magellan/klibc/usr/klibc/tests/getoptlong.c --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/getoptlong.c 2011-11-24 01:38:52.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/tests/getoptlong.c 2011-11-24 01:44:47.000000000 +0100 @@ -11,7 +11,7 @@ #include static int foo = 0; - + static const struct option long_options[] = { { "first", 1, NULL, 'f' }, { "second", 0, NULL, 's' }, diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/select.c mkinitrd-magellan/klibc/usr/klibc/tests/select.c --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/select.c 2011-11-24 01:38:52.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/tests/select.c 2011-11-24 01:44:47.000000000 +0100 @@ -42,7 +42,7 @@ FD_SET(fdz, &readset); rv = select(FD_SETSIZE, &readset, NULL, NULL, &timeout); - + if (rv != 1 || !FD_ISSET(fdz, &readset) || FD_ISSET(fdn, &readset)) { fprintf(stderr, diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/socket.c mkinitrd-magellan/klibc/usr/klibc/tests/socket.c --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/socket.c 2011-11-24 01:38:53.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/tests/socket.c 2011-11-24 01:44:47.000000000 +0100 @@ -16,4 +16,3 @@ return 0; } - diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/stat.c mkinitrd-magellan/klibc/usr/klibc/tests/stat.c --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/stat.c 2011-11-24 01:38:52.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/tests/stat.c 2011-11-24 01:44:47.000000000 +0100 @@ -1,6 +1,5 @@ #include #include -#include #include #include #include diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/statfs.c mkinitrd-magellan/klibc/usr/klibc/tests/statfs.c --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/statfs.c 2011-11-24 01:38:52.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/tests/statfs.c 2011-11-24 01:44:47.000000000 +0100 @@ -1,6 +1,5 @@ #include #include -#include #include static void do_statfs(const char *path) diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/testvsnp.c mkinitrd-magellan/klibc/usr/klibc/tests/testvsnp.c --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/tests/testvsnp.c 2011-11-24 01:38:53.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/tests/testvsnp.c 2011-11-24 01:44:47.000000000 +0100 @@ -1,5 +1,4 @@ #include -#include #include #include #include diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/klibc/version mkinitrd-magellan/klibc/usr/klibc/version --- ../tags/mkinitrd-6_3_5/klibc/usr/klibc/version 2011-11-24 01:38:53.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/klibc/version 2011-11-24 01:44:48.000000000 +0100 @@ -1 +1 @@ -1.5.19 +1.5.22 diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/utils/cat.c mkinitrd-magellan/klibc/usr/utils/cat.c --- ../tags/mkinitrd-6_3_5/klibc/usr/utils/cat.c 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/utils/cat.c 2011-11-24 01:44:46.000000000 +0100 @@ -39,13 +39,6 @@ #define __RCSID(arg) #endif -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#ifndef __KLIBC__ -#include -#endif #if !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ The Regents of the University of California. All rights reserved.\n"); @@ -60,14 +53,8 @@ #include #include -#ifndef __KLIBC__ -#include -#endif #include #include -#ifndef __KLIBC__ -#include -#endif #include #include #include @@ -88,11 +75,6 @@ int ch; struct flock stdout_lock; -#ifndef __KLIBC__ - setprogname(argv[0]); - (void)setlocale(LC_ALL, ""); -#endif - while ((ch = getopt(argc, argv, "beflnstuv")) != -1) switch (ch) { case 'b': @@ -117,9 +99,7 @@ tflag = vflag = 1; /* -t implies -v */ break; case 'u': -#ifndef __KLIBC__ - setbuf(stdout, NULL); -#endif + /* unimplemented */ break; case 'v': vflag = 1; diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/utils/cpio.c mkinitrd-magellan/klibc/usr/utils/cpio.c --- ../tags/mkinitrd-6_3_5/klibc/usr/utils/cpio.c 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/utils/cpio.c 2011-11-24 01:44:46.000000000 +0100 @@ -104,7 +104,7 @@ char *c_tar_linkname; }; -/* Total number of bytes read and written for all files. +/* Total number of bytes read and written for all files. * Now that many tape drives hold more than 4Gb we need more than 32 * bits to hold input_bytes and output_bytes. */ @@ -157,7 +157,7 @@ descriptor OUT_DES and reset `output_size' and `out_buff'. If `swapping_halfwords' or `swapping_bytes' is set, do the appropriate swapping first. Our callers have - to make sure to only set these flags if `output_size' + to make sure to only set these flags if `output_size' is appropriate (a multiple of 4 for `swapping_halfwords', 2 for `swapping_bytes'). The fact that DISK_IO_BLOCK_SIZE must always be a multiple of 4 helps us (and our callers) @@ -365,8 +365,7 @@ for (i = 0; i < hash_num; i++) hash_insert(old_table[i]); - if (old_table != NULL) - free(old_table); + free(old_table); } /* Insert the new record and increment the count of elements in the @@ -407,7 +406,7 @@ return NULL; } -/* Try and create a hard link from FILE_NAME to another file +/* Try and create a hard link from FILE_NAME to another file with the given major/minor device number and inode. If no other file with the same major/minor/inode numbers is known, add this file to the list of known files and associated major/minor/inode numbers @@ -482,10 +481,10 @@ return 0; } -/* The newc and crc formats store multiply linked copies of the same file - in the archive only once. The actual data is attached to the last link - in the archive, and the other links all have a filesize of 0. When a - file in the archive has multiple links and a filesize of 0, its data is +/* The newc and crc formats store multiply linked copies of the same file + in the archive only once. The actual data is attached to the last link + in the archive, and the other links all have a filesize of 0. When a + file in the archive has multiple links and a filesize of 0, its data is probably "attatched" to another file in the archive, so we can't create it right away. We have to "defer" creating it until we have created the file that has the data "attatched" to it. We keep a list of the @@ -680,8 +679,8 @@ tape_skip_padding(in_file_des, file_hdr->c_filesize); if (file_hdr->c_nlink > 1) { - /* (see comment above for how the newc and crc formats - store multiple links). Now that we have the data + /* (see comment above for how the newc and crc formats + store multiple links). Now that we have the data for this file, create any other links to it which we defered. */ create_defered_links(file_hdr); @@ -914,8 +913,7 @@ ah += 8; } /* Read file name from input. */ - if (file_hdr->c_name != NULL) - free(file_hdr->c_name); + free(file_hdr->c_name); file_hdr->c_name = (char *)xmalloc(file_hdr->c_namesize); tape_buffered_read(file_hdr->c_name, in_des, (long)file_hdr->c_namesize); diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/utils/dd.c mkinitrd-magellan/klibc/usr/utils/dd.c --- ../tags/mkinitrd-6_3_5/klibc/usr/utils/dd.c 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/utils/dd.c 2011-11-24 01:44:46.000000000 +0100 @@ -486,6 +486,7 @@ wr_fd = open(OPT_OF->str, flags, 0666); if (wr_fd == -1) { perror("open output file"); + close(rd_fd); return 1; } } @@ -493,14 +494,20 @@ /* * Skip obs-sized blocks of output file. */ - if (OPT_SEEK->str && skip_blocks(wr_fd, out_buf, seek, obs)) + if (OPT_SEEK->str && skip_blocks(wr_fd, out_buf, seek, obs)) { + close(rd_fd); + close(wr_fd); return 1; + } /* * Skip ibs-sized blocks of input file. */ - if (OPT_SKIP->str && skip_blocks(rd_fd, in_buf, skip, ibs)) + if (OPT_SKIP->str && skip_blocks(rd_fd, in_buf, skip, ibs)) { + close(rd_fd); + close(wr_fd); return 1; + } memset(&stats, 0, sizeof(stats)); diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/utils/dmesg.c mkinitrd-magellan/klibc/usr/utils/dmesg.c --- ../tags/mkinitrd-6_3_5/klibc/usr/utils/dmesg.c 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/utils/dmesg.c 2011-11-24 01:44:46.000000000 +0100 @@ -1,5 +1,4 @@ #include -#include #include #include #include diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/utils/losetup.c mkinitrd-magellan/klibc/usr/utils/losetup.c --- ../tags/mkinitrd-6_3_5/klibc/usr/utils/losetup.c 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/utils/losetup.c 2011-11-24 01:44:46.000000000 +0100 @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "loop.h" @@ -339,6 +340,7 @@ } if (ioctl (fd, LOOP_CLR_FD, 0) < 0) { perror ("ioctl: LOOP_CLR_FD"); + close (fd); return 1; } close (fd); @@ -348,9 +350,6 @@ } -#include -#include - int verbose = 0; char *progname; diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/utils/mkfifo.c mkinitrd-magellan/klibc/usr/utils/mkfifo.c --- ../tags/mkinitrd-6_3_5/klibc/usr/utils/mkfifo.c 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/utils/mkfifo.c 2011-11-24 01:44:46.000000000 +0100 @@ -1,6 +1,5 @@ #include #include -#include #include #include #include diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/utils/mknod.c mkinitrd-magellan/klibc/usr/utils/mknod.c --- ../tags/mkinitrd-6_3_5/klibc/usr/utils/mknod.c 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/utils/mknod.c 2011-11-24 01:44:46.000000000 +0100 @@ -20,6 +20,8 @@ dev_t dev; progname = *argv++; + if (argc == 1) + usage(); if (argv[0][0] == '-' && argv[0][1] == 'm' && !argv[0][2]) { mode_set = strtoul(argv[1], &endp, 8); @@ -36,7 +38,7 @@ typec = type[0]; mode = 0; - switch (type[0]) { + switch (typec) { case 'c': mode = S_IFCHR; break; diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/utils/nuke.c mkinitrd-magellan/klibc/usr/utils/nuke.c --- ../tags/mkinitrd-6_3_5/klibc/usr/utils/nuke.c 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/utils/nuke.c 2011-11-24 01:44:46.000000000 +0100 @@ -32,7 +32,6 @@ * do anything. */ -#include #include #include #include diff -Naur ../tags/mkinitrd-6_3_5/klibc/usr/utils/umount.c mkinitrd-magellan/klibc/usr/utils/umount.c --- ../tags/mkinitrd-6_3_5/klibc/usr/utils/umount.c 2011-11-24 01:38:51.000000000 +0100 +++ mkinitrd-magellan/klibc/usr/utils/umount.c 2011-11-24 01:44:46.000000000 +0100 @@ -2,7 +2,6 @@ * by rmk */ #include -#include #include #include #include diff -Naur ../tags/mkinitrd-6_3_5/klibc/VERSION mkinitrd-magellan/klibc/VERSION --- ../tags/mkinitrd-6_3_5/klibc/VERSION 2011-11-24 01:38:55.000000000 +0100 +++ mkinitrd-magellan/klibc/VERSION 2011-11-24 01:44:48.000000000 +0100 @@ -1 +1 @@ -1.5.19 +1.5.22