diff options
author | Steve French <sfrench@us.ibm.com> | 2005-06-22 21:26:47 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2005-06-22 21:26:47 -0400 |
commit | ea0daab4ae4a2f853f06c76961c0ed324fd0804c (patch) | |
tree | f6fbe2db5772695181b7a7257b05e43343bd8d75 /arch/um | |
parent | 58aab753de605c14b9878a897e7349c3063afeff (diff) | |
parent | 1bdf7a78c2b21fb94dfe7994dbe89310b18479d2 (diff) |
Merge with rsync://rsync.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6.git
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/Kconfig | 5 | ||||
-rw-r--r-- | arch/um/Makefile | 2 | ||||
-rw-r--r-- | arch/um/drivers/line.c | 3 | ||||
-rw-r--r-- | arch/um/drivers/net_kern.c | 1 | ||||
-rw-r--r-- | arch/um/drivers/port_kern.c | 1 | ||||
-rw-r--r-- | arch/um/drivers/xterm_kern.c | 1 | ||||
-rw-r--r-- | arch/um/kernel/irq.c | 11 | ||||
-rw-r--r-- | arch/um/kernel/irq_user.c | 2 | ||||
-rw-r--r-- | arch/um/kernel/mem.c | 1 | ||||
-rw-r--r-- | arch/um/kernel/tt/Makefile | 15 | ||||
-rw-r--r-- | arch/um/kernel/tt/unmap.c | 31 | ||||
-rw-r--r-- | arch/um/kernel/uml.lds.S | 15 | ||||
-rw-r--r-- | arch/um/scripts/Makefile.rules | 6 | ||||
-rw-r--r-- | arch/um/scripts/Makefile.unmap | 22 | ||||
-rw-r--r-- | arch/um/sys-i386/Makefile | 2 | ||||
-rw-r--r-- | arch/um/sys-i386/unmap.c | 25 | ||||
-rw-r--r-- | arch/um/sys-x86_64/Makefile | 2 | ||||
-rw-r--r-- | arch/um/sys-x86_64/unmap.c | 25 |
18 files changed, 98 insertions, 72 deletions
diff --git a/arch/um/Kconfig b/arch/um/Kconfig index c5292181a664..b8e952c88fd1 100644 --- a/arch/um/Kconfig +++ b/arch/um/Kconfig | |||
@@ -35,6 +35,11 @@ config GENERIC_CALIBRATE_DELAY | |||
35 | bool | 35 | bool |
36 | default y | 36 | default y |
37 | 37 | ||
38 | # Used in kernel/irq/manage.c and include/linux/irq.h | ||
39 | config IRQ_RELEASE_METHOD | ||
40 | bool | ||
41 | default y | ||
42 | |||
38 | menu "UML-specific options" | 43 | menu "UML-specific options" |
39 | 44 | ||
40 | config MODE_TT | 45 | config MODE_TT |
diff --git a/arch/um/Makefile b/arch/um/Makefile index f2a0c40a9204..3f073902351f 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile | |||
@@ -122,7 +122,7 @@ endif | |||
122 | CPPFLAGS_vmlinux.lds = $(shell echo -U$(SUBARCH) \ | 122 | CPPFLAGS_vmlinux.lds = $(shell echo -U$(SUBARCH) \ |
123 | -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \ | 123 | -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \ |
124 | -DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE-y) \ | 124 | -DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE-y) \ |
125 | -DKERNEL_STACK_SIZE=$(STACK_SIZE)) | 125 | -DKERNEL_STACK_SIZE=$(STACK_SIZE) -DSUBARCH=$(SUBARCH)) |
126 | 126 | ||
127 | #The wrappers will select whether using "malloc" or the kernel allocator. | 127 | #The wrappers will select whether using "malloc" or the kernel allocator. |
128 | LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc | 128 | LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc |
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index 025d3be8aca4..0f59736db329 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c | |||
@@ -406,14 +406,12 @@ void line_disable(struct tty_struct *tty, int current_irq) | |||
406 | if(line->driver->read_irq == current_irq) | 406 | if(line->driver->read_irq == current_irq) |
407 | free_irq_later(line->driver->read_irq, tty); | 407 | free_irq_later(line->driver->read_irq, tty); |
408 | else { | 408 | else { |
409 | free_irq_by_irq_and_dev(line->driver->read_irq, tty); | ||
410 | free_irq(line->driver->read_irq, tty); | 409 | free_irq(line->driver->read_irq, tty); |
411 | } | 410 | } |
412 | 411 | ||
413 | if(line->driver->write_irq == current_irq) | 412 | if(line->driver->write_irq == current_irq) |
414 | free_irq_later(line->driver->write_irq, tty); | 413 | free_irq_later(line->driver->write_irq, tty); |
415 | else { | 414 | else { |
416 | free_irq_by_irq_and_dev(line->driver->write_irq, tty); | ||
417 | free_irq(line->driver->write_irq, tty); | 415 | free_irq(line->driver->write_irq, tty); |
418 | } | 416 | } |
419 | 417 | ||
@@ -758,7 +756,6 @@ static void unregister_winch(struct tty_struct *tty) | |||
758 | if(winch->pid != -1) | 756 | if(winch->pid != -1) |
759 | os_kill_process(winch->pid, 1); | 757 | os_kill_process(winch->pid, 1); |
760 | 758 | ||
761 | free_irq_by_irq_and_dev(WINCH_IRQ, winch); | ||
762 | free_irq(WINCH_IRQ, winch); | 759 | free_irq(WINCH_IRQ, winch); |
763 | list_del(&winch->list); | 760 | list_del(&winch->list); |
764 | kfree(winch); | 761 | kfree(winch); |
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index 4eeaf88c1e97..5388a7428691 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c | |||
@@ -146,7 +146,6 @@ static int uml_net_close(struct net_device *dev) | |||
146 | netif_stop_queue(dev); | 146 | netif_stop_queue(dev); |
147 | spin_lock(&lp->lock); | 147 | spin_lock(&lp->lock); |
148 | 148 | ||
149 | free_irq_by_irq_and_dev(dev->irq, dev); | ||
150 | free_irq(dev->irq, dev); | 149 | free_irq(dev->irq, dev); |
151 | if(lp->close != NULL) | 150 | if(lp->close != NULL) |
152 | (*lp->close)(lp->fd, &lp->user); | 151 | (*lp->close)(lp->fd, &lp->user); |
diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c index b5ee07472f79..c41efd207fcc 100644 --- a/arch/um/drivers/port_kern.c +++ b/arch/um/drivers/port_kern.c | |||
@@ -257,7 +257,6 @@ int port_wait(void *data) | |||
257 | * connection. Then we loop here throwing out failed | 257 | * connection. Then we loop here throwing out failed |
258 | * connections until a good one is found. | 258 | * connections until a good one is found. |
259 | */ | 259 | */ |
260 | free_irq_by_irq_and_dev(TELNETD_IRQ, conn); | ||
261 | free_irq(TELNETD_IRQ, conn); | 260 | free_irq(TELNETD_IRQ, conn); |
262 | 261 | ||
263 | if(conn->fd >= 0) break; | 262 | if(conn->fd >= 0) break; |
diff --git a/arch/um/drivers/xterm_kern.c b/arch/um/drivers/xterm_kern.c index a4fdf3584ad2..d269a80f4b0c 100644 --- a/arch/um/drivers/xterm_kern.c +++ b/arch/um/drivers/xterm_kern.c | |||
@@ -69,7 +69,6 @@ int xterm_fd(int socket, int *pid_out) | |||
69 | * isn't set) this will hang... */ | 69 | * isn't set) this will hang... */ |
70 | wait_for_completion(&data->ready); | 70 | wait_for_completion(&data->ready); |
71 | 71 | ||
72 | free_irq_by_irq_and_dev(XTERM_IRQ, data); | ||
73 | free_irq(XTERM_IRQ, data); | 72 | free_irq(XTERM_IRQ, data); |
74 | 73 | ||
75 | ret = data->new_fd; | 74 | ret = data->new_fd; |
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c index d44fb5282547..9f18061ef4c9 100644 --- a/arch/um/kernel/irq.c +++ b/arch/um/kernel/irq.c | |||
@@ -124,14 +124,16 @@ void irq_unlock(unsigned long flags) | |||
124 | spin_unlock_irqrestore(&irq_spinlock, flags); | 124 | spin_unlock_irqrestore(&irq_spinlock, flags); |
125 | } | 125 | } |
126 | 126 | ||
127 | /* presently hw_interrupt_type must define (startup || enable) && | 127 | /* hw_interrupt_type must define (startup || enable) && |
128 | * disable && end */ | 128 | * (shutdown || disable) && end */ |
129 | static void dummy(unsigned int irq) | 129 | static void dummy(unsigned int irq) |
130 | { | 130 | { |
131 | } | 131 | } |
132 | 132 | ||
133 | static struct hw_interrupt_type SIGIO_irq_type = { | 133 | /* This is used for everything else than the timer. */ |
134 | static struct hw_interrupt_type normal_irq_type = { | ||
134 | .typename = "SIGIO", | 135 | .typename = "SIGIO", |
136 | .release = free_irq_by_irq_and_dev, | ||
135 | .disable = dummy, | 137 | .disable = dummy, |
136 | .enable = dummy, | 138 | .enable = dummy, |
137 | .ack = dummy, | 139 | .ack = dummy, |
@@ -140,6 +142,7 @@ static struct hw_interrupt_type SIGIO_irq_type = { | |||
140 | 142 | ||
141 | static struct hw_interrupt_type SIGVTALRM_irq_type = { | 143 | static struct hw_interrupt_type SIGVTALRM_irq_type = { |
142 | .typename = "SIGVTALRM", | 144 | .typename = "SIGVTALRM", |
145 | .release = free_irq_by_irq_and_dev, | ||
143 | .shutdown = dummy, /* never called */ | 146 | .shutdown = dummy, /* never called */ |
144 | .disable = dummy, | 147 | .disable = dummy, |
145 | .enable = dummy, | 148 | .enable = dummy, |
@@ -160,7 +163,7 @@ void __init init_IRQ(void) | |||
160 | irq_desc[i].status = IRQ_DISABLED; | 163 | irq_desc[i].status = IRQ_DISABLED; |
161 | irq_desc[i].action = NULL; | 164 | irq_desc[i].action = NULL; |
162 | irq_desc[i].depth = 1; | 165 | irq_desc[i].depth = 1; |
163 | irq_desc[i].handler = &SIGIO_irq_type; | 166 | irq_desc[i].handler = &normal_irq_type; |
164 | enable_irq(i); | 167 | enable_irq(i); |
165 | } | 168 | } |
166 | } | 169 | } |
diff --git a/arch/um/kernel/irq_user.c b/arch/um/kernel/irq_user.c index b3074cbaa479..c3ccaf24f3e0 100644 --- a/arch/um/kernel/irq_user.c +++ b/arch/um/kernel/irq_user.c | |||
@@ -85,8 +85,6 @@ void sigio_handler(int sig, union uml_pt_regs *regs) | |||
85 | next = irq_fd->next; | 85 | next = irq_fd->next; |
86 | if(irq_fd->freed){ | 86 | if(irq_fd->freed){ |
87 | free_irq(irq_fd->irq, irq_fd->id); | 87 | free_irq(irq_fd->irq, irq_fd->id); |
88 | free_irq_by_irq_and_dev(irq_fd->irq, | ||
89 | irq_fd->id); | ||
90 | } | 88 | } |
91 | } | 89 | } |
92 | } | 90 | } |
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index c22825f13e40..5597bd39e6b5 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c | |||
@@ -53,7 +53,6 @@ static void setup_highmem(unsigned long highmem_start, | |||
53 | for(i = 0; i < highmem_len >> PAGE_SHIFT; i++){ | 53 | for(i = 0; i < highmem_len >> PAGE_SHIFT; i++){ |
54 | page = &mem_map[highmem_pfn + i]; | 54 | page = &mem_map[highmem_pfn + i]; |
55 | ClearPageReserved(page); | 55 | ClearPageReserved(page); |
56 | set_bit(PG_highmem, &page->flags); | ||
57 | set_page_count(page, 1); | 56 | set_page_count(page, 1); |
58 | __free_page(page); | 57 | __free_page(page); |
59 | } | 58 | } |
diff --git a/arch/um/kernel/tt/Makefile b/arch/um/kernel/tt/Makefile index c3faea21a996..3fd2554e60b6 100644 --- a/arch/um/kernel/tt/Makefile +++ b/arch/um/kernel/tt/Makefile | |||
@@ -3,10 +3,6 @@ | |||
3 | # Licensed under the GPL | 3 | # Licensed under the GPL |
4 | # | 4 | # |
5 | 5 | ||
6 | extra-y := unmap_fin.o | ||
7 | targets := unmap.o | ||
8 | clean-files := unmap_tmp.o | ||
9 | |||
10 | obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \ | 6 | obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \ |
11 | syscall_kern.o syscall_user.o time.o tlb.o tracer.o trap_user.o \ | 7 | syscall_kern.o syscall_user.o time.o tlb.o tracer.o trap_user.o \ |
12 | uaccess.o uaccess_user.o | 8 | uaccess.o uaccess_user.o |
@@ -16,14 +12,3 @@ obj-$(CONFIG_PT_PROXY) += gdb_kern.o ptproxy/ | |||
16 | USER_OBJS := gdb.o time.o tracer.o | 12 | USER_OBJS := gdb.o time.o tracer.o |
17 | 13 | ||
18 | include arch/um/scripts/Makefile.rules | 14 | include arch/um/scripts/Makefile.rules |
19 | |||
20 | UNMAP_CFLAGS := $(patsubst -pg -DPROFILING,,$(USER_CFLAGS)) | ||
21 | UNMAP_CFLAGS := $(patsubst -fprofile-arcs -ftest-coverage,,$(UNMAP_CFLAGS)) | ||
22 | |||
23 | #XXX: partially copied from arch/um/scripts/Makefile.rules | ||
24 | $(obj)/unmap.o: c_flags = -Wp,-MD,$(depfile) $(UNMAP_CFLAGS) | ||
25 | |||
26 | $(obj)/unmap_fin.o : $(obj)/unmap.o | ||
27 | $(LD) -r -o $(obj)/unmap_tmp.o $< $(shell $(CC) -print-file-name=libc.a) | ||
28 | $(OBJCOPY) $(obj)/unmap_tmp.o $@ -G switcheroo | ||
29 | |||
diff --git a/arch/um/kernel/tt/unmap.c b/arch/um/kernel/tt/unmap.c deleted file mode 100644 index 3f7aecdbe532..000000000000 --- a/arch/um/kernel/tt/unmap.c +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include <sys/mman.h> | ||
7 | |||
8 | int switcheroo(int fd, int prot, void *from, void *to, int size) | ||
9 | { | ||
10 | if(munmap(to, size) < 0){ | ||
11 | return(-1); | ||
12 | } | ||
13 | if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){ | ||
14 | return(-1); | ||
15 | } | ||
16 | if(munmap(from, size) < 0){ | ||
17 | return(-1); | ||
18 | } | ||
19 | return(0); | ||
20 | } | ||
21 | |||
22 | /* | ||
23 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
24 | * Emacs will notice this stuff at the end of the file and automatically | ||
25 | * adjust the settings for this buffer only. This must remain at the end | ||
26 | * of the file. | ||
27 | * --------------------------------------------------------------------------- | ||
28 | * Local variables: | ||
29 | * c-file-style: "linux" | ||
30 | * End: | ||
31 | */ | ||
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S index dd5355500bdc..61dfd4fef752 100644 --- a/arch/um/kernel/uml.lds.S +++ b/arch/um/kernel/uml.lds.S | |||
@@ -14,19 +14,10 @@ SECTIONS | |||
14 | /* Used in arch/um/kernel/mem.c. Any memory between START and __binary_start | 14 | /* Used in arch/um/kernel/mem.c. Any memory between START and __binary_start |
15 | * is remapped.*/ | 15 | * is remapped.*/ |
16 | __binary_start = .; | 16 | __binary_start = .; |
17 | #ifdef MODE_TT | ||
18 | .thread_private : { | ||
19 | __start_thread_private = .; | ||
20 | errno = .; | ||
21 | . += 4; | ||
22 | arch/um/kernel/tt/unmap_fin.o (.data) | ||
23 | __end_thread_private = .; | ||
24 | } | ||
25 | . = ALIGN(4096); | ||
26 | .remap : { arch/um/kernel/tt/unmap_fin.o (.text) } | ||
27 | 17 | ||
28 | /* We want it only if we are in MODE_TT. In both cases, however, when MODE_TT | 18 | #ifdef MODE_TT |
29 | * is off the resulting binary segfaults.*/ | 19 | .remap_data : { arch/um/sys-SUBARCH/unmap_fin.o (.data .bss) } |
20 | .remap : { arch/um/sys-SUBARCH/unmap_fin.o (.text) } | ||
30 | 21 | ||
31 | . = ALIGN(4096); /* Init code and data */ | 22 | . = ALIGN(4096); /* Init code and data */ |
32 | #endif | 23 | #endif |
diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules index 98346c711493..7459d09c233e 100644 --- a/arch/um/scripts/Makefile.rules +++ b/arch/um/scripts/Makefile.rules | |||
@@ -10,6 +10,12 @@ USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) | |||
10 | $(USER_OBJS) : c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \ | 10 | $(USER_OBJS) : c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \ |
11 | $(CFLAGS_$(notdir $@)) | 11 | $(CFLAGS_$(notdir $@)) |
12 | 12 | ||
13 | # The stubs and unmap.o can't try to call mcount or update basic block data | ||
14 | define unprofile | ||
15 | $(patsubst -pg,,$(patsubst -fprofile-arcs -ftest-coverage,,$(1))) | ||
16 | endef | ||
17 | |||
18 | |||
13 | quiet_cmd_make_link = SYMLINK $@ | 19 | quiet_cmd_make_link = SYMLINK $@ |
14 | cmd_make_link = ln -sf $(srctree)/arch/$(SUBARCH)/$($(notdir $@)-dir)/$(notdir $@) $@ | 20 | cmd_make_link = ln -sf $(srctree)/arch/$(SUBARCH)/$($(notdir $@)-dir)/$(notdir $@) $@ |
15 | 21 | ||
diff --git a/arch/um/scripts/Makefile.unmap b/arch/um/scripts/Makefile.unmap new file mode 100644 index 000000000000..37a8f9765295 --- /dev/null +++ b/arch/um/scripts/Makefile.unmap | |||
@@ -0,0 +1,22 @@ | |||
1 | clean-files += unmap_tmp.o unmap_fin.o unmap.o | ||
2 | |||
3 | ifdef CONFIG_MODE_TT | ||
4 | |||
5 | #Always build unmap_fin.o | ||
6 | extra-y += unmap_fin.o | ||
7 | #Do dependency tracking for unmap.o (it will be always built, but won't get the tracking unless we use this). | ||
8 | targets += unmap.o | ||
9 | |||
10 | #XXX: partially copied from arch/um/scripts/Makefile.rules | ||
11 | $(obj)/unmap.o: _c_flags = $(call unprofile,$(CFLAGS)) | ||
12 | |||
13 | quiet_cmd_wrapld = LD $@ | ||
14 | define cmd_wrapld | ||
15 | $(LD) -r -o $(obj)/unmap_tmp.o $< $(shell $(CC) -print-file-name=libc.a); \ | ||
16 | $(OBJCOPY) $(obj)/unmap_tmp.o $@ -G switcheroo | ||
17 | endef | ||
18 | |||
19 | $(obj)/unmap_fin.o : $(obj)/unmap.o FORCE | ||
20 | $(call if_changed,wrapld) | ||
21 | |||
22 | endif | ||
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile index 4351e5605506..095bcdb0b9cc 100644 --- a/arch/um/sys-i386/Makefile +++ b/arch/um/sys-i386/Makefile | |||
@@ -17,3 +17,5 @@ highmem.c-dir = mm | |||
17 | module.c-dir = kernel | 17 | module.c-dir = kernel |
18 | 18 | ||
19 | subdir- := util | 19 | subdir- := util |
20 | |||
21 | include arch/um/scripts/Makefile.unmap | ||
diff --git a/arch/um/sys-i386/unmap.c b/arch/um/sys-i386/unmap.c new file mode 100644 index 000000000000..136875263d27 --- /dev/null +++ b/arch/um/sys-i386/unmap.c | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include <linux/mman.h> | ||
7 | #include <asm/unistd.h> | ||
8 | |||
9 | static int errno; | ||
10 | |||
11 | static inline _syscall2(int,munmap,void *,start,size_t,len) | ||
12 | static inline _syscall6(void *,mmap2,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset) | ||
13 | int switcheroo(int fd, int prot, void *from, void *to, int size) | ||
14 | { | ||
15 | if(munmap(to, size) < 0){ | ||
16 | return(-1); | ||
17 | } | ||
18 | if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){ | ||
19 | return(-1); | ||
20 | } | ||
21 | if(munmap(from, size) < 0){ | ||
22 | return(-1); | ||
23 | } | ||
24 | return(0); | ||
25 | } | ||
diff --git a/arch/um/sys-x86_64/Makefile b/arch/um/sys-x86_64/Makefile index 608466ad6b22..2bc6f6849010 100644 --- a/arch/um/sys-x86_64/Makefile +++ b/arch/um/sys-x86_64/Makefile | |||
@@ -29,3 +29,5 @@ thunk.S-dir = lib | |||
29 | module.c-dir = kernel | 29 | module.c-dir = kernel |
30 | 30 | ||
31 | subdir- := util | 31 | subdir- := util |
32 | |||
33 | include arch/um/scripts/Makefile.unmap | ||
diff --git a/arch/um/sys-x86_64/unmap.c b/arch/um/sys-x86_64/unmap.c new file mode 100644 index 000000000000..bc7094cce47e --- /dev/null +++ b/arch/um/sys-x86_64/unmap.c | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include <linux/mman.h> | ||
7 | #include <asm/unistd.h> | ||
8 | |||
9 | static int errno; | ||
10 | |||
11 | static inline _syscall2(int,munmap,void *,start,size_t,len) | ||
12 | static inline _syscall6(void *,mmap,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset) | ||
13 | int switcheroo(int fd, int prot, void *from, void *to, int size) | ||
14 | { | ||
15 | if(munmap(to, size) < 0){ | ||
16 | return(-1); | ||
17 | } | ||
18 | if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){ | ||
19 | return(-1); | ||
20 | } | ||
21 | if(munmap(from, size) < 0){ | ||
22 | return(-1); | ||
23 | } | ||
24 | return(0); | ||
25 | } | ||