/*
* write_file does not allow incomplete writes. It loops internally
* until len bytes are written or errno is set.
/*
* write_file does not allow incomplete writes. It loops internally
* until len bytes are written or errno is set.
read(). It gives sliding window access to a file. mmap() is not
used because of the possibility of another program (such as a
mailer) truncating the file thus giving us a SIGBUS */
read(). It gives sliding window access to a file. mmap() is not
used because of the possibility of another program (such as a
mailer) truncating the file thus giving us a SIGBUS */
/* slide the read window in the file */
char *map_ptr(struct map_struct *map,OFF_T offset,int len)
{
/* slide the read window in the file */
char *map_ptr(struct map_struct *map,OFF_T offset,int len)
{
OFF_T window_start, read_start;
int window_size, read_size, read_offset;
OFF_T window_start, read_start;
int window_size, read_size, read_offset;
/* nope, we are going to have to do a read. Work out our desired window */
if (offset > 2*CHUNK_SIZE) {
window_start = offset - 2*CHUNK_SIZE;
/* nope, we are going to have to do a read. Work out our desired window */
if (offset > 2*CHUNK_SIZE) {
window_start = offset - 2*CHUNK_SIZE;
/* make sure we have allocated enough memory for the window */
if (window_size > map->p_size) {
map->p = realloc_array(map->p, char, window_size);
/* make sure we have allocated enough memory for the window */
if (window_size > map->p_size) {
map->p = realloc_array(map->p, char, window_size);