Messages in this thread | | | From | fjolliton@free ... | Date | Thu, 27 Jul 2000 17:59:04 +0200 | Subject | [pre5/6] bad mmap behavior |
| |
Hi !
(First, I'm sorry for my bad english. Second, I'm a kernel newbie, and I'm not familiar with mmap)
It seem that mmap had a bad behavior since some pre test5 patch.
The above program show this.
On 2.2.17-pre13, output is "1 2", and on test5-pre5/6, output is "1 1".
BTW, for example, INN stop working correctly.
-=-=-=- #include <stdlib.h> #include <fcntl.h> #include <sys/mman.h>
static int fd ; char* ptr ;
void create_file() { char pattern = 1 ; int n ; fd = open( "test-mmap" , O_CREAT | O_WRONLY | O_TRUNC , 0664 ) ; if ( fd < 0 ) exit( 1 ) ; for ( n = 0 ; n < 100 ; ++ n ) write( fd , &pattern , 1 ) ; close( fd ) ; }
void init() { fd = open( "test-mmap" , O_RDWR ) ; if ( fd < 1 ) exit( 1 ) ; ptr = mmap( 0 , 100 , PROT_READ | PROT_WRITE , MAP_SHARED , fd , 0 ) ; if ( ptr == MAP_FAILED ) exit( 1 ) ; }
void cleanup() { munmap( ptr , 100 ) ; close( fd ) ; }
int main() { create_file() ;
init() ; printf( "%d\n" , (int)ptr[ 2 ] ) ; ptr[ 2 ] = 2 ; cleanup() ;
init() ; printf( "%d (should be 2 !?)\n" , (int)ptr[ 2 ] ) ; cleanup() ;
printf( ".\n" ) ;
return 0 ; } -=-=-=-
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |