SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

Diff markup

Differences between /userland/myprog10.c (Article 8) and /userland/myprog10.c (Article 9.5)


001 /* Copyright (C) 2005 David Decotigny             001 /* Copyright (C) 2005 David Decotigny
002                                                   002 
003    This program is free software; you can redi    003    This program is free software; you can redistribute it and/or
004    modify it under the terms of the GNU Genera    004    modify it under the terms of the GNU General Public License
005    as published by the Free Software Foundatio    005    as published by the Free Software Foundation; either version 2
006    of the License, or (at your option) any lat    006    of the License, or (at your option) any later version.
007                                                   007    
008    This program is distributed in the hope tha    008    This program is distributed in the hope that it will be useful,
009    but WITHOUT ANY WARRANTY; without even the     009    but WITHOUT ANY WARRANTY; without even the implied warranty of
010    MERCHANTABILITY or FITNESS FOR A PARTICULAR    010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011    GNU General Public License for more details    011    GNU General Public License for more details.
012                                                   012    
013    You should have received a copy of the GNU     013    You should have received a copy of the GNU General Public License
014    along with this program; if not, write to t    014    along with this program; if not, write to the Free Software
015    Foundation, Inc., 59 Temple Place - Suite 3    015    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
016    USA.                                           016    USA. 
017 */                                                017 */
018                                                   018 
019 #include <crt.h>                                  019 #include <crt.h>
020 #include <libc.h>                                 020 #include <libc.h>
021 #include <stdarg.h>                               021 #include <stdarg.h>
022 #include <debug.h>                                022 #include <debug.h>
023                                                   023 
024 /**                                               024 /**
025  * @file myprog10.c                               025  * @file myprog10.c
026  *                                                026  *
027  * mprotect tests                                 027  * mprotect tests
028  *                                                028  *
029  * We use the temporary syscall 4004 to dump t    029  * We use the temporary syscall 4004 to dump the list of VRs in the
030  * thread's address space                         030  * thread's address space
031  */                                               031  */
032                                                   032 
033 int main()                                     !! 033 int main(void)
034 {                                                 034 {
035   char * zoup;                                    035   char * zoup;
                                                   >> 036   int fd;
                                                   >> 037 
                                                   >> 038   fd = open("/dev/zero", O_RDWR);
                                                   >> 039   zoup = mmap((void*)4096, 8*1024*1024,
                                                   >> 040               PROT_READ | PROT_WRITE,
                                                   >> 041               MAP_SHARED,
                                                   >> 042               fd, 34);
                                                   >> 043   close(fd);
036                                                   044 
037   zoup = fakemmap((void*)4096, 8*1024*1024,    << 
038                   PROT_READ | PROT_WRITE,      << 
039                   MAP_SHARED,                  << 
040                   "/dev/zero", 34);            << 
041   bochs_printf("mapped @%x\n", (unsigned)zoup)    045   bochs_printf("mapped @%x\n", (unsigned)zoup);
042                                                   046 
043   /* Do some forks to complicate things */        047   /* Do some forks to complicate things */
044   fork();                                         048   fork();
045   fork();                                         049   fork();
046                                                   050 
047   _sos_syscall1(4004, (unsigned)"Initial");       051   _sos_syscall1(4004, (unsigned)"Initial");
048   mprotect(zoup, 10*4096, PROT_READ);             052   mprotect(zoup, 10*4096, PROT_READ);
049   zoup += 10*4096;                                053   zoup += 10*4096;
050   _sos_syscall1(4004, (unsigned)"After mprotec    054   _sos_syscall1(4004, (unsigned)"After mprotect Low");
051                                                   055 
052   mprotect(zoup-4096, 2*4096, PROT_READ);         056   mprotect(zoup-4096, 2*4096, PROT_READ);
053   zoup += 4096;                                   057   zoup += 4096;
054   _sos_syscall1(4004, (unsigned)"After mprotec    058   _sos_syscall1(4004, (unsigned)"After mprotect Before Low");
055                                                   059 
056   mprotect(zoup-4096, 4096, PROT_READ);           060   mprotect(zoup-4096, 4096, PROT_READ);
057   _sos_syscall1(4004, (unsigned)"After mprotec    061   _sos_syscall1(4004, (unsigned)"After mprotect Before low (bis)");
058                                                   062 
059   mprotect(zoup + 1024*1024, 4096, PROT_READ);    063   mprotect(zoup + 1024*1024, 4096, PROT_READ);
060   _sos_syscall1(4004, (unsigned)"After mprotec    064   _sos_syscall1(4004, (unsigned)"After mprotect Middle");
061                                                   065 
062   mprotect(zoup + 1024*1024, 4096, PROT_READ);    066   mprotect(zoup + 1024*1024, 4096, PROT_READ);
063   _sos_syscall1(4004, (unsigned)"After mprotec    067   _sos_syscall1(4004, (unsigned)"After mprotect Middle (bis)");
064                                                   068 
065   mprotect(zoup + 8*1024*1024 - 11*4096 - 4096    069   mprotect(zoup + 8*1024*1024 - 11*4096 - 4096, 4096, PROT_READ);
066   _sos_syscall1(4004, (unsigned)"After mprotec    070   _sos_syscall1(4004, (unsigned)"After mprotect High");
067                                                   071 
068   mprotect(zoup + 8*1024*1024 - 11*4096 - 2*40    072   mprotect(zoup + 8*1024*1024 - 11*4096 - 2*4096, 3*4096, PROT_READ);
069   _sos_syscall1(4004, (unsigned)"After mprotec    073   _sos_syscall1(4004, (unsigned)"After mprotect Past High");
070                                                   074 
071   mprotect((void*)0x40000000, 0x10000000, PROT    075   mprotect((void*)0x40000000, 0x10000000, PROT_READ);
072   _sos_syscall1(4004, (unsigned)"After mprotec    076   _sos_syscall1(4004, (unsigned)"After mprotect Complete VR");
073                                                   077 
074   mprotect((void*)0x40000000, 0x10000000, PROT    078   mprotect((void*)0x40000000, 0x10000000, PROT_READ);
075   _sos_syscall1(4004, (unsigned)"After mprotec    079   _sos_syscall1(4004, (unsigned)"After mprotect Complete VR (bis)");
076                                                   080 
077   return 0;                                       081   return 0;
078 }                                                 082 }
                                                      

source navigation ] diff markup ] identifier search ] general search ]