public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build
@ 2004-08-12  4:14 Jeff Dike
  2004-08-15 22:06 ` Andrew Morton
  0 siblings, 1 reply; 14+ messages in thread
From: Jeff Dike @ 2004-08-12  4:14 UTC (permalink / raw)
  To: akpm, kai, sam; +Cc: linux-kernel

The patch below makes UML build in the face of the ldchk addition to 2.6.8.
The basic problem for UML is that it has always had a two-stage link to produce
the final executable -
	vmlinux contains all the kernel bits, but no libc or gcc libs
	linux is vmlinux plus another .o, massaged by gcc, and linked against 
		libc

This means that, for UML, vmlinux will have unresolved symbols, and will fail
the ldchk test.

I fixed this in a reasonably nasty way by
	adding a $(post-y) to the end of the list of objects
	defining it to be 
		some link flags, an object, and a library from the old linux 
			link command
		a set of libraries pulled from the output of 'gcc -v'
	adding a -L flag to LDFLAGS_vmlinux which points at the location of
		the -lgcc, etc libraries - this is determined by using 'gcc -v'
		to figure out where its spec file is located and assuming that
		its libraries will be located in the same place
	adding arch/um/main.o to $(extra-y) in arch/um/kernel/Makefile because
		I couldn't figure out how to get it to build from 
		arch/um/Makefile

This is all inside UML, except for the $(post-y) in the top-level Makefile.

With this, vmlinux contains all the bits needed for UML, and passes the ldchk
test.  However, it won't run, and a gcc run is needed in order to produce a
real executable.  gcc needs to polish the bits or something.

This getting entirely too familiar with gcc, and I'd appreciate clues about
how to back out of this.  Ideally, I'd like to use the gcc driver as the 
vmlinux linker, but that would require at least rewriting the command, so
I'm not sure how practical that is.

Anyway, you have been warned.  Here it is.  Andrew, please apply.

				Jeff

Index: 2.6.8-rc4-mm1/Makefile
===================================================================
--- 2.6.8-rc4-mm1.orig/Makefile	2004-08-11 22:44:43.000000000 -0400
+++ 2.6.8-rc4-mm1/Makefile	2004-08-11 22:44:49.000000000 -0400
@@ -519,6 +519,7 @@
 	$(drivers-y) \
 	$(net-y) \
 	--end-group \
+	$(post-y) \
 	$(filter .tmp_kallsyms%,$^) \
 	-o $@
 endef
Index: 2.6.8-rc4-mm1/arch/um/Makefile
===================================================================
--- 2.6.8-rc4-mm1.orig/arch/um/Makefile	2004-08-11 22:44:43.000000000 -0400
+++ 2.6.8-rc4-mm1/arch/um/Makefile	2004-08-11 22:44:49.000000000 -0400
@@ -21,6 +21,10 @@
 			   $(ARCH_DIR)/drivers/          \
 			   $(ARCH_DIR)/sys-$(SUBARCH)/
 
+post-y			= --wrap malloc --wrap free --wrap calloc \
+			  $(ARCH_DIR)/main.o -lutil \
+			  --start-group -lgcc -lgcc_eh -lc --end-group
+
 # Have to precede the include because the included Makefiles reference them.
 SYMLINK_HEADERS = archparam.h system.h sigcontext.h processor.h ptrace.h \
 	arch-signal.h module.h
@@ -84,7 +88,10 @@
 
 prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS)
 
-LDFLAGS_vmlinux = -r
+# This stupidity extracts the directory in which gcc lives so that it can
+# be fed to ld when it's linking .tmp_vmlinux during the ldchk stage.
+LD_DIR = $(shell dirname `gcc -v 2>&1 | head -1 | awk '{print $$NF}'`)
+LDFLAGS_vmlinux = -L/usr/lib -L$(LD_DIR) -r
 
 vmlinux: $(ARCH_DIR)/main.o 
 
@@ -126,8 +133,7 @@
 #	$(call if_changed_dep,as_s_S)
 
 linux: vmlinux $(LD_SCRIPT-y)
-	$(CC) -Wl,-T,$(LD_SCRIPT-y) $(LINK-y) $(LINK_WRAPS) \
-		-o linux $(ARCH_DIR)/main.o vmlinux -L/usr/lib -lutil
+	$(CC) -Wl,-T,$(LD_SCRIPT-y) $(LINK-y) -o linux vmlinux
 
 USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
 USER_CFLAGS := $(patsubst -Derrno=kernel_errno,,$(USER_CFLAGS))
Index: 2.6.8-rc4-mm1/arch/um/kernel/Makefile
===================================================================
--- 2.6.8-rc4-mm1.orig/arch/um/kernel/Makefile	2004-08-11 22:44:43.000000000 -0400
+++ 2.6.8-rc4-mm1/arch/um/kernel/Makefile	2004-08-11 22:44:49.000000000 -0400
@@ -3,7 +3,7 @@
 # Licensed under the GPL
 #
 
-extra-y := vmlinux.lds.s
+extra-y := vmlinux.lds.s ../main.o
 
 obj-y = checksum.o config.o exec_kern.o exitcode.o frame_kern.o frame.o \
 	helper.o init_task.o irq.o irq_user.o ksyms.o mem.o mem_user.o \
@@ -24,7 +24,7 @@
 user-objs-$(CONFIG_TTY_LOG) += tty_log.o
 
 USER_OBJS := $(filter %_user.o,$(obj-y))  $(user-objs-y) config.o helper.o \
-	process.o tempfile.o time.o tty_log.o umid.o user_util.o
+	process.o tempfile.o time.o tty_log.o umid.o user_util.o ../main.o
 USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
 
 CFLAGS_frame.o := $(patsubst -fomit-frame-pointer,,$(USER_CFLAGS))
Index: 2.6.8-rc4-mm1/arch/um/kernel/vmlinux.lds.S
===================================================================
--- 2.6.8-rc4-mm1.orig/arch/um/kernel/vmlinux.lds.S	2004-08-11 22:44:43.000000000 -0400
+++ 2.6.8-rc4-mm1/arch/um/kernel/vmlinux.lds.S	2004-08-11 22:44:49.000000000 -0400
@@ -42,11 +42,10 @@
 
   #include "asm/common.lds.S"
 
-  init.data : { *(init.data) }
+  .init.data : { *(init.data) }
+  .data.init_task : { *(.data.init_task) } 
   .data    :
   {
-    . = ALIGN(KERNEL_STACK_SIZE);		/* init_task */
-    *(.data.init_task)
     *(.data)
     *(.gnu.linkonce.d*)
     CONSTRUCTORS
Index: 2.6.8-rc4-mm1/arch/um/sys-i386/Makefile
===================================================================
--- 2.6.8-rc4-mm1.orig/arch/um/sys-i386/Makefile	2004-08-11 22:44:43.000000000 -0400
+++ 2.6.8-rc4-mm1/arch/um/sys-i386/Makefile	2004-08-11 22:44:49.000000000 -0400
@@ -1,5 +1,5 @@
-obj-y = bugs.o checksum.o fault.o ksyms.o ldt.o ptrace.o ptrace_user.o \
-	semaphore.o sigcontext.o syscalls.o sysrq.o time.o
+obj-y = bitops.o bugs.o checksum.o fault.o ksyms.o ldt.o ptrace.o \
+	ptrace_user.o semaphore.o sigcontext.o syscalls.o sysrq.o time.o
 
 obj-$(CONFIG_HIGHMEM) += highmem.o
 obj-$(CONFIG_MODULES) += module.o
@@ -7,11 +7,12 @@
 USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o
 USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
 
-SYMLINKS = semaphore.c highmem.c module.c
+SYMLINKS = bitops.c semaphore.c highmem.c module.c
 SYMLINKS := $(foreach f,$(SYMLINKS),$(src)/$f)
 
 clean-files := $(SYMLINKS)
 
+bitops.c-dir = lib
 semaphore.c-dir = kernel
 highmem.c-dir = mm
 module.c-dir = kernel
Index: 2.6.8-rc4-mm1/arch/um/uml.lds.S
===================================================================
--- 2.6.8-rc4-mm1.orig/arch/um/uml.lds.S	2004-08-11 22:44:43.000000000 -0400
+++ 2.6.8-rc4-mm1/arch/um/uml.lds.S	2004-08-11 22:44:49.000000000 -0400
@@ -11,15 +11,9 @@
 
   __binary_start = .;
 #ifdef MODE_TT
-  .thread_private : {
-    __start_thread_private = .;
-    errno = .;
-    . += 4;
-    arch/um/kernel/tt/unmap_fin.o (.data)
-    __end_thread_private = .;
-  }
+  .thread_private : { *(.thread_private) }
   . = ALIGN(4096);
-  .remap : { arch/um/kernel/tt/unmap_fin.o (.text) }
+  .remap : { *(.remap) }
 #endif
 
   . = ALIGN(4096);		/* Init code and data */


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build
  2004-08-12  4:14 [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build Jeff Dike
@ 2004-08-15 22:06 ` Andrew Morton
  2004-08-17  6:02   ` Jeff Dike
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Morton @ 2004-08-15 22:06 UTC (permalink / raw)
  To: Jeff Dike; +Cc: kai, sam, linux-kernel

Jeff Dike <jdike@addtoit.com> wrote:
>
> The patch below makes UML build in the face of the ldchk addition to 2.6.8.

Confused.  Your vmlinux.lds.S doesn't look anything like mine:


#include <asm-generic/vmlinux.lds.h>
	
OUTPUT_FORMAT(ELF_FORMAT)
OUTPUT_ARCH(ELF_ARCH)
ENTRY(_start)
jiffies = jiffies_64;

SECTIONS
{
#include "asm/common.lds.S"
}


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build
  2004-08-17  6:02   ` Jeff Dike
