unmap.c 728 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
  3. * Licensed under the GPL
  4. */
  5. #include <sys/mman.h>
  6. int switcheroo(int fd, int prot, void *from, void *to, int size)
  7. {
  8. if(munmap(to, size) < 0){
  9. return(-1);
  10. }
  11. if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){
  12. return(-1);
  13. }
  14. if(munmap(from, size) < 0){
  15. return(-1);
  16. }
  17. return(0);
  18. }
  19. /*
  20. * Overrides for Emacs so that we follow Linus's tabbing style.
  21. * Emacs will notice this stuff at the end of the file and automatically
  22. * adjust the settings for this buffer only. This must remain at the end
  23. * of the file.
  24. * ---------------------------------------------------------------------------
  25. * Local variables:
  26. * c-file-style: "linux"
  27. * End:
  28. */