]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mpool.3
man*/: srcfix (Use .P instead of .PP or .LP)
[thirdparty/man-pages.git] / man3 / mpool.3
CommitLineData
fea681da
MK
1.\" Copyright (c) 1990, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
47009d5e 4.\" SPDX-License-Identifier: BSD-4-Clause-UC
fea681da
MK
5.\"
6.\" @(#)mpool.3 8.1 (Berkeley) 6/4/93
7.\"
4c1c5274 8.TH mpool 3 (date) "Linux man-pages (unreleased)"
fea681da
MK
9.UC 7
10.SH NAME
11mpool \- shared memory buffer pool
364fbecf
AC
12.SH LIBRARY
13Standard C library
8fc3b2cf 14.RI ( libc ", " \-lc )
fea681da
MK
15.SH SYNOPSIS
16.nf
495846d9
MK
17.B #include <db.h>
18.B #include <mpool.h>
c6d039a3 19.P
62218dc0 20.BI "MPOOL *mpool_open(DBT *" key ", int " fd ", pgno_t " pagesize \
da8cb51e 21", pgno_t " maxcache );
c6d039a3 22.P
62218dc0 23.BI "void mpool_filter(MPOOL *" mp ", void (*pgin)(void *, pgno_t, void *),"
3dc4c74e 24.BI " void (*" pgout ")(void *, pgno_t, void *),"
da8cb51e 25.BI " void *" pgcookie );
c6d039a3 26.P
da8cb51e 27.BI "void *mpool_new(MPOOL *" mp ", pgno_t *" pgnoaddr );
da8cb51e 28.BI "void *mpool_get(MPOOL *" mp ", pgno_t " pgno ", unsigned int " flags );
da8cb51e 29.BI "int mpool_put(MPOOL *" mp ", void *" pgaddr ", unsigned int " flags );
c6d039a3 30.P
da8cb51e 31.BI "int mpool_sync(MPOOL *" mp );
da8cb51e 32.BI "int mpool_close(MPOOL *" mp );
fea681da
MK
33.fi
34.SH DESCRIPTION
df21098d 35.IR "Note well" :
b324e17d
AC
36This page documents interfaces provided up until glibc 2.1.
37Since glibc 2.2, glibc no longer provides these interfaces.
df21098d
MK
38Probably, you are looking for the APIs provided by the
39.I libdb
40library instead.
c6d039a3 41.P
0daa9e92 42.I Mpool
fea681da
MK
43is the library interface intended to provide page oriented buffer management
44of files.
45The buffers may be shared between processes.
c6d039a3 46.P
fea681da 47The function
31e9a9ec 48.BR mpool_open ()
fea681da
MK
49initializes a memory pool.
50The
51.I key
52argument is the byte string used to negotiate between multiple
53processes wishing to share buffers.
54If the file buffers are mapped in shared memory, all processes using
55the same key will share the buffers.
56If
57.I key
58is NULL, the buffers are mapped into private memory.
59The
60.I fd
61argument is a file descriptor for the underlying file, which must be seekable.
62If
63.I key
64is non-NULL and matches a file already being mapped, the
65.I fd
66argument is ignored.
c6d039a3 67.P
fea681da
MK
68The
69.I pagesize
70argument is the size, in bytes, of the pages into which the file is broken up.
71The
72.I maxcache
73argument is the maximum number of pages from the underlying file to cache
74at any one time.
75This value is not relative to the number of processes which share a file's
76buffers, but will be the largest value specified by any of the processes
77sharing the file.
c6d039a3 78.P
fea681da 79The
31e9a9ec 80.BR mpool_filter ()
fea681da
MK
81function is intended to make transparent input and output processing of the
82pages possible.
83If the
84.I pgin
85function is specified, it is called each time a buffer is read into the memory
86pool from the backing file.
87If the
88.I pgout
89function is specified, it is called each time a buffer is written into the
90backing file.
fba59d25 91Both functions are called with the
fea681da
MK
92.I pgcookie
93pointer, the page number and a pointer to the page to being read or written.
c6d039a3 94.P
fea681da 95The function
31e9a9ec 96.BR mpool_new ()
4bd8c614
MK
97takes an
98.I MPOOL
99pointer and an address as arguments.
fea681da
MK
100If a new page can be allocated, a pointer to the page is returned and
101the page number is stored into the
102.I pgnoaddr
103address.
09b235db
MK
104Otherwise, NULL is returned and
105.I errno
106is set.
c6d039a3 107.P
fea681da 108The function
31e9a9ec 109.BR mpool_get ()
4bd8c614
MK
110takes an
111.I MPOOL
112pointer and a page number as arguments.
fea681da 113If the page exists, a pointer to the page is returned.
09b235db
MK
114Otherwise, NULL is returned and
115.I errno
116is set.
c4bb193f
MK
117The
118.I flags
119argument is not currently used.
c6d039a3 120.P
fea681da 121The function
31e9a9ec 122.BR mpool_put ()
fea681da
MK
123unpins the page referenced by
124.IR pgaddr .
bee2a277 125.I pgaddr
fea681da 126must be an address previously returned by
31e9a9ec 127.BR mpool_get ()
fea681da 128or
31e9a9ec 129.BR mpool_new ().
cebca1bd 130The flag value is specified by ORing
fea681da
MK
131any of the following values:
132.TP
4bd8c614 133.B MPOOL_DIRTY
fea681da 134The page has been modified and needs to be written to the backing file.
c6d039a3 135.P
31e9a9ec 136.BR mpool_put ()
fea681da 137returns 0 on success and \-1 if an error occurs.
c6d039a3 138.P
fea681da 139The function
31e9a9ec 140.BR mpool_sync ()
4bd8c614
MK
141writes all modified pages associated with the
142.I MPOOL
143pointer to the
fea681da 144backing file.
31e9a9ec 145.BR mpool_sync ()
fea681da 146returns 0 on success and \-1 if an error occurs.
c6d039a3 147.P
fea681da 148The
31e9a9ec 149.BR mpool_close ()
fea681da
MK
150function free's up any allocated memory associated with the memory pool
151cookie.
152Modified pages are
153.B not
154written to the backing file.
31e9a9ec 155.BR mpool_close ()
fea681da
MK
156returns 0 on success and \-1 if an error occurs.
157.SH ERRORS
158The
31e9a9ec 159.BR mpool_open ()
fea681da
MK
160function may fail and set
161.I errno
162for any of the errors specified for the library routine
31e9a9ec 163.BR malloc (3).
c6d039a3 164.P
fea681da 165The
31e9a9ec 166.BR mpool_get ()
fea681da
MK
167function may fail and set
168.I errno
169for the following:
170.TP 15
747944fe 171.B EINVAL
fea681da 172The requested record doesn't exist.
c6d039a3 173.P
fea681da 174The
31e9a9ec 175.BR mpool_new ()
fea681da 176and
31e9a9ec 177.BR mpool_get ()
fea681da
MK
178functions may fail and set
179.I errno
180for any of the errors specified for the library routines
1368e847
MK
181.BR read (2),
182.BR write (2),
fea681da 183and
31e9a9ec 184.BR malloc (3).
c6d039a3 185.P
fea681da 186The
31e9a9ec 187.BR mpool_sync ()
fea681da
MK
188function may fail and set
189.I errno
190for any of the errors specified for the library routine
31e9a9ec 191.BR write (2).
c6d039a3 192.P
fea681da 193The
31e9a9ec 194.BR mpool_close ()
fea681da
MK
195function may fail and set
196.I errno
197for any of the errors specified for the library routine
31e9a9ec 198.BR free (3).
3113c7f3 199.SH STANDARDS
4131356c 200BSD.
47297adb 201.SH SEE ALSO
31e9a9ec 202.BR btree (3),
f0c34053 203.BR dbopen (3),
31e9a9ec
MK
204.BR hash (3),
205.BR recno (3)