linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17]
@ 2006-04-07 14:27 Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:30 ` [PATCH 01/17] uml: make 64-bit COW files compatible with 32-bit ones Paolo 'Blaisorblade' Giarrusso
                   ` (16 more replies)
  0 siblings, 17 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:27 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

Lots of little patches for compilation fixups, error path bugs and the like.
New "features" are support for running sparse on userspace files, a Makefile
cleanup, and finally working around the COW format incompatibility between 32
and 64 bit UMLs; the last one has been tested for a while.
-- 
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade

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

* [PATCH 01/17] uml: make 64-bit COW files compatible with 32-bit ones.
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:30 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:30 ` [PATCH 02/17] uml: safe migration path to the correct V3 COW format Paolo 'Blaisorblade' Giarrusso
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

This is the minimal fix to make 64-bit UML binaries create 32-bit
compatible COW files and read them.
I've indeed tested that current code doesn't do this - the code gets SIGFPE for
a division by a value read at the wrong place, where 0 is found.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/drivers/cow_user.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c
index 61951b7..afdf1ea 100644
--- a/arch/um/drivers/cow_user.c
+++ b/arch/um/drivers/cow_user.c
@@ -75,7 +75,7 @@ struct cow_header_v3 {
 	__u32 alignment;
 	__u32 cow_format;
 	char backing_file[PATH_LEN_V3];
-};
+} __attribute__((packed));
 
 /* COW format definitions - for now, we have only the usual COW bitmap */
 #define COW_BITMAP 0

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

* [PATCH 02/17] uml: safe migration path to the correct V3 COW format
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:30 ` [PATCH 01/17] uml: make 64-bit COW files compatible with 32-bit ones Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:30 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:30 ` [PATCH 03/17] uml: fix 2 harmless cast warnings for 64-bit Paolo 'Blaisorblade' Giarrusso
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

*) Correct the layout of all header versions - make all them well-specified for
any external event. As we don't have 1-byte or 2-byte wide fields, the 32-bit
layout (historical one) has no extra padding, so we can safely add
__attribute__((packed)).

*) Add detection and reading of the broken 64-bit COW format which has been
around for a while - to allow safe migration to the correct 32-bit format. Safe
detection is possible, thanks to some luck with the existing format, and it
works in practice.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/drivers/cow_user.c |   91 +++++++++++++++++++++++++++++++++++++-------
 1 files changed, 76 insertions(+), 15 deletions(-)

diff --git a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c
index afdf1ea..a9afccf 100644
--- a/arch/um/drivers/cow_user.c
+++ b/arch/um/drivers/cow_user.c
@@ -17,30 +17,34 @@
 
 #define PATH_LEN_V1 256
 
+typedef __u32 time32_t;
+
 struct cow_header_v1 {
-	int magic;
-	int version;
+	__s32 magic;
+	__s32 version;
 	char backing_file[PATH_LEN_V1];
-	time_t mtime;
+	time32_t mtime;
 	__u64 size;
-	int sectorsize;
-};
+	__s32 sectorsize;
+} __attribute__((packed));
 
-#define PATH_LEN_V2 MAXPATHLEN
+/* Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in
+ * case other systems have different values for MAXPATHLEN.
+ *
+ * The same must hold for V2 - we want file format compatibility, not anything
+ * else.
+ */
+#define PATH_LEN_V3 4096
+#define PATH_LEN_V2 PATH_LEN_V3
 
 struct cow_header_v2 {
 	__u32 magic;
 	__u32 version;
 	char backing_file[PATH_LEN_V2];
-	time_t mtime;
+	time32_t mtime;
 	__u64 size;
-	int sectorsize;
-};
-
-/* Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in
- * case other systems have different values for MAXPATHLEN
- */
-#define PATH_LEN_V3 4096
+	__s32 sectorsize;
+} __attribute__((packed));
 
 /* Changes from V2 -
  *	PATH_LEN_V3 as described above
@@ -66,6 +70,15 @@ struct cow_header_v2 {
  *	Fixed (finally!) the rounding bug
  */
 
+/* Until Dec2005, __attribute__((packed)) was left out from the below
+ * definition, leading on 64-bit systems to 4 bytes of padding after mtime, to
+ * align size to 8-byte alignment.  This shifted all fields above (no padding
+ * was present on 32-bit, no other padding was added).
+ *
+ * However, this _can be detected_: it means that cow_format (always 0 until
+ * now) is shifted onto the first 4 bytes of backing_file, where it is otherwise
+ * impossible to find 4 zeros. -bb */
+
 struct cow_header_v3 {
 	__u32 magic;
 	__u32 version;
@@ -77,6 +90,18 @@ struct cow_header_v3 {
 	char backing_file[PATH_LEN_V3];
 } __attribute__((packed));
 
+/* This is the broken layout used by some 64-bit binaries. */
+struct cow_header_v3_broken {
+	__u32 magic;
+	__u32 version;
+	__s64 mtime;
+	__u64 size;
+	__u32 sectorsize;
+	__u32 alignment;
+	__u32 cow_format;
+	char backing_file[PATH_LEN_V3];
+};
+
 /* COW format definitions - for now, we have only the usual COW bitmap */
 #define COW_BITMAP 0
 
@@ -84,6 +109,7 @@ union cow_header {
 	struct cow_header_v1 v1;
 	struct cow_header_v2 v2;
 	struct cow_header_v3 v3;
+	struct cow_header_v3_broken v3_b;
 };
 
 #define COW_MAGIC 0x4f4f4f4d  /* MOOO */
@@ -300,7 +326,8 @@ int read_cow_header(int (*reader)(__u64,
 		*align_out = *sectorsize_out;
 		file = header->v2.backing_file;
 	}
-	else if(version == 3){
+	/* This is very subtle - see above at union cow_header definition */
+	else if(version == 3 && (*((int*)header->v3.backing_file) != 0)){
 		if(n < sizeof(header->v3)){
 			cow_printf("read_cow_header - failed to read V3 "
 				   "header\n");
@@ -310,9 +337,43 @@ int read_cow_header(int (*reader)(__u64,
 		*size_out = ntohll(header->v3.size);
 		*sectorsize_out = ntohl(header->v3.sectorsize);
 		*align_out = ntohl(header->v3.alignment);
+		if (*align_out == 0) {
+			cow_printf("read_cow_header - invalid COW header, "
+				   "align == 0\n");
+		}
 		*bitmap_offset_out = ROUND_UP(sizeof(header->v3), *align_out);
 		file = header->v3.backing_file;
 	}
+	else if(version == 3){
+		cow_printf("read_cow_header - broken V3 file with"
+			   " 64-bit layout - recovering content.\n");
+
+		if(n < sizeof(header->v3_b)){
+			cow_printf("read_cow_header - failed to read V3 "
+				   "header\n");
+			goto out;
+		}
+
+		/* this was used until Dec2005 - 64bits are needed to represent
+		 * 2038+. I.e. we can safely do this truncating cast.
+		 *
+		 * Additionally, we must use ntohl() instead of ntohll(), since
+		 * the program used to use the former (tested - I got mtime
+		 * mismatch "0 vs whatever").
+		 *
+		 * Ever heard about bug-to-bug-compatibility ? ;-) */
+		*mtime_out = (time32_t) ntohl(header->v3_b.mtime);
+
+		*size_out = ntohll(header->v3_b.size);
+		*sectorsize_out = ntohl(header->v3_b.sectorsize);
+		*align_out = ntohl(header->v3_b.alignment);
+		if (*align_out == 0) {
+			cow_printf("read_cow_header - invalid COW header, "
+				   "align == 0\n");
+		}
+		*bitmap_offset_out = ROUND_UP(sizeof(header->v3_b), *align_out);
+		file = header->v3_b.backing_file;
+	}
 	else {
 		cow_printf("read_cow_header - invalid COW version\n");
 		goto out;

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

* [PATCH 03/17] uml: fix 2 harmless cast warnings for 64-bit
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:30 ` [PATCH 01/17] uml: make 64-bit COW files compatible with 32-bit ones Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:30 ` [PATCH 02/17] uml: safe migration path to the correct V3 COW format Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:30 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 16:02   ` Jeff Dike
  2006-04-07 14:30 ` [PATCH 04/17] uml: request format warnings to GCC for appropriate functions Paolo 'Blaisorblade' Giarrusso
                   ` (13 subsequent siblings)
  16 siblings, 1 reply; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Fix two harmless warnings in 64-bit compilation (the 2nd doesn't trigger for now
because of a missing __attribute((format)) for cow_printf, but next patches fix
that).

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/drivers/cow_user.c      |    3 ++-
 arch/um/drivers/mconsole_kern.c |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c
