GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-602118adcc
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
}
G_warning
void G_warning(const char *,...) __attribute__((format(printf
gis.h
seg_pageout
int seg_pageout(SEGMENT *SEG, int i)
Internal use only.
Definition:
pageout.c:35
SEGMENT::scb::n
int n
Definition:
segment.h:49
SEGMENT::scb::dirty
char dirty
Definition:
segment.h:47
SEGMENT::scb::buf
char * buf
Definition:
segment.h:46
SEGMENT
Definition:
segment.h:19
SEGMENT::scb
struct SEGMENT::scb * scb
SEGMENT::fd
int fd
Definition:
segment.h:43
SEGMENT::seek
int(* seek)(const struct SEGMENT *S, int, int)
Definition:
segment.h:40
SEGMENT::size
int size
Definition:
segment.h:27
err
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
Definition:
symbol/read.c:216
lib
segment
pageout.c
Generated on Mon Nov 18 2024 06:59:54 for GRASS GIS 8 Programmer's Manual by
1.9.1