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