diff options
author | Jeff Dike <jdike@addtoit.com> | 2005-09-16 22:27:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-17 14:50:00 -0400 |
commit | 0f80bc85c587e8fdeecece4f294a47eca4922ea2 (patch) | |
tree | f18924fbc19779b2fffb5337c8c6826d2d181508 /arch/um/os-Linux/start_up.c | |
parent | b4fd310e163477236a241580b3b8c29aee65f4cc (diff) |
[PATCH] uml: move libc code out of mem_user.c and tempfile.c
The serial UML OS-abstraction layer patch (um/kernel dir).
This moves all system calls from mem_user.c and tempfile.c files under
os-Linux dir.
Signed-off-by: Gennady Sharapov <Gennady.V.Sharapov@intel.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/os-Linux/start_up.c')
-rw-r--r-- | arch/um/os-Linux/start_up.c | 109 |
1 files changed, 107 insertions, 2 deletions
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c index 040cc1472bc7..6af83171ca4e 100644 --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c | |||
@@ -4,18 +4,22 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | #include <stddef.h> | ||
8 | #include <stdarg.h> | ||
9 | #include <stdlib.h> | ||
10 | #include <string.h> | ||
7 | #include <unistd.h> | 11 | #include <unistd.h> |
8 | #include <signal.h> | 12 | #include <signal.h> |
9 | #include <sched.h> | 13 | #include <sched.h> |
14 | #include <fcntl.h> | ||
10 | #include <errno.h> | 15 | #include <errno.h> |
11 | #include <stdarg.h> | ||
12 | #include <stdlib.h> | ||
13 | #include <setjmp.h> | 16 | #include <setjmp.h> |
14 | #include <sys/time.h> | 17 | #include <sys/time.h> |
15 | #include <sys/wait.h> | 18 | #include <sys/wait.h> |
16 | #include <sys/mman.h> | 19 | #include <sys/mman.h> |
17 | #include <asm/unistd.h> | 20 | #include <asm/unistd.h> |
18 | #include <asm/page.h> | 21 | #include <asm/page.h> |
22 | #include <sys/types.h> | ||
19 | #include "user_util.h" | 23 | #include "user_util.h" |
20 | #include "kern_util.h" | 24 | #include "kern_util.h" |
21 | #include "user.h" | 25 | #include "user.h" |
@@ -25,6 +29,7 @@ | |||
25 | #include "sysdep/sigcontext.h" | 29 | #include "sysdep/sigcontext.h" |
26 | #include "irq_user.h" | 30 | #include "irq_user.h" |
27 | #include "ptrace_user.h" | 31 | #include "ptrace_user.h" |
32 | #include "mem_user.h" | ||
28 | #include "time_user.h" | 33 | #include "time_user.h" |
29 | #include "init.h" | 34 | #include "init.h" |
30 | #include "os.h" | 35 | #include "os.h" |
@@ -32,6 +37,8 @@ | |||
32 | #include "choose-mode.h" | 37 | #include "choose-mode.h" |
33 | #include "mode.h" | 38 | #include "mode.h" |
34 | #include "tempfile.h" | 39 | #include "tempfile.h" |
40 | #include "kern_constants.h" | ||
41 | |||
35 | #ifdef UML_CONFIG_MODE_SKAS | 42 | #ifdef UML_CONFIG_MODE_SKAS |
36 | #include "skas.h" | 43 | #include "skas.h" |
37 | #include "skas_ptrace.h" | 44 | #include "skas_ptrace.h" |
@@ -276,9 +283,38 @@ static void __init check_ptrace(void) | |||
276 | check_sysemu(); | 283 | check_sysemu(); |
277 | } | 284 | } |
278 | 285 | ||
286 | extern int create_tmp_file(unsigned long len); | ||
287 | |||
288 | static void check_tmpexec(void) | ||
289 | { | ||
290 | void *addr; | ||
291 | int err, fd = create_tmp_file(UM_KERN_PAGE_SIZE); | ||
292 | |||
293 | addr = mmap(NULL, UM_KERN_PAGE_SIZE, | ||
294 | PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); | ||
295 | printf("Checking PROT_EXEC mmap in /tmp..."); | ||
296 | fflush(stdout); | ||
297 | if(addr == MAP_FAILED){ | ||
298 | err = errno; | ||
299 | perror("failed"); | ||
300 | if(err == EPERM) | ||
301 | printf("/tmp must be not mounted noexec\n"); | ||
302 | exit(1); | ||
303 | } | ||
304 | printf("OK\n"); | ||
305 | munmap(addr, UM_KERN_PAGE_SIZE); | ||
306 | |||
307 | close(fd); | ||
308 | } | ||
309 | |||
279 | void os_early_checks(void) | 310 | void os_early_checks(void) |
280 | { | 311 | { |
281 | check_ptrace(); | 312 | check_ptrace(); |
313 | |||
314 | /* Need to check this early because mmapping happens before the | ||
315 | * kernel is running. | ||
316 | */ | ||
317 | check_tmpexec(); | ||
282 | } | 318 | } |
283 | 319 | ||
284 | static int __init noprocmm_cmd_param(char *str, int* add) | 320 | static int __init noprocmm_cmd_param(char *str, int* add) |
@@ -357,3 +393,72 @@ int can_do_skas(void) | |||
357 | return(0); | 393 | return(0); |
358 | } | 394 | } |
359 | #endif | 395 | #endif |
396 | |||
397 | int have_devanon = 0; | ||
398 | |||
399 | void check_devanon(void) | ||
400 | { | ||
401 | int fd; | ||
402 | |||
403 | printk("Checking for /dev/anon on the host..."); | ||
404 | fd = open("/dev/anon", O_RDWR); | ||
405 | if(fd < 0){ | ||
406 | printk("Not available (open failed with errno %d)\n", errno); | ||
407 | return; | ||
408 | } | ||
409 | |||
410 | printk("OK\n"); | ||
411 | have_devanon = 1; | ||
412 | } | ||
413 | |||
414 | int __init parse_iomem(char *str, int *add) | ||
415 | { | ||
416 | struct iomem_region *new; | ||
417 | struct uml_stat buf; | ||
418 | char *file, *driver; | ||
419 | int fd, err, size; | ||
420 | |||
421 | driver = str; | ||
422 | file = strchr(str,','); | ||
423 | if(file == NULL){ | ||
424 | printf("parse_iomem : failed to parse iomem\n"); | ||
425 | goto out; | ||
426 | } | ||
427 | *file = '\0'; | ||
428 | file++; | ||
429 | fd = os_open_file(file, of_rdwr(OPENFLAGS()), 0); | ||
430 | if(fd < 0){ | ||
431 | os_print_error(fd, "parse_iomem - Couldn't open io file"); | ||
432 | goto out; | ||
433 | } | ||
434 | |||
435 | err = os_stat_fd(fd, &buf); | ||
436 | if(err < 0){ | ||
437 | os_print_error(err, "parse_iomem - cannot stat_fd file"); | ||
438 | goto out_close; | ||
439 | } | ||
440 | |||
441 | new = malloc(sizeof(*new)); | ||
442 | if(new == NULL){ | ||
443 | perror("Couldn't allocate iomem_region struct"); | ||
444 | goto out_close; | ||
445 | } | ||
446 | |||
447 | size = (buf.ust_size + UM_KERN_PAGE_SIZE) & ~(UM_KERN_PAGE_SIZE - 1); | ||
448 | |||
449 | *new = ((struct iomem_region) { .next = iomem_regions, | ||
450 | .driver = driver, | ||
451 | .fd = fd, | ||
452 | .size = size, | ||
453 | .phys = 0, | ||
454 | .virt = 0 }); | ||
455 | iomem_regions = new; | ||
456 | iomem_size += new->size + UM_KERN_PAGE_SIZE; | ||
457 | |||
458 | return(0); | ||
459 | out_close: | ||
460 | os_close_file(fd); | ||
461 | out: | ||
462 | return(1); | ||
463 | } | ||
464 | |||