GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-a351e5eb69
pageout.c
Go to the documentation of this file.
1 /**
2  * \file pageout.c
3  *
4  * \brief Segment page-out routines.
5  *
6  * This program is free software under the GNU General Public License
7  * (>=v2). Read the file COPYING that comes with GRASS for details.
8  *
9  * \author GRASS GIS Development Team
10  *
11  * \date 2005-2009
12  */
13 
14 #include <stdio.h>
15 #include <unistd.h>
16 #include <string.h>
17 #include <errno.h>
18 #include <grass/gis.h>
19 #include "local_proto.h"
20 
21 /**
22  * \brief Internal use only
23  *
24  * Pages segment to disk.
25  *
26  * Finds segment value <b>i</b> in segment <b>seg</b> and pages it out
27  * to disk.
28  *
29  * \param[in] SEG segment
30  * \param[in] i segment value
31  * \return 1 if successful
32  * \return -1 on error
33  */
34 
35 int seg_pageout(SEGMENT *SEG, int i)
36 {
37  SEG->seek(SEG, SEG->scb[i].n, 0);
38  errno = 0;
39  if (write(SEG->fd, SEG->scb[i].buf, SEG->size) != SEG->size) {
40  int err = errno;
41 
42  if (err)
43  G_warning("Segment pageout: %s", strerror(err));
44  else
45  G_warning("Segment pageout: insufficient disk space?");
46  return -1;
47  }
48  SEG->scb[i].dirty = 0;
49 
50  return 1;
51 }
void G_warning(const char *,...) __attribute__((format(printf
int seg_pageout(SEGMENT *SEG, int i)
Internal use only.
Definition: pageout.c:35
char dirty
Definition: segment.h:47
char * buf
Definition: segment.h:46
struct SEGMENT::scb * scb
int fd
Definition: segment.h:43
int(* seek)(const struct SEGMENT *S, int, int)
Definition: segment.h:40
int size
Definition: segment.h:27
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
Definition: symbol/read.c:216