if (PFE_set.mapfile)
{
PFE.mapfile_fd = open (PFE_set.mapfile, O_RDWR|O_CREAT|O_TRUNC, 0660);
if (PFE.mapfile_fd == -1)
{
P4_info3("[%p] %s: could not open: %s" ,
p4TH, PFE_set.mapfile, strerror(errno));
PFE.mapfile_fd = 0;
}else{
lseek (PFE.mapfile_fd, PFE_set.total_size-3, SEEK_SET);
write (PFE.mapfile_fd, "END" , 3);
# ifndef MAP_FAILED
# define MAP_FAILED ((void *) -1)
# endif
PFE_MEM = MAP_FAILED;
if (PFE_set.mapbase)
{
PFE_MEM = mmap(PFE_set.mapbase, PFE_set.total_size,
PROT_READ|PROT_WRITE, MAP_SHARED, PFE.mapfile_fd, 0);
if (PFE_MEM == MAP_FAILED)
P4_fail4 ("[%p] %s: could not mmap to mapbase %08p : %s" ,
p4TH, PFE_set.mapfile, PFE_set.mapbase, strerror(errno));
}
if (PFE_MEM == MAP_FAILED)
{
PFE_MEM = mmap(0, PFE_set.total_size,
PROT_READ|PROT_WRITE, MAP_SHARED, PFE.mapfile_fd, 0);
if (PFE_MEM == MAP_FAILED)
P4_info3("[%p] %s: could not mmap: %s" ,
p4TH, PFE_set.mapfile, strerror(errno));
}
if (PFE_MEM == MAP_FAILED)
{
close(PFE.mapfile_fd);
PFE.mapfile_fd = 0;
PFE_MEM = 0;
}else{
P4_info3 ("[%p] mapped at %8p len %d" ,
p4TH, PFE_MEM, PFE_set.total_size);
}
}
} |