@ 2004-08-17  5:06     ` William Lee Irwin III
  2004-08-17  5:10       ` Andrew Morton
  2004-08-17  5:08     ` Andrew Morton
  2004-08-17  8:55     ` Andreas Schwab
  2 siblings, 1 reply; 14+ messages in thread
From: William Lee Irwin III @ 2004-08-17  5:06 UTC (permalink / raw)
  To: Jeff Dike; +Cc: Andrew Morton, kai, sam, linux-kernel

On Tue, Aug 17, 2004 at 02:02:21AM -0400, Jeff Dike wrote:
> The undefined symbol checking is continuing to cause UML pain.  This time,
> it picked up a bunch of 'w' symbols as undefined.  They were present in the
> 2.6.8-rc4-mm1 vmlinux and caused no problems for the final link, so I added
> them as a second special case to mksysmap (and I just noticed that I forgot
> a comment there - I can submit a patch for that if there's demand for one).

Likewise for sparc64; the 'w' symbols are showing up as 'undefined'
there too. Probably because [^w] isn't behaving as expected.


-- wli

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build
  2004-08-17  6:02   ` Jeff Dike
  2004-08-17  5:06     ` William Lee Irwin III
@ 2004-08-17  5:08     ` Andrew Morton
  2004-08-17 19:15       ` Jeff Dike
  2004-08-17  8:55     ` Andreas Schwab
  2 siblings, 1 reply; 14+ messages in thread
From: Andrew Morton @ 2004-08-17  5:08 UTC (permalink / raw)
  To: Jeff Dike; +Cc: kai, sam, linux-kernel

Jeff Dike <jdike@addtoit.com> wrote:
>
> Here is a fixed fix-build patch, against 2.6.8.1-mm1.

Thanks.  Where do we stand now with getting all this stuff merged up?  Are
the patches in -mm suitable?  Did the controversial blockdev stuff get
cleaned up? (it looks like it did...).

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build
  2004-08-17  5:06     ` William Lee Irwin III
@ 2004-08-17  5:10       ` Andrew Morton
  2004-08-17 14:45         ` Sam Ravnborg
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Morton @ 2004-08-17  5:10 UTC (permalink / raw)
  To: William Lee Irwin III; +Cc: jdike, kai, sam, linux-kernel

William Lee Irwin III <wli@holomorphy.com> wrote:
>
> On Tue, Aug 17, 2004 at 02:02:21AM -0400, Jeff Dike wrote:
> > The undefined symbol checking is continuing to cause UML pain.  This time,
> > it picked up a bunch of 'w' symbols as undefined.  They were present in the
> > 2.6.8-rc4-mm1 vmlinux and caused no problems for the final link, so I added
> > them as a second special case to mksysmap (and I just noticed that I forgot
> > a comment there - I can submit a patch for that if there's demand for one).
> 
> Likewise for sparc64; the 'w' symbols are showing up as 'undefined'
> there too. Probably because [^w] isn't behaving as expected.
> 

Sigh.  That patch is causing a ton of grief.  But Russell's reasons for
needing it on ARM were solid, and it is a bit weird for any architecture to
have undefined symbols in vmlinux.  I guess we persist.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build
  2004-08-15 22:06 ` Andrew Morton
@ 2004-08-17  6:02   ` Jeff Dike
  2004-08-17  5:06     ` William Lee Irwin III
                       ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Jeff Dike @ 2004-08-17  6:02 UTC (permalink / raw)
  To: Andrew Morton; +Cc: kai, sam, linux-kernel

akpm@osdl.org said:
> Confused.  

So was I for a while :-)

> Your vmlinux.lds.S doesn't look anything like mine: 

My apologies.  A combination of a mashed stock tree and some quilt lossage
at my end caused some bogus patches and let them pass my sanity tests.

Here is a fixed fix-build patch, against 2.6.8.1-mm1.

The undefined symbol checking is continuing to cause UML pain.  This time,
it picked up a bunch of 'w' symbols as undefined.  They were present in the
2.6.8-rc4-mm1 vmlinux and caused no problems for the final link, so I added
them as a second special case to mksysmap (and I just noticed that I forgot
a comment there - I can submit a patch for that if there's demand for one).

				Jeff

Index: test/Makefile
===================================================================
--- test.orig/Makefile	2004-08-17 00:37:33.000000000 -0400
+++ test/Makefile	2004-08-17 00:38:20.000000000 -0400
@@ -523,6 +523,7 @@
 	$(drivers-y) \
 	$(net-y) \
 	--end-group \
+	$(post-y) \
 	$(filter .tmp_kallsyms%,$^) \
 	-o $@
 endef
Index: test/arch/um/Makefile
===================================================================
--- test.orig/arch/um/Makefile	2004-08-17 00:37:33.000000000 -0400
+++ test/arch/um/Makefile	2004-08-17 00:38:20.000000000 -0400
@@ -21,6 +21,10 @@
 			   $(ARCH_DIR)/drivers/          \
 			   $(ARCH_DIR)/sys-$(SUBARCH)/
 
+post-y			= --wrap malloc --wrap free --wrap calloc \
+			  $(ARCH_DIR)/main.o -lutil \
+			  --start-group -lgcc -lgcc_eh -lc --end-group
+
 # Have to precede the include because the included Makefiles reference them.
 SYMLINK_HEADERS = archparam.h system.h sigcontext.h processor.h ptrace.h \
 	arch-signal.h module.h
@@ -84,7 +88,10 @@
 
 prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS)
 
-LDFLAGS_vmlinux = -r
+# This stupidity extracts the directory in which gcc lives so that it can
+# be fed to ld when it's linking .tmp_vmlinux during the ldchk stage.
+LD_DIR = $(shell dirname `gcc -v 2>&1 | head -1 | awk '{print $$NF}'`)
+LDFLAGS_vmlinux = -L/usr/lib -L$(LD_DIR) -r
 
 vmlinux: $(ARCH_DIR)/main.o 
 
@@ -117,17 +124,28 @@
 	-DSTART=$$(($(TOP_ADDR) - $(SIZE))) -DELF_ARCH=$(ELF_ARCH) \
 	-DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE_TT) \
 	-DKERNEL_STACK_SIZE=$(STACK_SIZE))
+CPPFLAGS_$(LD_SCRIPT-y) = $(CPPFLAGS_vmlinux.lds) -P -C -Uum
 
-export CPPFLAGS_$(LD_SCRIPT-y) = $(CPPFLAGS_vmlinux.lds) -P -C -Uum
+export CPPFLAGS_$(LD_SCRIPT-y)
 
 LD_SCRIPT-y := $(ARCH_DIR)/$(LD_SCRIPT-y)
 
-#$(LD_SCRIPT-y) : $(LD_SCRIPT-y:.s=.S) scripts FORCE
-#	$(call if_changed_dep,as_s_S)
+# More kbuild lossage - I can't get uml.lds to fire the %.lds : %.lds.S rule.
+# It always ends up going into the .S assembly rule.  So, an explicit rule
+# here works around that.  Then, it turns out that cmd_cpp_lds_S is undefined,
+# which I don't understand since I would have thought that the entire Makefile
+# had been read by the time it executes commands.  So, defining that here works
+# around that.  Then, it turns out that cpp_flags isn't defined, which I don't
+# understand for the same reason.  So, I just included the expansion here,
+# and after much grossness, you get a building and working UML.
+quiet_cmd_cpp_lds_S = LDS     $@
+      cmd_cpp_lds_S = $(CPP) -Wp,-MD,$(depfile) -Iinclude $(CPPFLAGS_vmlinux.lds) -P -C -Uum $(NOSTDINC_FLAGS) -D__ASSEMBLY__ -o $@ $<
+
+$(LD_SCRIPT-y) : $(LD_SCRIPT-y).S scripts FORCE
+	$(call if_changed_dep,cpp_lds_S)
 
 linux: vmlinux $(LD_SCRIPT-y)
-	$(CC) -Wl,-T,$(LD_SCRIPT-y) $(LINK-y) $(LINK_WRAPS) \
-		-o linux $(ARCH_DIR)/main.o vmlinux -L/usr/lib -lutil
+	$(CC) -Wl,-T,$(LD_SCRIPT-y) $(LINK-y) -o linux vmlinux
 
 USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
 USER_CFLAGS := $(patsubst -Derrno=kernel_errno,,$(USER_CFLAGS))
Index: test/arch/um/kernel/Makefile
===================================================================
--- test.orig/arch/um/kernel/Makefile	2004-08-17 00:37:33.000000000 -0400
+++ test/arch/um/kernel/Makefile	2004-08-17 00:38:20.000000000 -0400
@@ -3,7 +3,7 @@
 # Licensed under the GPL
 #
 
-extra-y := vmlinux.lds
+extra-y := vmlinux.lds ../main.o
 
 obj-y = checksum.o config.o exec_kern.o exitcode.o frame_kern.o frame.o \
 	helper.o init_task.o irq.o irq_user.o ksyms.o mem.o mem_user.o \
@@ -24,7 +24,7 @@
 user-objs-$(CONFIG_TTY_LOG) += tty_log.o
 
 USER_OBJS := $(filter %_user.o,$(obj-y))  $(user-objs-y) config.o helper.o \
-	process.o tempfile.o time.o tty_log.o umid.o user_util.o
+	process.o tempfile.o time.o tty_log.o umid.o user_util.o ../main.o
 USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
 
 CFLAGS_frame.o := $(patsubst -fomit-frame-pointer,,$(USER_CFLAGS))
Index: test/arch/um/kernel/vmlinux.lds.S
===================================================================
--- test.orig/arch/um/kernel/vmlinux.lds.S	2004-06-16 01:18:37.000000000 -0400
+++ test/arch/um/kernel/vmlinux.lds.S	2004-08-17 00:38:20.000000000 -0400
@@ -7,5 +7,89 @@
 
 SECTIONS
 {
-#include "asm/common.lds.S"
+  . = START + SIZEOF_HEADERS;
+
+  __binary_start = .;
+#ifdef MODE_TT
+  .thread_private : {
+    __start_thread_private = .;
+    errno = .;
+    . += 4;
+    arch/um/kernel/tt/unmap_fin.o (.data)
+    __end_thread_private = .;
+  }
+  . = ALIGN(4096);
+  .remap : { arch/um/kernel/tt/unmap_fin.o (.text) }
+#endif
+
+  . = ALIGN(4096);		/* Init code and data */
+  _stext = .;
+  __init_begin = .;
+  .init.text : {
+	_sinittext = .;
+	*(.init.text)
+	_einittext = .;
+  }
+  . = ALIGN(4096);
+  .text      :
+  {
+    *(.text)
+    SCHED_TEXT
+    /* .gnu.warning sections are handled specially by elf32.em.  */
+    *(.gnu.warning)
+    *(.gnu.linkonce.t*)
+  }
+
+  #include "asm/common.lds.S"
+
+  .init.data : { *(init.data) }
+  .data.init_task : { *(.data.init_task) } 
+  .data    :
+  {
+    *(.data)
+    *(.gnu.linkonce.d*)
+    CONSTRUCTORS
+  }
+  .data1   : { *(.data1) }
+  .ctors         :
+  {
+    *(.ctors)
+  }
+  .dtors         :
+  {
+    *(.dtors)
+  }
+
+  .got           : { *(.got.plt) *(.got) }
+  .dynamic       : { *(.dynamic) }
+  /* We want the small data sections together, so single-instruction offsets
+     can access them all, and initialized data all before uninitialized, so
+     we can shorten the on-disk segment size.  */
+  .sdata     : { *(.sdata) }
+  _edata  =  .;
+  PROVIDE (edata = .);
+  . = ALIGN(0x1000);
+  .sbss      : 
+  {
+   __bss_start = .;
+   PROVIDE(_bss_start = .);
+   *(.sbss) 
+   *(.scommon) 
+  }
+  .bss       :
+  {
+   *(.dynbss)
+   *(.bss)
+   *(COMMON)
+  }
+  _end = . ;
+  PROVIDE (end = .);
+  /* Stabs debugging sections.  */
+  .stab 0 : { *(.stab) }
+  .stabstr 0 : { *(.stabstr) }
+  .stab.excl 0 : { *(.stab.excl) }
+  .stab.exclstr 0 : { *(.stab.exclstr) }
+  .stab.index 0 : { *(.stab.index) }
+  .stab.indexstr 0 : { *(.stab.indexstr) }
+  .comment 0 : { *(.comment) }
 }
Index: test/arch/um/sys-i386/Makefile
===================================================================
--- test.orig/arch/um/sys-i386/Makefile	2004-08-17 00:37:33.000000000 -0400
+++ test/arch/um/sys-i386/Makefile	2004-08-17 00:38:20.000000000 -0400
@@ -1,5 +1,5 @@
-obj-y = bugs.o checksum.o fault.o ksyms.o ldt.o ptrace.o ptrace_user.o \
-	semaphore.o sigcontext.o syscalls.o sysrq.o time.o
+obj-y = bitops.o bugs.o checksum.o fault.o ksyms.o ldt.o ptrace.o \
+	ptrace_user.o semaphore.o sigcontext.o syscalls.o sysrq.o time.o
 
 obj-$(CONFIG_HIGHMEM) += highmem.o
 obj-$(CONFIG_MODULES) += module.o
@@ -7,11 +7,12 @@
 USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o
 USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
 
-SYMLINKS = semaphore.c highmem.c module.c
+SYMLINKS = bitops.c semaphore.c highmem.c module.c
 SYMLINKS := $(foreach f,$(SYMLINKS),$(src)/$f)
 
 clean-files := $(SYMLINKS)
 
+bitops.c-dir = lib
 semaphore.c-dir = kernel
 highmem.c-dir = mm
 module.c-dir = kernel
Index: test/arch/um/uml.lds.S
===================================================================
--- test.orig/arch/um/uml.lds.S	2004-08-17 00:37:33.000000000 -0400
+++ test/arch/um/uml.lds.S	2004-08-17 00:38:20.000000000 -0400
@@ -11,15 +11,9 @@
 
   __binary_start = .;
 #ifdef MODE_TT
-  .thread_private : {
-    __start_thread_private = .;
-    errno = .;
-    . += 4;
-    arch/um/kernel/tt/unmap_fin.o (.data)
-    __end_thread_private = .;
-  }
+  .thread_private : { *(.thread_private) }
   . = ALIGN(4096);
-  .remap : { arch/um/kernel/tt/unmap_fin.o (.text) }
+  .remap : { *(.remap) }
 #endif
 
   . = ALIGN(4096);		/* Init code and data */
Index: test/scripts/mksysmap
===================================================================
--- test.orig/scripts/mksysmap	2004-08-17 00:37:45.000000000 -0400
+++ test/scripts/mksysmap	2004-08-17 00:38:20.000000000 -0400
@@ -18,7 +18,7 @@
 # they are used by the sparc BTFIXUP logic - and is assumed to be undefined.
 
 
-if [ "`$NM -u $1 | grep -v ' ___'`" != "" ]; then
+if [ "`$NM -u $1 | grep -v '\( ___\)\|\(^ *w \)'`" != "" ]; then
 	echo "$1: error: undefined symbol(s) found:"
 	$NM -u $1 | grep -v ' ___'
 	exit 1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build
  2004-08-17  6:02   ` Jeff Dike
  2004-08-17  5:06     ` William Lee Irwin III
  2004-08-17  5:08     ` Andrew Morton
@ 2004-08-17  8:55     ` Andreas Schwab
  2004-08-17 18:17       ` Jeff Dike
  2 siblings, 1 reply; 14+ messages in thread
From: Andreas Schwab @ 2004-08-17  8:55 UTC (permalink / raw)
  To: Jeff Dike; +Cc: Andrew Morton, kai, sam, linux-kernel

Jeff Dike <jdike@addtoit.com> writes:

> @@ -84,7 +88,10 @@
>  
>  prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS)
>  
> -LDFLAGS_vmlinux = -r
> +# This stupidity extracts the directory in which gcc lives so that it can
> +# be fed to ld when it's linking .tmp_vmlinux during the ldchk stage.
> +LD_DIR = $(shell dirname `gcc -v 2>&1 | head -1 | awk '{print $$NF}'`)

Try gcc -print-search-dirs.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build
  2004-08-17 14:45         ` Sam Ravnborg
@ 2004-08-17 12:51           ` Russell King
  0 siblings, 0 replies; 14+ messages in thread
From: Russell King @ 2004-08-17 12:51 UTC (permalink / raw)
  To: Andrew Morton, William Lee Irwin III, jdike, kai, sam,
	linux-kernel

On Tue, Aug 17, 2004 at 04:45:27PM +0200, Sam Ravnborg wrote:
> On Mon, Aug 16, 2004 at 10:10:17PM -0700, Andrew Morton wrote:
> > William Lee Irwin III <wli@holomorphy.com> wrote:
> > >
> > > On Tue, Aug 17, 2004 at 02:02:21AM -0400, Jeff Dike wrote:
> > > > The undefined symbol checking is continuing to cause UML pain.  This time,
> > > > it picked up a bunch of 'w' symbols as undefined.  They were present in the
> > > > 2.6.8-rc4-mm1 vmlinux and caused no problems for the final link, so I added
> > > > them as a second special case to mksysmap (and I just noticed that I forgot
> > > > a comment there - I can submit a patch for that if there's demand for one).
> > > 
> > > Likewise for sparc64; the 'w' symbols are showing up as 'undefined'
> > > there too. Probably because [^w] isn't behaving as expected.
> > > 
> > 
> > Sigh.  That patch is causing a ton of grief.  But Russell's reasons for
> > needing it on ARM were solid, and it is a bit weird for any architecture to
> > have undefined symbols in vmlinux.  I guess we persist.
> Please note that the functionality is moved to scripts/mksysmap,
> so Russell's original ldchk needs to be backed out.

I'm hopeful that the next release of binutils (any ideas when that'll
be?) should resolve the various problems I've found.

At that point, I think we should consider whether to keep the check
(for possible problems in the future) and/or prevent older ARM
binutils building the kernel.  That depends whether forcing all ARM
people to use the latest and greatest binutils (which may have other
issues) is really the best plan...

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build
  2004-08-17  5:10       ` Andrew Morton
@ 2004-08-17 14:45         ` Sam Ravnborg
  2004-08-17 12:51           ` Russell King
  0 siblings, 1 reply; 14+ messages in thread
From: Sam Ravnborg @ 2004-08-17 14:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: William Lee Irwin III, jdike, kai, sam, linux-kernel

On Mon, Aug 16, 2004 at 10:10:17PM -0700, Andrew Morton wrote:
> William Lee Irwin III <wli@holomorphy.com> wrote:
> >
> > On Tue, Aug 17, 2004 at 02:02:21AM -0400, Jeff Dike wrote:
> > > The undefined symbol checking is continuing to cause UML pain.  This time,
> > > it picked up a bunch of 'w' symbols as undefined.  They were present in the
> > > 2.6.8-rc4-mm1 vmlinux and caused no problems for the final link, so I added
> > > them as a second special case to mksysmap (and I just noticed that I forgot
> > > a comment there - I can submit a patch for that if there's demand for one).
> > 
> > Likewise for sparc64; the 'w' symbols are showing up as 'undefined'
> > there too. Probably because [^w] isn't behaving as expected.
> > 
> 
> Sigh.  That patch is causing a ton of grief.  But Russell's reasons for
> needing it on ARM were solid, and it is a bit weird for any architecture to
> have undefined symbols in vmlinux.  I guess we persist.
Please note that the functionality is moved to scripts/mksysmap,
so Russell's original ldchk needs to be backed out.

	Sam

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build
  2004-08-17  8:55     ` Andreas Schwab
@ 2004-08-17 18:17       ` Jeff Dike
  0 siblings, 0 replies; 14+ messages in thread
From: Jeff Dike @ 2004-08-17 18:17 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Andrew Morton, kai, sam, linux-kernel

schwab@suse.de said:
> Try gcc -print-search-dirs. 

Ah, excellent, thanks very much.  I had looked around gcc's info, but I missed
that.

				Jeff


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build
  2004-08-17 19:15       ` Jeff Dike
@ 2004-08-17 18:26         ` Andrew Morton
  2004-08-18  2:58           ` Jeff Dike
  2004-08-18 18:28           ` Chris Wedgwood
  0 siblings, 2 replies; 14+ messages in thread
From: Andrew Morton @ 2004-08-17 18:26 UTC (permalink / raw)
  To: Jeff Dike; +Cc: linux-kernel

Jeff Dike <jdike@addtoit.com> wrote:
>
>  akpm@osdl.org said:
>  > Thanks.  Where do we stand now with getting all this stuff merged up?
>  > Are the patches in -mm suitable?  Did the controversial blockdev stuff
>  > get cleaned up? (it looks like it did...). 
> 
>  Not really, the code is still there but it's not built.  Below is a patch
>  which removes it totally.

Thanks.

>  I also have to get rid of ghash.h and fix some inappropriate intimacy between
>  one of the drivers and VFS.

OK.

>  I'd also wouldn't mind breaking up the big UML patch into somewhat more sane 
>  pieces.  Can I do something like break pieces off it, send them plus the 
>  smaller big patch, and have you subsititute them for the current big patch?

Feel free if you think there's some benefit in that.

>  Is that preferable to dropping the current patches on Linus, or would you
>  rather send him what you have, in more or less its current form, once it's
>  been tidied up?

Frankly, when a subsystem gets this far out of date I don't think it
matters a lot - nobody has much hope of following all the changes anyway. 
We'll just merge the megapatch on the assumption that Jeff knows what he's
doing, and that it's better than what we had before.  You should have seen
the size of some of those MIPS patches ;)


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build
  2004-08-17  5:08     ` Andrew Morton
@ 2004-08-17 19:15       ` Jeff Dike
  2004-08-17 18:26         ` Andrew Morton
  0 siblings, 1 reply; 14+ messages in thread
From: Jeff Dike @ 2004-08-17 19:15 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

akpm@osdl.org said:
> Thanks.  Where do we stand now with getting all this stuff merged up?
> Are the patches in -mm suitable?  Did the controversial blockdev stuff
> get cleaned up? (it looks like it did...). 

Not really, the code is still there but it's not built.  Below is a patch
which removes it totally.

I also have to get rid of ghash.h and fix some inappropriate intimacy between
one of the drivers and VFS.

I'd also wouldn't mind breaking up the big UML patch into somewhat more sane 
pieces.  Can I do something like break pieces off it, send them plus the 
smaller big patch, and have you subsititute them for the current big patch?

Is that preferable to dropping the current patches on Linus, or would you
rather send him what you have, in more or less its current form, once it's
been tidied up?

				Jeff

Index: 2.6.8.1-mm1/arch/um/Kconfig_block
===================================================================
--- 2.6.8.1-mm1.orig/arch/um/Kconfig_block	2004-08-17 13:48:15.000000000 -0400
+++ 2.6.8.1-mm1/arch/um/Kconfig_block	2004-08-17 13:48:19.000000000 -0400
@@ -29,19 +29,9 @@
         wise choice too.  In all other cases (for example, if you're just
         playing around with User-Mode Linux) you can choose N.
 
-# Turn this back on when the driver actually works
-#
-#config BLK_DEV_COW
-#	tristate "COW block device"
-#	help
-#	This is a layered driver which sits above two other block devices.
-#	One is read-only, and the other is a read-write layer which stores
-#	all changes.  This provides the illusion that the read-only layer
-#	can be mounted read-write and changed.
-
 config BLK_DEV_COW_COMMON
 	bool
-	default BLK_DEV_COW || BLK_DEV_UBD
+	default BLK_DEV_UBD
 
 config BLK_DEV_LOOP
 	tristate "Loopback device support"
Index: 2.6.8.1-mm1/arch/um/drivers/Makefile
===================================================================
--- 2.6.8.1-mm1.orig/arch/um/drivers/Makefile	2004-08-17 00:09:30.000000000 -0400
+++ 2.6.8.1-mm1/arch/um/drivers/Makefile	2004-08-17 13:48:52.000000000 -0400
@@ -39,7 +39,6 @@
 obj-$(CONFIG_TTY_CHAN) += tty.o 
 obj-$(CONFIG_XTERM_CHAN) += xterm.o xterm_kern.o
 obj-$(CONFIG_UML_WATCHDOG) += harddog.o
-obj-$(CONFIG_BLK_DEV_COW) += cow_kern.o
 obj-$(CONFIG_BLK_DEV_COW_COMMON) += cow_user.o
 
 obj-y += stdio_console.o $(CHAN_OBJS)
Index: 2.6.8.1-mm1/arch/um/drivers/cow_kern.c
===================================================================
--- 2.6.8.1-mm1.orig/arch/um/drivers/cow_kern.c	2004-08-17 00:09:30.000000000 -0400
+++ 2.6.8.1-mm1/arch/um/drivers/cow_kern.c	2003-09-15 09:40:47.000000000 -0400
@@ -1,630 +0,0 @@
-#define COW_MAJOR 60
-#define MAJOR_NR COW_MAJOR
-
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/ctype.h>
-#include <linux/stat.h>
-#include <linux/vmalloc.h>
-#include <linux/blkdev.h>
-#include <linux/blk.h>
-#include <linux/fs.h>
-#include <linux/genhd.h>
-#include <linux/devfs_fs.h>
-#include <asm/uaccess.h>
-#include "2_5compat.h"
-#include "cow.h"
-#include "ubd_user.h"
-
-#define COW_SHIFT 4
-
-struct cow {
-	int count;
-	char *cow_path;
-	dev_t cow_dev;
-	struct block_device *cow_bdev;
-	char *backing_path;
-	dev_t backing_dev;
-	struct block_device *backing_bdev;
-	int sectorsize;
-	unsigned long *bitmap;
-	unsigned long bitmap_len;
-	int bitmap_offset;
-	int data_offset;
-	devfs_handle_t devfs;
-	struct semaphore sem;
-	struct semaphore io_sem;
-	atomic_t working;
-	spinlock_t io_lock;
-	struct buffer_head *bh;
-	struct buffer_head *bhtail;
-	void *end_io;
-};
-
-#define DEFAULT_COW { \
-	.count			= 0, \
-	.cow_path		= NULL, \
-	.cow_dev		= 0, \
-	.backing_path		= NULL, \
-	.backing_dev		= 0, \
-        .bitmap			= NULL, \
-	.bitmap_len		= 0, \
-	.bitmap_offset		= 0, \
-        .data_offset		= 0, \
-	.devfs			= NULL, \
-	.working		= ATOMIC_INIT(0), \
-	.io_lock		= SPIN_LOCK_UNLOCKED, \
-}
-
-#define MAX_DEV (8)
-#define MAX_MINOR (MAX_DEV << COW_SHIFT)
-
-struct cow cow_dev[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_COW };
-
-/* Not modified by this driver */
-static int blk_sizes[MAX_MINOR] = { [ 0 ... MAX_MINOR - 1 ] = BLOCK_SIZE };
-static int hardsect_sizes[MAX_MINOR] = { [ 0 ... MAX_MINOR - 1 ] = 512 };
-
-/* Protected by cow_lock */
-static int sizes[MAX_MINOR] = { [ 0 ... MAX_MINOR - 1 ] = 0 };
-
-static struct hd_struct	cow_part[MAX_MINOR] =
-	{ [ 0 ... MAX_MINOR - 1 ] = { 0, 0, 0 } };
-
-/* Protected by io_request_lock */
-static request_queue_t *cow_queue;
-
-static int cow_open(struct inode *inode, struct file *filp);
-static int cow_release(struct inode * inode, struct file * file);
-static int cow_ioctl(struct inode * inode, struct file * file,
-		     unsigned int cmd, unsigned long arg);
-static int cow_revalidate(kdev_t rdev);
-
-static struct block_device_operations cow_blops = {
-	.open		= cow_open,
-	.release	= cow_release,
-	.ioctl		= cow_ioctl,
-	.revalidate	= cow_revalidate,
-};
-
-/* Initialized in an initcall, and unchanged thereafter */
-devfs_handle_t cow_dir_handle;
-
-#define INIT_GENDISK(maj, name, parts, shift, bsizes, max, blops) \
-{ \
-	.major 		= maj, \
-	.major_name  	= name, \
-	.minor_shift 	= shift, \
-	.max_p  	= 1 << shift, \
-	.part  		= parts, \
-	.sizes  	= bsizes, \
-	.nr_real  	= max, \
-	.real_devices  	= NULL, \
-	.next  		= NULL, \
-	.fops  		= blops, \
-	.de_arr  	= NULL, \
-	.flags  	= 0 \
-}
-
-static spinlock_t cow_lock = SPIN_LOCK_UNLOCKED;
-
-static struct gendisk cow_gendisk = INIT_GENDISK(MAJOR_NR, "cow", cow_part,
-						 COW_SHIFT, sizes, MAX_DEV,
-						 &cow_blops);
-
-static int cow_add(int n)
-{
-	struct cow *dev = &cow_dev[n];
-	char name[sizeof("nnnnnn\0")];
-	int err = -ENODEV;
-
-	if(dev->cow_path == NULL)
-		goto out;
-
-	sprintf(name, "%d", n);
-	dev->devfs = devfs_register(cow_dir_handle, name, DEVFS_FL_REMOVABLE,
-				    MAJOR_NR, n << COW_SHIFT, S_IFBLK |
-				    S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-				    &cow_blops, NULL);
-
-	init_MUTEX_LOCKED(&dev->sem);
-	init_MUTEX(&dev->io_sem);
-
-	return(0);
-
- out:
-	return(err);
-}
-
-/*
- * Add buffer_head to back of pending list
- */
-static void cow_add_bh(struct cow *cow, struct buffer_head *bh)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&cow->io_lock, flags);
-	if(cow->bhtail != NULL){
-		cow->bhtail->b_reqnext = bh;
-		cow->bhtail = bh;
-	}
-	else {
-		cow->bh = bh;
-		cow->bhtail = bh;
-	}
-	spin_unlock_irqrestore(&cow->io_lock, flags);
-}
-
-/*
-* Grab first pending buffer
-*/
-static struct buffer_head *cow_get_bh(struct cow *cow)
-{
-	struct buffer_head *bh;
-
-	spin_lock_irq(&cow->io_lock);
-	bh = cow->bh;
-	if(bh != NULL){
-		if(bh == cow->bhtail)
-			cow->bhtail = NULL;
-		cow->bh = bh->b_reqnext;
-		bh->b_reqnext = NULL;
-	}
-	spin_unlock_irq(&cow->io_lock);
-
-	return(bh);
-}
-
-static void cow_handle_bh(struct cow *cow, struct buffer_head *bh,
-			  struct buffer_head **cow_bh, int ncow_bh)
-{
-	int i;
-
-	if(ncow_bh > 0)
-		ll_rw_block(WRITE, ncow_bh, cow_bh);
-
-	for(i = 0; i < ncow_bh ; i++){
-		wait_on_buffer(cow_bh[i]);
-		brelse(cow_bh[i]);
-	}
-
-	ll_rw_block(WRITE, 1, &bh);
-	brelse(bh);
-}
-
-static struct buffer_head *cow_new_bh(struct cow *dev, int sector)
-{
-	struct buffer_head *bh;
-
-	sector = (dev->bitmap_offset + sector / 8) / dev->sectorsize;
-	bh = getblk(dev->cow_dev, sector, dev->sectorsize);
-	memcpy(bh->b_data, dev->bitmap + sector / (8 * sizeof(dev->bitmap[0])),
-	       dev->sectorsize);
-	return(bh);
-}
-
-/* Copied from loop.c, needed to avoid deadlocking in make_request. */
-
-static int cow_thread(void *data)
-{
-	struct cow *dev = data;
-	struct buffer_head *bh;
-
-	daemonize();
-	exit_files(current);
-
-	sprintf(current->comm, "cow%d", dev - cow_dev);
-
-	spin_lock_irq(&current->sigmask_lock);
-	sigfillset(&current->blocked);
-	flush_signals(current);
-	spin_unlock_irq(&current->sigmask_lock);
-
-	atomic_inc(&dev->working);
-
-	current->policy = SCHED_OTHER;
-	current->nice = -20;
-
-	current->flags |= PF_NOIO;
-
-	/*
-	 * up sem, we are running
-	 */
-	up(&dev->sem);
-
-	for(;;){
-		int start, len, nbh, i, update_bitmap = 0;
-		struct buffer_head *cow_bh[2];
-
-		down_interruptible(&dev->io_sem);
-		/*
-		 * could be upped because of tear-down, not because of
-		 * pending work
-		 */
-		if(!atomic_read(&dev->working))
-			break;
-
-		bh = cow_get_bh(dev);
-		if(bh == NULL){
-			printk(KERN_ERR "cow: missing bh\n");
-			continue;
-		}
-
-		start = bh->b_blocknr * bh->b_size / dev->sectorsize;
-		len = bh->b_size / dev->sectorsize;
-		for(i = 0; i < len ; i++){
-			if(ubd_test_bit(start + i,
-					(unsigned char *) dev->bitmap))
-				continue;
-
-			update_bitmap = 1;
-			ubd_set_bit(start + i, (unsigned char *) dev->bitmap);
-		}
-
-		cow_bh[0] = NULL;
-		cow_bh[1] = NULL;
-		nbh = 0;
-		if(update_bitmap){
-			cow_bh[0] = cow_new_bh(dev, start);
-			nbh++;
-			if(start / dev->sectorsize !=
-			   (start + len) / dev->sectorsize){
-				cow_bh[1] = cow_new_bh(dev, start + len);
-				nbh++;
-			}
-		}
-
-		bh->b_dev = dev->cow_dev;
-		bh->b_blocknr += dev->data_offset / dev->sectorsize;
-
-		cow_handle_bh(dev, bh, cow_bh, nbh);
-
-		/*
-		 * upped both for pending work and tear-down, lo_pending
-		 * will hit zero then
-		 */
-		if(atomic_dec_and_test(&dev->working))
-			break;
-	}
-
-	up(&dev->sem);
-	return(0);
-}
-
-static int cow_make_request(request_queue_t *q, int rw, struct buffer_head *bh)
-{
-	struct cow *dev;
-	int n, minor;
-
-	minor = MINOR(bh->b_rdev);
-	n = minor >> COW_SHIFT;
-	dev = &cow_dev[n];
-
-	dev->end_io = NULL;
-	if(ubd_test_bit(bh->b_rsector, (unsigned char *) dev->bitmap)){
-		bh->b_rdev = dev->cow_dev;
-		bh->b_rsector += dev->data_offset / dev->sectorsize;
-	}
-	else if(rw == WRITE){
-		bh->b_dev = dev->cow_dev;
-		bh->b_blocknr += dev->data_offset / dev->sectorsize;
-
-		cow_add_bh(dev, bh);
-		up(&dev->io_sem);
-		return(0);
-	}
-	else {
-		bh->b_rdev = dev->backing_dev;
-	}
-
-	return(1);
-}
-
-int cow_init(void)
-{
-	int i;
-
-	cow_dir_handle = devfs_mk_dir (NULL, "cow", NULL);
-	if (devfs_register_blkdev(MAJOR_NR, "cow", &cow_blops)) {
-		printk(KERN_ERR "cow: unable to get major %d\n", MAJOR_NR);
-		return -1;
-	}
-	read_ahead[MAJOR_NR] = 8;		/* 8 sector (4kB) read-ahead */
-	blksize_size[MAJOR_NR] = blk_sizes;
-	blk_size[MAJOR_NR] = sizes;
-	INIT_HARDSECT(hardsect_size, MAJOR_NR, hardsect_sizes);
-
-	cow_queue = BLK_DEFAULT_QUEUE(MAJOR_NR);
-	blk_init_queue(cow_queue, NULL);
-	INIT_ELV(cow_queue, &cow_queue->elevator);
-	blk_queue_make_request(cow_queue, cow_make_request);
-
-	add_gendisk(&cow_gendisk);
-
-	for(i=0;i<MAX_DEV;i++)
-		cow_add(i);
-
-	return(0);
-}
-
-__initcall(cow_init);
-
-static int reader(__u64 start, char *buf, int count, void *arg)
-{
-	dev_t dev = *((dev_t *) arg);
-	struct buffer_head *bh;
-	__u64 block;
-	int cur, offset, left, n, blocksize = get_hardsect_size(dev);
-
-	if(blocksize == 0)
-		panic("Zero blocksize");
-
-	block = start / blocksize;
-	offset = start % blocksize;
-	left = count;
-	cur = 0;
-	while(left > 0){
-		n = (left > blocksize) ? blocksize : left;
-
-		bh = bread(dev, block, (n < 512) ? 512 : n);
-		if(bh == NULL)
-			return(-EIO);
-
-		n -= offset;
-		memcpy(&buf[cur], bh->b_data + offset, n);
-		block++;
-		left -= n;
-		cur += n;
-		offset = 0;
-		brelse(bh);
-	}
-
-	return(count);
-}
-
-static int cow_open(struct inode *inode, struct file *filp)
-{
-	int (*dev_ioctl)(struct inode *, struct file *, unsigned int,
-			 unsigned long);
-	mm_segment_t fs;
-	struct cow *dev;
-	__u64 size;
-	__u32 version, align;
-	time_t mtime;
-	char *backing_file;
-	int n, offset, err = 0;
-
-	n = DEVICE_NR(inode->i_rdev);
-	if(n >= MAX_DEV)
-		return(-ENODEV);
-	dev = &cow_dev[n];
-	offset = n << COW_SHIFT;
-
-	spin_lock(&cow_lock);
-
-	if(dev->count == 0){
-		dev->cow_dev = name_to_kdev_t(dev->cow_path);
-		if(dev->cow_dev == 0){
-			printk(KERN_ERR "cow_open - name_to_kdev_t(\"%s\") "
-			       "failed\n", dev->cow_path);
-			err = -ENODEV;
-		}
-
-		dev->backing_dev = name_to_kdev_t(dev->backing_path);
-		if(dev->backing_dev == 0){
-			printk(KERN_ERR "cow_open - name_to_kdev_t(\"%s\") "
-			       "failed\n", dev->backing_path);
-			err = -ENODEV;
-		}
-
-		if(err)
-			goto out;
-
-		dev->cow_bdev = bdget(dev->cow_dev);
-		if(dev->cow_bdev == NULL){
-			printk(KERN_ERR "cow_open - bdget(\"%s\") failed\n",
-			       dev->cow_path);
-			err = -ENOMEM;
-		}
-		dev->backing_bdev = bdget(dev->backing_dev);
-		if(dev->backing_bdev == NULL){
-			printk(KERN_ERR "cow_open - bdget(\"%s\") failed\n",
-			       dev->backing_path);
-			err = -ENOMEM;
-		}
-
-		if(err)
-			goto out;
-
-		err = blkdev_get(dev->cow_bdev, FMODE_READ|FMODE_WRITE, 0,
-				 BDEV_RAW);
-		if(err){
-			printk("cow_open - blkdev_get of COW device failed, "
-			       "error = %d\n", err);
-			goto out;
-		}
-
-		err = blkdev_get(dev->backing_bdev, FMODE_READ, 0, BDEV_RAW);
-		if(err){
-			printk("cow_open - blkdev_get of backing device "
-			       "failed, error = %d\n", err);
-			goto out;
-		}
-
-		err = read_cow_header(reader, &dev->cow_dev, &version,
-				      &backing_file, &mtime, &size,
-				      &dev->sectorsize, &align,
-				      &dev->bitmap_offset);
-		if(err){
-			printk(KERN_ERR "cow_open - read_cow_header failed, "
-			       "err = %d\n", err);
-			goto out;
-		}
-
-		cow_sizes(version, size, dev->sectorsize, align,
-			  dev->bitmap_offset, &dev->bitmap_len,
-			  &dev->data_offset);
-		dev->bitmap = (void *) vmalloc(dev->bitmap_len);
-		if(dev->bitmap == NULL){
-			err = -ENOMEM;
-			printk(KERN_ERR "Failed to vmalloc COW bitmap\n");
-			goto out;
-		}
-		flush_tlb_kernel_vm();
-
-		err = reader(dev->bitmap_offset, (char *) dev->bitmap,
-			     dev->bitmap_len, &dev->cow_dev);
-		if(err < 0){
-			printk(KERN_ERR "Failed to read COW bitmap\n");
-			vfree(dev->bitmap);
-			goto out;
-		}
-
-		dev_ioctl = dev->backing_bdev->bd_op->ioctl;
-		fs = get_fs();
-		set_fs(KERNEL_DS);
-		err = (*dev_ioctl)(inode, filp, BLKGETSIZE,
-				   (unsigned long) &sizes[offset]);
-		set_fs(fs);
-		if(err){
-			printk(KERN_ERR "cow_open - BLKGETSIZE failed, "
-			       "error = %d\n", err);
-			goto out;
-		}
-
-		kernel_thread(cow_thread, dev,
-			      CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
-		down(&dev->sem);
-	}
-	dev->count++;
- out:
-	spin_unlock(&cow_lock);
-	return(err);
-}
-
-static int cow_release(struct inode * inode, struct file * file)
-{
-	struct cow *dev;
-	int n, err;
-
-	n = DEVICE_NR(inode->i_rdev);
-	if(n >= MAX_DEV)
-		return(-ENODEV);
-	dev = &cow_dev[n];
-
-	spin_lock(&cow_lock);
-
-	if(--dev->count > 0)
-		goto out;
-
-	err = blkdev_put(dev->cow_bdev, BDEV_RAW);
-	if(err)
-		printk("cow_release - blkdev_put of cow device failed, "
-		       "error = %d\n", err);
-	bdput(dev->cow_bdev);
-	dev->cow_bdev = 0;
-
-	err = blkdev_put(dev->backing_bdev, BDEV_RAW);
-	if(err)
-		printk("cow_release - blkdev_put of backing device failed, "
-		       "error = %d\n", err);
-	bdput(dev->backing_bdev);
-	dev->backing_bdev = 0;
-
- out:
-	spin_unlock(&cow_lock);
-	return(0);
-}
-
-static int cow_ioctl(struct inode * inode, struct file * file,
-		     unsigned int cmd, unsigned long arg)
-{
-	struct cow *dev;
-	int (*dev_ioctl)(struct inode *, struct file *, unsigned int,
-			 unsigned long);
-	int n;
-
-	n = DEVICE_NR(inode->i_rdev);
-	if(n >= MAX_DEV)
-		return(-ENODEV);
-	dev = &cow_dev[n];
-
-	dev_ioctl = dev->backing_bdev->bd_op->ioctl;
-	return((*dev_ioctl)(inode, file, cmd, arg));
-}
-
-static int cow_revalidate(kdev_t rdev)
-{
-	printk(KERN_ERR "Need to implement cow_revalidate\n");
-	return(0);
-}
-
-static int parse_unit(char **ptr)
-{
-	char *str = *ptr, *end;
-	int n = -1;
-
-	if(isdigit(*str)) {
-		n = simple_strtoul(str, &end, 0);
-		if(end == str)
-			return(-1);
-		*ptr = end;
-	}
-	else if (('a' <= *str) && (*str <= 'h')) {
-		n = *str - 'a';
-		str++;
-		*ptr = str;
-	}
-	return(n);
-}
-
-static int cow_setup(char *str)
-{
-	struct cow *dev;
-	char *cow_name, *backing_name;
-	int unit;
-
-	unit = parse_unit(&str);
-	if(unit < 0){
-		printk(KERN_ERR "cow_setup - Couldn't parse unit number\n");
-		return(1);
-	}
-
-	if(*str != '='){
-		printk(KERN_ERR "cow_setup - Missing '=' after unit "
-		       "number\n");
-		return(1);
-	}
-	str++;
-
-	cow_name = str;
-	backing_name = strchr(str, ',');
-	if(backing_name == NULL){
-		printk(KERN_ERR "cow_setup - missing backing device name\n");
-		return(0);
-	}
-	*backing_name = '\0';
-	backing_name++;
-
-	spin_lock(&cow_lock);
-
-	dev = &cow_dev[unit];
-	dev->cow_path = cow_name;
-	dev->backing_path = backing_name;
-
-	spin_unlock(&cow_lock);
-	return(0);
-}
-
-__setup("cow", cow_setup);
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build
  2004-08-17 18:26         ` Andrew Morton
@ 2004-08-18  2:58           ` Jeff Dike
  2004-08-18 18:28           ` Chris Wedgwood
  1 sibling, 0 replies; 14+ messages in thread
From: Jeff Dike @ 2004-08-18  2:58 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

On Tue, Aug 17, 2004 at 11:26:29AM -0700, Andrew Morton wrote:
> Frankly, when a subsystem gets this far out of date I don't think it
> matters a lot - nobody has much hope of following all the changes anyway. 
> We'll just merge the megapatch on the assumption that Jeff knows what he's
> doing, and that it's better than what we had before.  

Well, that latter is pretty certain, but I wouldn't be too sure about the
former :-)

> You should have seen
> the size of some of those MIPS patches ;)

Hehe.  OK, I'll keep the current big patch, and stack little ones on top of
it to fix it.

				Jeff

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build
  2004-08-17 18:26         ` Andrew Morton
  2004-08-18  2:58           ` Jeff Dike
@ 2004-08-18 18:28           ` Chris Wedgwood
  1 sibling, 0 replies; 14+ messages in thread
From: Chris Wedgwood @ 2004-08-18 18:28 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel

On Tue, Aug 17, 2004 at 11:26:29AM -0700, Andrew Morton wrote:

> Frankly, when a subsystem gets this far out of date I don't think it
> matters a lot - nobody has much hope of following all the changes
> anyway.  We'll just merge the megapatch on the assumption that Jeff
> knows what he's doing, and that it's better than what we had before.
> You should have seen the size of some of those MIPS patches ;)

I've been pushing for a large giant UML merge for ages, mostly as
nobody is looking over the broken down patches much anyhow...

I'd even be happy with the current stuff being shoved into mainline
even if it doesn't build for a few days until it gets fixed --- not
having a common point of reference is really quite frustrating.

There are a ton of white-space cleanups and sparsification changes
that could be done too --- I assume this would be best done *before* a
giant-patch merge?


  --cw

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-08-18 18:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-12  4:14 [PATCH 1/3] 2.6.8-rc4-mm1 - Fix UML build Jeff Dike
2004-08-15 22:06 ` Andrew Morton
2004-08-17  6:02   ` Jeff Dike
2004-08-17  5:06     ` William Lee Irwin III
2004-08-17  5:10       ` Andrew Morton
2004-08-17 14:45         ` Sam Ravnborg
2004-08-17 12:51           ` Russell King
2004-08-17  5:08     ` Andrew Morton
2004-08-17 19:15       ` Jeff Dike
2004-08-17 18:26         ` Andrew Morton
2004-08-18  2:58           ` Jeff Dike
2004-08-18 18:28           ` Chris Wedgwood
2004-08-17  8:55     ` Andreas Schwab
2004-08-17 18:17       ` Jeff Dike

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox