The file to be mapped is a regular file.
if( ( fildes = open( filename , 2 ) ) < 0 )
{
printf( "cannot open file\n" );
exit(1);
}
file_ptr = shmat( fildes, 0, SHM_COPY );
The SHM_COPY constant is defined in the /usr/include/sys/shm.h file. This constant indicates that the file is a copy-on-write mapped file. Include this header file and other shared memory header files in a program with the following directives:
#include <sys/shm.h>
while ( file_ptr < eof)
{
.
.
.
(references to file using file_ptr)
}
fsync( fildes );
close( fildes );
Mapping Files with the shmat Subroutine.
Creating a Mapped Data File with the shmat Subroutine.
The shmat subroutine, shmctl subroutine, shmdt subroutine, shmget subroutine.