Mike Waychison
2010-Mar-02 07:45 UTC
[klibc] [PATCH 00/16] External building, update for 2.6.33 and multiple root devices.
The following patchset implements 3 seperate series of changes. External Building ================ Patches 1 through 8 enable to use of klibc's build system while leaving the src tree pristine (and potentially read only). Specifically: - srctree=<Sources for klibc> - objtree=<Ouput directory for klibc> - KLIBCKERNELSRC=<Kernel sources> - KLIBCKERNELOBJ=<Kernel output directory> As an example, with these patches, one can call 'make' as follows (assuming /usr/local/src/linux-2.6 are kernel sources and object files and /usr/local/src/klibc are pristine klibc sources): $ cd /tmp $ mkdir klibc-obj $ cd klibc-obj $ make KLIBCKERNELSRC=/usr/local/src/linux-2.6/ \ KLIBCKERNELOBJ=/usr/local/src/linux-2.6/ \ srctree=/usr/local/src/klibc \ -f /usr/local/src/klibc/Makefile Updating headers for 2.6.33 ========================== Patches 9 through 14 handle various little breakages that I encountered while trying to compile klibc using 2.6.33 kernel headers. Many of these seem to revolve around change in kernel headers for networking, with the biggest change being the use of __KERNEL__ in linux/socket.h. I'm not sure what the policy is for keeping klibc in sync with kernel headers as they evolve upstream, but these patches should help anyone interested in using a newer kernel tree. Allowing multiple mounts to be specified. ======================================== Patch 15 and 16 implement the ability to specify multiple root devices on the kernel command line. In our production environment, we are used to specifying the following non-standard cmdline option: "root=/dev/hda1,/dev/sda1". We currently maintain internal patches to support this, but would like to move this logic down into kinit. To implement this functionality, we introduce a new internal dev_t called 'Root_MULTI'. This device type is used to signify that there are multiple root devices listed. As for compability with legacy boots using linuxrc in an initrd, we simply disallow using multiple roots and a linuxrc (it is unclear to me what the proper behaviour here should be). Patch Summary (one-liners) ========================= 1: Allow kernel sources to be specified on the command line 2: Remove redundent include of the klibc .config 3: Allow override of klibc .config location 4: Fix srctree references in build. 5: Specify VPATH 6: Fix flags to always use relative paths. 7: Update syscalls.pl commands to use $(srctree) 8: Update socketcalls.pl commands to use $(srctree) 9: Fix asm includes for newer kernel sources. 10: Add missing NFS mount RPC call ordinals. 11: packet.h needs a definition for struct iovec 12: netdev.c needs sockios.h 13: Define types and values in sys/socket.h 14: Include sys/socket.h from net/if_arp.h 15: Drop unused argument root_dev to ramdisk_load() 16: Support for multiple devices specified on the root= cmdline. Thanks, Mike Waychison
Mike Waychison
2010-Mar-02 07:45 UTC
[klibc] [PATCH 01/16] Allow kernel sources to be specified on the command line
Builds that need to keep the source tree pristine need to be able to specify the location of the kernel sources on the make command line. We do this by letting KLIBCKERNELSRC to be overriden with a default of 'linux'. Signed-off-by: Mike Waychison <mikew at google.com> --- Makefile | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 136d4e8..4380727 100644 --- a/Makefile +++ b/Makefile @@ -84,13 +84,15 @@ klibc := -f $(srctree)/scripts/Kbuild.klibc obj .PHONY: all klcc klibc all: klcc klibc -.config: defconfig linux +.config: defconfig $(KLIBCKERNELSRC) @echo "defconfig has changed, please remove or edit .config" @false -linux: - @echo "The 'linux' symlink is missing; it should point to a kernel tree " - @echo "configured for the $(KLIBCARCH) architecture." +$(KLIBCKERNELSRC): + @echo "Cannot find kernel sources." + @echo "Either make a 'linux' symlink point to a kernel tree " + @echo "configured for the $(KLIBCARCH) architecture or specify " + @echo "KLIBCKERNELSRC=<path> to the build." @false rpmbuild = $(shell which rpmbuild 2>/dev/null || which rpm)
Mike Waychison
2010-Mar-02 07:45 UTC
[klibc] [PATCH 02/16] Remove redundent include of the klibc .config
The .config is included already higher up in this file, and there are no side-effects between it's inclusion and this one that can change it (or make it be created). Signed-off-by: Mike Waychison <mikew at google.com> --- scripts/Kbuild.klibc | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc index 227b9bd..1ab71fc 100644 --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -137,9 +137,6 @@ export KLIBCLD KLIBCCC KLIBCAR KLIBCSTRIP KLIBCNM export KLIBCCFLAGS KLIBCAFLAGS KLIBCLIBGCC KLIBCSHAREDFLAGS KLIBCSTRIPFLAGS export KLIBCCRT0 KLIBCLIBC SHLIBDIR -# kernel configuration -include .config - # Add $(obj)/ for paths that is not absolute objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
Mike Waychison
2010-Mar-02 07:45 UTC
[klibc] [PATCH 03/16] Allow override of klibc .config location
Parameterize the location of the .config file so that it can be placed elsewhere for builds that require a pristine source tree. Signed-off-by: Mike Waychison <mikew at google.com> --- Makefile | 11 ++++++----- scripts/Kbuild.klibc | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 4380727..dcee00e 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,8 @@ export INSTALLROOT # Create a fake .config as present in the kernel tree # But if it exists leave it alone -$(if $(wildcard $(objtree)/.config),,$(shell cp defconfig .config)) +$(if $(wildcard $(objtree)/.config),,\ + $(shell cp $(srctree)/defconfig $(objtree)/.config)) # Prefix Make commands with $(Q) to silence them # Use quiet_cmd_xxx, cmd_xxx to create nice output @@ -84,7 +85,7 @@ klibc := -f $(srctree)/scripts/Kbuild.klibc obj .PHONY: all klcc klibc all: klcc klibc -.config: defconfig $(KLIBCKERNELSRC) +$(objtree)/.config: $(srctree)/defconfig $(KLIBCKERNELOBJ) @echo "defconfig has changed, please remove or edit .config" @false @@ -101,10 +102,10 @@ klibc.spec: klibc.spec.in $(KLIBCSRC)/version sed -e 's/@@VERSION@@/$(VERSION)/g' < $< > $@ # Build klcc - it is the first target -klcc: .config +klcc: $(objtree)/.config $(Q)$(MAKE) $(klibc)=klcc -klibc: .config +klibc: $(objtree)/.config $(Q)$(MAKE) $(klibc)=. test: klibc @@ -137,7 +138,7 @@ clean: -name '.*.d' -o -name '.*.tmp' \) \ -type f -print | xargs rm -f -rm-files := .config linux +rm-files := $(objtree)/.config linux distclean mrproper: clean $(Q)find . $(FIND_IGNORE) \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc index 1ab71fc..78bc665 100644 --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -58,7 +58,7 @@ targets : __build: # Read .config if it exist, otherwise ignore --include .config +-include $(objtree)/.config # Generic Kbuild routines include $(srctree)/scripts/Kbuild.include
Mike Waychison
2010-Mar-02 07:45 UTC
[klibc] [PATCH 04/16] Fix srctree references in build.
Fix references in the build where we need to specify expliclity that we are referring to files in the $(srctree) Signed-off-by: Mike Waychison <mikew at google.com> --- Makefile | 4 ++-- scripts/Kbuild.klibc | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index dcee00e..e9d003b 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,12 @@ SRCROOT = . export srctree := $(shell pwd) export objtree := $(shell pwd) export KLIBCSRC := usr/klibc -export VERSION := $(shell cat $(KLIBCSRC)/version) +export VERSION := $(shell cat $(srctree)/$(KLIBCSRC)/version) export KLIBCINC := usr/include export KLIBCOBJ := usr/klibc export KLIBCKERNELSRC := linux/ export KLIBCKERNELOBJ := linux/ -include scripts/Kbuild.include +include $(srctree)/scripts/Kbuild.include KLIBCROSS ?= $(CROSS_COMPILE) export KLIBCROSS diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc index 78bc665..9baada8 100644 --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -76,7 +76,7 @@ KLIBCLDFLAGS : KLIBCCFLAGS : # Arch specific definitions for klibc -include $(KLIBCSRC)/arch/$(KLIBCARCHDIR)/MCONFIG +include $(srctree)/$(KLIBCSRC)/arch/$(KLIBCARCHDIR)/MCONFIG # include/asm-* architecture KLIBCASMARCH ?= $(KLIBCARCH) @@ -141,7 +141,7 @@ export KLIBCCRT0 KLIBCLIBC SHLIBDIR objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) # Kbuild file in the directory that is being build -include $(obj)/Kbuild +include $(srctree)/$(obj)/Kbuild ##### # static-y + shared-y handling @@ -412,4 +412,4 @@ endif # Shorthand for $(Q)$(MAKE) -f scripts/Kbuild.klibc obj # Usage: # $(Q)$(MAKE) $(klibc)=dir -klibc := -rR -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Kbuild.klibc obj +klibc := -rR -f $(srctree)/scripts/Kbuild.klibc obj
Specifing VPATH allows make(1) to use an alternate path for sources. This allows implicit build rules to find sources when $(srctree) != `pwd`. Signed-off-by: Mike Waychison <mikew at google.com> --- Makefile | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/Makefile b/Makefile index e9d003b..83c5338 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,9 @@ export KLIBCINC := usr/include export KLIBCOBJ := usr/klibc export KLIBCKERNELSRC := linux/ export KLIBCKERNELOBJ := linux/ + +export VPATH := $(srctree) + include $(srctree)/scripts/Kbuild.include KLIBCROSS ?= $(CROSS_COMPILE)
Mike Waychison
2010-Mar-02 07:45 UTC
[klibc] [PATCH 06/16] Fix flags to always use relative paths.
Fix the include paths in flags to refer to the directories in the $(srctree) (by making them be absolute paths). No harm is done by always doing this. Signed-off-by: Mike Waychison <mikew at google.com> --- scripts/Kbuild.klibc | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-) diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc index 9baada8..cc7495d 100644 --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -200,13 +200,8 @@ klib-dirs := $(addprefix $(obj)/,$(klib-dirs)) __klibccflags = $(KLIBCCFLAGS) $(EXTRA_KLIBCCFLAGS) $(KLIBCCFLAGS_$(*F).o) __klibcaflags = $(KLIBCAFLAGS) $(EXTRA_KLIBCAFLAGS) $(KLIBCAFLAGS_$(*F).o) -ifeq ($(KBUILD_SRC),) -_klibccflags = $(__klibccflags) -_klibcaflags = $(__klibcaflags) -else _klibccflags = $(call flags,__klibccflags) _klibcaflags = $(call flags,__klibcaflags) -endif klibccflags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(_klibccflags) klibcaflags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(_klibcaflags)
Mike Waychison
2010-Mar-02 07:46 UTC
[klibc] [PATCH 07/16] Update syscalls.pl commands to use $(srctree)
Change the Makefile to refer to $(srctree) instead of $(KBUILD_SRC) for syscalls.pl commands. While here, clean up the whitespace. Signed-off-by: Mike Waychison <mikew at google.com> --- usr/klibc/syscalls/Kbuild | 55 ++++++++++++++++++++++++--------------------- 1 files changed, 29 insertions(+), 26 deletions(-) diff --git a/usr/klibc/syscalls/Kbuild b/usr/klibc/syscalls/Kbuild index 8a5b94d..4dbbc31 100644 --- a/usr/klibc/syscalls/Kbuild +++ b/usr/klibc/syscalls/Kbuild @@ -53,18 +53,20 @@ $(obj)/syscalls.nrs: $(KLIBCINC)/sys/syscall.h FORCE # Generate typesize.c quiet_cmd_syscalsz = GEN $@ - cmd_syscalsz = mkdir -p $(KLIBCINC)/klibc/; \ - $(PERL) $(KLIBCSRC)/syscalls.pl -1 $(obj)/SYSCALLS.i \ - $(KLIBCSRC)/arch/$(KLIBCARCHDIR)/sysstub.ph \ - $(KLIBCARCH) $(KLIBCBITSIZE) $(obj)/syscalls.nrs \ - $(obj) \ - $(KLIBCINC)/klibc/havesyscall.h \ - $(obj)/typesize.c > $@ \ - || ( rm -f $@ ; exit 1 ) - -$(obj)/typesize.c: $(KLIBCSRC)/syscalls.pl $(obj)/SYSCALLS.i \ - $(KLIBCSRC)/arch/$(KLIBCARCHDIR)/sysstub.ph \ - $(src)/syscommon.h $(obj)/syscalls.nrs FORCE + cmd_syscalsz = \ + mkdir -p $(KLIBCINC)/klibc/; \ + $(PERL) $(srctree)/$(KLIBCSRC)/syscalls.pl \ + -1 $(obj)/SYSCALLS.i \ + $(srctree)/$(KLIBCSRC)/arch/$(KLIBCARCHDIR)/sysstub.ph \ + $(KLIBCARCH) $(KLIBCBITSIZE) $(obj)/syscalls.nrs \ + $(obj) \ + $(KLIBCINC)/klibc/havesyscall.h \ + $(obj)/typesize.c > $@ \ + || ( rm -f $@ ; exit 1 ) + +$(obj)/typesize.c: $(srctree)/$(KLIBCSRC)/syscalls.pl $(obj)/SYSCALLS.i \ + $(srctree)/$(KLIBCSRC)/arch/$(KLIBCARCHDIR)/sysstub.ph \ + $(src)/syscommon.h $(obj)/syscalls.nrs FORCE $(call if_changed,syscalsz) # Convert typesize.o to typesize.bin @@ -77,18 +79,19 @@ $(obj)/typesize.bin: $(obj)/typesize.o FORCE # Generate $(KLIBINC)/klibc/havesyscall.h + makefile fragment # Using sysstub.pl in arch dir generate all .S files quiet_cmd_syscalls = GEN $@ - cmd_syscalls = mkdir -p $(KLIBCINC)/klibc/; \ - $(PERL) $(KLIBCSRC)/syscalls.pl -2 $(obj)/SYSCALLS.i \ - $(KLIBCSRC)/arch/$(KLIBCARCHDIR)/sysstub.ph \ - $(KLIBCARCH) $(KLIBCBITSIZE) $(obj)/syscalls.nrs \ - $(obj) \ - $(KLIBCINC)/klibc/havesyscall.h \ - $(obj)/typesize.bin > $@ \ - || ( rm -f $@ ; exit 1 ) - -$(obj)/syscalls.mk: $(KLIBCSRC)/syscalls.pl $(obj)/SYSCALLS.i \ - $(KLIBCSRC)/arch/$(KLIBCARCHDIR)/sysstub.ph \ - $(call objectify, $(syscall-objs:.o=.S)) \ - $(src)/syscommon.h $(obj)/syscalls.nrs \ - $(obj)/typesize.bin FORCE + cmd_syscalls = \ + mkdir -p $(KLIBCINC)/klibc/; \ + $(PERL) $(srctree)/$(KLIBCSRC)/syscalls.pl -2 $(obj)/SYSCALLS.i \ + $(srctree)/$(KLIBCSRC)/arch/$(KLIBCARCHDIR)/sysstub.ph \ + $(KLIBCARCH) $(KLIBCBITSIZE) $(obj)/syscalls.nrs \ + $(obj) \ + $(KLIBCINC)/klibc/havesyscall.h \ + $(obj)/typesize.bin > $@ \ + || ( rm -f $@ ; exit 1 ) + +$(obj)/syscalls.mk: $(srctree)/$(KLIBCSRC)/syscalls.pl $(obj)/SYSCALLS.i \ + $(srctree)/$(KLIBCSRC)/arch/$(KLIBCARCHDIR)/sysstub.ph \ + $(call objectify, $(syscall-objs:.o=.S)) \ + $(src)/syscommon.h $(obj)/syscalls.nrs \ + $(obj)/typesize.bin FORCE $(call if_changed,syscalls)
Mike Waychison
2010-Mar-02 07:46 UTC
[klibc] [PATCH 08/16] Update socketcalls.pl commands to use $(srctree)
Change the Makefile to refer to $(srctree) instead of $(KBUILD_SRC) for socketcalls.pl commands. While here, clean up the whitespace. Signed-off-by: Mike Waychison <mikew at google.com> --- usr/klibc/socketcalls/Kbuild | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/usr/klibc/socketcalls/Kbuild b/usr/klibc/socketcalls/Kbuild index f0fc9a8..648c928 100644 --- a/usr/klibc/socketcalls/Kbuild +++ b/usr/klibc/socketcalls/Kbuild @@ -39,12 +39,12 @@ $(obj)/SOCKETCALLS.i: $(KLIBCSRC)/SOCKETCALLS.def FORCE # Generate socketcall stubs quiet_cmd_socketcalls = GEN $@ - cmd_socketcalls = $(PERL) $(KLIBCSRC)/socketcalls.pl \ - $(obj)/SOCKETCALLS.i \ - $(KLIBCARCH) $(obj) > $@ \ - || ( rm -f $@ ; exit 1 ) + cmd_socketcalls = $(PERL) $(srctree)/$(KLIBCSRC)/socketcalls.pl \ + $(obj)/SOCKETCALLS.i \ + $(KLIBCARCH) $(obj) > $@ \ + || ( rm -f $@ ; exit 1 ) -$(obj)/socketcalls.mk: $(KLIBCSRC)/socketcalls.pl \ +$(obj)/socketcalls.mk: $(srctree)/$(KLIBCSRC)/socketcalls.pl \ $(obj)/SOCKETCALLS.i \ $(src)/socketcommon.h $(call cmd,socketcalls)
Mike Waychison
2010-Mar-02 07:46 UTC
[klibc] [PATCH 09/16] Fix asm includes for newer kernel sources.
Newer kernel sources have moved the include/asm-* directories for all architectures over to arch/$(ARCH)/include/asm. Update the klibc build system to always include this directory in the include paths. This should still work with older kernel sources as the include path directory will simply be ignored in those cases. Signed-off-by: Mike Waychison <mikew at google.com> --- scripts/Kbuild.klibc | 3 +++ usr/klibc/arch/ppc/MCONFIG | 2 +- usr/klibc/arch/ppc64/MCONFIG | 2 +- usr/klibc/arch/x86_64/MCONFIG | 3 +++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc index cc7495d..32d49fa 100644 --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -75,6 +75,9 @@ KLIBCBITSIZE : KLIBCLDFLAGS : KLIBCCFLAGS : +# Defaults for arch to override +KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)arch/$(KLIBCARCH)/include + # Arch specific definitions for klibc include $(srctree)/$(KLIBCSRC)/arch/$(KLIBCARCHDIR)/MCONFIG diff --git a/usr/klibc/arch/ppc/MCONFIG b/usr/klibc/arch/ppc/MCONFIG index e973389..5530f40 100644 --- a/usr/klibc/arch/ppc/MCONFIG +++ b/usr/klibc/arch/ppc/MCONFIG @@ -23,7 +23,7 @@ KLIBCBITSIZE = 32 KLIBCSHAREDFLAGS = -Ttext 0x0f800200 # The kernel so far has both asm-ppc* and asm-powerpc. -KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)arch/$(KLIBCARCH)/include +KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)arch/powerpc/include # The asm include files live in asm-powerpc KLIBCASMARCH = powerpc diff --git a/usr/klibc/arch/ppc64/MCONFIG b/usr/klibc/arch/ppc64/MCONFIG index eb2d07a..32e0281 100644 --- a/usr/klibc/arch/ppc64/MCONFIG +++ b/usr/klibc/arch/ppc64/MCONFIG @@ -20,7 +20,7 @@ KLIBCLDFLAGS = -m elf64ppc KLIBCSHAREDFLAGS = -Ttext 0x0f000200 # The kernel so far has both asm-ppc* and asm-powerpc. -KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)arch/$(KLIBCARCH)/include +KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)arch/powerpc/include # The asm include files live in asm-powerpc KLIBCASMARCH = powerpc diff --git a/usr/klibc/arch/x86_64/MCONFIG b/usr/klibc/arch/x86_64/MCONFIG index b40c627..ff58a18 100644 --- a/usr/klibc/arch/x86_64/MCONFIG +++ b/usr/klibc/arch/x86_64/MCONFIG @@ -35,5 +35,8 @@ KLIBCLDFLAGS = -m elf_x86_64 # Revert to the old max-page-size=0x100000 value. KLIBCSHAREDFLAGS = -Ttext 0x00200200 -z max-page-size=0x100000 +# Asm includes for x86_64 are in the merged x86 tree +KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)arch/x86/include + # Additional asm- directories needed during installation ASMARCH = asm-i386
Mike Waychison
2010-Mar-02 07:46 UTC
[klibc] [PATCH 10/16] Add missing NFS mount RPC call ordinals.
The mount ordinals for the NFS mount protocol are no longer available in the kernel headers. #define them if they aren't already available. Signed-off-by: Mike Waychison <mikew at google.com> --- usr/kinit/nfsmount/nfsmount.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/usr/kinit/nfsmount/nfsmount.h b/usr/kinit/nfsmount/nfsmount.h index 6d958bc..abe04c2 100644 --- a/usr/kinit/nfsmount/nfsmount.h +++ b/usr/kinit/nfsmount/nfsmount.h @@ -32,4 +32,11 @@ enum nfs_proto { #define DEBUG(x) do { } while(0) #endif +#ifndef MNTPROC_MNT +#define MNTPROC_MNT 1 +#endif +#ifndef MNTPROC_UMNT +#define MNTPROC_UMNT 3 +#endif + #endif /* NFSMOUNT_NFSMOUNT_H */
Mike Waychison
2010-Mar-02 07:46 UTC
[klibc] [PATCH 11/16] packet.h needs a definition for struct iovec
struct iovec is now hidden behind __KERNEL__ in the kernel headers. Let the compiler know that struct iovec is a valid structure in packet.h. Signed-off-by: Mike Waychison <mikew at google.com> --- usr/kinit/ipconfig/packet.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/usr/kinit/ipconfig/packet.h b/usr/kinit/ipconfig/packet.h index 6e545b5..627d282 100644 --- a/usr/kinit/ipconfig/packet.h +++ b/usr/kinit/ipconfig/packet.h @@ -1,6 +1,8 @@ #ifndef IPCONFIG_PACKET_H #define IPCONFIG_PACKET_H +struct iovec; + int packet_open(void); void packet_close(void); int packet_send(struct netdev *dev, struct iovec *iov, int iov_len);
netdev.c needs to pull in sockios.h directly to get at the socket ioctls. sockios.h used to be pulled in from linux/socket.h, but its include is now hidden behind __KERNEL__. Signed-off-by: Mike Waychison <mikew at google.com> --- usr/kinit/ipconfig/netdev.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/usr/kinit/ipconfig/netdev.c b/usr/kinit/ipconfig/netdev.c index 35a920c..e0f7dad 100644 --- a/usr/kinit/ipconfig/netdev.c +++ b/usr/kinit/ipconfig/netdev.c @@ -12,6 +12,7 @@ #include <net/if_arp.h> #include <netinet/in.h> #include <linux/route.h> +#include <linux/sockios.h> #include "netdev.h"
Mike Waychison
2010-Mar-02 07:46 UTC
[klibc] [PATCH 13/16] Define types and values in sys/socket.h
It seems a lot of #defines and types in linux/socket.h are now hidden behind __KERNEL__. Include them in sys/socket.h for the time being. At the same time, pull in asm/socket.h and linux/uio.h as they aren't implicitly pulled in anymore. Signed-off-by: Mike Waychison <mikew at google.com> --- usr/include/sys/socket.h | 133 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 132 insertions(+), 1 deletions(-) diff --git a/usr/include/sys/socket.h b/usr/include/sys/socket.h index 7d47087..c69caaf 100644 --- a/usr/include/sys/socket.h +++ b/usr/include/sys/socket.h @@ -9,6 +9,8 @@ #include <klibc/compiler.h> #include <klibc/sysconfig.h> #include <linux/socket.h> +#include <linux/uio.h> +#include <asm/socket.h> #if _KLIBC_HAS_ARCHSOCKET_H #include <klibc/archsocket.h> #endif @@ -17,7 +19,7 @@ that are hidden under #ifdef __KERNEL__... what a brilliant idea! These are the "common" definitions; if not appropriate, override them in <klibc/archsocket.h>. */ - + #ifndef SOCK_STREAM # define SOCK_STREAM 1 # define SOCK_DGRAM 2 @@ -27,7 +29,136 @@ # define SOCK_PACKET 10 #endif +#ifndef AF_INET +#define AF_UNSPEC 0 +#define AF_UNIX 1 /* Unix domain sockets */ +#define AF_LOCAL 1 /* POSIX name for AF_UNIX */ +#define AF_INET 2 /* Internet IP Protocol */ +#define AF_AX25 3 /* Amateur Radio AX.25 */ +#define AF_IPX 4 /* Novell IPX */ +#define AF_APPLETALK 5 /* AppleTalk DDP */ +#define AF_NETROM 6 /* Amateur Radio NET/ROM */ +#define AF_BRIDGE 7 /* Multiprotocol bridge */ +#define AF_ATMPVC 8 /* ATM PVCs */ +#define AF_X25 9 /* Reserved for X.25 project */ +#define AF_INET6 10 /* IP version 6 */ +#define AF_ROSE 11 /* Amateur Radio X.25 PLP */ +#define AF_DECnet 12 /* Reserved for DECnet project */ +#define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/ +#define AF_SECURITY 14 /* Security callback pseudo AF */ +#define AF_KEY 15 /* PF_KEY key management API */ +#define AF_NETLINK 16 +#define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */ +#define AF_PACKET 17 /* Packet family */ +#define AF_ASH 18 /* Ash */ +#define AF_ECONET 19 /* Acorn Econet */ +#define AF_ATMSVC 20 /* ATM SVCs */ +#define AF_RDS 21 /* RDS sockets */ +#define AF_SNA 22 /* Linux SNA Project (nutters!) */ +#define AF_IRDA 23 /* IRDA sockets */ +#define AF_PPPOX 24 /* PPPoX sockets */ +#define AF_WANPIPE 25 /* Wanpipe API Sockets */ +#define AF_LLC 26 /* Linux LLC */ +#define AF_CAN 29 /* Controller Area Network */ +#define AF_TIPC 30 /* TIPC sockets */ +#define AF_BLUETOOTH 31 /* Bluetooth sockets */ +#define AF_IUCV 32 /* IUCV sockets */ +#define AF_RXRPC 33 /* RxRPC sockets */ +#define AF_ISDN 34 /* mISDN sockets */ +#define AF_PHONET 35 /* Phonet sockets */ +#define AF_IEEE802154 36 /* IEEE802154 sockets */ +#define AF_MAX 37 /* For now.. */ +#endif // !AF_INET + +#ifndef PF_UNSPEC +#define PF_UNSPEC AF_UNSPEC +#define PF_UNIX AF_UNIX +#define PF_LOCAL AF_LOCAL +#define PF_INET AF_INET +#define PF_AX25 AF_AX25 +#define PF_IPX AF_IPX +#define PF_APPLETALK AF_APPLETALK +#define PF_NETROM AF_NETROM +#define PF_BRIDGE AF_BRIDGE +#define PF_ATMPVC AF_ATMPVC +#define PF_X25 AF_X25 +#define PF_INET6 AF_INET6 +#define PF_ROSE AF_ROSE +#define PF_DECnet AF_DECnet +#define PF_NETBEUI AF_NETBEUI +#define PF_SECURITY AF_SECURITY +#define PF_KEY AF_KEY +#define PF_NETLINK AF_NETLINK +#define PF_ROUTE AF_ROUTE +#define PF_PACKET AF_PACKET +#define PF_ASH AF_ASH +#define PF_ECONET AF_ECONET +#define PF_ATMSVC AF_ATMSVC +#define PF_RDS AF_RDS +#define PF_SNA AF_SNA +#define PF_IRDA AF_IRDA +#define PF_PPPOX AF_PPPOX +#define PF_WANPIPE AF_WANPIPE +#define PF_LLC AF_LLC +#define PF_CAN AF_CAN +#define PF_TIPC AF_TIPC +#define PF_BLUETOOTH AF_BLUETOOTH +#define PF_IUCV AF_IUCV +#define PF_RXRPC AF_RXRPC +#define PF_ISDN AF_ISDN +#define PF_PHONET AF_PHONET +#define PF_IEEE802154 AF_IEEE802154 +#define PF_MAX AF_MAX +#endif // !PF_UNSPEC + +#ifndef MSG_OOB +#define MSG_OOB 1 +#define MSG_PEEK 2 +#define MSG_DONTROUTE 4 +#define MSG_TRYHARD 4 /* Synonym for MSG_DONTROUTE for DECnet */ +#define MSG_CTRUNC 8 +#define MSG_PROBE 0x10 /* Do not send. Only probe path f.e. for MTU */ +#define MSG_TRUNC 0x20 +#define MSG_DONTWAIT 0x40 /* Nonblocking io */ +#define MSG_EOR 0x80 /* End of record */ +#define MSG_WAITALL 0x100 /* Wait for a full request */ +#define MSG_FIN 0x200 +#define MSG_SYN 0x400 +#define MSG_CONFIRM 0x800 /* Confirm path validity */ +#define MSG_RST 0x1000 +#define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */ +#define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */ +#define MSG_MORE 0x8000 /* Sender will send more */ + +#define MSG_EOF MSG_FIN + +#define MSG_CMSG_CLOEXEC 0x40000000 /* Set close_on_exit for file + descriptor received through + SCM_RIGHTS */ +#if defined(CONFIG_COMPAT) +#define MSG_CMSG_COMPAT 0x80000000 /* This message needs 32 bit fixups */ +#else +#define MSG_CMSG_COMPAT 0 /* We never have 32 bit fixups */ +#endif +#endif // !MSG_OOB + +/* These types is hidden under __KERNEL__ in kernel sources */ +typedef unsigned short sa_family_t; +struct sockaddr { + sa_family_t sa_family; /* address family, AF_xxx */ + char sa_data[14]; /* 14 bytes of protocol address */ +}; typedef int socklen_t; +struct msghdr { + void *msg_name; + int msg_namelen; + struct iovec *msg_iov; + size_t msg_iovlen; + void *msg_control; + size_t msg_controllen; + unsigned msg_flags; +}; + __extern int socket(int, int, int); __extern int bind(int, struct sockaddr *, int);
Mike Waychison
2010-Mar-02 07:46 UTC
[klibc] [PATCH 14/16] Include sys/socket.h from net/if_arp.h
if_arp.h requires a definition for struct sockaddr. Pull in sys/socket.h to get one. Signed-off-by: Mike Waychison <mikew at google.com> --- usr/include/net/if_arp.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/usr/include/net/if_arp.h b/usr/include/net/if_arp.h index a25f1b4..6261eeb 100644 --- a/usr/include/net/if_arp.h +++ b/usr/include/net/if_arp.h @@ -1 +1,3 @@ +/* if_arp.h needs sockaddr */ +#include <sys/socket.h> #include <linux/if_arp.h>
Mike Waychison
2010-Mar-02 07:46 UTC
[klibc] [PATCH 15/16] Drop unused argument root_dev to ramdisk_load()
This argument isn't used and can be removed. Signed-off-by: Mike Waychison <mikew at google.com> --- usr/kinit/do_mounts.c | 2 +- usr/kinit/kinit.h | 2 +- usr/kinit/ramdisk_load.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/usr/kinit/do_mounts.c b/usr/kinit/do_mounts.c index 9daa006..967e881 100644 --- a/usr/kinit/do_mounts.c +++ b/usr/kinit/do_mounts.c @@ -213,7 +213,7 @@ int do_mounts(int argc, char *argv[]) } if (load_ramdisk && atoi(load_ramdisk)) { - if (ramdisk_load(argc, argv, root_dev)) + if (ramdisk_load(argc, argv)) root_dev = Root_RAM0; } diff --git a/usr/kinit/kinit.h b/usr/kinit/kinit.h index 895f920..3a37951 100644 --- a/usr/kinit/kinit.h +++ b/usr/kinit/kinit.h @@ -11,7 +11,7 @@ int do_mounts(int argc, char *argv[]); int mount_nfs_root(int argc, char *argv[], int flags); -int ramdisk_load(int argc, char *argv[], dev_t root_dev); +int ramdisk_load(int argc, char *argv[]); void md_run(int argc, char *argv[]); const char *bdevname(dev_t dev); diff --git a/usr/kinit/ramdisk_load.c b/usr/kinit/ramdisk_load.c index 9d2e0b9..3995e8f 100644 --- a/usr/kinit/ramdisk_load.c +++ b/usr/kinit/ramdisk_load.c @@ -189,7 +189,7 @@ load_ramdisk_raw(const char *devpath, FILE * wfd, off_t ramdisk_start, return !!fssize; } -int ramdisk_load(int argc, char *argv[], dev_t root_dev) +int ramdisk_load(int argc, char *argv[]) { const char *arg_prompt_ramdisk = get_arg(argc, argv, "prompt_ramdisk="); const char *arg_ramdisk_blocksize =
Mike Waychison
2010-Mar-02 07:46 UTC
[klibc] [PATCH 16/16] Support for multiple devices specified on the root= cmdline.
In order to handle multiple root devices, such as root=/dev/hda1,/dev/sda1, we introduce a new internal dev_t called Root_MULTI. This device is returned if name_to_dev sees a comma in the root line. When handling multiple roots, we are careful to not support running linuxrc as mixing multiple roots together with linuxrc doesn't make a lot of sense. When we get to mounting and we have a Root_MULTI dev_t, we parse the comma seperated tokens out of the cmdline argument and try each in succession, stopping when we have a successful mount. Signed-off-by: Mike Waychison <mikew at google.com> --- usr/kinit/do_mounts.c | 26 ++++++++++++++++++++++++++ usr/kinit/do_mounts.h | 1 + usr/kinit/initrd.c | 6 ++++++ usr/kinit/name_to_dev.c | 3 +++ 4 files changed, 36 insertions(+), 0 deletions(-) diff --git a/usr/kinit/do_mounts.c b/usr/kinit/do_mounts.c index 967e881..3f63870 100644 --- a/usr/kinit/do_mounts.c +++ b/usr/kinit/do_mounts.c @@ -139,6 +139,30 @@ mount_block_root(int argc, char *argv[], dev_t root_dev, return 0; } +static int +mount_roots(int argc, char *argv[], const char *root_dev_name) +{ + char *roots = strdup(root_dev_name); + char *root; + const char *sep = ","; + char *saveptr; + int ret = -ESRCH; + + root = strtok_r(roots, sep, &saveptr); + while (root) { + dev_t root_dev; + + DEBUG(("kinit: trying to mount %s\n", root)); + root_dev = name_to_dev_t(root); + ret = mount_root(argc, argv, root_dev, root); + if (!ret) + break; + root = strtok_r(NULL, sep, &saveptr); + } + free(roots); + return ret; +} + int mount_root(int argc, char *argv[], dev_t root_dev, const char *root_dev_name) { @@ -217,5 +241,7 @@ int do_mounts(int argc, char *argv[]) root_dev = Root_RAM0; } + if (root_dev == Root_MULTI) + return mount_roots(argc, argv, root_dev_name); return mount_root(argc, argv, root_dev, root_dev_name); } diff --git a/usr/kinit/do_mounts.h b/usr/kinit/do_mounts.h index 2024e86..c309289 100644 --- a/usr/kinit/do_mounts.h +++ b/usr/kinit/do_mounts.h @@ -14,6 +14,7 @@ /* These device numbers are only used internally */ #define Root_NFS __makedev(0,255) #define Root_MTD __makedev(0,254) +#define Root_MULTI __makedev(0,253) int create_dev(const char *name, dev_t dev); diff --git a/usr/kinit/initrd.c b/usr/kinit/initrd.c index dc3af1a..86f8d91 100644 --- a/usr/kinit/initrd.c +++ b/usr/kinit/initrd.c @@ -182,6 +182,12 @@ int initrd_load(int argc, char *argv[], dev_t root_dev) DEBUG(("kinit: initrd copied\n")); + if (root_dev == Root_MULTI) { + DEBUG(("kinit: skipping linuxrc: incompatible with multiple roots\n")); + /* Mounting initrd as ordinary root */ + return 0; + } + if (root_dev != Root_RAM0) { int err; DEBUG(("kinit: running linuxrc\n")); diff --git a/usr/kinit/name_to_dev.c b/usr/kinit/name_to_dev.c index e5ad1cc..fbe3c27 100644 --- a/usr/kinit/name_to_dev.c +++ b/usr/kinit/name_to_dev.c @@ -107,6 +107,9 @@ static inline dev_t name_to_dev_t_real(const char *name) char *cptr, *e1, *e2; int major_num, minor_num; + /* Are we a multi root line? */ + if (strchr(name, ',')) + return Root_MULTI; if (name[0] == '/') { devname = name;
H. Peter Anvin
2010-Mar-02 07:52 UTC
[klibc] [PATCH 00/16] External building, update for 2.6.33 and multiple root devices.
On 03/01/2010 11:45 PM, Mike Waychison wrote:> > I'm not sure what the policy is for keeping klibc in sync with kernel headers > as they evolve upstream, but these patches should help anyone interested in > using a newer kernel tree. >They should be kept up. I have been neglectful on this. Thank you for doing this.. this looks like a great patchset. I will try to integrate it and push a new release out... although since it's the kernel merge window right now I can't promise this week. However, this was the biggest hangup for a release, and other people have been sending patches for the last few weeks, so this is fantastic. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.