int do_mappings(void) { int size_fd; int uio_size; size_fd = open( UIO_SIZE0, O_RDONLY ); if( size_fd<0 || uio_fd<0 ) { fprintf(stderr,"Can't open UIO file 0...\n"); return -1; } read( size_fd, uio_size_buf, sizeof(uio_size_buf) ); uio_size = (int)strtol( uio_size_buf, NULL, 0 ); BAR[0] = (BYTE *)mmap(NULL, uio_size, PROT_READ | PROT_WRITE, MAP_SHARED, uio_fd, 0); if(BAR[0] == MAP_FAILED) perror("BAR0:\n"); close(size_fd); size_fd = open( UIO_SIZE1, O_RDONLY ); if( size_fd<0 ) { fprintf(stderr,"Can't open UIO file 1...\n"); return -1; } read( size_fd, uio_size_buf, sizeof(uio_size_buf) ); uio_size = (int)strtol( uio_size_buf, NULL, 0 ); BAR[1] = (BYTE *)mmap(NULL, uio_size, PROT_READ | PROT_WRITE, MAP_SHARED, uio_fd, getpagesize()); close(size_fd); size_fd = open( UIO_SIZE2, O_RDONLY ); if( size_fd<0 ) { fprintf(stderr,"Can't open UIO file 2...\n"); return -1; } read( size_fd, uio_size_buf, sizeof(uio_size_buf) ); uio_size = (int)strtol( uio_size_buf, NULL, 0 ); BAR[2] = (BYTE *)mmap(NULL, uio_size, PROT_READ | PROT_WRITE, MAP_SHARED, uio_fd, 2*getpagesize()); close(size_fd); return(0); }