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

Return an early error message when no TT support is compiled in and no SKAS
support is detected.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/um/kernel/process.c |   35 ++++++++++++++++++++++++++---------
 25-akpm/arch/um/kernel/um_arch.c |   10 +++++++++-
 2 files changed, 35 insertions(+), 10 deletions(-)

diff -puN arch/um/kernel/process.c~uml-refuse-to-run-without-skas-if-no-tt-mode-in arch/um/kernel/process.c
--- 25/arch/um/kernel/process.c~uml-refuse-to-run-without-skas-if-no-tt-mode-in	Thu Jan 13 15:32:06 2005
+++ 25-akpm/arch/um/kernel/process.c	Thu Jan 13 15:32:06 2005
@@ -375,9 +375,9 @@ void forward_pending_sigio(int target)
 		kill(target, SIGIO);
 }
 
-int can_do_skas(void)
-{
 #ifdef UML_CONFIG_MODE_SKAS
+static inline int check_skas3_ptrace_support(void)
+{
 	struct ptrace_faultinfo fi;
 	void *stack;
 	int pid, n, ret = 1;
@@ -386,29 +386,46 @@ int can_do_skas(void)
 	pid = start_ptraced_child(&stack);
 
 	n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi);
-	if(n < 0){
+	if (n < 0) {
 		if(errno == EIO)
 			printf("not found\n");
-		else printf("No (unexpected errno - %d)\n", errno);
+		else {
+			perror("not found");
+		}
 		ret = 0;
+	} else {
+		printf("found\n");
 	}
-	else printf("found\n");
 
 	init_registers(pid);
 	stop_ptraced_child(pid, stack, 1, 1);
 
+	return(ret);
+}
+
+int can_do_skas(void)
+{
+	int ret = 1;
+
 	printf("Checking for /proc/mm...");
-	if(os_access("/proc/mm", OS_ACC_W_OK) < 0){
+	if (os_access("/proc/mm", OS_ACC_W_OK) < 0) {
 		printf("not found\n");
 		ret = 0;
+		goto out;
+	} else {
+		printf("found\n");
 	}
-	else printf("found\n");
 
-	return(ret);
+	ret = check_skas3_ptrace_support();
+out:
+	return ret;
+}
 #else
+int can_do_skas(void)
+{
 	return(0);
-#endif
 }
+#endif
 
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
diff -puN arch/um/kernel/um_arch.c~uml-refuse-to-run-without-skas-if-no-tt-mode-in arch/um/kernel/um_arch.c
--- 25/arch/um/kernel/um_arch.c~uml-refuse-to-run-without-skas-if-no-tt-mode-in	Thu Jan 13 15:32:06 2005
+++ 25-akpm/arch/um/kernel/um_arch.c	Thu Jan 13 15:32:06 2005
@@ -198,7 +198,7 @@ __uml_setup("ncpus=", uml_ncpus_setup,
 );
 #endif
 
-int force_tt = 0;
+static int force_tt = 0;
 
 #if defined(CONFIG_MODE_TT) && defined(CONFIG_MODE_SKAS)
 #define DEFAULT_TT 0
@@ -319,6 +319,14 @@ int linux_main(int argc, char **argv)
 	if(have_root == 0) add_arg(saved_command_line, DEFAULT_COMMAND_LINE);
 
 	mode_tt = force_tt ? 1 : !can_do_skas();
+#ifndef CONFIG_MODE_TT
+	if (mode_tt) {
+		/*Since CONFIG_MODE_TT is #undef'ed, force_tt cannot be 1. So,
+		 * can_do_skas() returned 0, and the message is correct. */
+		printf("Support for TT mode is disabled, and no SKAS support is present on the host.\n");
+		exit(1);
+	}
+#endif
 	uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0,
 				     &host_task_size, &task_size);
 
_