* (c) 2003--2005 Robert Spalek <robert@ucw.cz>
*
* This software may be freely distributed and used according to the terms
* (c) 2003--2005 Robert Spalek <robert@ucw.cz>
*
* This software may be freely distributed and used according to the terms
if ((p->file_size = sh_seek(p->fd, 0, SEEK_END)) < 0)
die("lseek(%s): %m", name);
p->writeable = writeable;
if ((p->file_size = sh_seek(p->fd, 0, SEEK_END)) < 0)
die("lseek(%s): %m", name);
p->writeable = writeable;
if (p->start_map)
munmap(p->start_map, p->end_off - p->start_off);
sh_off_t end = start + size;
if (p->start_map)
munmap(p->start_map, p->end_off - p->start_off);
sh_off_t end = start + size;
if ((sh_off_t) (win_start+win_len) < end)
die("partmap_map: Window is too small for mapping %d bytes", size);
p->start_map = sh_mmap(NULL, win_len, p->writeable ? (PROT_READ | PROT_WRITE) : PROT_READ, MAP_SHARED, p->fd, win_start);
if (p->start_map == MAP_FAILED)
if ((sh_off_t) (win_start+win_len) < end)
die("partmap_map: Window is too small for mapping %d bytes", size);
p->start_map = sh_mmap(NULL, win_len, p->writeable ? (PROT_READ | PROT_WRITE) : PROT_READ, MAP_SHARED, p->fd, win_start);
if (p->start_map == MAP_FAILED)