summaryrefslogtreecommitdiffstats
path: root/arch/um/sys-i386/unmap.c
blob: 8e55cd5d3d07230bb5d98d5a5113fd6b707cec8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
 * Licensed under the GPL
 */

#include <linux/mman.h>
#include <asm/unistd.h>
#include <sys/syscall.h>

int switcheroo(int fd, int prot, void *from, void *to, int size)
{
	if (syscall(__NR_munmap, to, size) < 0){
		return(-1);
	}
	if (syscall(__NR_mmap2, to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){
		return(-1);
	}
	if (syscall(__NR_munmap, from, size) < 0){
		return(-1);
	}
	return(0);
}