index a9afccf..0ec4052 100644
--- a/arch/um/drivers/cow_user.c
+++ b/arch/um/drivers/cow_user.c
@@ -210,8 +210,9 @@ int write_cow_header(char *cow_file, int
 
 	err = -EINVAL;
 	if(strlen(backing_file) > sizeof(header->backing_file) - 1){
+		/* Below, %zd is for a size_t value */
 		cow_printf("Backing file name \"%s\" is too long - names are "
-			   "limited to %d characters\n", backing_file,
+			   "limited to %zd characters\n", backing_file,
 			   sizeof(header->backing_file) - 1);
 		goto out_free;
 	}
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 28e3760..f8c6269 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -616,7 +616,7 @@ static void console_write(struct console
 		return;
 
 	while(1){
-		n = min((size_t)len, ARRAY_SIZE(console_buf) - console_index);
+		n = min((size_t) len, ARRAY_SIZE(console_buf) - console_index);
 		strncpy(&console_buf[console_index], string, n);
 		console_index += n;
 		string += n;

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

* [PATCH 04/17] uml: request format warnings to GCC for appropriate functions
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
                   ` (2 preceding siblings ...)
  2006-04-07 14:30 ` [PATCH 03/17] uml: fix 2 harmless cast warnings for 64-bit Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:30 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:31 ` [PATCH 05/17] uml: fix format errors Paolo 'Blaisorblade' Giarrusso
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Add the format attribute to prototypes so GCC warns about improper usage.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/include/tt/tt.h     |    3 ++-
 arch/um/include/user.h      |    6 ++++--
 arch/um/include/user_util.h |    3 ++-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/um/include/tt/tt.h b/arch/um/include/tt/tt.h
index 8085219..acb8356 100644
--- a/arch/um/include/tt/tt.h
+++ b/arch/um/include/tt/tt.h
@@ -19,7 +19,8 @@ extern int fork_tramp(void *sig_stack);
 extern int do_proc_op(void *t, int proc_id);
 extern int tracer(int (*init_proc)(void *), void *sp);
 extern void attach_process(int pid);
-extern void tracer_panic(char *format, ...);
+extern void tracer_panic(char *format, ...)
+	__attribute__ ((format (printf, 1, 2)));
 extern void set_init_pid(int pid);
 extern int set_user_mode(void *task);
 extern void set_tracing(void *t, int tracing);
diff --git a/arch/um/include/user.h b/arch/um/include/user.h
index 91b0ac4..39f8c88 100644
--- a/arch/um/include/user.h
+++ b/arch/um/include/user.h
@@ -6,8 +6,10 @@
 #ifndef __USER_H__
 #define __USER_H__
 
-extern void panic(const char *fmt, ...);
-extern int printk(const char *fmt, ...);
+extern void panic(const char *fmt, ...)
+	__attribute__ ((format (printf, 1, 2)));
+extern int printk(const char *fmt, ...)
+	__attribute__ ((format (printf, 1, 2)));
 extern void schedule(void);
 extern void *um_kmalloc(int size);
 extern void *um_kmalloc_atomic(int size);
diff --git a/arch/um/include/user_util.h b/arch/um/include/user_util.h
index fe0c29b..802d784 100644
--- a/arch/um/include/user_util.h
+++ b/arch/um/include/user_util.h
@@ -55,7 +55,8 @@ extern int get_pty(void);
 extern void *um_kmalloc(int size);
 extern int switcheroo(int fd, int prot, void *from, void *to, int size);
 extern void do_exec(int old_pid, int new_pid);
-extern void tracer_panic(char *msg, ...);
+extern void tracer_panic(char *msg, ...)
+	__attribute__ ((format (printf, 1, 2)));
 extern int detach(int pid, int sig);
 extern int attach(int pid);
 extern void kill_child_dead(int pid);

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

* [PATCH 05/17] uml: fix format errors
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
                   ` (3 preceding siblings ...)
  2006-04-07 14:30 ` [PATCH 04/17] uml: request format warnings to GCC for appropriate functions Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:31 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:31 ` [PATCH 06/17] uml: fix some double export warnings Paolo 'Blaisorblade' Giarrusso
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Now that GCC warns about format errors, fix them. Nothing able to cause a crash,
however.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/drivers/slirp_user.c             |    2 +-
 arch/um/os-Linux/drivers/ethertap_user.c |    2 +-
 arch/um/os-Linux/skas/mem.c              |    4 ++--
 arch/um/os-Linux/skas/process.c          |    4 ++--
 arch/um/sys-i386/ptrace_user.c           |    2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/um/drivers/slirp_user.c b/arch/um/drivers/slirp_user.c
index b94c661..33c5f6e 100644
--- a/arch/um/drivers/slirp_user.c
+++ b/arch/um/drivers/slirp_user.c
@@ -104,7 +104,7 @@ static void slirp_close(int fd, void *da
 	}
 
 	if(err == 0) {
-		printk("slirp_close: process %d has not exited\n");
+		printk("slirp_close: process %d has not exited\n", pri->pid);
 		return;
 	}
 
diff --git a/arch/um/os-Linux/drivers/ethertap_user.c b/arch/um/os-Linux/drivers/ethertap_user.c
index 901b85e..8f49507 100644
--- a/arch/um/os-Linux/drivers/ethertap_user.c
+++ b/arch/um/os-Linux/drivers/ethertap_user.c
@@ -40,7 +40,7 @@ static void etap_change(int op, unsigned
 			int fd)
 {
 	struct addr_change change;
-	void *output;
+	char *output;
 	int n;
 
 	change.what = op;
diff --git a/arch/um/os-Linux/skas/mem.c b/arch/um/os-Linux/skas/mem.c
index fbb080c..b3c11cf 100644
--- a/arch/um/os-Linux/skas/mem.c
+++ b/arch/um/os-Linux/skas/mem.c
@@ -82,8 +82,8 @@ static inline long do_syscall_stub(struc
 	if (offset) {
 		data = (unsigned long *)(mm_idp->stack +
 					 offset - UML_CONFIG_STUB_DATA);
-		printk("do_syscall_stub : ret = %d, offset = %d, "
-		       "data = 0x%x\n", ret, offset, data);
+		printk("do_syscall_stub : ret = %ld, offset = %ld, "
+		       "data = %p\n", ret, offset, data);
 		syscall = (unsigned long *)((unsigned long)data + data[0]);
 		printk("do_syscall_stub: syscall %ld failed, return value = "
 		       "0x%lx, expected return value = 0x%lx\n",
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index bbf34cb..045ae00 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -265,7 +265,7 @@ void userspace(union uml_pt_regs *regs)
 		if(err)
 			panic("userspace - could not resume userspace process, "
 			      "pid=%d, ptrace operation = %d, errno = %d\n",
-			      op, errno);
+			      pid, op, errno);
 
 		CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
 		if(err < 0)
@@ -369,7 +369,7 @@ int copy_context_skas0(unsigned long new
 	 */
 	wait_stub_done(pid, -1, "copy_context_skas0");
 	if (child_data->err != UML_CONFIG_STUB_DATA)
-		panic("copy_context_skas0 - stub-child reports error %d\n",
+		panic("copy_context_skas0 - stub-child reports error %ld\n",
 		      child_data->err);
 
 	if (ptrace(PTRACE_OLDSETOPTIONS, pid, NULL,
diff --git a/arch/um/sys-i386/ptrace_user.c b/arch/um/sys-i386/ptrace_user.c
index 9f3bd8e..40aa885 100644
--- a/arch/um/sys-i386/ptrace_user.c
+++ b/arch/um/sys-i386/ptrace_user.c
@@ -57,7 +57,7 @@ static void write_debugregs(int pid, uns
 		if(ptrace(PTRACE_POKEUSR, pid, &dummy->u_debugreg[i],
 			  regs[i]) < 0)
 			printk("write_debugregs - ptrace failed on "
-			       "register %d, value = 0x%x, errno = %d\n", i,
+			       "register %d, value = 0x%lx, errno = %d\n", i,
 			       regs[i], errno);
 	}
 }

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

* [PATCH 06/17] uml: fix some double export warnings
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
                   ` (4 preceding siblings ...)
  2006-04-07 14:31 ` [PATCH 05/17] uml: fix format errors Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:31 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:31 ` [PATCH 07/17] uml: fix "extern-vs-static" proto conflict in TLS code Paolo 'Blaisorblade' Giarrusso
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Some functions are exported twice in current code - remove the excess export.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/kernel/ksyms.c       |    5 +----
 arch/um/os-Linux/user_syms.c |    9 +++++++--
 arch/um/sys-i386/ksyms.c     |    4 ----
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/arch/um/kernel/ksyms.c b/arch/um/kernel/ksyms.c
index 7713e7a..432cf0b 100644
--- a/arch/um/kernel/ksyms.c
+++ b/arch/um/kernel/ksyms.c
@@ -39,7 +39,6 @@ EXPORT_SYMBOL(um_virt_to_phys);
 EXPORT_SYMBOL(mode_tt);
 EXPORT_SYMBOL(handle_page_fault);
 EXPORT_SYMBOL(find_iomem);
-EXPORT_SYMBOL(end_iomem);
 
 #ifdef CONFIG_MODE_TT
 EXPORT_SYMBOL(strncpy_from_user_tt);
@@ -89,12 +88,10 @@ EXPORT_SYMBOL(dump_thread);
 EXPORT_SYMBOL(do_gettimeofday);
 EXPORT_SYMBOL(do_settimeofday);
 
-/* This is here because UML expands open to sys_open, not to a system
+/* This is here because UML expands lseek to sys_lseek, not to a system
  * call instruction.
  */
-EXPORT_SYMBOL(sys_open);
 EXPORT_SYMBOL(sys_lseek);
-EXPORT_SYMBOL(sys_read);
 EXPORT_SYMBOL(sys_wait4);
 
 #ifdef CONFIG_SMP
diff --git a/arch/um/os-Linux/user_syms.c b/arch/um/os-Linux/user_syms.c
index 8da6ab3..2598158 100644
--- a/arch/um/os-Linux/user_syms.c
+++ b/arch/um/os-Linux/user_syms.c
@@ -18,14 +18,19 @@ extern void *memmove(void *, const void 
 extern void *memset(void *, int, size_t);
 extern int printf(const char *, ...);
 
+/* If they're not defined, the export is included in lib/string.c.*/
+#ifdef __HAVE_ARCH_STRLEN
 EXPORT_SYMBOL(strlen);
+#endif
+#ifdef __HAVE_ARCH_STRSTR
+EXPORT_SYMBOL(strstr);
+#endif
+
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memmove);
 EXPORT_SYMBOL(memset);
 EXPORT_SYMBOL(printf);
 
-EXPORT_SYMBOL(strstr);
-
 /* Here, instead, I can provide a fake prototype. Yes, someone cares: genksyms.
  * However, the modules will use the CRC defined *here*, no matter if it is
  * good; so the versions of these symbols will always match
diff --git a/arch/um/sys-i386/ksyms.c b/arch/um/sys-i386/ksyms.c
index db524ab..2a1eac1 100644
--- a/arch/um/sys-i386/ksyms.c
+++ b/arch/um/sys-i386/ksyms.c
@@ -15,7 +15,3 @@ EXPORT_SYMBOL(__up_wakeup);
 
 /* Networking helper routines. */
 EXPORT_SYMBOL(csum_partial);
-
-/* delay core functions */
-EXPORT_SYMBOL(__const_udelay);
-EXPORT_SYMBOL(__udelay);

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

* [PATCH 07/17] uml: fix "extern-vs-static" proto conflict in TLS code
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
                   ` (5 preceding siblings ...)
  2006-04-07 14:31 ` [PATCH 06/17] uml: fix some double export warnings Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:31 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:31 ` [PATCH 08/17] uml: prepare fixing compilation output Paolo 'Blaisorblade' Giarrusso
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Move the prototype from arch-generic to arch-specific includes because on x86_64
these functions are two static inlines.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/include/kern_util.h  |    4 ----
 include/asm-um/ptrace-i386.h |    3 +++
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/um/include/kern_util.h b/arch/um/include/kern_util.h
index 4255713..efa3d33 100644
--- a/arch/um/include/kern_util.h
+++ b/arch/um/include/kern_util.h
@@ -117,10 +117,6 @@ extern struct task_struct *get_task(int 
 extern void machine_halt(void);
 extern int is_syscall(unsigned long addr);
 
-extern void arch_switch_to_tt(struct task_struct *from, struct task_struct *to);
-
-extern void arch_switch_to_skas(struct task_struct *from, struct task_struct *to);
-
 extern void free_irq(unsigned int, void *);
 extern int cpu(void);
 
diff --git a/include/asm-um/ptrace-i386.h b/include/asm-um/ptrace-i386.h
index 30656c9..6e2528b 100644
--- a/include/asm-um/ptrace-i386.h
+++ b/include/asm-um/ptrace-i386.h
@@ -56,6 +56,9 @@ extern int do_get_thread_area_tt(struct 
 extern int arch_switch_tls_skas(struct task_struct *from, struct task_struct *to);
 extern int arch_switch_tls_tt(struct task_struct *from, struct task_struct *to);
 
+extern void arch_switch_to_tt(struct task_struct *from, struct task_struct *to);
+extern void arch_switch_to_skas(struct task_struct *from, struct task_struct *to);
+
 static inline int do_get_thread_area(struct user_desc *info)
 {
 	return CHOOSE_MODE_PROC(do_get_thread_area_tt, do_get_thread_area_skas, info);

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

* [PATCH 08/17] uml: prepare fixing compilation output
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
                   ` (6 preceding siblings ...)
  2006-04-07 14:31 ` [PATCH 07/17] uml: fix "extern-vs-static" proto conflict in TLS code Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:31 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 16:05   ` Jeff Dike
  2006-04-07 14:31 ` [PATCH 09/17] uml: fix critical typo for TT mode Paolo 'Blaisorblade' Giarrusso
                   ` (8 subsequent siblings)
  16 siblings, 1 reply; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Move the build of user-offsets to arch/um/Kbuild, this will allow using the
normal user-objs machinery. I had written this to fixup for a Kbuild change, but
another fix was merged. This is still useful however.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/Kbuild   |    4 ++++
 arch/um/Makefile |    4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/um/Kbuild b/arch/um/Kbuild
new file mode 100644
index 0000000..ae2a254
--- /dev/null
+++ b/arch/um/Kbuild
@@ -0,0 +1,4 @@
+ARCH_DIR := arch/um
+
+$(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c
+	$(CC) $(USER_CFLAGS) -S -o $@ $<
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 24790be..ef8d71d 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -202,8 +202,8 @@ endef
 $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
 	$(call filechk,umlconfig)
 
-$(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c
-	$(CC) $(USER_CFLAGS) -S -o $@ $<
+$(ARCH_DIR)/user-offsets.s: FORCE
+	$(Q)$(MAKE) $(build)=$(ARCH_DIR) $@
 
 define filechk_gen-asm-offsets
         (set -e; \

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

* [PATCH 09/17] uml: fix critical typo for TT mode
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
                   ` (7 preceding siblings ...)
  2006-04-07 14:31 ` [PATCH 08/17] uml: prepare fixing compilation output Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:31 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 15:45   ` Jeff Dike
  2006-04-07 14:31 ` [PATCH 10/17] uml: support sparse for userspace files Paolo 'Blaisorblade' Giarrusso
                   ` (7 subsequent siblings)
  16 siblings, 1 reply; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Noticed this for a compilation-time warning, so I'm fixing it even for TT mode -
this is not put_user, but copy_to_user, so we need a pointer to sp, not sp
itself (we're trying to write the word pointed to by the "sp" var.).

Jeff, have I misunderstood anything?

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/sys-i386/signal.c   |    2 +-
 arch/um/sys-x86_64/signal.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/um/sys-i386/signal.c b/arch/um/sys-i386/signal.c
index f5d0e1c..618fd85 100644
--- a/arch/um/sys-i386/signal.c
+++ b/arch/um/sys-i386/signal.c
@@ -147,7 +147,7 @@ int copy_sc_to_user_tt(struct sigcontext
 	 * delivery.  The sp passed in is the original, and this needs
 	 * to be restored, so we stick it in separately.
 	 */
-	err |= copy_to_user(&SC_SP(to), sp, sizeof(sp));
+	err |= copy_to_user(&SC_SP(to), &sp, sizeof(sp));
 
 	if(from_fp != NULL){
 		err |= copy_to_user(&to->fpstate, &to_fp, sizeof(to->fpstate));
diff --git a/arch/um/sys-x86_64/signal.c b/arch/um/sys-x86_64/signal.c
index e75c4e1..a4c46a8 100644
--- a/arch/um/sys-x86_64/signal.c
+++ b/arch/um/sys-x86_64/signal.c
@@ -137,7 +137,7 @@ int copy_sc_to_user_tt(struct sigcontext
 	 * delivery.  The sp passed in is the original, and this needs
 	 * to be restored, so we stick it in separately.
 	 */
-	err |= copy_to_user(&SC_SP(to), sp, sizeof(sp));
+	err |= copy_to_user(&SC_SP(to), &sp, sizeof(sp));
 
 	if(from_fp != NULL){
 		err |= copy_to_user(&to->fpstate, &to_fp, sizeof(to->fpstate));

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

* [PATCH 10/17] uml: support sparse for userspace files
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
                   ` (8 preceding siblings ...)
  2006-04-07 14:31 ` [PATCH 09/17] uml: fix critical typo for TT mode Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:31 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:31 ` [PATCH 11/17] uml: move outside spinlock call not needing it Paolo 'Blaisorblade' Giarrusso
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Make sparse checker work for userspace files - it normally gets -nostdinc
separately, so avoid having it for userspace files. Also, add -D$(SUBARCH) for
multiarch hosts (i.e. AMD64 with compatibility headers).

It works, the only problem is a bit of bogus warnings for system headers, but
they're not too many.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/scripts/Makefile.rules |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules
index b696b45..5e7a9c3 100644
--- a/arch/um/scripts/Makefile.rules
+++ b/arch/um/scripts/Makefile.rules
@@ -9,10 +9,8 @@ USER_OBJS := $(foreach file,$(USER_OBJS)
 
 $(USER_OBJS) $(USER_OBJS:.o=.i) $(USER_OBJS:.o=.s) $(USER_OBJS:.o=.lst): \
 	c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) $(CFLAGS_$(notdir $@))
-$(USER_OBJS): cmd_checksrc =
-$(USER_OBJS): quiet_cmd_checksrc =
-$(USER_OBJS): cmd_force_checksrc =
-$(USER_OBJS): quiet_cmd_force_checksrc =
+$(USER_OBJS) : CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ \
+	-Dunix -D__unix__ -D__$(SUBARCH)__
 
 
 # The stubs and unmap.o can't try to call mcount or update basic block data

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

* [PATCH 11/17] uml: move outside spinlock call not needing it
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
                   ` (9 preceding siblings ...)
  2006-04-07 14:31 ` [PATCH 10/17] uml: support sparse for userspace files Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:31 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:31 ` [PATCH 12/17] uml: fix hang on run_helper() failure on uml_net Paolo 'Blaisorblade' Giarrusso
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Move a call to kfree on a local variable out of a spinlock - there's no need to
have it in. Done on a just merged patch.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/os-Linux/sigio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c
index 9ba9429..00e9388 100644
--- a/arch/um/os-Linux/sigio.c
+++ b/arch/um/os-Linux/sigio.c
@@ -304,8 +304,8 @@ out_clear_poll:
 					   .size	= 0,
 					   .used	= 0 });
 out_free:
-	kfree(p);
 	sigio_unlock();
+	kfree(p);
 out_close2:
 	close(l_sigio_private[0]);
 	close(l_sigio_private[1]);

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

* [PATCH 12/17] uml: fix hang on run_helper() failure on uml_net
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
                   ` (10 preceding siblings ...)
  2006-04-07 14:31 ` [PATCH 11/17] uml: move outside spinlock call not needing it Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:31 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:31 ` [PATCH 13/17] uml: fix failure path after conversion Paolo 'Blaisorblade' Giarrusso
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Fix an hang on a pipe when run_helper() fails when called by change_tramp()
(i.e. when calling uml_net) - reproduced the bug and verified this fixes it.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/drivers/net_user.c |    4 +++-
 arch/um/os-Linux/helper.c  |   10 +++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c
index 0e2f061..0a7786e 100644
--- a/arch/um/drivers/net_user.c
+++ b/arch/um/drivers/net_user.c
@@ -182,7 +182,9 @@ static int change_tramp(char **argv, cha
 	pe_data.stdout = fds[1];
 	pid = run_helper(change_pre_exec, &pe_data, argv, NULL);
 
-	read_output(fds[0], output, output_len);
+	if (pid > 0)	/* Avoid hang as we won't get data in failure case. */
+		read_output(fds[0], output, output_len);
+
 	os_close_file(fds[0]);
 	os_close_file(fds[1]);
 
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c
index 6490a4f..6987d1d 100644
--- a/arch/um/os-Linux/helper.c
+++ b/arch/um/os-Linux/helper.c
@@ -43,7 +43,7 @@ static int helper_child(void *arg)
 		(*data->pre_exec)(data->pre_data);
 	execvp(argv[0], argv);
 	errval = errno;
-	printk("execvp of '%s' failed - errno = %d\n", argv[0], errno);
+	printk("helper_child - execve of '%s' failed - errno = %d\n", argv[0], errno);
 	os_write_file(data->fd, &errval, sizeof(errval));
 	kill(os_getpid(), SIGKILL);
 	return(0);
@@ -92,15 +92,15 @@ int run_helper(void (*pre_exec)(void *),
 	close(fds[1]);
 	fds[1] = -1;
 
-	/*Read the errno value from the child.*/
+	/* Read the errno value from the child, if the exec failed, or get 0 if
+	 * the exec succeeded because the pipe fd was set as close-on-exec. */
 	n = os_read_file(fds[0], &ret, sizeof(ret));
-	if(n < 0){
+	if (n < 0) {
 		printk("run_helper : read on pipe failed, ret = %d\n", -n);
 		ret = n;
 		kill(pid, SIGKILL);
 		CATCH_EINTR(waitpid(pid, NULL, 0));
-	}
-	else if(n != 0){
+	} else if(n != 0){
 		CATCH_EINTR(n = waitpid(pid, NULL, 0));
 		ret = -errno;
 	} else {

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

* [PATCH 13/17] uml: fix failure path after conversion
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
                   ` (11 preceding siblings ...)
  2006-04-07 14:31 ` [PATCH 12/17] uml: fix hang on run_helper() failure on uml_net Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:31 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:31 ` [PATCH 14/17] uml: fix big stack user Paolo 'Blaisorblade' Giarrusso
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Little fix for error paths in this code.
*) Some bug come from conversion to os-Linux (open() doesn't follow
the kernel -errno return convention, while the old code called os_open_file()
which followed it). This caused the wrong return code to be printed.
*) Then be more precise about what happened and do some whitespace fixes.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/os-Linux/umid.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/arch/um/os-Linux/umid.c b/arch/um/os-Linux/umid.c
index 198e591..34bfc1b 100644
--- a/arch/um/os-Linux/umid.c
+++ b/arch/um/os-Linux/umid.c
@@ -120,7 +120,8 @@ static int not_dead_yet(char *dir)
 
 	dead = 0;
 	fd = open(file, O_RDONLY);
-	if(fd < 0){
+	if(fd < 0) {
+		fd = -errno;
 		if(fd != -ENOENT){
 			printk("not_dead_yet : couldn't open pid file '%s', "
 			       "err = %d\n", file, -fd);
@@ -130,9 +131,13 @@ static int not_dead_yet(char *dir)
 
 	err = 0;
 	n = read(fd, pid, sizeof(pid));
-	if(n <= 0){
+	if(n < 0){
+		printk("not_dead_yet : couldn't read pid file '%s', "
+		       "err = %d\n", file, errno);
+		goto out_close;
+	} else if(n == 0){
 		printk("not_dead_yet : couldn't read pid file '%s', "
-		       "err = %d\n", file, -n);
+		       "0-byte read\n", file);
 		goto out_close;
 	}
 
@@ -155,9 +160,9 @@ static int not_dead_yet(char *dir)
 
 	return err;
 
- out_close:
+out_close:
 	close(fd);
- out:
+out:
 	return 0;
 }
 

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

* [PATCH 14/17] uml: fix big stack user
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
                   ` (12 preceding siblings ...)
  2006-04-07 14:31 ` [PATCH 13/17] uml: fix failure path after conversion Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:31 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:31 ` [PATCH 15/17] uml: local_irq_save, not local_save_flags Paolo 'Blaisorblade' Giarrusso
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Switch this proc from storing 4k of data (a whole path) on the stack to keeping
it on the heap.

Maybe it's not called in process context but only in early boot context (where
in UML you have a normal process stack on the host) but just to be safe, fix it.

While at it some little readability simplifications.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/os-Linux/mem.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index 6ab372d..71bb90a 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -53,33 +53,36 @@ static void __init find_tempdir(void)
  */
 int make_tempfile(const char *template, char **out_tempname, int do_unlink)
 {
-	char tempname[MAXPATHLEN];
+	char *tempname;
 	int fd;
 
+	tempname = malloc(MAXPATHLEN);
+
 	find_tempdir();
-	if (*template != '/')
+	if (template[0] != '/')
 		strcpy(tempname, tempdir);
 	else
-		*tempname = 0;
+		tempname[0] = '\0';
 	strcat(tempname, template);
 	fd = mkstemp(tempname);
 	if(fd < 0){
 		fprintf(stderr, "open - cannot create %s: %s\n", tempname,
 			strerror(errno));
-		return -1;
+		goto out;
 	}
 	if(do_unlink && (unlink(tempname) < 0)){
 		perror("unlink");
-		return -1;
+		goto out;
 	}
 	if(out_tempname){
-		*out_tempname = strdup(tempname);
-		if(*out_tempname == NULL){
-			perror("strdup");
-			return -1;
-		}
+		*out_tempname = tempname;
+	} else {
+		free(tempname);
 	}
 	return(fd);
+out:
+	free(tempname);
+	return -1;
 }
 
 #define TEMPNAME_TEMPLATE "vm_file-XXXXXX"

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

* [PATCH 15/17] uml: local_irq_save, not local_save_flags
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
                   ` (13 preceding siblings ...)
  2006-04-07 14:31 ` [PATCH 14/17] uml: fix big stack user Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:31 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:31 ` [PATCH 16/17] uml: fix parallel make early failure on clean tree Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:31 ` [PATCH 17/17] uml: avoid warnings for diffent names for an unsigned quadword Paolo 'Blaisorblade' Giarrusso
  16 siblings, 0 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

The call to local_save_flags seems bogus since it is followed by
local_irq_restore, and it's intended to lock the list from concurrent
mconsole_interrupt invocations.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/drivers/mconsole_kern.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index f8c6269..a0e1200 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -62,7 +62,7 @@ static void mc_work_proc(void *unused)
 	unsigned long flags;
 
 	while(!list_empty(&mc_requests)){
-		local_save_flags(flags);
+		local_irq_save(flags);
 		req = list_entry(mc_requests.next, struct mconsole_entry,
 				 list);
 		list_del(&req->list);

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

* [PATCH 16/17] uml: fix parallel make early failure on clean tree
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
                   ` (14 preceding siblings ...)
  2006-04-07 14:31 ` [PATCH 15/17] uml: local_irq_save, not local_save_flags Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:31 ` Paolo 'Blaisorblade' Giarrusso
  2006-04-07 14:31 ` [PATCH 17/17] uml: avoid warnings for diffent names for an unsigned quadword Paolo 'Blaisorblade' Giarrusso
  16 siblings, 0 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Parallel make failed once for me - fix this by adding the appropriate command
(mkdir before creating a link in that dir).

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/Makefile |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/um/Makefile b/arch/um/Makefile
index ef8d71d..e79454d 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -159,6 +159,7 @@ archclean:
 $(SYMLINK_HEADERS):
 	@echo '  SYMLINK $@'
 ifneq ($(KBUILD_SRC),)
+	$(Q)mkdir -p $(objtree)/include/asm-um
 	$(Q)ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@
 else
 	$(Q)cd $(TOPDIR)/$(dir $@) ; \
@@ -168,7 +169,7 @@ endif
 include/asm-um/arch:
 	@echo '  SYMLINK $@'
 ifneq ($(KBUILD_SRC),)
-	$(Q)mkdir -p include/asm-um
+	$(Q)mkdir -p $(objtree)/include/asm-um
 	$(Q)ln -fsn $(srctree)/include/asm-$(SUBARCH) include/asm-um/arch
 else
 	$(Q)cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch

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

* [PATCH 17/17] uml: avoid warnings for diffent names for an unsigned quadword
  2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
                   ` (15 preceding siblings ...)
  2006-04-07 14:31 ` [PATCH 16/17] uml: fix parallel make early failure on clean tree Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 14:31 ` Paolo 'Blaisorblade' Giarrusso
  16 siblings, 0 replies; 23+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07 14:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Since on some 64-bit systems __u64 is rightfully defined to unsigned long and
GCC recognizes anyway unsigned long and unsigned long long as different, fix
some types back to being unsigned long long to avoid warnings and errors (for
prototype mismatch) on those systems.

Thanks to the report by Wesley Emeneker wesleyemeneker (at) google (dot) com

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/drivers/cow.h     |    2 +-
 arch/um/drivers/cow_sys.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/um/drivers/cow.h b/arch/um/drivers/cow.h
index 04e3958..dc36b22 100644
--- a/arch/um/drivers/cow.h
+++ b/arch/um/drivers/cow.h
@@ -46,7 +46,7 @@ extern int file_reader(__u64 offset, cha
 extern int read_cow_header(int (*reader)(__u64, char *, int, void *),
 			   void *arg, __u32 *version_out,
 			   char **backing_file_out, time_t *mtime_out,
-			   __u64 *size_out, int *sectorsize_out,
+			   unsigned long long *size_out, int *sectorsize_out,
 			   __u32 *align_out, int *bitmap_offset_out);
 
 extern int write_cow_header(char *cow_file, int fd, char *backing_file,
diff --git a/arch/um/drivers/cow_sys.h b/arch/um/drivers/cow_sys.h
index 94de4ea..7a5b4af 100644
--- a/arch/um/drivers/cow_sys.h
+++ b/arch/um/drivers/cow_sys.h
@@ -28,7 +28,7 @@ static inline int cow_seek_file(int fd, 
 	return(os_seek_file(fd, offset));
 }
 
-static inline int cow_file_size(char *file, __u64 *size_out)
+static inline int cow_file_size(char *file, unsigned long long *size_out)
 {
 	return(os_file_size(file, size_out));
 }

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

* Re: [PATCH 09/17] uml: fix critical typo for TT mode
  2006-04-07 14:31 ` [PATCH 09/17] uml: fix critical typo for TT mode Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 15:45   ` Jeff Dike
  0 siblings, 0 replies; 23+ messages in thread
From: Jeff Dike @ 2006-04-07 15:45 UTC (permalink / raw)
  To: Paolo 'Blaisorblade' Giarrusso
  Cc: Andrew Morton, linux-kernel, user-mode-linux-devel

On Fri, Apr 07, 2006 at 04:31:10PM +0200, Paolo 'Blaisorblade' Giarrusso wrote:
> Noticed this for a compilation-time warning, so I'm fixing it even for TT mode -
> this is not put_user, but copy_to_user, so we need a pointer to sp, not sp
> itself (we're trying to write the word pointed to by the "sp" var.).
> 
> Jeff, have I misunderstood anything?

No, you're right.  Al spotted this as well, and I have this fix in my tree.

				Jeff

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

* Re: [PATCH 03/17] uml: fix 2 harmless cast warnings for 64-bit
  2006-04-07 14:30 ` [PATCH 03/17] uml: fix 2 harmless cast warnings for 64-bit Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 16:02   ` Jeff Dike
  2006-04-07 21:46     ` Blaisorblade
  0 siblings, 1 reply; 23+ messages in thread
From: Jeff Dike @ 2006-04-07 16:02 UTC (permalink / raw)
  To: Paolo 'Blaisorblade' Giarrusso
  Cc: Andrew Morton, linux-kernel, user-mode-linux-devel

On Fri, Apr 07, 2006 at 04:30:54PM +0200, Paolo 'Blaisorblade' Giarrusso wrote:
> From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
> 
> Fix two harmless warnings in 64-bit compilation (the 2nd doesn't trigger for now
> because of a missing __attribute((format)) for cow_printf, but next patches fix
> that).

I don't object to this bit, but it doesn't seem to match the comment.  Was
there another cast that you meant to have here, but missed?

> -		n = min((size_t)len, ARRAY_SIZE(console_buf) - console_index);
> +		n = min((size_t) len, ARRAY_SIZE(console_buf) - console_index);

				Jeff

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

* Re: [PATCH 08/17] uml: prepare fixing compilation output
  2006-04-07 14:31 ` [PATCH 08/17] uml: prepare fixing compilation output Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07 16:05   ` Jeff Dike
  2006-04-07 21:50     ` Blaisorblade
  0 siblings, 1 reply; 23+ messages in thread
From: Jeff Dike @ 2006-04-07 16:05 UTC (permalink / raw)
  To: Paolo 'Blaisorblade' Giarrusso
  Cc: Andrew Morton, linux-kernel, user-mode-linux-devel

On Fri, Apr 07, 2006 at 04:31:08PM +0200, Paolo 'Blaisorblade' Giarrusso wrote:
> Move the build of user-offsets to arch/um/Kbuild, this will allow using the
> normal user-objs machinery. I had written this to fixup for a Kbuild change, but
> another fix was merged. This is still useful however.

What's the benefit of this?

			Jeff

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

* Re: [PATCH 03/17] uml: fix 2 harmless cast warnings for 64-bit
  2006-04-07 16:02   ` Jeff Dike
@ 2006-04-07 21:46     ` Blaisorblade
  0 siblings, 0 replies; 23+ messages in thread
From: Blaisorblade @ 2006-04-07 21:46 UTC (permalink / raw)
  To: Jeff Dike; +Cc: Andrew Morton, linux-kernel, user-mode-linux-devel

On Friday 07 April 2006 18:02, Jeff Dike wrote:
> On Fri, Apr 07, 2006 at 04:30:54PM +0200, Paolo 'Blaisorblade' Giarrusso 
wrote:
> > From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
> >
> > Fix two harmless warnings in 64-bit compilation (the 2nd doesn't trigger
> > for now because of a missing __attribute((format)) for cow_printf, but
> > next patches fix that).

> I don't object to this bit, but it doesn't seem to match the comment.  Was
> there another cast that you meant to have here, but missed?

No, the below one was a whitespace change which slipped in without mention 
(but that I confirm).

> > -		n = min((size_t)len, ARRAY_SIZE(console_buf) - console_index);
> > +		n = min((size_t) len, ARRAY_SIZE(console_buf) - console_index);

-- 
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade

	

	
		
___________________________________ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it

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

* Re: [PATCH 08/17] uml: prepare fixing compilation output
  2006-04-07 16:05   ` Jeff Dike
@ 2006-04-07 21:50     ` Blaisorblade
  0 siblings, 0 replies; 23+ messages in thread
From: Blaisorblade @ 2006-04-07 21:50 UTC (permalink / raw)
  To: Jeff Dike; +Cc: Andrew Morton, linux-kernel, user-mode-linux-devel

On Friday 07 April 2006 18:05, Jeff Dike wrote:
> On Fri, Apr 07, 2006 at 04:31:08PM +0200, Paolo 'Blaisorblade' Giarrusso 
wrote:
> > Move the build of user-offsets to arch/um/Kbuild, this will allow using
> > the normal user-objs machinery. I had written this to fixup for a Kbuild
> > change, but another fix was merged. This is still useful however.

> What's the benefit of this?
Er, just a style issue - or now it's a little cleanup just for style - I've 
thought to merge it anyway, even if I haven't converted it to a standard 
rule.
-- 
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade

	

	
		
___________________________________ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it

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

end of thread, other threads:[~2006-04-07 21:50 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-07 14:27 [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:30 ` [PATCH 01/17] uml: make 64-bit COW files compatible with 32-bit ones Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:30 ` [PATCH 02/17] uml: safe migration path to the correct V3 COW format Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:30 ` [PATCH 03/17] uml: fix 2 harmless cast warnings for 64-bit Paolo 'Blaisorblade' Giarrusso
2006-04-07 16:02   ` Jeff Dike
2006-04-07 21:46     ` Blaisorblade
2006-04-07 14:30 ` [PATCH 04/17] uml: request format warnings to GCC for appropriate functions Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [PATCH 05/17] uml: fix format errors Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [PATCH 06/17] uml: fix some double export warnings Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [PATCH 07/17] uml: fix "extern-vs-static" proto conflict in TLS code Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [PATCH 08/17] uml: prepare fixing compilation output Paolo 'Blaisorblade' Giarrusso
2006-04-07 16:05   ` Jeff Dike
2006-04-07 21:50     ` Blaisorblade
2006-04-07 14:31 ` [PATCH 09/17] uml: fix critical typo for TT mode Paolo 'Blaisorblade' Giarrusso
2006-04-07 15:45   ` Jeff Dike
2006-04-07 14:31 ` [PATCH 10/17] uml: support sparse for userspace files Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [PATCH 11/17] uml: move outside spinlock call not needing it Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [PATCH 12/17] uml: fix hang on run_helper() failure on uml_net Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [PATCH 13/17] uml: fix failure path after conversion Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [PATCH 14/17] uml: fix big stack user Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [PATCH 15/17] uml: local_irq_save, not local_save_flags Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [PATCH 16/17] uml: fix parallel make early failure on clean tree Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [PATCH 17/17] uml: avoid warnings for diffent names for an unsigned quadword Paolo 'Blaisorblade' Giarrusso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).